gio-miniprogram-sdk 4.0.0 → 4.1.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 +13 -10
- package/src/{pluginsOut/frameworks → adapters}/gioTaobaoAdapter.ts +47 -44
- package/src/adapters/gioTaroAdapter.ts +459 -0
- package/src/{pluginsOut/frameworks → adapters}/gioUniAppAdapter.ts +35 -6
- package/src/constants/config.ts +49 -20
- package/src/constants/emitMsg.ts +23 -0
- package/src/constants/regex.ts +14 -0
- package/src/core/dataStore/eventContextBuilder.ts +28 -17
- package/src/core/dataStore/eventHooks/appEffects.ts +50 -31
- package/src/core/dataStore/eventHooks/index.ts +7 -5
- package/src/core/dataStore/eventHooks/minipPage.ts +2 -11
- package/src/core/dataStore/eventHooks/pageEffects.ts +61 -27
- package/src/core/dataStore/index.ts +266 -181
- package/src/core/growingIO.ts +312 -179
- 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 -87
- 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 -4
- package/src/{pluginsOut/ordinary → plugins}/gioABTest.ts +74 -37
- package/src/{pluginsOut/ordinary → plugins}/gioEventAutoTracking.ts +25 -18
- package/src/{pluginsOut/ordinary → plugins}/gioImpressionTracking.ts +109 -41
- package/src/plugins/gioMultipleInstances.ts +176 -0
- package/src/types/base.ts +12 -3
- package/src/types/dataStore.ts +31 -16
- package/src/types/eventHooks.ts +8 -9
- package/src/types/growingIO.ts +30 -14
- package/src/types/platforms.ts +0 -4
- package/src/types/plugins.ts +1 -1
- package/src/types/uploader.ts +16 -12
- package/src/types/userStore.ts +21 -17
- package/src/utils/glodash.ts +10 -3
- package/src/utils/tools.ts +27 -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/README.md +0 -50
- package/src/pluginsOut/frameworks/gioTaroAdapter.ts +0 -358
- package/src/pluginsOut/ordinary/gioCustomTracking.ts +0 -71
- package/bin/{build/all.sh → build.sh} +3 -3
- /package/src/{pluginsOut/ordinary → plugins}/gioCompress.ts +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { get, isEmpty, isFunction, unset } from '@@/utils/glodash';
|
|
2
2
|
import { GrowingIOType } from '@@/types/growingIO';
|
|
3
|
+
import { niceTry } from '@@/utils/tools';
|
|
3
4
|
import { PageHookLifeCircle } from '@@/types/eventHooks';
|
|
5
|
+
import EMIT_MSG from '@@/constants/emitMsg';
|
|
4
6
|
|
|
5
7
|
class PageEffects {
|
|
6
8
|
public buildTabClickEvent: (tabItem: any) => void;
|
|
@@ -20,6 +22,8 @@ class PageEffects {
|
|
|
20
22
|
vdsConfig,
|
|
21
23
|
platformConfig,
|
|
22
24
|
dataStore: {
|
|
25
|
+
getTrackerVds,
|
|
26
|
+
trackersExecute,
|
|
23
27
|
shareOut,
|
|
24
28
|
eventHooks,
|
|
25
29
|
toggleShareOut,
|
|
@@ -45,7 +49,7 @@ class PageEffects {
|
|
|
45
49
|
}
|
|
46
50
|
const path =
|
|
47
51
|
page.route || page.uri || page.__route__ || page?.$page?.fullPath || '';
|
|
48
|
-
emitter.emit(
|
|
52
|
+
emitter.emit(EMIT_MSG.MINIP_LIFECYCLE, {
|
|
49
53
|
event: `Page ${event}`,
|
|
50
54
|
timestamp: eventTime,
|
|
51
55
|
params: { page, args: args[0] }
|
|
@@ -56,7 +60,7 @@ class PageEffects {
|
|
|
56
60
|
this.prevEvent[event] = Date.now();
|
|
57
61
|
const pageListeners = platformConfig.listeners.page;
|
|
58
62
|
// 向插件广播事件
|
|
59
|
-
emitter.emit(
|
|
63
|
+
emitter.emit(EMIT_MSG.ON_COMPOSE_BEFORE, {
|
|
60
64
|
page,
|
|
61
65
|
event: `Page ${event}`,
|
|
62
66
|
params: { page, args: args[0] }
|
|
@@ -84,18 +88,26 @@ class PageEffects {
|
|
|
84
88
|
currentPage.path = `/插件${vdsConfig.appId}}`;
|
|
85
89
|
currentPage.title = `/插件${vdsConfig.appId}}`;
|
|
86
90
|
}
|
|
87
|
-
|
|
91
|
+
trackersExecute((trackingId: string) => {
|
|
92
|
+
const { trackPage } = getTrackerVds(trackingId);
|
|
93
|
+
if (trackPage) {
|
|
94
|
+
this.buildPageEvent(trackingId);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
88
97
|
} else if (!shareOut || !eventHooks.currentPage.time) {
|
|
89
98
|
// 不是因为分享切出再返回的onshow(视为第一次进入改页面)和切出去以后因为超时或者进入的场景值不一致时(会在appshow清掉页面时间),发page
|
|
90
99
|
currentPage.parsePage(page, this.argQuery[path]);
|
|
91
100
|
// 超时进入页面时前后path一致parsePage方法不会重置页面时间,可能会没有值,所以要补充重设一次
|
|
92
101
|
eventHooks.currentPage.time = Date.now();
|
|
93
|
-
|
|
102
|
+
trackersExecute((trackingId: string) => {
|
|
103
|
+
const { trackPage } = getTrackerVds(trackingId);
|
|
104
|
+
if (trackPage) {
|
|
105
|
+
this.buildPageEvent(trackingId);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
94
108
|
}
|
|
95
109
|
// 分享标记置为false
|
|
96
110
|
toggleShareOut(false);
|
|
97
|
-
// 保存分享id(记录是从哪个用户id的分享来的)
|
|
98
|
-
currentPage.saveShareId(this.argQuery[path]);
|
|
99
111
|
break;
|
|
100
112
|
}
|
|
101
113
|
case pageListeners.pageHide:
|
|
@@ -104,19 +116,30 @@ class PageEffects {
|
|
|
104
116
|
}
|
|
105
117
|
case pageListeners.shareApp: {
|
|
106
118
|
toggleShareOut(true);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
119
|
+
trackersExecute((trackingId: string) => {
|
|
120
|
+
const { followShare } = getTrackerVds(trackingId);
|
|
121
|
+
if (followShare) {
|
|
122
|
+
buildAppMessageEvent(trackingId, args);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
110
125
|
break;
|
|
111
126
|
}
|
|
112
127
|
case pageListeners.shareTime: {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
128
|
+
trackersExecute((trackingId: string) => {
|
|
129
|
+
const { followShare } = getTrackerVds(trackingId);
|
|
130
|
+
if (followShare) {
|
|
131
|
+
buildTimelineEvent(trackingId, args);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
116
134
|
break;
|
|
117
135
|
}
|
|
118
136
|
case pageListeners.addFavorites: {
|
|
119
|
-
|
|
137
|
+
trackersExecute((trackingId: string) => {
|
|
138
|
+
const { followShare } = getTrackerVds(trackingId);
|
|
139
|
+
if (followShare) {
|
|
140
|
+
buildAddFavorites(trackingId, args);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
120
143
|
break;
|
|
121
144
|
}
|
|
122
145
|
case pageListeners.tabTap: {
|
|
@@ -127,7 +150,7 @@ class PageEffects {
|
|
|
127
150
|
buildTabClickEvent &&
|
|
128
151
|
isFunction(buildTabClickEvent)
|
|
129
152
|
) {
|
|
130
|
-
buildTabClickEvent(args[0]);
|
|
153
|
+
buildTabClickEvent(this.growingIO.trackingId, args[0]);
|
|
131
154
|
}
|
|
132
155
|
break;
|
|
133
156
|
}
|
|
@@ -136,30 +159,41 @@ class PageEffects {
|
|
|
136
159
|
}
|
|
137
160
|
// 页面销毁移除当前页面的属性
|
|
138
161
|
if (event === pageListeners.pageUnload) {
|
|
139
|
-
|
|
162
|
+
trackersExecute((trackingId: string) => {
|
|
163
|
+
currentPage.pageProps[trackingId] = undefined;
|
|
164
|
+
});
|
|
140
165
|
}
|
|
141
166
|
};
|
|
142
167
|
|
|
143
168
|
// 构建页面访问事件
|
|
144
|
-
buildPageEvent = (props?: any) => {
|
|
169
|
+
buildPageEvent = (trackingId: string, props?: any) => {
|
|
145
170
|
const {
|
|
146
|
-
dataStore: {
|
|
171
|
+
dataStore: {
|
|
172
|
+
eventContextBuilder,
|
|
173
|
+
eventInterceptor,
|
|
174
|
+
eventHooks: { currentPage }
|
|
175
|
+
},
|
|
176
|
+
minipInstance
|
|
147
177
|
} = this.growingIO;
|
|
148
|
-
const { currentPage } = eventHooks;
|
|
149
178
|
const event = {
|
|
150
179
|
eventType: 'PAGE',
|
|
151
|
-
referralPage: currentPage.getReferralPage(),
|
|
152
|
-
...eventContextBuilder(),
|
|
180
|
+
referralPage: currentPage.getReferralPage(trackingId),
|
|
181
|
+
...eventContextBuilder(trackingId),
|
|
182
|
+
// page事件要单独设一个title以覆盖eventContextBuilder中的lastPage的title错误值
|
|
183
|
+
title:
|
|
184
|
+
currentPage?.title ||
|
|
185
|
+
minipInstance.getPageTitle(minipInstance.getCurrentPage()),
|
|
153
186
|
timestamp: currentPage.time
|
|
154
187
|
};
|
|
155
|
-
//
|
|
156
|
-
if (!isEmpty(
|
|
157
|
-
event.
|
|
188
|
+
// 传入参数生成的page事件取值为传入参数
|
|
189
|
+
if (!isEmpty(props) && props.title) {
|
|
190
|
+
event.title = props.title;
|
|
158
191
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
event.
|
|
192
|
+
// 添加页面属性
|
|
193
|
+
const pageProps = niceTry(() => currentPage.pageProps[trackingId]);
|
|
194
|
+
if (!isEmpty(pageProps)) {
|
|
195
|
+
event.attributes = pageProps;
|
|
196
|
+
currentPage.pageProps[trackingId] = undefined;
|
|
163
197
|
}
|
|
164
198
|
eventInterceptor(event);
|
|
165
199
|
};
|