aegis-mp-rum-wrapper 0.1.3 → 0.1.4
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/index.d.ts +1 -6
- package/dist/index.js +112 -69
- package/package.json +1 -1
- package/src/index.ts +94 -41
package/dist/index.d.ts
CHANGED
|
@@ -46,9 +46,4 @@ export declare function getInstances(): {
|
|
|
46
46
|
defaultAegis: any;
|
|
47
47
|
serviceAegis: any;
|
|
48
48
|
};
|
|
49
|
-
export
|
|
50
|
-
user: AegisUserInfo;
|
|
51
|
-
rumID: string;
|
|
52
|
-
reportEvent: (params: string | ReportParams) => void;
|
|
53
|
-
}
|
|
54
|
-
export declare const AegisW: AegisWrapperFacade;
|
|
49
|
+
export declare const AegisW: any;
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
@@ -20,10 +9,10 @@ exports.setUser = setUser;
|
|
|
20
9
|
exports.setRumID = setRumID;
|
|
21
10
|
exports.reportEvent = reportEvent;
|
|
22
11
|
exports.getInstances = getInstances;
|
|
23
|
-
|
|
12
|
+
const aegis_mp_sdk_1 = __importDefault(require("aegis-mp-sdk"));
|
|
24
13
|
// RUM 上报 ID(默认使用国服服务)
|
|
25
14
|
exports.GPPRumID = 'zYpo1fz400Vk86JR5Z';
|
|
26
|
-
|
|
15
|
+
const logItemTemplate = {
|
|
27
16
|
report_type: 11,
|
|
28
17
|
event_id: '',
|
|
29
18
|
service_type: '',
|
|
@@ -67,9 +56,9 @@ var logItemTemplate = {
|
|
|
67
56
|
source: 'fe_rum',
|
|
68
57
|
};
|
|
69
58
|
// 内部状态
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
59
|
+
let defaultAegis;
|
|
60
|
+
let serviceAegis;
|
|
61
|
+
const internalState = {
|
|
73
62
|
id: exports.GPPRumID,
|
|
74
63
|
uin: '',
|
|
75
64
|
reportApiSpeed: false,
|
|
@@ -84,11 +73,11 @@ var internalState = {
|
|
|
84
73
|
// 构建一条上报日志 JSON 字符串(写入 ext1)
|
|
85
74
|
function buildReportStr(params, isPV) {
|
|
86
75
|
var _a, _b, _c, _d, _e;
|
|
87
|
-
|
|
76
|
+
const logItem = Object.assign({}, logItemTemplate);
|
|
88
77
|
if (isPV) {
|
|
89
78
|
logItem.report_type = 1;
|
|
90
79
|
}
|
|
91
|
-
|
|
80
|
+
const user = internalState.user;
|
|
92
81
|
logItem.openid = ((_a = user.openid) !== null && _a !== void 0 ? _a : '') + '';
|
|
93
82
|
logItem.role_id = user.roleID ? user.roleID + '' : '';
|
|
94
83
|
logItem.area_id = user.area ? parseInt(String(user.area), 10) : 0;
|
|
@@ -99,7 +88,7 @@ function buildReportStr(params, isPV) {
|
|
|
99
88
|
logItem.event_id = ((_c = user.eventID) !== null && _c !== void 0 ? _c : '') + '';
|
|
100
89
|
logItem.country = user.country ? user.country + '' : '';
|
|
101
90
|
logItem.content_id = user.contentID ? user.contentID + '' : '';
|
|
102
|
-
|
|
91
|
+
const lang = (_e = (_d = user.language) !== null && _d !== void 0 ? _d : user.locale) !== null && _e !== void 0 ? _e : '';
|
|
103
92
|
logItem.language = lang ? lang + '' : '';
|
|
104
93
|
logItem.in_game = user.in_game ? parseInt(String(user.in_game), 10) : logItem.in_game;
|
|
105
94
|
logItem.env = user.env ? user.env + '' : logItem.env;
|
|
@@ -127,13 +116,14 @@ function buildReportStr(params, isPV) {
|
|
|
127
116
|
}
|
|
128
117
|
// 初始化 Aegis 实例(isDefault=true 为默认实例,false 为服务实例)
|
|
129
118
|
function initAegis(isDefault) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
119
|
+
console.log('initAegis205', isDefault, internalState);
|
|
120
|
+
let id = internalState.id;
|
|
121
|
+
let apiSpeed = internalState.reportApiSpeed;
|
|
122
|
+
let assetSpeed = internalState.reportAssetSpeed;
|
|
123
|
+
let pagePerformance = internalState.pagePerformance;
|
|
124
|
+
let webVitals = internalState.webVitals;
|
|
125
|
+
let delay = internalState.delay;
|
|
126
|
+
let ext1;
|
|
137
127
|
if (!isDefault) {
|
|
138
128
|
id = internalState.rumID || internalState.id;
|
|
139
129
|
apiSpeed = true;
|
|
@@ -142,32 +132,30 @@ function initAegis(isDefault) {
|
|
|
142
132
|
webVitals = true;
|
|
143
133
|
delay = 1000;
|
|
144
134
|
}
|
|
145
|
-
|
|
146
|
-
// 无论是否有用户信息,都会上报PV
|
|
147
|
-
if (isDefault) {
|
|
148
|
-
var pvName = internalState.ready ? '@@init_with_user' : '@@init_no_user';
|
|
149
|
-
console.log('pvName', pvName);
|
|
135
|
+
if (internalState.ready) {
|
|
150
136
|
ext1 = buildReportStr({
|
|
151
|
-
name:
|
|
137
|
+
name: '@@init',
|
|
152
138
|
ext1: internalState.user.ext1,
|
|
153
139
|
ext2: internalState.user.ext2,
|
|
154
140
|
ext3: internalState.user.ext3,
|
|
155
141
|
}, true);
|
|
156
|
-
console.log('[Aegis Wrapper] PV数据已构建,report_type=1');
|
|
157
142
|
}
|
|
143
|
+
console.log('AegisCtor235', aegis_mp_sdk_1.default);
|
|
158
144
|
// 小程序环境直接使用构造函数
|
|
159
145
|
if (typeof aegis_mp_sdk_1.default === 'function') {
|
|
146
|
+
console.log('return new AegisCtor');
|
|
160
147
|
return new aegis_mp_sdk_1.default({
|
|
161
|
-
id
|
|
148
|
+
id,
|
|
162
149
|
uin: internalState.uin,
|
|
163
150
|
reportApiSpeed: apiSpeed,
|
|
164
151
|
reportAssetSpeed: assetSpeed,
|
|
165
|
-
pagePerformance
|
|
166
|
-
webVitals
|
|
167
|
-
delay
|
|
152
|
+
pagePerformance,
|
|
153
|
+
webVitals,
|
|
154
|
+
delay,
|
|
168
155
|
spa: true,
|
|
169
|
-
ext1
|
|
170
|
-
beforeRequest
|
|
156
|
+
ext1,
|
|
157
|
+
beforeRequest(data) {
|
|
158
|
+
console.log('beforeRequest', data);
|
|
171
159
|
if (!isDefault) {
|
|
172
160
|
return data;
|
|
173
161
|
}
|
|
@@ -178,7 +166,7 @@ function initAegis(isDefault) {
|
|
|
178
166
|
},
|
|
179
167
|
});
|
|
180
168
|
}
|
|
181
|
-
console.error('[Aegis Wrapper] 找不到 aegis-mp-sdk 构造函数,请确认依赖是否正确安装和引用');
|
|
169
|
+
console.error('[Aegis Wrapper] 找不到 aegis-mp-sdk 构造函数,请确认依赖是否正确安装和引用265');
|
|
182
170
|
return undefined;
|
|
183
171
|
}
|
|
184
172
|
// 对外暴露的配置 API
|
|
@@ -199,8 +187,8 @@ function configureWrapper(config) {
|
|
|
199
187
|
internalState.delay = config.delay;
|
|
200
188
|
}
|
|
201
189
|
function setUser(user) {
|
|
202
|
-
|
|
203
|
-
|
|
190
|
+
const incoming = user;
|
|
191
|
+
const nextUser = Object.assign(Object.assign({}, internalState.user), user);
|
|
204
192
|
// 兼容 channeldID(文档示例里的字段名)到 channelID
|
|
205
193
|
if (incoming.channeldID != null && nextUser.channelID == null) {
|
|
206
194
|
nextUser.channelID = incoming.channeldID;
|
|
@@ -210,18 +198,13 @@ function setUser(user) {
|
|
|
210
198
|
nextUser.language = incoming.locale;
|
|
211
199
|
}
|
|
212
200
|
internalState.user = nextUser;
|
|
213
|
-
|
|
201
|
+
const u = internalState.user;
|
|
214
202
|
if (u.openid && u.serviceType && u.eventID) {
|
|
215
|
-
console.log('
|
|
203
|
+
console.log('294', internalState, defaultAegis);
|
|
216
204
|
if (!internalState.ready) {
|
|
217
205
|
internalState.ready = true;
|
|
218
|
-
console.log('[Aegis Wrapper] default aegis 已就绪');
|
|
219
|
-
defaultAegis = initAegis(true);
|
|
220
|
-
}
|
|
221
|
-
else if (!defaultAegis) {
|
|
222
|
-
// ready为true但defaultAegis丢失,重新初始化
|
|
223
|
-
console.log('[Aegis Wrapper] 重新初始化default aegis');
|
|
224
206
|
defaultAegis = initAegis(true);
|
|
207
|
+
console.log('[Aegis Wrapper] default aegis 已就绪298');
|
|
225
208
|
}
|
|
226
209
|
}
|
|
227
210
|
else {
|
|
@@ -239,8 +222,8 @@ function reportEvent(params) {
|
|
|
239
222
|
if (serviceAegis && typeof serviceAegis.reportEvent === 'function') {
|
|
240
223
|
serviceAegis.reportEvent(params);
|
|
241
224
|
}
|
|
242
|
-
if (!defaultAegis) {
|
|
243
|
-
console.error('[Aegis Wrapper] default aegis
|
|
225
|
+
if (!defaultAegis || typeof defaultAegis.reportEvent !== 'function') {
|
|
226
|
+
console.error('[Aegis Wrapper] default aegis 尚未准备就绪,请先调用 setUser 并补全必要字段');
|
|
244
227
|
return;
|
|
245
228
|
}
|
|
246
229
|
if (typeof params !== 'string' && typeof params !== 'object') {
|
|
@@ -251,30 +234,90 @@ function reportEvent(params) {
|
|
|
251
234
|
console.error('[Aegis Wrapper] reportEvent 缺少 name 字段');
|
|
252
235
|
return;
|
|
253
236
|
}
|
|
254
|
-
|
|
237
|
+
const payload = typeof params === 'string' ? { name: params } : Object.assign({}, params);
|
|
255
238
|
payload.ext1 = buildReportStr(payload, false);
|
|
256
239
|
defaultAegis.reportEvent(payload);
|
|
257
240
|
}
|
|
258
241
|
// 方便调试或高级用户直接访问底层实例
|
|
259
242
|
function getInstances() {
|
|
260
243
|
return {
|
|
261
|
-
defaultAegis
|
|
262
|
-
serviceAegis
|
|
244
|
+
defaultAegis,
|
|
245
|
+
serviceAegis,
|
|
263
246
|
};
|
|
264
247
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
set
|
|
270
|
-
console.log('
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
248
|
+
// 面向业务侧的简单封装对象,支持示例中的两种用法:
|
|
249
|
+
// 1)AegisW.user = {...}
|
|
250
|
+
// 2)AegisW.reportEvent({...})
|
|
251
|
+
const handler = {
|
|
252
|
+
set(target, prop, value) {
|
|
253
|
+
console.log('user change351', target, prop, value);
|
|
254
|
+
// console.log(`changed ${prop} from ${target[prop]} to ${value}`); // debug info
|
|
255
|
+
target[prop] = value;
|
|
256
|
+
if (prop === "user" && typeof value === "object") {
|
|
257
|
+
console.log('user change368');
|
|
258
|
+
if (value.openid != undefined &&
|
|
259
|
+
value.openid != "" &&
|
|
260
|
+
value.serviceType != undefined &&
|
|
261
|
+
value.serviceType != "" &&
|
|
262
|
+
value.eventID != undefined &&
|
|
263
|
+
value.eventID != "") {
|
|
264
|
+
target.ready = true; // set ready
|
|
265
|
+
console.log("[Aegis Wrapper]Ready367");
|
|
266
|
+
// init default aegis
|
|
267
|
+
defaultAegis = initAegis(true);
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
console.log("[Aegis Wrapper]Init Failed384: ", value);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (prop == "rumID") {
|
|
274
|
+
// init service aegis instance
|
|
275
|
+
serviceAegis = initAegis(false);
|
|
276
|
+
console.log("[Aegis Wrapper]rum id is set378");
|
|
277
|
+
}
|
|
278
278
|
},
|
|
279
|
-
reportEvent: reportEvent,
|
|
280
279
|
};
|
|
280
|
+
exports.AegisW = new Proxy(internalState, handler);
|
|
281
|
+
// init
|
|
282
|
+
function init() {
|
|
283
|
+
console.log("initing...385");
|
|
284
|
+
// set report func
|
|
285
|
+
exports.AegisW.reportEvent = function () {
|
|
286
|
+
console.log("args", arguments);
|
|
287
|
+
// normal report
|
|
288
|
+
if (serviceAegis !== undefined) {
|
|
289
|
+
serviceAegis.reportEvent(arguments[0]);
|
|
290
|
+
}
|
|
291
|
+
// proxy report
|
|
292
|
+
if (defaultAegis !== undefined) {
|
|
293
|
+
if (!internalState.ready) {
|
|
294
|
+
console.error("aegis is not ready!");
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
// check params
|
|
298
|
+
if (typeof arguments[0] !== "object" &&
|
|
299
|
+
typeof arguments[0] !== "string") {
|
|
300
|
+
console.error("invalid params!");
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (typeof arguments[0] === "object" && arguments[0].name === undefined) {
|
|
304
|
+
console.error("invalid name field!");
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
// build params string and report
|
|
308
|
+
arguments[0].ext1 = buildReportStr(arguments[0], false);
|
|
309
|
+
defaultAegis.reportEvent(arguments[0]);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
// init report wrapper
|
|
314
|
+
if ((document === null || document === void 0 ? void 0 : document.readyState) === "loading") {
|
|
315
|
+
console.log('document.readyState === "loading"431');
|
|
316
|
+
// add event listener for report wrapper
|
|
317
|
+
document.addEventListener("DOMContentLoaded", init);
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
console.log('init()434');
|
|
321
|
+
// init report wrapper
|
|
322
|
+
init();
|
|
323
|
+
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -202,6 +202,7 @@ function buildReportStr(params: string | ReportParams, isPV: boolean): string {
|
|
|
202
202
|
|
|
203
203
|
// 初始化 Aegis 实例(isDefault=true 为默认实例,false 为服务实例)
|
|
204
204
|
function initAegis(isDefault: boolean): any | undefined {
|
|
205
|
+
console.log('initAegis205',isDefault,internalState);
|
|
205
206
|
let id = internalState.id;
|
|
206
207
|
let apiSpeed = internalState.reportApiSpeed;
|
|
207
208
|
let assetSpeed = internalState.reportAssetSpeed;
|
|
@@ -219,26 +220,22 @@ function initAegis(isDefault: boolean): any | undefined {
|
|
|
219
220
|
delay = 1000;
|
|
220
221
|
}
|
|
221
222
|
|
|
222
|
-
|
|
223
|
-
// 无论是否有用户信息,都会上报PV
|
|
224
|
-
if (isDefault) {
|
|
225
|
-
const pvName = internalState.ready ? '@@init_with_user' : '@@init_no_user';
|
|
226
|
-
console.log('pvName',pvName);
|
|
227
|
-
|
|
223
|
+
if (internalState.ready) {
|
|
228
224
|
ext1 = buildReportStr(
|
|
229
225
|
{
|
|
230
|
-
name:
|
|
226
|
+
name: '@@init',
|
|
231
227
|
ext1: internalState.user.ext1,
|
|
232
228
|
ext2: internalState.user.ext2,
|
|
233
229
|
ext3: internalState.user.ext3,
|
|
234
230
|
},
|
|
235
|
-
true,
|
|
231
|
+
true,
|
|
236
232
|
);
|
|
237
|
-
console.log('[Aegis Wrapper] PV数据已构建,report_type=1');
|
|
238
233
|
}
|
|
234
|
+
console.log('AegisCtor235',AegisCtor);
|
|
239
235
|
|
|
240
236
|
// 小程序环境直接使用构造函数
|
|
241
237
|
if (typeof AegisCtor === 'function') {
|
|
238
|
+
console.log('return new AegisCtor');
|
|
242
239
|
return new (AegisCtor as any)({
|
|
243
240
|
id,
|
|
244
241
|
uin: internalState.uin,
|
|
@@ -250,6 +247,7 @@ function initAegis(isDefault: boolean): any | undefined {
|
|
|
250
247
|
spa: true,
|
|
251
248
|
ext1,
|
|
252
249
|
beforeRequest(data: any) {
|
|
250
|
+
console.log('beforeRequest',data);
|
|
253
251
|
if (!isDefault) {
|
|
254
252
|
return data;
|
|
255
253
|
}
|
|
@@ -261,7 +259,7 @@ function initAegis(isDefault: boolean): any | undefined {
|
|
|
261
259
|
});
|
|
262
260
|
}
|
|
263
261
|
|
|
264
|
-
console.error('[Aegis Wrapper] 找不到 aegis-mp-sdk 构造函数,请确认依赖是否正确安装和引用');
|
|
262
|
+
console.error('[Aegis Wrapper] 找不到 aegis-mp-sdk 构造函数,请确认依赖是否正确安装和引用265');
|
|
265
263
|
return undefined;
|
|
266
264
|
}
|
|
267
265
|
|
|
@@ -297,16 +295,11 @@ export function setUser(user: Partial<AegisUserInfo>): void {
|
|
|
297
295
|
|
|
298
296
|
const u = internalState.user;
|
|
299
297
|
if (u.openid && u.serviceType && u.eventID) {
|
|
300
|
-
console.log('
|
|
301
|
-
|
|
302
|
-
if (!internalState.ready) {
|
|
298
|
+
console.log('294',internalState,defaultAegis);
|
|
299
|
+
if (!internalState.ready) {
|
|
303
300
|
internalState.ready = true;
|
|
304
|
-
console.log('[Aegis Wrapper] default aegis 已就绪');
|
|
305
|
-
defaultAegis = initAegis(true);
|
|
306
|
-
} else if (!defaultAegis) {
|
|
307
|
-
// ready为true但defaultAegis丢失,重新初始化
|
|
308
|
-
console.log('[Aegis Wrapper] 重新初始化default aegis');
|
|
309
301
|
defaultAegis = initAegis(true);
|
|
302
|
+
console.log('[Aegis Wrapper] default aegis 已就绪298');
|
|
310
303
|
}
|
|
311
304
|
} else {
|
|
312
305
|
console.log('[Aegis Wrapper] 初始化条件不足:需要 openid / serviceType / eventID', u);
|
|
@@ -326,8 +319,8 @@ export function reportEvent(params: string | ReportParams): void {
|
|
|
326
319
|
(serviceAegis as any).reportEvent(params as any);
|
|
327
320
|
}
|
|
328
321
|
|
|
329
|
-
if (!defaultAegis) {
|
|
330
|
-
console.error('[Aegis Wrapper] default aegis
|
|
322
|
+
if (!defaultAegis || typeof (defaultAegis as any).reportEvent !== 'function') {
|
|
323
|
+
console.error('[Aegis Wrapper] default aegis 尚未准备就绪,请先调用 setUser 并补全必要字段');
|
|
331
324
|
return;
|
|
332
325
|
}
|
|
333
326
|
|
|
@@ -357,25 +350,85 @@ export function getInstances() {
|
|
|
357
350
|
// 面向业务侧的简单封装对象,支持示例中的两种用法:
|
|
358
351
|
// 1)AegisW.user = {...}
|
|
359
352
|
// 2)AegisW.reportEvent({...})
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
353
|
+
const handler:any = {
|
|
354
|
+
set(target:any, prop:any, value:any) {
|
|
355
|
+
console.log('user change351',target, prop, value);
|
|
356
|
+
|
|
357
|
+
// console.log(`changed ${prop} from ${target[prop]} to ${value}`); // debug info
|
|
358
|
+
target[prop] = value;
|
|
359
|
+
if (prop === "user" && typeof value === "object") {
|
|
360
|
+
console.log('user change368');
|
|
361
|
+
|
|
362
|
+
if (
|
|
363
|
+
value.openid != undefined &&
|
|
364
|
+
value.openid != "" &&
|
|
365
|
+
value.serviceType != undefined &&
|
|
366
|
+
value.serviceType != "" &&
|
|
367
|
+
value.eventID != undefined &&
|
|
368
|
+
value.eventID != ""
|
|
369
|
+
) {
|
|
370
|
+
target.ready = true; // set ready
|
|
371
|
+
console.log("[Aegis Wrapper]Ready367");
|
|
372
|
+
|
|
373
|
+
// init default aegis
|
|
374
|
+
defaultAegis = initAegis(true);
|
|
375
|
+
} else {
|
|
376
|
+
console.log("[Aegis Wrapper]Init Failed384: ", value);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (prop == "rumID") {
|
|
380
|
+
// init service aegis instance
|
|
381
|
+
serviceAegis = initAegis(false);
|
|
382
|
+
console.log("[Aegis Wrapper]rum id is set378");
|
|
383
|
+
}
|
|
379
384
|
},
|
|
380
|
-
|
|
381
|
-
|
|
385
|
+
};
|
|
386
|
+
export const AegisW:any = new Proxy(internalState, handler);
|
|
387
|
+
// init
|
|
388
|
+
function init() {
|
|
389
|
+
console.log("initing...385");
|
|
390
|
+
|
|
391
|
+
// set report func
|
|
392
|
+
AegisW.reportEvent = function () {
|
|
393
|
+
console.log("args", arguments);
|
|
394
|
+
|
|
395
|
+
// normal report
|
|
396
|
+
if (serviceAegis !== undefined) {
|
|
397
|
+
serviceAegis.reportEvent(arguments[0]);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// proxy report
|
|
401
|
+
if (defaultAegis !== undefined) {
|
|
402
|
+
if (!internalState.ready) {
|
|
403
|
+
console.error("aegis is not ready!");
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
// check params
|
|
407
|
+
if (
|
|
408
|
+
typeof arguments[0] !== "object" &&
|
|
409
|
+
typeof arguments[0] !== "string"
|
|
410
|
+
) {
|
|
411
|
+
console.error("invalid params!");
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
if (typeof arguments[0] === "object" && arguments[0].name === undefined) {
|
|
415
|
+
console.error("invalid name field!");
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// build params string and report
|
|
420
|
+
arguments[0].ext1 = buildReportStr(arguments[0], false);
|
|
421
|
+
defaultAegis.reportEvent(arguments[0]);
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
// init report wrapper
|
|
426
|
+
if (document?.readyState === "loading") {
|
|
427
|
+
console.log('document.readyState === "loading"431');
|
|
428
|
+
// add event listener for report wrapper
|
|
429
|
+
document.addEventListener("DOMContentLoaded", init);
|
|
430
|
+
} else {
|
|
431
|
+
console.log('init()434');
|
|
432
|
+
// init report wrapper
|
|
433
|
+
init();
|
|
434
|
+
}
|