aegis-mp-rum-wrapper 0.1.6 → 0.1.7
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/package.json +1 -1
- package/src/index.ts +8 -37
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Aegis from "aegis-mp-sdk";
|
|
2
2
|
|
|
3
3
|
// RUM 上报 ID(默认使用国服服务)
|
|
4
4
|
export const GPPRumID = "8lDwXIovanY8d1awa6";
|
|
@@ -28,16 +28,6 @@ export interface AegisUserInfo {
|
|
|
28
28
|
ext3?: string;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export interface AegisMpWrapperConfig {
|
|
32
|
-
id?: string; // 默认使用 GPPRumID
|
|
33
|
-
uin?: string;
|
|
34
|
-
reportApiSpeed?: boolean;
|
|
35
|
-
reportAssetSpeed?: boolean;
|
|
36
|
-
pagePerformance?: boolean;
|
|
37
|
-
webVitals?: boolean;
|
|
38
|
-
delay?: number;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
31
|
// 日志字段模板
|
|
42
32
|
interface LogItem {
|
|
43
33
|
report_type: number;
|
|
@@ -235,22 +225,18 @@ function initAegis(isDefault: boolean): any | undefined {
|
|
|
235
225
|
true
|
|
236
226
|
);
|
|
237
227
|
}
|
|
238
|
-
console.log("
|
|
228
|
+
console.log("Aegis235", Aegis);
|
|
239
229
|
|
|
240
230
|
// 小程序环境直接使用构造函数
|
|
241
|
-
if (typeof
|
|
242
|
-
console.log("return new
|
|
243
|
-
return new (
|
|
244
|
-
id,
|
|
231
|
+
if (typeof Aegis === "function") {
|
|
232
|
+
console.log("return new Aegis");
|
|
233
|
+
return new (Aegis as any)({
|
|
234
|
+
id:'8lDwXIovanY8d1awa6',
|
|
245
235
|
uin: internalState.uin,
|
|
246
|
-
|
|
247
|
-
reportAssetSpeed: assetSpeed,
|
|
248
|
-
pagePerformance,
|
|
249
|
-
webVitals,
|
|
250
|
-
delay,
|
|
236
|
+
|
|
251
237
|
spa: true,
|
|
252
238
|
ext1,
|
|
253
|
-
|
|
239
|
+
hostUrl: "https://aegis.qq.com",
|
|
254
240
|
beforeRequest(data: any) {
|
|
255
241
|
if (data.logType === "speed" || data.logType === "log") {
|
|
256
242
|
return false;
|
|
@@ -266,21 +252,6 @@ function initAegis(isDefault: boolean): any | undefined {
|
|
|
266
252
|
return undefined;
|
|
267
253
|
}
|
|
268
254
|
|
|
269
|
-
// 对外暴露的配置 API
|
|
270
|
-
export function configureWrapper(config: AegisMpWrapperConfig): void {
|
|
271
|
-
if (config.id) internalState.id = config.id;
|
|
272
|
-
if (typeof config.uin === "string") internalState.uin = config.uin;
|
|
273
|
-
if (typeof config.reportApiSpeed === "boolean")
|
|
274
|
-
internalState.reportApiSpeed = config.reportApiSpeed;
|
|
275
|
-
if (typeof config.reportAssetSpeed === "boolean")
|
|
276
|
-
internalState.reportAssetSpeed = config.reportAssetSpeed;
|
|
277
|
-
if (typeof config.pagePerformance === "boolean")
|
|
278
|
-
internalState.pagePerformance = config.pagePerformance;
|
|
279
|
-
if (typeof config.webVitals === "boolean")
|
|
280
|
-
internalState.webVitals = config.webVitals;
|
|
281
|
-
if (typeof config.delay === "number") internalState.delay = config.delay;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
255
|
export function setUser(user: Partial<AegisUserInfo>): void {
|
|
285
256
|
const incoming: any = user as any;
|
|
286
257
|
const nextUser: AegisUserInfo = {
|