Skip to content

Commit

Permalink
[feat] 属性根据当前网络环境实时更新
Browse files Browse the repository at this point in the history
  • Loading branch information
huangriya committed Oct 21, 2022
1 parent 46e56d8 commit ddd1781
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 28 deletions.
3 changes: 2 additions & 1 deletion demo/demo/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ AnalysysAgent.init({
$appname: 'test_appname',
$appid: 'test_app_id',
autoPageViewDuration: true,
autoShare: false
autoShare: false,
autoTrack: true
})

AnalysysAgent.registerSuperProperty('sfsf', 1)
Expand Down
2 changes: 1 addition & 1 deletion demo/demo/sdk/AnalysysAgent_WX_SDK.es6.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/demo/sdk/AnalysysAgent_WX_SDK.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/demoPlugin/sdk/AnalysysAgent_WX_SDK.plugin.es6.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/demoPlugin/sdk/AnalysysAgent_WX_SDK.plugin.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions demo/demoTaro/sdk/AnalysysAgent_WX_SDK.custom.es6.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions demo/demoTaro/sdk/AnalysysAgent_WX_SDK.custom.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/AnalysysAgent_WX_SDK.custom.es6.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/AnalysysAgent_WX_SDK.custom.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/AnalysysAgent_WX_SDK.es6.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/AnalysysAgent_WX_SDK.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/AnalysysAgent_WX_SDK.plugin.es6.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/AnalysysAgent_WX_SDK.plugin.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "asd-wechat-sdk",
"version": "5.0.1",
"version": "5.0.2",
"description": "This is the offical wechat SDK for Analysys.",
"main": "dist/AnalysysAgent_WX_SDK.min.js",
"module": "dist/AnalysysAgent_WX_SDK.es6.min.js",
Expand Down
21 changes: 13 additions & 8 deletions src/module/fillData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,26 @@ export default function (eventName: string) : buriedPointData {

const event = events[eventName]

// 设置事件属性
function setEventAttr(attrName) {
let getAttrFn = getAttr[attrName]
if (getAttrFn) {
const value = getAttrFn()
if (value !== '' && value !== null && value !== undefined) {
obj.xcontext[attrName] = value
}
}
}

// 填充公共属性
publicAttrs.forEach(o => {
const value = getAttr[o]()
if (value) {
obj.xcontext[o] = value
}
setEventAttr(o)
})

// 填充事件私有属性
if (event) {
event.forEach(o => {
const value = getAttr[o] && getAttr[o]()
if (value) {
obj.xcontext[o] = value
}
setEventAttr(o)
})
}

Expand Down
5 changes: 3 additions & 2 deletions src/module/methods/userClick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import sendData from '../sendData'
import fillData from '../fillData'
import { isObject } from '../../utils/type'
import { getSuperProperty } from '../../store/core'
import { getPageProperty } from '../../store/pageProperty'
import { setUserClickAttrs } from '../../store/clickElement'

function userClick(...args: any[]) {
Expand All @@ -28,7 +29,7 @@ function userClick(...args: any[]) {
const res = fillData('$user_click')

// 合并通用属性
res.xcontext = Object.assign({}, res.xcontext, getSuperProperty())
res.xcontext = Object.assign({}, res.xcontext, getSuperProperty(), getPageProperty())

sendData(res)
}
Expand All @@ -50,7 +51,7 @@ export function userClickTab(tabItem) {
const res = fillData('$user_click')

// 合并通用属性
res.xcontext = Object.assign({}, res.xcontext, getSuperProperty())
res.xcontext = Object.assign({}, res.xcontext, getSuperProperty(), getPageProperty())

sendData(res)
}
4 changes: 4 additions & 0 deletions src/store/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ function hasNetwork () : boolean {
return !network.networkType ? false : true
}

globalWindow.onNetworkStatusChange((res: {networkType: string}) => {
network.networkType = res.networkType
})

export { network, getNetwork, setNetwork, hasNetwork, isGetNetWork }

0 comments on commit ddd1781

Please sign in to comment.