gio-miniprogram-sdk 4.0.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alipay.js +1 -1
- package/dist/baidu.js +1 -1
- package/dist/bytedance.js +1 -1
- package/dist/jingdong.js +1 -1
- package/dist/kuaishou.js +1 -1
- package/dist/plugins/gioABTest.js +1 -1
- package/dist/plugins/gioCompress.js +1 -1
- package/dist/plugins/gioEventAutoTracking.js +1 -1
- package/dist/plugins/gioImpressionTracking.js +1 -1
- package/dist/plugins/gioMultipleInstances.js +1 -0
- package/dist/qq.js +1 -1
- package/dist/quickapp.js +1 -1
- package/dist/taobao.js +1 -1
- package/dist/taro.js +1 -1
- package/dist/uniapp.js +1 -1
- package/dist/wechat.js +1 -1
- package/package.json +39 -42
- package/rollup.config.js +11 -6
- package/rollup.plugins.config.js +18 -10
- package/src/{pluginsOut/frameworks → adapters}/gioTaobaoAdapter.ts +49 -43
- package/src/{pluginsOut/frameworks → adapters}/gioTaroAdapter.ts +6 -4
- package/src/{pluginsOut/frameworks → adapters}/gioUniAppAdapter.ts +37 -6
- package/src/constants/config.ts +48 -18
- package/src/constants/emitMsg.ts +23 -0
- package/src/constants/regex.ts +0 -1
- package/src/core/dataStore/eventContextBuilder.ts +54 -25
- package/src/core/dataStore/eventHooks/appEffects.ts +50 -31
- package/src/core/dataStore/eventHooks/index.ts +13 -6
- package/src/core/dataStore/eventHooks/minipPage.ts +41 -13
- package/src/core/dataStore/eventHooks/pageEffects.ts +54 -31
- package/src/core/dataStore/index.ts +287 -205
- package/src/core/growingIO.ts +370 -180
- package/src/core/pluginsInstance/base.ts +157 -0
- package/src/core/pluginsInstance/taro.ts +15 -0
- package/src/core/pluginsInstance/tb.ts +15 -0
- package/src/core/pluginsInstance/uniapp.ts +15 -0
- package/src/core/uploader.ts +131 -82
- package/src/core/userStore.ts +160 -121
- package/src/index.ts +37 -28
- package/src/minipInstance/base.ts +2 -1
- package/src/minipInstance/quickapp.ts +5 -19
- package/src/platformConfig/base.ts +0 -5
- package/src/{pluginsOut/ordinary → plugins}/gioABTest.ts +88 -44
- package/src/{pluginsOut/ordinary → plugins}/gioCompress.ts +2 -0
- package/src/{pluginsOut/ordinary → plugins}/gioEventAutoTracking.ts +45 -21
- package/src/{pluginsOut/ordinary → plugins}/gioImpressionTracking.ts +67 -23
- package/src/plugins/gioMultipleInstances.ts +187 -0
- package/src/types/base.ts +10 -3
- package/src/types/dataStore.ts +35 -16
- package/src/types/eventHooks.ts +8 -6
- package/src/types/growingIO.ts +74 -39
- package/src/types/platforms.ts +0 -4
- package/src/types/plugins.ts +1 -1
- package/src/types/uploader.ts +16 -10
- package/src/types/userStore.ts +21 -17
- package/src/utils/glodash.ts +10 -3
- package/src/utils/tools.ts +31 -6
- package/src/utils/verifiers.ts +25 -50
- package/typings/global.d.ts +5 -0
- package/.babelrc +0 -4
- package/bin/build/full.sh +0 -32
- package/bin/build/jd.sh +0 -14
- package/bin/build/ks.sh +0 -14
- package/bin/build/my.sh +0 -14
- package/bin/build/plugins.sh +0 -5
- package/bin/build/qq.sh +0 -14
- package/bin/build/quickapp.sh +0 -14
- package/bin/build/swan.sh +0 -14
- package/bin/build/taro.sh +0 -18
- package/bin/build/tb.sh +0 -18
- package/bin/build/tt.sh +0 -14
- package/bin/build/uniapp.sh +0 -18
- package/bin/build/wx.sh +0 -14
- package/src/core/plugins.ts +0 -152
- package/src/pluginsOut/ordinary/gioCustomTracking.ts +0 -71
- package/bin/{build/all.sh → build.sh} +3 -3
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
isNil
|
|
11
11
|
} from '@@/utils/glodash';
|
|
12
12
|
import { qsStringify } from '@@/utils/tools';
|
|
13
|
+
import EMIT_MSG from '@@/constants/emitMsg';
|
|
13
14
|
|
|
14
15
|
class AppEffects {
|
|
15
16
|
constructor(public growingIO: GrowingIOType) {}
|
|
@@ -24,14 +25,15 @@ class AppEffects {
|
|
|
24
25
|
uploader,
|
|
25
26
|
dataStore,
|
|
26
27
|
dataStore: {
|
|
28
|
+
trackersExecute,
|
|
27
29
|
shareOut,
|
|
28
|
-
keepAlive,
|
|
29
30
|
lastCloseTime,
|
|
30
31
|
eventHooks,
|
|
31
|
-
saveStorageInfo
|
|
32
|
+
saveStorageInfo,
|
|
33
|
+
setOriginalSource
|
|
32
34
|
}
|
|
33
35
|
}: GrowingIOType = this.growingIO;
|
|
34
|
-
emitter.emit(
|
|
36
|
+
emitter.emit(EMIT_MSG.MINIP_LIFECYCLE, {
|
|
35
37
|
event: `App ${event}`,
|
|
36
38
|
timestamp: eventTime,
|
|
37
39
|
params: args[0] ?? {}
|
|
@@ -41,7 +43,7 @@ class AppEffects {
|
|
|
41
43
|
}
|
|
42
44
|
const appListeners = platformConfig.listeners.app;
|
|
43
45
|
// 向插件广播事件
|
|
44
|
-
emitter.emit(
|
|
46
|
+
emitter.emit(EMIT_MSG.ON_COMPOSE_BEFORE, {
|
|
45
47
|
event: `App ${event}`,
|
|
46
48
|
params: args[0] ?? {}
|
|
47
49
|
});
|
|
@@ -54,25 +56,33 @@ class AppEffects {
|
|
|
54
56
|
const { path, query } = this.enterParamsParse(args[0]);
|
|
55
57
|
if (!shareOut && vdsConfig.originalSource) {
|
|
56
58
|
// 保存初始来源信息
|
|
57
|
-
|
|
59
|
+
trackersExecute((trackingId: string) => {
|
|
60
|
+
setOriginalSource(trackingId, { path, query });
|
|
61
|
+
});
|
|
58
62
|
}
|
|
59
63
|
// 以下条件均会被认为是一次新的访问
|
|
60
64
|
// 没有关闭时间说明是新访问
|
|
61
65
|
if (!lastCloseTime) {
|
|
62
66
|
// 保存进入小程序的参数
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
dataStore.lastVisitEvent = { path, query };
|
|
68
|
+
trackersExecute((trackingId: string) => {
|
|
69
|
+
this.buildVisitEvent(trackingId, { path, query });
|
|
70
|
+
});
|
|
65
71
|
} else if (
|
|
66
72
|
// 两次打开间隔时间超过keepAlive设定(默认5分钟)
|
|
67
|
-
Date.now() - lastCloseTime > keepAlive ||
|
|
73
|
+
Date.now() - lastCloseTime > vdsConfig.keepAlive ||
|
|
68
74
|
// 两次打开时的场景值不一样(即从不同的来源进入小程序)
|
|
69
75
|
(dataStore.lastScene && dataStore.scene !== dataStore.lastScene)
|
|
70
76
|
) {
|
|
71
77
|
// 重置sessionId
|
|
72
|
-
|
|
78
|
+
trackersExecute((trackingId: string) => {
|
|
79
|
+
userStore.setSessionId(trackingId);
|
|
80
|
+
});
|
|
73
81
|
// 需要按自然逻辑发visit时,清掉pagetime,防止取值错误(会在page中重新生成)
|
|
74
82
|
eventHooks.currentPage.time = undefined;
|
|
75
|
-
|
|
83
|
+
trackersExecute((trackingId: string) => {
|
|
84
|
+
this.buildVisitEvent(trackingId, { path, query });
|
|
85
|
+
});
|
|
76
86
|
}
|
|
77
87
|
break;
|
|
78
88
|
}
|
|
@@ -82,11 +92,14 @@ class AppEffects {
|
|
|
82
92
|
dataStore.lastCloseTime = Date.now();
|
|
83
93
|
saveStorageInfo();
|
|
84
94
|
userStore.saveUserInfo();
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
95
|
+
trackersExecute((trackingId: string) => {
|
|
96
|
+
this.buildCloseEvent(trackingId);
|
|
97
|
+
// forceLogin不生效时强制把请求队列中的事件全部发送
|
|
98
|
+
if (!vdsConfig.forceLogin) {
|
|
99
|
+
uploader.initiateRequest(trackingId, true);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
90
103
|
break;
|
|
91
104
|
}
|
|
92
105
|
default:
|
|
@@ -173,45 +186,51 @@ class AppEffects {
|
|
|
173
186
|
};
|
|
174
187
|
|
|
175
188
|
// 构建访问事件
|
|
176
|
-
buildVisitEvent = (
|
|
177
|
-
const { dataStore, vdsConfig, minipInstance } = this.growingIO;
|
|
189
|
+
buildVisitEvent = (trackingId: string, props?: any) => {
|
|
178
190
|
const {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
191
|
+
dataStore: {
|
|
192
|
+
getOriginalSource,
|
|
193
|
+
eventContextBuilder,
|
|
194
|
+
eventInterceptor,
|
|
195
|
+
eventHooks
|
|
196
|
+
},
|
|
197
|
+
minipInstance,
|
|
198
|
+
vdsConfig
|
|
199
|
+
} = this.growingIO;
|
|
200
|
+
const originalSource = getOriginalSource(trackingId);
|
|
185
201
|
// 生命周期中调用构建使用参数赋值,补发场景调用构建使用上一次的值
|
|
186
202
|
const query = props?.query || '';
|
|
187
203
|
let event = {
|
|
188
204
|
eventType: 'VISIT',
|
|
189
|
-
...eventContextBuilder({
|
|
205
|
+
...eventContextBuilder(trackingId, {
|
|
190
206
|
// params.path是生命周期值或者是已有的值
|
|
191
207
|
path: props?.path || '',
|
|
192
208
|
// params.query是对象说明是生命周期调用,否则是补发调用
|
|
193
|
-
query: typeOf(query) === 'string' ? query : qsStringify(query)
|
|
209
|
+
query: typeOf(query) === 'string' ? query : qsStringify(query),
|
|
210
|
+
// visit事件要单独设一次title以覆盖eventContextBuilder中的lastPage的可能的title错误值
|
|
211
|
+
title:
|
|
212
|
+
eventHooks.currentPage?.title ||
|
|
213
|
+
minipInstance.getPageTitle(minipInstance.getCurrentPage()),
|
|
214
|
+
timestamp: eventHooks.currentPage.time
|
|
215
|
+
? eventHooks.currentPage.time - 1
|
|
216
|
+
: +Date.now()
|
|
194
217
|
})
|
|
195
218
|
};
|
|
196
219
|
// 配置使用初始来源时,visit使用初始来源数据
|
|
197
220
|
if (vdsConfig.originalSource && !isNil(originalSource)) {
|
|
198
221
|
event = { ...event, ...originalSource };
|
|
199
|
-
// 采集开关开启状态下的第一个visit消费过初始来源信息后删除
|
|
200
|
-
if (vdsConfig.dataCollect) {
|
|
201
|
-
minipInstance.removeStorageSync(originalSourceName);
|
|
202
|
-
}
|
|
203
222
|
}
|
|
204
223
|
eventInterceptor(event);
|
|
205
224
|
};
|
|
206
225
|
|
|
207
226
|
// 构建关闭事件
|
|
208
|
-
buildCloseEvent = () => {
|
|
227
|
+
buildCloseEvent = (trackingId: string) => {
|
|
209
228
|
const {
|
|
210
229
|
dataStore: { eventContextBuilder, eventInterceptor }
|
|
211
230
|
} = this.growingIO;
|
|
212
231
|
const event = {
|
|
213
232
|
eventType: 'APP_CLOSED',
|
|
214
|
-
...eventContextBuilder()
|
|
233
|
+
...eventContextBuilder(trackingId)
|
|
215
234
|
};
|
|
216
235
|
eventInterceptor(event);
|
|
217
236
|
};
|
|
@@ -6,6 +6,7 @@ import { consoleText, getGlobal, niceTry } from '@@/utils/tools';
|
|
|
6
6
|
import AppEffects from './appEffects';
|
|
7
7
|
import MinipPage from './minipPage';
|
|
8
8
|
import PageEffects from './pageEffects';
|
|
9
|
+
import EMIT_MSG from '@@/constants/emitMsg';
|
|
9
10
|
|
|
10
11
|
class EventHooks implements EventHooksType {
|
|
11
12
|
private appHooked: boolean;
|
|
@@ -33,10 +34,6 @@ class EventHooks implements EventHooksType {
|
|
|
33
34
|
this.appHandlers = config.appHandlers;
|
|
34
35
|
this.pageHandlers = config.pageHandlers;
|
|
35
36
|
this.actionEventTypes = config.actionEventTypes;
|
|
36
|
-
this.originalApp = config.originalApp;
|
|
37
|
-
this.originalPage = config.originalPage;
|
|
38
|
-
this.originalComponent = config.originalComponent;
|
|
39
|
-
this.originalBehavior = config.originalBehavior ?? function () {}; // eslint-disable-line
|
|
40
37
|
this.appEffects = new AppEffects(this.growingIO);
|
|
41
38
|
this.pageEffects = new PageEffects(this.growingIO);
|
|
42
39
|
this.currentPage = new MinipPage(this.growingIO);
|
|
@@ -121,7 +118,12 @@ class EventHooks implements EventHooksType {
|
|
|
121
118
|
if (eventName === 'onShareAppMessage') {
|
|
122
119
|
// 先执行分享的生命周期拿到分享数据
|
|
123
120
|
// 与基础库保持一致,没有返回值时默认使用{}
|
|
124
|
-
result =
|
|
121
|
+
result = method.apply(this, args) ?? {};
|
|
122
|
+
// 如果分享事件是个promise函数,需要等待异步结果
|
|
123
|
+
if (typeOf(result) === 'promise') {
|
|
124
|
+
result = await result.then((r) => r);
|
|
125
|
+
}
|
|
126
|
+
// 如果返回的对象中包含promise,要等待异步结果
|
|
125
127
|
if (typeOf(result.promise) === 'promise') {
|
|
126
128
|
const f = async function () {
|
|
127
129
|
let sRes = result;
|
|
@@ -161,7 +163,7 @@ class EventHooks implements EventHooksType {
|
|
|
161
163
|
if (eventName !== 'onShareAppMessage') {
|
|
162
164
|
result = method.apply(this, args);
|
|
163
165
|
}
|
|
164
|
-
self.growingIO.emitter.emit(
|
|
166
|
+
self.growingIO.emitter.emit(EMIT_MSG.MINIP_LIFECYCLE, {
|
|
165
167
|
event: `${cType} ${eventName}End`,
|
|
166
168
|
timestamp: Date.now(),
|
|
167
169
|
params: { instance: this, arguments: Array.from(args) }
|
|
@@ -324,6 +326,7 @@ class EventHooks implements EventHooksType {
|
|
|
324
326
|
try {
|
|
325
327
|
// 重写App
|
|
326
328
|
if (platformHooks.App && !this.appHooked) {
|
|
329
|
+
this.originalApp = App || global.App || function () {};
|
|
327
330
|
App = function (...args) {
|
|
328
331
|
return self.growingApp(args[0]);
|
|
329
332
|
};
|
|
@@ -337,6 +340,7 @@ class EventHooks implements EventHooksType {
|
|
|
337
340
|
try {
|
|
338
341
|
// 重写Page
|
|
339
342
|
if (platformHooks.Page && !this.pageHooked) {
|
|
343
|
+
this.originalPage = Page || global.Page || function () {};
|
|
340
344
|
Page = function (...args) {
|
|
341
345
|
return self.growingPage(args[0]);
|
|
342
346
|
};
|
|
@@ -350,6 +354,8 @@ class EventHooks implements EventHooksType {
|
|
|
350
354
|
try {
|
|
351
355
|
// 重写Component
|
|
352
356
|
if (platformHooks.Component && !this.componentHooked) {
|
|
357
|
+
this.originalComponent =
|
|
358
|
+
Component || global.Component || function () {};
|
|
353
359
|
Component = function (...args) {
|
|
354
360
|
return self.growingComponent(args[0]);
|
|
355
361
|
};
|
|
@@ -363,6 +369,7 @@ class EventHooks implements EventHooksType {
|
|
|
363
369
|
try {
|
|
364
370
|
// 重写Behavior
|
|
365
371
|
if (platformHooks.Behavior && !this.behaviorHooked) {
|
|
372
|
+
this.originalBehavior = Behavior || global.Behavior || function () {};
|
|
366
373
|
Behavior = function (...args) {
|
|
367
374
|
return self.growingBehavior(args[0]);
|
|
368
375
|
};
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
compact,
|
|
3
|
+
has,
|
|
4
|
+
head,
|
|
5
|
+
isEmpty,
|
|
6
|
+
keys,
|
|
7
|
+
last,
|
|
8
|
+
unset
|
|
9
|
+
} from '@@/utils/glodash';
|
|
2
10
|
import { GrowingIOType } from '@@/types/growingIO';
|
|
3
11
|
import { MinipPageType, PageShareResult } from '@@/types/eventHooks';
|
|
4
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
qsStringify,
|
|
14
|
+
normalPath,
|
|
15
|
+
splitPath,
|
|
16
|
+
qsParse,
|
|
17
|
+
niceTry,
|
|
18
|
+
getDynamicAttributes,
|
|
19
|
+
limitObject
|
|
20
|
+
} from '@@/utils/tools';
|
|
21
|
+
import { EVENT } from '@@/types/base';
|
|
5
22
|
|
|
6
23
|
class MinipPage implements MinipPageType {
|
|
7
24
|
public path: string;
|
|
@@ -11,8 +28,6 @@ class MinipPage implements MinipPageType {
|
|
|
11
28
|
public title: string;
|
|
12
29
|
// 通过调用wx.setNavigationBarTitle设置的title
|
|
13
30
|
public settedTitle: any;
|
|
14
|
-
// 当前页面参数中的分享id
|
|
15
|
-
public queryShareId: string;
|
|
16
31
|
// 页面级属性
|
|
17
32
|
public pageProps: any;
|
|
18
33
|
// 上一个执行的小程序生命周期
|
|
@@ -56,24 +71,17 @@ class MinipPage implements MinipPageType {
|
|
|
56
71
|
};
|
|
57
72
|
|
|
58
73
|
// 获取上一个页面路径
|
|
59
|
-
getReferralPage = () => {
|
|
74
|
+
getReferralPage = (trackingId: string) => {
|
|
60
75
|
const {
|
|
61
76
|
minipInstance,
|
|
62
77
|
dataStore: { lastPageEvent, scene }
|
|
63
78
|
} = this.growingIO;
|
|
64
79
|
return (
|
|
65
|
-
lastPageEvent?.path ||
|
|
80
|
+
lastPageEvent[trackingId]?.path ||
|
|
66
81
|
(scene ? `scn:${minipInstance.scnPrefix}${scene}` : null)
|
|
67
82
|
);
|
|
68
83
|
};
|
|
69
84
|
|
|
70
|
-
// 保存分享id(记录是从哪个用户id的分享来的)
|
|
71
|
-
saveShareId = (query: any) => {
|
|
72
|
-
if (query?.gioShareId) {
|
|
73
|
-
this.queryShareId = query.gioShareId;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
85
|
// 处理分享参数
|
|
78
86
|
buildShareQuery(
|
|
79
87
|
result: PageShareResult // 客户自定义的参数
|
|
@@ -93,6 +101,12 @@ class MinipPage implements MinipPageType {
|
|
|
93
101
|
// 自定义path中没有截取到query说明是在onShareAppMessage中没有参数,或是在onShareTimeline中需要取自定义query
|
|
94
102
|
if (isEmpty(parsedQeury)) {
|
|
95
103
|
parsedQeury = qsParse(result.query ?? '') || {};
|
|
104
|
+
compact(keys(parsedQeury)).forEach((key) => {
|
|
105
|
+
// 删除从默认页面的query中原有的utm参数,防止带入到下一次分享导致渠道统计错误(如果客户质疑参数被删,让他们自己拼回去或者关followshare)
|
|
106
|
+
if (key.toLowerCase().startsWith('utm_')) {
|
|
107
|
+
unset(parsedQeury, key);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
96
110
|
}
|
|
97
111
|
|
|
98
112
|
// 以上两种都是自定义的地址和参数,不做处理直接用,防止出现encode/decode的问题。
|
|
@@ -127,6 +141,20 @@ class MinipPage implements MinipPageType {
|
|
|
127
141
|
result.query = queryString;
|
|
128
142
|
return result;
|
|
129
143
|
};
|
|
144
|
+
|
|
145
|
+
// 给事件合并页面属性
|
|
146
|
+
eventSetPageProps = (trackingId: string, event: EVENT) => {
|
|
147
|
+
const pageProps = niceTry(() => this.pageProps[trackingId][this.path]);
|
|
148
|
+
if (!isEmpty(pageProps)) {
|
|
149
|
+
return limitObject(
|
|
150
|
+
getDynamicAttributes({
|
|
151
|
+
...event.attributes,
|
|
152
|
+
...pageProps
|
|
153
|
+
})
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
return event.attributes;
|
|
157
|
+
};
|
|
130
158
|
}
|
|
131
159
|
|
|
132
160
|
export default MinipPage;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { get, isEmpty, isFunction, unset } from '@@/utils/glodash';
|
|
2
2
|
import { GrowingIOType } from '@@/types/growingIO';
|
|
3
3
|
import { PageHookLifeCircle } from '@@/types/eventHooks';
|
|
4
|
+
import EMIT_MSG from '@@/constants/emitMsg';
|
|
4
5
|
|
|
5
6
|
class PageEffects {
|
|
6
7
|
public buildTabClickEvent: (tabItem: any) => void;
|
|
@@ -20,6 +21,8 @@ class PageEffects {
|
|
|
20
21
|
vdsConfig,
|
|
21
22
|
platformConfig,
|
|
22
23
|
dataStore: {
|
|
24
|
+
getTrackerVds,
|
|
25
|
+
trackersExecute,
|
|
23
26
|
shareOut,
|
|
24
27
|
eventHooks,
|
|
25
28
|
toggleShareOut,
|
|
@@ -45,7 +48,7 @@ class PageEffects {
|
|
|
45
48
|
}
|
|
46
49
|
const path =
|
|
47
50
|
page.route || page.uri || page.__route__ || page?.$page?.fullPath || '';
|
|
48
|
-
emitter.emit(
|
|
51
|
+
emitter.emit(EMIT_MSG.MINIP_LIFECYCLE, {
|
|
49
52
|
event: `Page ${event}`,
|
|
50
53
|
timestamp: eventTime,
|
|
51
54
|
params: { page, args: args[0] }
|
|
@@ -56,7 +59,7 @@ class PageEffects {
|
|
|
56
59
|
this.prevEvent[event] = Date.now();
|
|
57
60
|
const pageListeners = platformConfig.listeners.page;
|
|
58
61
|
// 向插件广播事件
|
|
59
|
-
emitter.emit(
|
|
62
|
+
emitter.emit(EMIT_MSG.ON_COMPOSE_BEFORE, {
|
|
60
63
|
page,
|
|
61
64
|
event: `Page ${event}`,
|
|
62
65
|
params: { page, args: args[0] }
|
|
@@ -84,18 +87,26 @@ class PageEffects {
|
|
|
84
87
|
currentPage.path = `/插件${vdsConfig.appId}}`;
|
|
85
88
|
currentPage.title = `/插件${vdsConfig.appId}}`;
|
|
86
89
|
}
|
|
87
|
-
|
|
90
|
+
trackersExecute((trackingId: string) => {
|
|
91
|
+
const { trackPage } = getTrackerVds(trackingId);
|
|
92
|
+
if (trackPage) {
|
|
93
|
+
this.buildPageEvent(trackingId);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
88
96
|
} else if (!shareOut || !eventHooks.currentPage.time) {
|
|
89
97
|
// 不是因为分享切出再返回的onshow(视为第一次进入改页面)和切出去以后因为超时或者进入的场景值不一致时(会在appshow清掉页面时间),发page
|
|
90
98
|
currentPage.parsePage(page, this.argQuery[path]);
|
|
91
99
|
// 超时进入页面时前后path一致parsePage方法不会重置页面时间,可能会没有值,所以要补充重设一次
|
|
92
100
|
eventHooks.currentPage.time = Date.now();
|
|
93
|
-
|
|
101
|
+
trackersExecute((trackingId: string) => {
|
|
102
|
+
const { trackPage } = getTrackerVds(trackingId);
|
|
103
|
+
if (trackPage) {
|
|
104
|
+
this.buildPageEvent(trackingId);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
94
107
|
}
|
|
95
108
|
// 分享标记置为false
|
|
96
109
|
toggleShareOut(false);
|
|
97
|
-
// 保存分享id(记录是从哪个用户id的分享来的)
|
|
98
|
-
currentPage.saveShareId(this.argQuery[path]);
|
|
99
110
|
break;
|
|
100
111
|
}
|
|
101
112
|
case pageListeners.pageHide:
|
|
@@ -104,19 +115,30 @@ class PageEffects {
|
|
|
104
115
|
}
|
|
105
116
|
case pageListeners.shareApp: {
|
|
106
117
|
toggleShareOut(true);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
trackersExecute((trackingId: string) => {
|
|
119
|
+
const { followShare } = getTrackerVds(trackingId);
|
|
120
|
+
if (followShare) {
|
|
121
|
+
buildAppMessageEvent(trackingId, args);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
110
124
|
break;
|
|
111
125
|
}
|
|
112
126
|
case pageListeners.shareTime: {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
127
|
+
trackersExecute((trackingId: string) => {
|
|
128
|
+
const { followShare } = getTrackerVds(trackingId);
|
|
129
|
+
if (followShare) {
|
|
130
|
+
buildTimelineEvent(trackingId, args);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
116
133
|
break;
|
|
117
134
|
}
|
|
118
135
|
case pageListeners.addFavorites: {
|
|
119
|
-
|
|
136
|
+
trackersExecute((trackingId: string) => {
|
|
137
|
+
const { followShare } = getTrackerVds(trackingId);
|
|
138
|
+
if (followShare) {
|
|
139
|
+
buildAddFavorites(trackingId, args);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
120
142
|
break;
|
|
121
143
|
}
|
|
122
144
|
case pageListeners.tabTap: {
|
|
@@ -127,39 +149,40 @@ class PageEffects {
|
|
|
127
149
|
buildTabClickEvent &&
|
|
128
150
|
isFunction(buildTabClickEvent)
|
|
129
151
|
) {
|
|
130
|
-
buildTabClickEvent(args[0]);
|
|
152
|
+
buildTabClickEvent(this.growingIO.trackingId, args[0]);
|
|
131
153
|
}
|
|
132
154
|
break;
|
|
133
155
|
}
|
|
134
156
|
default:
|
|
135
157
|
break;
|
|
136
158
|
}
|
|
137
|
-
// 页面销毁移除当前页面的属性
|
|
138
|
-
if (event === pageListeners.pageUnload) {
|
|
139
|
-
currentPage.pageProps[path] = undefined;
|
|
140
|
-
}
|
|
141
159
|
};
|
|
142
160
|
|
|
143
161
|
// 构建页面访问事件
|
|
144
|
-
buildPageEvent = (props?: any) => {
|
|
162
|
+
buildPageEvent = (trackingId: string, props?: any) => {
|
|
145
163
|
const {
|
|
146
|
-
dataStore: {
|
|
164
|
+
dataStore: {
|
|
165
|
+
eventContextBuilder,
|
|
166
|
+
eventInterceptor,
|
|
167
|
+
eventHooks: { currentPage }
|
|
168
|
+
},
|
|
169
|
+
minipInstance
|
|
147
170
|
} = this.growingIO;
|
|
148
|
-
const { currentPage } = eventHooks;
|
|
149
171
|
const event = {
|
|
150
172
|
eventType: 'PAGE',
|
|
151
|
-
referralPage: currentPage.getReferralPage(),
|
|
152
|
-
...eventContextBuilder(),
|
|
173
|
+
referralPage: currentPage.getReferralPage(trackingId),
|
|
174
|
+
...eventContextBuilder(trackingId),
|
|
175
|
+
// page事件要单独设一个title以覆盖eventContextBuilder中的lastPage的title错误值
|
|
176
|
+
title:
|
|
177
|
+
currentPage?.title ||
|
|
178
|
+
minipInstance.getPageTitle(minipInstance.getCurrentPage()),
|
|
153
179
|
timestamp: currentPage.time
|
|
154
180
|
};
|
|
155
|
-
//
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
event.path = props.path;
|
|
161
|
-
event.query = props.query;
|
|
162
|
-
event.title = props.title ?? event.title;
|
|
181
|
+
// 合并页面属性
|
|
182
|
+
event.attributes = currentPage.eventSetPageProps(trackingId, event);
|
|
183
|
+
// 传入参数生成的page事件取值为传入参数
|
|
184
|
+
if (!isEmpty(props) && props.title) {
|
|
185
|
+
event.title = props.title;
|
|
163
186
|
}
|
|
164
187
|
eventInterceptor(event);
|
|
165
188
|
};
|