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
package/src/core/userStore.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { batchGetStorageSync, batchSetStorageSync, guid } from '@@/utils/tools';
|
|
1
2
|
import { GrowingIOType } from '@@/types/growingIO';
|
|
3
|
+
import { isNil } from '@@/utils/glodash';
|
|
4
|
+
import { StringObject } from '@@/types/base';
|
|
2
5
|
import { UserStoreType } from '@@/types/userStore';
|
|
3
|
-
import
|
|
6
|
+
import EMIT_MSG from '@@/constants/emitMsg';
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* 代码中与3.0测量协议字段对应关系
|
|
@@ -13,190 +16,226 @@ import { batchGetStorageSync, batchSetStorageSync, guid } from '@@/utils/tools';
|
|
|
13
16
|
*/
|
|
14
17
|
|
|
15
18
|
class UserStore implements UserStoreType {
|
|
16
|
-
// 访问用户id
|
|
17
|
-
public uidStorageName: string;
|
|
18
|
-
// 登录用户id在存储中的名称
|
|
19
|
-
public userIdStorageName: string;
|
|
20
|
-
// 登录用户key在存储中的名称
|
|
21
|
-
public userKeyStorageName: string;
|
|
22
|
-
// 最后一次登录用户id在存储中的名称
|
|
23
|
-
public gioIdStorageName: string;
|
|
24
|
-
// 用户访问会话id
|
|
25
|
-
public _sessionId: string;
|
|
26
|
-
// 访问用户id(系统设置持久性存储)
|
|
19
|
+
// 访问用户id/设备id(系统设置持久性存储)
|
|
27
20
|
public _uid: string;
|
|
21
|
+
// 用户访问会话id
|
|
22
|
+
public _sessionId: StringObject;
|
|
28
23
|
// 登录用户id(客户设置持久性存储)
|
|
29
|
-
public _userId:
|
|
24
|
+
public _userId: StringObject;
|
|
30
25
|
// 登录用户key(客户设置持久性存储)
|
|
31
|
-
public _userKey:
|
|
26
|
+
public _userKey: StringObject;
|
|
32
27
|
// 最后一次登录用户id(持久性存储)
|
|
33
|
-
public _gioId:
|
|
28
|
+
public _gioId: StringObject;
|
|
34
29
|
constructor(public growingIO: GrowingIOType) {
|
|
35
|
-
const { inPlugin } = this.growingIO;
|
|
36
|
-
this.uidStorageName = inPlugin ? '_growing_plugin_uid_' : '_growing_uid_';
|
|
37
|
-
this.userIdStorageName = inPlugin
|
|
38
|
-
? '_growing_plugin_userId_'
|
|
39
|
-
: '_growing_userId_';
|
|
40
|
-
this.userKeyStorageName = inPlugin
|
|
41
|
-
? '_growing_plugin_userKey_'
|
|
42
|
-
: '_growing_userKey_';
|
|
43
|
-
this.gioIdStorageName = inPlugin
|
|
44
|
-
? '_growing_plugin_gioId_'
|
|
45
|
-
: '_growing_gioId_';
|
|
46
|
-
this._sessionId = guid();
|
|
47
30
|
this._uid = undefined;
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
50
|
-
this.
|
|
51
|
-
|
|
52
|
-
this.initUserInfo();
|
|
53
|
-
}
|
|
31
|
+
this._sessionId = {};
|
|
32
|
+
this._userId = {};
|
|
33
|
+
this._userKey = {};
|
|
34
|
+
this._gioId = {};
|
|
54
35
|
}
|
|
55
36
|
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
this._sessionId = guid();
|
|
60
|
-
}
|
|
61
|
-
return this._sessionId;
|
|
62
|
-
}
|
|
37
|
+
// 获取sessionId存储key
|
|
38
|
+
_getUidKey = () =>
|
|
39
|
+
this.growingIO.inPlugin ? '_growing_plugin_uid_' : '_growing_uid_';
|
|
63
40
|
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this._sessionId = id;
|
|
41
|
+
// 获取设备Id
|
|
42
|
+
getUid = () => {
|
|
43
|
+
const { minipInstance } = this.growingIO;
|
|
44
|
+
// 内存中拿不到尝试从存储中拿
|
|
45
|
+
if (!this._uid) {
|
|
46
|
+
this._uid = minipInstance.getStorageSync(this._getUidKey());
|
|
71
47
|
}
|
|
72
|
-
//
|
|
73
|
-
if (
|
|
74
|
-
this.
|
|
75
|
-
|
|
76
|
-
oldSessionId: prevId
|
|
77
|
-
});
|
|
48
|
+
// 存储中拿不到尝试设新值
|
|
49
|
+
if (!this._uid) {
|
|
50
|
+
this._uid = guid();
|
|
51
|
+
minipInstance.setStorage(this._getUidKey(), this._uid);
|
|
78
52
|
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// @ts-ignore
|
|
82
|
-
get uid() {
|
|
83
53
|
return this._uid;
|
|
84
|
-
}
|
|
54
|
+
};
|
|
85
55
|
|
|
86
|
-
//
|
|
87
|
-
|
|
56
|
+
// 设置设备Id
|
|
57
|
+
setUid = (id: string) => {
|
|
88
58
|
const prevId = this._uid;
|
|
89
59
|
this._uid = id;
|
|
90
60
|
if (prevId !== this._uid) {
|
|
91
|
-
this.growingIO.minipInstance.setStorage(this.
|
|
61
|
+
this.growingIO.minipInstance.setStorage(this._getUidKey(), this._uid);
|
|
92
62
|
// 广播通知访问用户Id变更
|
|
93
|
-
this.growingIO.emitter.emit(
|
|
63
|
+
this.growingIO.emitter.emit(EMIT_MSG.UID_UPDATE, {
|
|
94
64
|
newUId: id,
|
|
95
65
|
oldUId: prevId
|
|
96
66
|
});
|
|
97
67
|
}
|
|
98
|
-
}
|
|
68
|
+
};
|
|
99
69
|
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
70
|
+
// 获取sessionId
|
|
71
|
+
getSessionId = (trackingId: string) => {
|
|
72
|
+
if (!this._sessionId[trackingId]) {
|
|
73
|
+
this.setSessionId(trackingId);
|
|
74
|
+
}
|
|
75
|
+
return this._sessionId[trackingId];
|
|
76
|
+
};
|
|
104
77
|
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
const prevId = this.
|
|
108
|
-
|
|
109
|
-
|
|
78
|
+
// 设置sessionId
|
|
79
|
+
setSessionId = (trackingId: string, id?: string) => {
|
|
80
|
+
const prevId = this._sessionId[trackingId];
|
|
81
|
+
if (!id) {
|
|
82
|
+
id = guid();
|
|
83
|
+
}
|
|
84
|
+
// 小程序中sessionId只需要在内存中存储就可以,不需要持久化存储
|
|
85
|
+
this._sessionId[trackingId] = id;
|
|
86
|
+
// 广播通知登录sessionId变更
|
|
87
|
+
if (prevId !== id) {
|
|
88
|
+
this.growingIO.emitter.emit(EMIT_MSG.SESSIONID_UPDATE, {
|
|
89
|
+
newSessionId: id,
|
|
90
|
+
oldSessionId: prevId
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// 获取userId存储key
|
|
96
|
+
_getUserIdKey = (trackingId: string) =>
|
|
97
|
+
this.growingIO.dataStore.getStorageKey(trackingId, 'userId');
|
|
98
|
+
|
|
99
|
+
// 获取userId
|
|
100
|
+
getUserId = (trackingId: string) => {
|
|
101
|
+
const { minipInstance } = this.growingIO;
|
|
102
|
+
// 内存中拿不到尝试从存储中拿
|
|
103
|
+
if (!this._userId[trackingId]) {
|
|
104
|
+
this._userId[trackingId] = minipInstance.getStorageSync(
|
|
105
|
+
this._getUserIdKey(trackingId)
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
return this._userId[trackingId];
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// 设置userId
|
|
112
|
+
setUserId = (trackingId: string, id: string) => {
|
|
113
|
+
const prevId = this._userId[trackingId];
|
|
114
|
+
this._userId[trackingId] = isNil(id) ? '' : id;
|
|
115
|
+
if (prevId !== this._userId[trackingId]) {
|
|
110
116
|
this.growingIO.minipInstance.setStorage(
|
|
111
|
-
this.
|
|
112
|
-
this._userId
|
|
117
|
+
this._getUserIdKey(trackingId),
|
|
118
|
+
this._userId[trackingId]
|
|
113
119
|
);
|
|
114
120
|
// 广播通知登录用户Id变更
|
|
115
|
-
this.growingIO.emitter.emit(
|
|
121
|
+
this.growingIO.emitter.emit(EMIT_MSG.USERID_UPDATE, {
|
|
116
122
|
newUserId: id,
|
|
117
123
|
oldUserId: prevId
|
|
118
124
|
});
|
|
119
125
|
}
|
|
120
|
-
if (id) this.
|
|
121
|
-
}
|
|
126
|
+
if (id) this.setGioId(trackingId, id);
|
|
127
|
+
};
|
|
122
128
|
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
129
|
+
// 获取userKey存储key
|
|
130
|
+
_getUserKeyKey = (trackingId: string) =>
|
|
131
|
+
this.growingIO.dataStore.getStorageKey(trackingId, 'userKey');
|
|
127
132
|
|
|
128
|
-
//
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
if (
|
|
133
|
+
// 获取userKey
|
|
134
|
+
getUserKey = (trackingId: string) => {
|
|
135
|
+
const { minipInstance } = this.growingIO;
|
|
136
|
+
// 内存中拿不到尝试从存储中拿
|
|
137
|
+
if (!this._userKey[trackingId]) {
|
|
138
|
+
this._userKey[trackingId] = minipInstance.getStorageSync(
|
|
139
|
+
this._getUserKeyKey(trackingId)
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
return this._userKey[trackingId];
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// 设置userKey
|
|
146
|
+
setUserKey = (trackingId: string, key: string) => {
|
|
147
|
+
const prevKey = this._userKey[trackingId];
|
|
148
|
+
this._userKey[trackingId] = isNil(key) ? '' : key;
|
|
149
|
+
if (prevKey !== this._userKey[trackingId]) {
|
|
133
150
|
this.growingIO.minipInstance.setStorage(
|
|
134
|
-
this.
|
|
135
|
-
this._userKey
|
|
151
|
+
this._getUserKeyKey(trackingId),
|
|
152
|
+
this._userKey[trackingId]
|
|
136
153
|
);
|
|
137
154
|
// 广播通知登录用户key变更
|
|
138
|
-
this.growingIO.emitter.emit(
|
|
155
|
+
this.growingIO.emitter.emit(EMIT_MSG.USERKEY_UPDATE, {
|
|
139
156
|
newUserKey: key,
|
|
140
157
|
oldUserKey: prevKey
|
|
141
158
|
});
|
|
142
159
|
}
|
|
143
|
-
}
|
|
160
|
+
};
|
|
144
161
|
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
162
|
+
// 获取gioId存储key
|
|
163
|
+
_getGioIdKey = (trackingId: string) =>
|
|
164
|
+
this.growingIO.dataStore.getStorageKey(trackingId, 'gioId');
|
|
149
165
|
|
|
150
|
-
//
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
if (
|
|
166
|
+
// 获取gioId
|
|
167
|
+
getGioId = (trackingId: string) => {
|
|
168
|
+
const { minipInstance } = this.growingIO;
|
|
169
|
+
// 内存中拿不到尝试从存储中拿
|
|
170
|
+
if (!this._gioId[trackingId]) {
|
|
171
|
+
this._gioId[trackingId] = minipInstance.getStorageSync(
|
|
172
|
+
this._getGioIdKey(trackingId)
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
return this._gioId[trackingId];
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// 设置gioId
|
|
179
|
+
setGioId = (trackingId: string, gioId: string) => {
|
|
180
|
+
const prevId = this._gioId[trackingId];
|
|
181
|
+
this._gioId[trackingId] = isNil(gioId) ? '' : gioId;
|
|
182
|
+
if (prevId !== this._gioId[trackingId]) {
|
|
155
183
|
this.growingIO.minipInstance.setStorage(
|
|
156
|
-
this.
|
|
157
|
-
this._gioId
|
|
184
|
+
this._getGioIdKey(trackingId),
|
|
185
|
+
this._gioId[trackingId]
|
|
158
186
|
);
|
|
159
187
|
// 广播通知登录用户Id变更
|
|
160
|
-
this.growingIO.emitter.emit(
|
|
188
|
+
this.growingIO.emitter.emit(EMIT_MSG.GIOID_UPDATE, {
|
|
161
189
|
newGioId: gioId,
|
|
162
190
|
oldGioId: prevId
|
|
163
191
|
});
|
|
164
192
|
}
|
|
165
|
-
}
|
|
193
|
+
};
|
|
166
194
|
|
|
167
195
|
// 初始化用户信息
|
|
168
|
-
initUserInfo = () => {
|
|
196
|
+
initUserInfo = (trackingId: string) => {
|
|
169
197
|
const { minipInstance } = this.growingIO;
|
|
170
198
|
const storeKeys = [
|
|
171
|
-
this.
|
|
172
|
-
this.
|
|
173
|
-
this.
|
|
174
|
-
this.
|
|
199
|
+
this._getUidKey(),
|
|
200
|
+
this._getUserIdKey(trackingId),
|
|
201
|
+
this._getUserKeyKey(trackingId),
|
|
202
|
+
this._getGioIdKey(trackingId)
|
|
175
203
|
];
|
|
176
204
|
const memoryKeys = ['_uid', '_userId', '_userKey', '_gioId'];
|
|
177
205
|
// 批量获取的存储数据
|
|
178
206
|
const values = batchGetStorageSync(minipInstance, storeKeys) ?? [];
|
|
179
207
|
// 往存储中重设的key
|
|
180
208
|
memoryKeys.forEach((key: string, index: number) => {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
//
|
|
186
|
-
this
|
|
209
|
+
if (key === '_uid') {
|
|
210
|
+
// 调用一次往内存里存一份
|
|
211
|
+
this.getUid();
|
|
212
|
+
} else {
|
|
213
|
+
// 往内存中赋值
|
|
214
|
+
this[key][trackingId] = values[index];
|
|
187
215
|
}
|
|
188
216
|
});
|
|
189
217
|
};
|
|
190
218
|
|
|
191
219
|
// 退出小程序时在存储中同步用户信息
|
|
192
220
|
saveUserInfo = () => {
|
|
193
|
-
const {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
221
|
+
const {
|
|
222
|
+
minipInstance,
|
|
223
|
+
dataStore: { trackersExecute }
|
|
224
|
+
} = this.growingIO;
|
|
225
|
+
trackersExecute((trackingId: string) => {
|
|
226
|
+
batchSetStorageSync(minipInstance, [
|
|
227
|
+
{ key: this._getUidKey(), value: this._uid },
|
|
228
|
+
{
|
|
229
|
+
key: this._getUserIdKey(trackingId),
|
|
230
|
+
value: this._userId[trackingId]
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
key: this._getUserKeyKey(trackingId),
|
|
234
|
+
value: this._userKey[trackingId]
|
|
235
|
+
},
|
|
236
|
+
{ key: this._getGioIdKey(trackingId), value: this._gioId[trackingId] }
|
|
237
|
+
]);
|
|
238
|
+
});
|
|
200
239
|
};
|
|
201
240
|
}
|
|
202
241
|
|
package/src/index.ts
CHANGED
|
@@ -1,52 +1,61 @@
|
|
|
1
|
-
import {
|
|
2
|
-
initPreCheck,
|
|
3
|
-
paramExtraCheck,
|
|
4
|
-
paramsBaseCheck,
|
|
5
|
-
paramsEmptyCheck
|
|
6
|
-
} from '@@/utils/verifiers';
|
|
1
|
+
import { initialCheck } from '@@/utils/verifiers';
|
|
7
2
|
import { consoleText, getGlobal, niceTry } from '@@/utils/tools';
|
|
8
3
|
import { drop, isString, toString } from '@@/utils/glodash';
|
|
9
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
HANDLERS,
|
|
6
|
+
DEPRECATED_HANDLERS,
|
|
7
|
+
INSTANCE_HANDLERS
|
|
8
|
+
} from '@@/constants/config';
|
|
10
9
|
import GrowingIO from './core/growingIO';
|
|
11
10
|
|
|
12
11
|
const gioInstance: any = new GrowingIO();
|
|
13
12
|
|
|
14
13
|
const gdp = function () {
|
|
15
|
-
const
|
|
14
|
+
const handlerName = arguments[0];
|
|
15
|
+
let trackingId = 'g0';
|
|
16
|
+
let handler = handlerName;
|
|
17
|
+
if (handlerName.indexOf('.') > -1) {
|
|
18
|
+
trackingId = handlerName.split('.')[0] ?? 'g0'; // 没有指定trackingId,默认为g0
|
|
19
|
+
handler = handlerName.split('.')[1];
|
|
20
|
+
}
|
|
16
21
|
// 判断指令为字符串且配置项中允许调用且实例中存在的方法
|
|
17
|
-
if (
|
|
18
|
-
isString(actionName) &&
|
|
19
|
-
HANDLERS.includes(actionName) &&
|
|
20
|
-
gioInstance[actionName]
|
|
21
|
-
) {
|
|
22
|
+
if (isString(handler) && HANDLERS.includes(handler) && gioInstance[handler]) {
|
|
22
23
|
const args = drop(Array.from(arguments));
|
|
23
24
|
// 初始化方法单独处理
|
|
24
|
-
if (
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (preCheckRes && emptyCheckRes && baseCheckRes && extraCheckRes) {
|
|
30
|
-
const { projectId } = baseCheckRes;
|
|
31
|
-
const { dataSourceId, appId, options } = extraCheckRes;
|
|
25
|
+
if (handler === 'init') {
|
|
26
|
+
const initialCheckRes: any = initialCheck(gioInstance, args);
|
|
27
|
+
if (initialCheckRes) {
|
|
28
|
+
const { projectId, dataSourceId, appId, userOptions } = initialCheckRes;
|
|
29
|
+
// 返回初始化结果
|
|
32
30
|
return gioInstance.init({
|
|
33
|
-
...
|
|
31
|
+
...userOptions,
|
|
34
32
|
projectId,
|
|
35
33
|
dataSourceId,
|
|
36
|
-
appId
|
|
34
|
+
appId,
|
|
35
|
+
trackingId
|
|
37
36
|
});
|
|
37
|
+
} else {
|
|
38
|
+
return false;
|
|
38
39
|
}
|
|
39
|
-
} else if (
|
|
40
|
+
} else if (handler === 'registerPlugins') {
|
|
40
41
|
gioInstance.registerPlugins(args[0]);
|
|
41
42
|
} else if (gioInstance.gioSDKInitialized && gioInstance.vdsConfig) {
|
|
42
|
-
|
|
43
|
+
if (INSTANCE_HANDLERS.includes(handler)) {
|
|
44
|
+
return niceTry(() =>
|
|
45
|
+
gioInstance.handlerDistribute(trackingId, handler, args)
|
|
46
|
+
);
|
|
47
|
+
} else {
|
|
48
|
+
return niceTry(() => gioInstance[handler](...args));
|
|
49
|
+
}
|
|
43
50
|
} else {
|
|
44
51
|
consoleText('SDK未初始化!', 'error');
|
|
45
52
|
}
|
|
46
|
-
} else if (DEPRECATED_HANDLERS.includes(
|
|
47
|
-
consoleText(`方法 ${toString(
|
|
53
|
+
} else if (DEPRECATED_HANDLERS.includes(handler)) {
|
|
54
|
+
consoleText(`方法 ${toString(handler)} 已被弃用,请移除!`, 'warn');
|
|
55
|
+
} else if (handler === 'canIUse') {
|
|
56
|
+
return HANDLERS.includes(arguments[1]) && !!gioInstance[arguments[1]];
|
|
48
57
|
} else {
|
|
49
|
-
consoleText(`不存在名为 ${toString(
|
|
58
|
+
consoleText(`不存在名为 ${toString(handler)} 的方法调用!`, 'error');
|
|
50
59
|
}
|
|
51
60
|
};
|
|
52
61
|
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from '@@/types/minipInstance';
|
|
9
9
|
import { PLATFORMS } from '@@/types/platforms';
|
|
10
10
|
import { isFunction, isObject, isString, last } from '@@/utils/glodash';
|
|
11
|
+
import EMIT_MSG from '@@/constants/emitMsg';
|
|
11
12
|
import {
|
|
12
13
|
limitString,
|
|
13
14
|
niceTry,
|
|
@@ -32,7 +33,7 @@ class BaseInstance implements MinipInstanceType {
|
|
|
32
33
|
} = this.growingIO;
|
|
33
34
|
this.platform = platform;
|
|
34
35
|
this.scnPrefix = scnPrefix;
|
|
35
|
-
this.growingIO.emitter.on(
|
|
36
|
+
this.growingIO.emitter.on(EMIT_MSG.OPTION_INITIALIZED, () => {
|
|
36
37
|
this.getNetworkType().then(() =>
|
|
37
38
|
this.growingIO.dataStore?.eventReleaseInspector()
|
|
38
39
|
);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { GrowingIOType } from '@@/types/growingIO';
|
|
2
|
-
import { SystemInfo } from '@@/types/minipInstance';
|
|
3
2
|
import { isString, last } from '@@/utils/glodash';
|
|
4
3
|
import { limitString } from '@@/utils/tools';
|
|
4
|
+
import { SystemInfo } from '@@/types/minipInstance';
|
|
5
5
|
import app from '@system.app';
|
|
6
|
+
import BaseImplements from './base';
|
|
6
7
|
import device from '@system.device';
|
|
8
|
+
import EMIT_MSG from '@@/constants/emitMsg';
|
|
7
9
|
import fetch from '@system.fetch';
|
|
8
10
|
import image from '@system.image';
|
|
9
11
|
import network from '@system.network';
|
|
@@ -11,12 +13,10 @@ import router from '@system.router';
|
|
|
11
13
|
import share from '@system.share';
|
|
12
14
|
import storage from '@system.storage';
|
|
13
15
|
|
|
14
|
-
import BaseImplements from './base';
|
|
15
|
-
|
|
16
16
|
class QuickApp extends BaseImplements {
|
|
17
17
|
constructor(public growingIO: GrowingIOType) {
|
|
18
18
|
super(growingIO);
|
|
19
|
-
this.growingIO.emitter.on(
|
|
19
|
+
this.growingIO.emitter.on(EMIT_MSG.MINIP_LIFECYCLE, ({ event }) => {
|
|
20
20
|
switch (event) {
|
|
21
21
|
case 'App onCreate':
|
|
22
22
|
{
|
|
@@ -76,24 +76,10 @@ class QuickApp extends BaseImplements {
|
|
|
76
76
|
|
|
77
77
|
// 初始化分享
|
|
78
78
|
initShareAppMessage = (growingIO: GrowingIOType) => {
|
|
79
|
-
const {
|
|
79
|
+
const { platformConfig } = growingIO;
|
|
80
80
|
try {
|
|
81
81
|
this.growingIO.shareAppMessage = function () {
|
|
82
82
|
const params = arguments[0];
|
|
83
|
-
if (
|
|
84
|
-
params &&
|
|
85
|
-
params.type &&
|
|
86
|
-
!/^text.*/.test(params.type) &&
|
|
87
|
-
params.data
|
|
88
|
-
) {
|
|
89
|
-
if (vdsConfig.followShare) {
|
|
90
|
-
if (params.data.indexOf('?') === -1) {
|
|
91
|
-
params.data = params.data + '?suid=' + growingIO.userStore.uid;
|
|
92
|
-
} else {
|
|
93
|
-
params.data = params.data + '&suid=' + growingIO.userStore.uid;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
83
|
share?.share(params);
|
|
98
84
|
growingIO?.eventTracking?.pageEffects(
|
|
99
85
|
this,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PlatformConfigType } from '@@/types/platforms';
|
|
2
|
-
import { niceTry } from '@@/utils/tools';
|
|
3
2
|
|
|
4
3
|
const Config: PlatformConfigType = {
|
|
5
4
|
scnPrefix: '',
|
|
@@ -40,10 +39,6 @@ const Config: PlatformConfigType = {
|
|
|
40
39
|
'contact',
|
|
41
40
|
'mouseup'
|
|
42
41
|
],
|
|
43
|
-
originalApp: niceTry(() => App),
|
|
44
|
-
originalPage: niceTry(() => Page),
|
|
45
|
-
originalComponent: niceTry(() => Component),
|
|
46
|
-
originalBehavior: niceTry(() => Behavior),
|
|
47
42
|
canHook: true,
|
|
48
43
|
hooks: {
|
|
49
44
|
App: true,
|