gio-miniprogram-sdk 4.0.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.
Files changed (103) hide show
  1. package/.babelrc +4 -0
  2. package/.eslintignore +11 -0
  3. package/.eslintrc.js +120 -0
  4. package/.github/workflows/greetings.yml +13 -0
  5. package/.github/workflows/publish.yml +43 -0
  6. package/.prettierignore +19 -0
  7. package/.prettierrc.js +9 -0
  8. package/LICENSE +674 -0
  9. package/README.md +103 -0
  10. package/babel.config.js +6 -0
  11. package/bin/build/all.sh +38 -0
  12. package/bin/build/full.sh +32 -0
  13. package/bin/build/jd.sh +14 -0
  14. package/bin/build/ks.sh +14 -0
  15. package/bin/build/my.sh +14 -0
  16. package/bin/build/plugins.sh +5 -0
  17. package/bin/build/qq.sh +14 -0
  18. package/bin/build/quickapp.sh +14 -0
  19. package/bin/build/swan.sh +14 -0
  20. package/bin/build/taro.sh +18 -0
  21. package/bin/build/tb.sh +18 -0
  22. package/bin/build/tt.sh +14 -0
  23. package/bin/build/uniapp.sh +18 -0
  24. package/bin/build/wx.sh +14 -0
  25. package/dist/alipay.js +1 -0
  26. package/dist/baidu.js +1 -0
  27. package/dist/bytedance.js +1 -0
  28. package/dist/jingdong.js +1 -0
  29. package/dist/kuaishou.js +1 -0
  30. package/dist/plugins/gioABTest.js +1 -0
  31. package/dist/plugins/gioCompress.js +1 -0
  32. package/dist/plugins/gioEventAutoTracking.js +1 -0
  33. package/dist/plugins/gioImpressionTracking.js +1 -0
  34. package/dist/qq.js +1 -0
  35. package/dist/quickapp.js +1 -0
  36. package/dist/taobao.js +1 -0
  37. package/dist/taro.js +1 -0
  38. package/dist/uniapp.js +1 -0
  39. package/dist/wechat.js +1 -0
  40. package/package.json +144 -0
  41. package/rollup.config.js +92 -0
  42. package/rollup.plugins.config.js +76 -0
  43. package/src/constants/config.ts +136 -0
  44. package/src/constants/regex.ts +4 -0
  45. package/src/core/dataStore/eventContextBuilder.ts +70 -0
  46. package/src/core/dataStore/eventHooks/appEffects.ts +220 -0
  47. package/src/core/dataStore/eventHooks/index.ts +403 -0
  48. package/src/core/dataStore/eventHooks/minipPage.ts +132 -0
  49. package/src/core/dataStore/eventHooks/pageEffects.ts +168 -0
  50. package/src/core/dataStore/index.ts +543 -0
  51. package/src/core/growingIO.ts +433 -0
  52. package/src/core/plugins.ts +152 -0
  53. package/src/core/uploader.ts +219 -0
  54. package/src/core/userStore.ts +203 -0
  55. package/src/index.ts +68 -0
  56. package/src/minipInstance/base.ts +287 -0
  57. package/src/minipInstance/framework.ts +22 -0
  58. package/src/minipInstance/jd.ts +11 -0
  59. package/src/minipInstance/ks.ts +12 -0
  60. package/src/minipInstance/my.ts +53 -0
  61. package/src/minipInstance/qq.ts +12 -0
  62. package/src/minipInstance/quickapp.ts +230 -0
  63. package/src/minipInstance/swan.ts +20 -0
  64. package/src/minipInstance/tb.ts +53 -0
  65. package/src/minipInstance/tt.ts +12 -0
  66. package/src/minipInstance/wx.ts +12 -0
  67. package/src/platformConfig/base.ts +86 -0
  68. package/src/platformConfig/framework.ts +29 -0
  69. package/src/platformConfig/jd.ts +11 -0
  70. package/src/platformConfig/ks.ts +11 -0
  71. package/src/platformConfig/my.ts +15 -0
  72. package/src/platformConfig/qq.ts +13 -0
  73. package/src/platformConfig/quickapp.ts +48 -0
  74. package/src/platformConfig/swan.ts +11 -0
  75. package/src/platformConfig/tb.ts +29 -0
  76. package/src/platformConfig/tt.ts +11 -0
  77. package/src/platformConfig/wx.ts +20 -0
  78. package/src/pluginsOut/README.md +50 -0
  79. package/src/pluginsOut/frameworks/gioTaobaoAdapter.ts +195 -0
  80. package/src/pluginsOut/frameworks/gioTaroAdapter.ts +358 -0
  81. package/src/pluginsOut/frameworks/gioUniAppAdapter.ts +220 -0
  82. package/src/pluginsOut/ordinary/gioABTest.ts +254 -0
  83. package/src/pluginsOut/ordinary/gioCompress.ts +251 -0
  84. package/src/pluginsOut/ordinary/gioCustomTracking.ts +71 -0
  85. package/src/pluginsOut/ordinary/gioEventAutoTracking.ts +164 -0
  86. package/src/pluginsOut/ordinary/gioImpressionTracking.ts +298 -0
  87. package/src/types/base.ts +150 -0
  88. package/src/types/dataStore.ts +43 -0
  89. package/src/types/eventHooks.ts +141 -0
  90. package/src/types/gioCustomTracking.ts +9 -0
  91. package/src/types/gioEventTracking.ts +10 -0
  92. package/src/types/gioPerformance.ts +8 -0
  93. package/src/types/growingIO.ts +102 -0
  94. package/src/types/minipInstance.ts +126 -0
  95. package/src/types/platforms.ts +65 -0
  96. package/src/types/plugins.ts +24 -0
  97. package/src/types/uploader.ts +26 -0
  98. package/src/types/userStore.ts +22 -0
  99. package/src/utils/glodash.ts +423 -0
  100. package/src/utils/tools.ts +384 -0
  101. package/src/utils/verifiers.ts +76 -0
  102. package/tsconfig.json +32 -0
  103. package/typings/global.d.ts +92 -0
@@ -0,0 +1,164 @@
1
+ /**
2
+ * 名称:无埋点插件
3
+ * 用途:用于提供无埋点的事件构建方法。
4
+ */
5
+ import { EventTarget } from '@@/types/eventHooks';
6
+ import { GrowingIOType } from '@@/types/growingIO';
7
+ import { consoleText, isTaro3 } from '@@/utils/tools';
8
+
9
+ let ut;
10
+ class GioEventAutoTracking {
11
+ private prevEvent: any;
12
+ constructor(public growingIO: GrowingIOType) {
13
+ ut = this.growingIO.utils;
14
+ this.prevEvent = {};
15
+ }
16
+
17
+ main = (e: EventTarget, eventName: string) => {
18
+ const { vdsConfig, platformConfig, plugins, emitter }: GrowingIOType =
19
+ this.growingIO;
20
+ if (
21
+ // 无埋点事件拦截
22
+ !vdsConfig.autotrack ||
23
+ // 无事件名称拦截
24
+ !eventName ||
25
+ // 标记忽略的节点拦截
26
+ ut.get(e, 'currentTarget.dataset.growingIgnore') ||
27
+ ut.get(e, 'target.dataset.growingIgnore') ||
28
+ // 没有标记强制采集且是自动播放的组件(例如轮播、视频播放)事件拦截
29
+ (!ut.get(e, 'target.dataset.growingTrack') &&
30
+ ut.get(e, 'detail.source') === 'autoplay') ||
31
+ // 防止重写页面后可能出现重复的事件
32
+ (e.type === this.prevEvent?.type &&
33
+ // uniapp中后产生事件的时间戳可能比前序的小导致相减为负值,所以要取绝对值保证两个事件不是重复触发即可。事件重复触发是taro才会出现的
34
+ Math.abs(Number(e.timeStamp) - Number(this.prevEvent?.timeStamp)) < 10)
35
+ ) {
36
+ return;
37
+ }
38
+ // taro3多余事件过滤
39
+ if (vdsConfig.taro && [('#eh', 'eh')].includes(eventName)) {
40
+ return;
41
+ }
42
+ this.prevEvent = e;
43
+ // uniapp
44
+ if (vdsConfig.uniVue) {
45
+ eventName = plugins?.gioUniAppAdapter.getHandlerName(eventName, e);
46
+ }
47
+ // 事件逻辑
48
+ if (vdsConfig.debug) {
49
+ console.log('Action:', e.type, Date.now());
50
+ }
51
+ // 向其他插件广播事件
52
+ emitter.emit('onComposeBefore', {
53
+ event: eventName,
54
+ params: e ?? {}
55
+ });
56
+ const actionListeners = platformConfig.listeners.actions;
57
+ if (actionListeners.click.includes(e.type)) {
58
+ this.buildClickEvent(e, eventName);
59
+ } else if (actionListeners.change.includes(e.type)) {
60
+ this.buildChangeEvent(e, eventName);
61
+ }
62
+ };
63
+
64
+ // 获取触发节点xpath信息
65
+ getNodeXpath = (e: EventTarget, eventName: string) => {
66
+ const { gioPlatform, vdsConfig } = this.growingIO;
67
+ const target = e.currentTarget || e.target;
68
+ let id = target.id;
69
+ if (
70
+ !id ||
71
+ (gioPlatform === 'swan' && /^_[0-9a-f]+/.test(id)) ||
72
+ (isTaro3(vdsConfig.taro) && /^_n_[0-9]+$/.test(id))
73
+ ) {
74
+ id = '';
75
+ }
76
+ return `${id}#${eventName}`;
77
+ };
78
+
79
+ // 构建点击事件
80
+ buildClickEvent = (e: EventTarget, eventName: string) => {
81
+ const xpath = this.getNodeXpath(e, eventName);
82
+ if (xpath) {
83
+ const {
84
+ dataStore: { eventContextBuilder, eventInterceptor }
85
+ } = this.growingIO;
86
+ const target = e.currentTarget || e.target;
87
+ let idx;
88
+ if (ut.has(target?.dataset, 'index') && target?.dataset?.index !== '') {
89
+ const index: any = ut.toString(target.dataset.index);
90
+ if (
91
+ /^\d{1,10}$/.test(index) &&
92
+ index - 0 > 0 &&
93
+ index - 0 < 2147483647
94
+ ) {
95
+ idx = +index;
96
+ } else {
97
+ consoleText(
98
+ `${target.dataset.index},index标记应为 大于 0 且小于 2147483647 的整数!`,
99
+ 'warn'
100
+ );
101
+ }
102
+ }
103
+ const event = {
104
+ eventType: 'VIEW_CLICK',
105
+ element: [
106
+ {
107
+ xpath,
108
+ index: idx,
109
+ textValue: target?.dataset?.title,
110
+ hyperlink: target?.dataset?.src
111
+ }
112
+ ],
113
+ ...eventContextBuilder()
114
+ };
115
+ eventInterceptor(event);
116
+ }
117
+ };
118
+
119
+ // 构建tab菜单点击事件
120
+ buildTabClickEvent = (tabItem: any) => {
121
+ const {
122
+ dataStore: { eventContextBuilder, eventInterceptor }
123
+ } = this.growingIO;
124
+ const event = {
125
+ eventType: 'VIEW_CLICK',
126
+ element: [
127
+ {
128
+ xpath: '#onTabItemTap',
129
+ textValue: tabItem.text,
130
+ index: tabItem.index + 1,
131
+ hyperlink: ut.toString(tabItem.pagePath)
132
+ }
133
+ ],
134
+ ...eventContextBuilder()
135
+ };
136
+ eventInterceptor(event);
137
+ };
138
+
139
+ // 构建表单变化事件
140
+ buildChangeEvent = (e: EventTarget, eventName: string) => {
141
+ const xpath = this.getNodeXpath(e, eventName);
142
+ if (xpath) {
143
+ const {
144
+ dataStore: { eventContextBuilder, eventInterceptor }
145
+ } = this.growingIO;
146
+ const target = e.currentTarget || e.target;
147
+ const event = {
148
+ eventType: 'VIEW_CHANGE',
149
+ element: { xpath },
150
+ ...eventContextBuilder()
151
+ };
152
+ const ev = ut.get(e, 'detail.value') || ut.get(e, 'target.attr.value');
153
+ if (target?.dataset?.growingTrack || target?.dataset?.growingtrack) {
154
+ if (!ut.isNil(ev)) {
155
+ event.element.textValue = ut.toString(ev);
156
+ }
157
+ }
158
+ event.element = [event.element];
159
+ eventInterceptor(event);
160
+ }
161
+ };
162
+ }
163
+
164
+ export default { name: 'gioEventAutoTracking', method: GioEventAutoTracking };
@@ -0,0 +1,298 @@
1
+ /**
2
+ * 名称:半自动浏览埋点插件
3
+ * 用途:用于提供半自动浏览埋点事件的自动注册、参数检验构建和创建事件方法。
4
+ */
5
+ import { GrowingIOType } from '@@/types/growingIO';
6
+ import { isEqualArray } from '@@/utils/glodash';
7
+ import { hashCode } from '@@/utils/tools';
8
+
9
+ let ut;
10
+ class GioImpressionTracking {
11
+ public observerIds: any;
12
+ public rects: any;
13
+ public pageImpObserver: any;
14
+ public componentImpObserver: any;
15
+ public pageQueryTarget: any;
16
+ public componentQueryTarget: any;
17
+ public sentImps: any;
18
+ constructor(public growingIO: GrowingIOType) {
19
+ ut = this.growingIO.utils;
20
+ this.observerIds = {};
21
+ this.rects = {};
22
+ this.sentImps = {};
23
+ const { emitter, minipInstance } = this.growingIO;
24
+ this.growingIO.updateImpression = (collect: any) => {
25
+ if (!collect) {
26
+ collect = minipInstance.getCurrentPage();
27
+ }
28
+ minipInstance.initImpression(collect);
29
+ };
30
+ emitter.on('minipLifecycle', ({ event, params }) => {
31
+ const { minipInstance } = this.growingIO;
32
+ if (event === 'Page onShowEnd') {
33
+ const page = minipInstance.getCurrentPage();
34
+ this.traverseListen(page);
35
+ }
36
+ if (['Page onHide', 'Page onUnload'].includes(event)) {
37
+ // 页面隐藏时销毁曝光监听
38
+ const route = params.page.route;
39
+ const observers = Object.values(this.observerIds[route] ?? {});
40
+ observers.forEach((o: any) => o.disconnect());
41
+ }
42
+ });
43
+ }
44
+
45
+ // 遍历页面中的自定义组件进行监听
46
+ traverseListen = (target: any) => {
47
+ const { minipInstance } = this.growingIO;
48
+ if (ut.isFunction(target?.selectAllComponents)) {
49
+ const selects = target?.selectAllComponents(
50
+ '.growing_collect_imp_component'
51
+ );
52
+ if (!ut.isEmpty(selects)) {
53
+ selects.forEach((s) => {
54
+ this.traverseListen(s);
55
+ });
56
+ }
57
+ }
58
+ minipInstance.initImpression(target);
59
+ };
60
+
61
+ // 判断是否为相同的监听节点
62
+ // 这个方法中的hashCode和isEqualArray要直接引入使用,否则可能会在jd/my/tb小程序中出现找不到的情况(运行时机问题)
63
+ isEqualRects = (rs: any[], route: string, nodeId: string) => {
64
+ const controlGroup = ((this.rects[route] ?? {})[nodeId] ?? []).map((o) =>
65
+ hashCode(JSON.stringify(o))
66
+ );
67
+ const comparisonGroup = (rs ?? []).map((o) => hashCode(JSON.stringify(o)));
68
+ return isEqualArray(controlGroup, comparisonGroup);
69
+ };
70
+
71
+ // 获取到可监听节点后校验节点信息
72
+ rectobserve = (rect, collectTarget, optionKey) => {
73
+ const nodeId = collectTarget.__wxExparserNodeId__;
74
+ const page = collectTarget.route
75
+ ? collectTarget
76
+ : this.growingIO.minipInstance.getCurrentPage();
77
+ // 监听的节点和上一次的不一致,或者监听的组件或页面的监听已经被注销时,可以继续生成新的监听
78
+ let observerNeedNew = false;
79
+ if (page.route) {
80
+ const isEqualRects = this.isEqualRects(rect, page.route, nodeId);
81
+ const disconnect = ut.get(
82
+ this.observerIds,
83
+ `${page.route}.${nodeId}._disconnected`
84
+ );
85
+ observerNeedNew = !isEqualRects || disconnect !== false;
86
+ }
87
+ if (
88
+ ut.isArray(rect) &&
89
+ !ut.isEmpty(rect) &&
90
+ !ut.isNil(rect[0]) &&
91
+ observerNeedNew
92
+ ) {
93
+ if (ut.isEmpty(this.rects[page.route])) {
94
+ this.rects[page.route] = {};
95
+ }
96
+ this.rects[page.route][nodeId] = rect;
97
+ this.creatObserver(collectTarget, optionKey);
98
+ }
99
+ };
100
+
101
+ // swan、my中optionKey为'selectAll',其他为'observeAll',不含快应用
102
+ main = (collectTarget: any, optionKey: 'observeAll' | 'selectAll') => {
103
+ const { gioPlatform } = this.growingIO;
104
+ // 页面中存在曝光标记的节点才监听
105
+ // 有route字段的是页面,没有的是组件内部
106
+ const query = collectTarget.route
107
+ ? this.growingIO.minipInstance.minip?.createSelectorQuery()
108
+ : this.growingIO.minipInstance.minip
109
+ ?.createSelectorQuery()
110
+ .in(collectTarget);
111
+ if (['ks', 'qq'].includes(gioPlatform)) {
112
+ query.selectAll('.growing_collect_imp').boundingClientRect(([rect]) => {
113
+ rect = ut.isNil(rect) || ut.isArray(rect) ? rect : [rect];
114
+ this.rectobserve(rect, collectTarget, optionKey);
115
+ });
116
+ query.exec();
117
+ } else {
118
+ query.selectAll('.growing_collect_imp').boundingClientRect();
119
+ query.exec(([rect]) => {
120
+ this.rectobserve(rect, collectTarget, optionKey);
121
+ });
122
+ }
123
+ };
124
+
125
+ // 创建监听
126
+ creatObserver = (
127
+ collectTarget: any,
128
+ optionKey: 'observeAll' | 'selectAll'
129
+ ) => {
130
+ const { gioPlatform, minipInstance } = this.growingIO;
131
+ // 初始化监听对象
132
+ const observerOption = { [optionKey]: true };
133
+ if (
134
+ ['tb', 'my'].includes(gioPlatform) &&
135
+ ut.compareVersion(my.SDKVersion, '2.7.0') >= -1
136
+ ) {
137
+ observerOption.dataset = true;
138
+ }
139
+
140
+ const nodeId = collectTarget.__wxExparserNodeId__;
141
+ let page = collectTarget;
142
+ // uniapp是组件和页面一体,所以要分两次尝试监听;原生是组件和页面互相独立,按类型监听
143
+ // 自定义组件是不能直接在页面上被拿到,所以直接监听页面不会监听到自定义组件
144
+ if (
145
+ collectTarget.isComponent ||
146
+ !collectTarget.route ||
147
+ collectTarget.mpType === 'component'
148
+ ) {
149
+ page = minipInstance.getCurrentPage();
150
+ }
151
+
152
+ if (!this.observerIds[page.route]) {
153
+ this.observerIds[page.route] = {};
154
+ }
155
+ // 存在组件id一致的监听时要先移除监听,防止重复监听重复触发
156
+ const originObserver = this.observerIds[page.route][nodeId];
157
+ if (originObserver && !originObserver._disconnected) {
158
+ originObserver.disconnect();
159
+ }
160
+ // 创建一个新的监听
161
+ let observer =
162
+ gioPlatform === 'jd'
163
+ ? minipInstance.minip?.createIntersectionObserver(
164
+ collectTarget,
165
+ observerOption
166
+ )
167
+ : collectTarget.createIntersectionObserver(observerOption);
168
+ observer = observer.relativeToViewport();
169
+ // 不管原先是否创建过,直接覆盖(obeserverId会更新)
170
+ this.observerIds[page.route][nodeId] = observer;
171
+ // 添加监听回调
172
+ this.targetObserve(observer, page);
173
+ };
174
+
175
+ // 给目标节点添加监听回调
176
+ targetObserve = (observerTarget: any, collectPage: any) => {
177
+ const { taro } = this.growingIO.vdsConfig;
178
+ // 监听节点变化
179
+ observerTarget.observe('.growing_collect_imp', (result: any) => {
180
+ if (!ut.isEmpty(result) && result.intersectionRatio > 0) {
181
+ let dataset: any = result.dataset;
182
+ if (taro && ut.isTaro3(taro)) {
183
+ dataset = this.getTaro3Dataset(collectPage.route, result.id);
184
+ }
185
+ const dataProperties = this.getImpressionProperties(dataset);
186
+ // 曝光类型判断,单次曝光的需要有id和gio-imp-type字段
187
+ const sentId = result.id;
188
+ if (sentId) {
189
+ if (dataset.gioImpType === 'once' && ut.has(this.sentImps, sentId)) {
190
+ return;
191
+ } else {
192
+ this.sentImps[sentId] = dataProperties;
193
+ }
194
+ }
195
+ if (dataProperties.eventId) {
196
+ // 要直接构建custom事件,不要去调用埋点插件的方法,万一插件没有加载就发不出去了
197
+ this.buildImpEvent(dataProperties);
198
+ } else {
199
+ ut.consoleText(
200
+ '曝光事件格式不正确,事件名只能包含数字、字母和下划线,且不以数字开头!',
201
+ 'warn'
202
+ );
203
+ }
204
+ }
205
+ });
206
+ };
207
+
208
+ // 曝光参数获取
209
+ getImpressionProperties = (dataSet: any) => {
210
+ let data: any = {
211
+ eventId: undefined,
212
+ properties: {}
213
+ };
214
+ if (!dataSet?.gioImpTrack) {
215
+ return data;
216
+ } else {
217
+ data.eventId = dataSet.gioImpTrack;
218
+ }
219
+ if (ut.has(dataSet, 'gioImpAttrs')) {
220
+ // imp写法二
221
+ data.properties = ut.niceTry(() =>
222
+ ut.isObject(dataSet.gioImpAttrs)
223
+ ? dataSet.gioImpAttrs
224
+ : JSON.parse(dataSet.gioImpAttrs)
225
+ );
226
+ } else {
227
+ // imp写法一
228
+ const propReg = /^gioTrack(.+)/;
229
+ for (const key in dataSet) {
230
+ let normKey;
231
+ const matchArr = key.match(propReg);
232
+ if (matchArr) {
233
+ normKey = ut.lowerFirst(matchArr[1]);
234
+ if (normKey !== 'track') {
235
+ data.properties[normKey] = dataSet[key];
236
+ }
237
+ }
238
+ }
239
+ }
240
+ // 对参数对象进行限制
241
+ data.properties = ut.limitObject(data.properties);
242
+ // 校验eventId
243
+ const eventIdReg = /^\w+$/;
244
+ if (
245
+ !eventIdReg.test(data.eventId) ||
246
+ Number.isInteger(Number.parseInt(ut.head(data.eventId.split('')), 10))
247
+ ) {
248
+ data.eventId = null;
249
+ data = {};
250
+ }
251
+ return data;
252
+ };
253
+
254
+ // 获取Taro3节点上的dataset
255
+ getTaro3Dataset = (route: string, targetId: string) => {
256
+ const page = this.growingIO?.taro3VMs[route];
257
+ if (!page) {
258
+ return false;
259
+ }
260
+ let impDataset = {};
261
+ const searchTraverse = (n: any) => {
262
+ n.some((o: any) => {
263
+ if (
264
+ (o.uid === targetId || o.sid === targetId) &&
265
+ o.props?.class.indexOf('growing_collect_imp') > -1 &&
266
+ !ut.isEmpty(o.dataset)
267
+ ) {
268
+ impDataset = o.dataset;
269
+ return true;
270
+ } else if (Array.isArray(o.childNodes)) {
271
+ return searchTraverse(o.childNodes);
272
+ } else {
273
+ return false;
274
+ }
275
+ });
276
+ };
277
+ searchTraverse(page.childNodes);
278
+ return impDataset;
279
+ };
280
+
281
+ // 创建半自动曝光事件
282
+ buildImpEvent = (dataProperties: any) => {
283
+ const { eventId, properties } = dataProperties;
284
+ const {
285
+ dataStore: { eventContextBuilder, eventInterceptor }
286
+ } = this.growingIO;
287
+ const event = {
288
+ eventType: 'CUSTOM',
289
+ eventName: eventId,
290
+ attributes: properties,
291
+ ...eventContextBuilder(),
292
+ customEventType: 0
293
+ };
294
+ eventInterceptor(event);
295
+ };
296
+ }
297
+
298
+ export default { name: 'gioImpressionTracking', method: GioImpressionTracking };
@@ -0,0 +1,150 @@
1
+ interface TBConfig {
2
+ cloud: any;
3
+ cloudFuncSend?: boolean;
4
+ cloudFuncName?: string;
5
+ cloudFuncHandler?: string;
6
+ cloudAppId?: string;
7
+ path?: string;
8
+ }
9
+ export interface UserOptions {
10
+ // 是否开启无埋点
11
+ autotrack: boolean;
12
+ // 是否开启加密压缩
13
+ compress: boolean;
14
+ // 是否开启数据采集
15
+ dataCollect: boolean;
16
+ // 是否开启调试模式
17
+ debug: boolean;
18
+ // 是否开启
19
+ idMapping: boolean;
20
+ // 与内嵌页打通时额外的信息参数
21
+ extraParams: string[];
22
+ // 是否开启分享跟踪
23
+ followShare: boolean;
24
+ // 是否开启强制登录
25
+ forceLogin: boolean;
26
+ // 或略上报字段
27
+ ignoreFields: string[];
28
+ // 是否使用原始来源信息作为访问事件的参数上报
29
+ originalSource: boolean;
30
+ // session保活时长(5分钟)
31
+ keepAlive: number;
32
+ // 性能采集配置
33
+ performance?: { monitor: boolean; exception: boolean };
34
+ // 数据上报域名
35
+ serverUrl?: string;
36
+ // 是否标记为分包
37
+ subpackage: boolean;
38
+ // taro框架实例
39
+ taro?: any;
40
+ // taro框架vue实例
41
+ taroVue?: any;
42
+ // 淘宝小程序/小部件配置
43
+ tbConfig?: TBConfig;
44
+ // uniapp vue实例
45
+ uniVue?: boolean;
46
+ // 上报间隔(1秒)
47
+ uploadInterval: number;
48
+ // 小程序应用版本
49
+ version: string;
50
+ }
51
+
52
+ export interface ErrorEventParams {
53
+ key?: string;
54
+ error: string;
55
+ page?: string;
56
+ function?: string;
57
+ }
58
+
59
+ export interface Element {
60
+ x: string;
61
+ v?: string;
62
+ h?: string;
63
+ idx?: number;
64
+ obj?: number;
65
+ }
66
+
67
+ export type EventTypes =
68
+ | 'PAGE'
69
+ | 'VISIT'
70
+ | 'CUSTOM'
71
+ | 'VISITOR_ATTRIBUTES'
72
+ | 'LOGIN_USER_ATTRIBUTES'
73
+ | 'APP_CLOSED'
74
+ | 'VIEW_CLICK'
75
+ | 'VIEW_CHANGE';
76
+
77
+ export interface Event {
78
+ appChannel: string;
79
+ appVersion: string;
80
+ attributes?: any;
81
+ dataSourceId: string;
82
+ deviceBrand: string;
83
+ deviceId: string;
84
+ deviceModel: string;
85
+ deviceType: string;
86
+ domain: string;
87
+ eventName: string;
88
+ eventSequenceId: number;
89
+ eventType: EventTypes;
90
+ hyperlink?: string;
91
+ index?: number;
92
+ language: string;
93
+ latitude?: number;
94
+ longitude?: number;
95
+ networkState: string;
96
+ path?: string;
97
+ platform: string;
98
+ platformVersion: string;
99
+ properties?: any;
100
+ query?: string;
101
+ referralPage?: string;
102
+ screenHeight: number;
103
+ screenWidth: number;
104
+ sdkVersion: string;
105
+ sessionId: string;
106
+ textValue?: string;
107
+ timestamp: number;
108
+ title: string;
109
+ userId?: string;
110
+ xpath?: string;
111
+ }
112
+
113
+ export type Actions =
114
+ | 'tap'
115
+ | 'longpress'
116
+ | 'longtap'
117
+ | 'change'
118
+ | 'confirm'
119
+ | 'blur'
120
+ | 'getphonenumber'
121
+ | 'contact'
122
+ | 'getuserinfo';
123
+
124
+ export interface EventTarget {
125
+ type: Actions;
126
+ currentTarget: {
127
+ id: string;
128
+ dataset: {
129
+ index: number | string;
130
+ src: string;
131
+ title: string;
132
+ growingTrack: boolean;
133
+ growingtrack: boolean;
134
+ growingIgnore: boolean;
135
+ };
136
+ };
137
+ target: {
138
+ id: string;
139
+ dataset: {
140
+ index: number | string;
141
+ src: string;
142
+ title: string;
143
+ growingTrack: boolean;
144
+ growingtrack: boolean;
145
+ growingIgnore: boolean;
146
+ };
147
+ };
148
+ detail: any;
149
+ handler: string | undefined;
150
+ }
@@ -0,0 +1,43 @@
1
+ import { UserOptions } from '@@/types/base';
2
+ import { EventHooksType } from '@@/types/eventHooks';
3
+
4
+ export interface OriginOptions extends UserOptions {
5
+ appId: string;
6
+ dataSourceId?: string;
7
+ projectId: string;
8
+ }
9
+
10
+ export interface DataStoreType {
11
+ buildAddFavorites: (args: any) => void;
12
+ buildAppMessageEvent: (args: any) => void;
13
+ buildTimelineEvent: (args: any) => void;
14
+ eventContextBuilder: (params?: any) => any;
15
+ eventConverter?: (event) => void;
16
+ eventHooks: EventHooksType;
17
+ eventInterceptor?: (event: any | void) => void;
18
+ eventReleaseInspector?: () => void;
19
+ generalProps: any;
20
+ getOption: (k?: string) => OriginOptions;
21
+ getOriginalSource: () => any;
22
+ gsid: number;
23
+ gsidStorageName: string;
24
+ initOptions: (userOptions: OriginOptions) => void;
25
+ initStorageInfo: () => void;
26
+ interceptEvents: any[];
27
+ keepAlive: number;
28
+ lastCloseTime: number;
29
+ lastPageEvent: any;
30
+ lastScene: number | string;
31
+ lastVisitEvent: any;
32
+ locationData: any;
33
+ originalSourceName: string;
34
+ saveStorageInfo: () => void;
35
+ scene: number | string;
36
+ sendPage: (props?: any) => void;
37
+ sendVisit: (props?: any) => void;
38
+ setOption: (k: string, v: any) => boolean;
39
+ setOriginalSource: (origins: any) => void;
40
+ shareOut: boolean;
41
+ toggleShareOut: (v?: boolean) => void;
42
+ trackTimers?: any;
43
+ }