gio-miniprogram-sdk 4.4.1 → 4.4.3
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 -1
- package/dist/plugins/gioPerformance.js +1 -1
- 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/dist/xiaohongshu.js +1 -1
- package/package.json +7 -1
- package/.eslintignore +0 -11
- package/.eslintrc.js +0 -120
- package/.github/workflows/greetings.yml +0 -13
- package/.github/workflows/publish.yml +0 -45
- package/.prettierignore +0 -19
- package/.prettierrc.js +0 -9
- package/babel.config.js +0 -6
- package/rollup.config.js +0 -100
- package/rollup.plugins.config.js +0 -84
- package/src/adapters/gioTaobaoAdapter.ts +0 -202
- package/src/adapters/gioTaroAdapter.ts +0 -467
- package/src/adapters/gioUniAppAdapter.ts +0 -431
- package/src/constants/config.ts +0 -170
- package/src/constants/emitMsg.ts +0 -24
- package/src/constants/regex.ts +0 -18
- package/src/core/dataStore/eventContextBuilder.ts +0 -95
- package/src/core/dataStore/eventHooks/appEffects.ts +0 -218
- package/src/core/dataStore/eventHooks/index.ts +0 -468
- package/src/core/dataStore/eventHooks/minipPage.ts +0 -234
- package/src/core/dataStore/eventHooks/pageEffects.ts +0 -189
- package/src/core/dataStore/index.ts +0 -661
- package/src/core/growingIO.ts +0 -637
- package/src/core/pluginsInstance/base.ts +0 -157
- package/src/core/pluginsInstance/taro.ts +0 -15
- package/src/core/pluginsInstance/tb.ts +0 -15
- package/src/core/pluginsInstance/uniapp.ts +0 -15
- package/src/core/uploader.ts +0 -272
- package/src/core/userStore.ts +0 -267
- package/src/index.ts +0 -77
- package/src/minipInstance/base.ts +0 -352
- package/src/minipInstance/framework.ts +0 -24
- package/src/minipInstance/jd.ts +0 -11
- package/src/minipInstance/ks.ts +0 -12
- package/src/minipInstance/my.ts +0 -131
- package/src/minipInstance/qq.ts +0 -12
- package/src/minipInstance/quickapp.ts +0 -233
- package/src/minipInstance/swan.ts +0 -20
- package/src/minipInstance/tb.ts +0 -58
- package/src/minipInstance/tt.ts +0 -12
- package/src/minipInstance/wx.ts +0 -27
- package/src/minipInstance/xhs.ts +0 -20
- package/src/platformConfig/base.ts +0 -82
- package/src/platformConfig/framework.ts +0 -31
- package/src/platformConfig/jd.ts +0 -11
- package/src/platformConfig/ks.ts +0 -11
- package/src/platformConfig/my.ts +0 -16
- package/src/platformConfig/qq.ts +0 -13
- package/src/platformConfig/quickapp.ts +0 -48
- package/src/platformConfig/swan.ts +0 -11
- package/src/platformConfig/tb.ts +0 -29
- package/src/platformConfig/tt.ts +0 -11
- package/src/platformConfig/wx.ts +0 -20
- package/src/platformConfig/xhs.ts +0 -27
- package/src/plugins/gioABTest.ts +0 -348
- package/src/plugins/gioCompress.ts +0 -253
- package/src/plugins/gioEventAutoTracking.ts +0 -288
- package/src/plugins/gioImpressionTracking.ts +0 -386
- package/src/plugins/gioMultipleInstances.ts +0 -189
- package/src/plugins/gioPerformance/exception.ts +0 -152
- package/src/plugins/gioPerformance/monitor.ts +0 -284
- package/src/plugins/gioPerformance/network.ts +0 -197
- package/src/plugins/gioPerformance.ts +0 -131
- package/src/types/base.ts +0 -167
- package/src/types/dataStore.ts +0 -62
- package/src/types/eventHooks.ts +0 -147
- package/src/types/gioCustomTracking.ts +0 -9
- package/src/types/gioEventTracking.ts +0 -10
- package/src/types/gioPerformance.ts +0 -8
- package/src/types/growingIO.ts +0 -137
- package/src/types/minipInstance.ts +0 -133
- package/src/types/platforms.ts +0 -64
- package/src/types/plugins.ts +0 -24
- package/src/types/uploader.ts +0 -30
- package/src/types/userStore.ts +0 -28
- package/src/utils/glodash.ts +0 -430
- package/src/utils/tools.ts +0 -472
- package/src/utils/verifiers.ts +0 -52
- package/tsconfig.json +0 -32
- package/typings/global.d.ts +0 -105
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { get, isEmpty, isFunction, unset } from '@@/utils/glodash';
|
|
2
|
-
import { GrowingIOType } from '@@/types/growingIO';
|
|
3
|
-
import { PageHookLifeCircle } from '@@/types/eventHooks';
|
|
4
|
-
import EMIT_MSG from '@@/constants/emitMsg';
|
|
5
|
-
|
|
6
|
-
class PageEffects {
|
|
7
|
-
public buildTabClickEvent: (tabItem: any) => void;
|
|
8
|
-
private prevEvent: any;
|
|
9
|
-
constructor(public growingIO: GrowingIOType) {
|
|
10
|
-
this.prevEvent = {};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
main = (page: any, event: PageHookLifeCircle, args: any) => {
|
|
14
|
-
const eventTime = Date.now();
|
|
15
|
-
const {
|
|
16
|
-
emitter,
|
|
17
|
-
minipInstance,
|
|
18
|
-
plugins,
|
|
19
|
-
vdsConfig,
|
|
20
|
-
platformConfig,
|
|
21
|
-
dataStore: {
|
|
22
|
-
getTrackerVds,
|
|
23
|
-
getOriginalSource,
|
|
24
|
-
setOriginalSource,
|
|
25
|
-
trackersExecute,
|
|
26
|
-
eventHooks,
|
|
27
|
-
toggleShareOut,
|
|
28
|
-
buildAppMessageEvent,
|
|
29
|
-
buildTimelineEvent,
|
|
30
|
-
buildAddFavorites
|
|
31
|
-
}
|
|
32
|
-
}: GrowingIOType = this.growingIO;
|
|
33
|
-
const { currentPage } = eventHooks;
|
|
34
|
-
if (
|
|
35
|
-
// 防止重写页面后可能出现重复的事件
|
|
36
|
-
this.prevEvent[event] &&
|
|
37
|
-
Date.now() - Number(this.prevEvent[event]) < 50
|
|
38
|
-
) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (!page) {
|
|
42
|
-
page = minipInstance.getCurrentPage();
|
|
43
|
-
}
|
|
44
|
-
if (!page.route) {
|
|
45
|
-
page.route = minipInstance.getCurrentPath(page);
|
|
46
|
-
}
|
|
47
|
-
const path =
|
|
48
|
-
page.route || page.uri || page.__route__ || page?.$page?.fullPath || '';
|
|
49
|
-
emitter.emit(EMIT_MSG.MINIP_LIFECYCLE, {
|
|
50
|
-
event: `Page ${event}`,
|
|
51
|
-
timestamp: eventTime,
|
|
52
|
-
params: { page, args: args[0] }
|
|
53
|
-
});
|
|
54
|
-
if (vdsConfig.debug) {
|
|
55
|
-
console.log('Page:', path, '#', event, eventTime);
|
|
56
|
-
}
|
|
57
|
-
this.prevEvent[event] = Date.now();
|
|
58
|
-
const pageListeners = platformConfig.listeners.page;
|
|
59
|
-
// 向插件广播事件
|
|
60
|
-
emitter.emit(EMIT_MSG.ON_COMPOSE_BEFORE, {
|
|
61
|
-
page,
|
|
62
|
-
event: `Page ${event}`,
|
|
63
|
-
params: { page, args: args[0] }
|
|
64
|
-
});
|
|
65
|
-
currentPage.lastLifecycle = currentPage.currentLifecycle;
|
|
66
|
-
currentPage.currentLifecycle = event;
|
|
67
|
-
switch (event) {
|
|
68
|
-
case pageListeners.pageLoad: {
|
|
69
|
-
// 获取一次页面参数存起来,防止类似支付宝小程序只能通过生命周期获取页面参数或页面堆栈拿不到页面参数,做兜底
|
|
70
|
-
currentPage.queryOptions[path] =
|
|
71
|
-
get(page, 'options') ||
|
|
72
|
-
get(page, '__displayReporter.query') ||
|
|
73
|
-
get(page, '$page.query') ||
|
|
74
|
-
get(page, '$wx.__displayReporter.query') ||
|
|
75
|
-
get(page, '$taroParams') ||
|
|
76
|
-
args[0] ||
|
|
77
|
-
{};
|
|
78
|
-
unset(currentPage.queryOptions[path], [
|
|
79
|
-
'$taroTimestamp',
|
|
80
|
-
'gdpCircleRoomCollectUrl'
|
|
81
|
-
]);
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
case pageListeners.pageShow: {
|
|
85
|
-
trackersExecute((trackingId: string) => {
|
|
86
|
-
// 检查originalSource内容是否已经被消费,如果没有被消费是同一个页面,说明visit还没被发出去,要更新title
|
|
87
|
-
const originalSource = getOriginalSource(trackingId);
|
|
88
|
-
if (!isEmpty(originalSource) && originalSource.path === path) {
|
|
89
|
-
setOriginalSource(trackingId, {
|
|
90
|
-
...originalSource,
|
|
91
|
-
title: currentPage.getPageTitle()
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
// 发page事件
|
|
95
|
-
const { trackPage } = getTrackerVds(trackingId);
|
|
96
|
-
if (trackPage) {
|
|
97
|
-
this.buildPageEvent(trackingId);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
// 分享标记置为false
|
|
101
|
-
toggleShareOut(false);
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
case pageListeners.pageHide:
|
|
105
|
-
case pageListeners.pageUnload: {
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
case pageListeners.shareChat: // 小红书特有事件
|
|
109
|
-
case pageListeners.shareApp: {
|
|
110
|
-
toggleShareOut(true);
|
|
111
|
-
trackersExecute((trackingId: string) => {
|
|
112
|
-
const { followShare } = getTrackerVds(trackingId);
|
|
113
|
-
if (followShare) {
|
|
114
|
-
buildAppMessageEvent(trackingId, args);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
case pageListeners.shareTime: {
|
|
120
|
-
if (minipInstance.platform === 'xhsp') {
|
|
121
|
-
toggleShareOut(true);
|
|
122
|
-
}
|
|
123
|
-
trackersExecute((trackingId: string) => {
|
|
124
|
-
const { followShare } = getTrackerVds(trackingId);
|
|
125
|
-
if (followShare) {
|
|
126
|
-
buildTimelineEvent(trackingId, args);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
case pageListeners.addFavorites: {
|
|
132
|
-
trackersExecute((trackingId: string) => {
|
|
133
|
-
const { followShare } = getTrackerVds(trackingId);
|
|
134
|
-
if (followShare) {
|
|
135
|
-
buildAddFavorites(trackingId, args);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
case pageListeners.tabTap: {
|
|
141
|
-
const buildTabClickEvent =
|
|
142
|
-
plugins?.gioEventAutoTracking?.buildTabClickEvent;
|
|
143
|
-
if (
|
|
144
|
-
vdsConfig.autotrack &&
|
|
145
|
-
buildTabClickEvent &&
|
|
146
|
-
isFunction(buildTabClickEvent)
|
|
147
|
-
) {
|
|
148
|
-
buildTabClickEvent(this.growingIO.trackingId, args[0]);
|
|
149
|
-
}
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
default:
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
currentPage.lastLifecycle = currentPage.currentLifecycle;
|
|
156
|
-
currentPage.currentLifecycle = `${event}End`;
|
|
157
|
-
if (['onHideEnd', 'onUnloadEnd'].includes(currentPage.currentLifecycle)) {
|
|
158
|
-
currentPage.lifeBeforeShow = true;
|
|
159
|
-
}
|
|
160
|
-
if (currentPage.currentLifecycle === 'onShowEnd') {
|
|
161
|
-
currentPage.lifeBeforeShow = false;
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
// 构建页面访问事件
|
|
166
|
-
buildPageEvent = (trackingId: string, props?: any) => {
|
|
167
|
-
const {
|
|
168
|
-
dataStore: {
|
|
169
|
-
eventContextBuilder,
|
|
170
|
-
eventInterceptor,
|
|
171
|
-
eventHooks: { currentPage }
|
|
172
|
-
}
|
|
173
|
-
} = this.growingIO;
|
|
174
|
-
const event = {
|
|
175
|
-
eventType: 'PAGE',
|
|
176
|
-
referralPage: currentPage.getReferralPage(trackingId),
|
|
177
|
-
...eventContextBuilder(trackingId)
|
|
178
|
-
};
|
|
179
|
-
// 合并页面属性
|
|
180
|
-
event.attributes = currentPage.eventSetPageProps(trackingId, event);
|
|
181
|
-
// 传入参数生成的page事件取值为传入参数
|
|
182
|
-
if (!isEmpty(props) && props.title) {
|
|
183
|
-
event.title = props.title;
|
|
184
|
-
}
|
|
185
|
-
eventInterceptor(event);
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export default PageEffects;
|