@blueking/open-telemetry 0.0.8 → 0.0.10
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/README.md +424 -112
- package/dist/bk-rum.global.js +2 -2
- package/dist/bk-rum.global.js.map +1 -1
- package/dist/core/config.d.ts +44 -87
- package/dist/core/telemetry-attributes.d.ts +3 -0
- package/dist/core/url.d.ts +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +636 -658
- package/dist/index.js.map +1 -1
- package/dist/plugins/action.d.ts +5 -2
- package/dist/plugins/blank-screen.d.ts +7 -2
- package/dist/plugins/common.d.ts +1 -1
- package/dist/plugins/csp-violation.d.ts +1 -2
- package/dist/plugins/device.d.ts +4 -2
- package/dist/plugins/error.d.ts +5 -2
- package/dist/plugins/http-body.d.ts +2 -2
- package/dist/plugins/long-task.d.ts +4 -2
- package/dist/plugins/page-view.d.ts +1 -2
- package/dist/plugins/resource.d.ts +1 -2
- package/dist/plugins/route-timing.d.ts +1 -2
- package/dist/plugins/session.d.ts +6 -2
- package/dist/plugins/web-vitals.d.ts +1 -2
- package/dist/plugins/websocket.d.ts +1 -2
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -68,7 +68,7 @@ function x(e) {
|
|
|
68
68
|
}
|
|
69
69
|
//#endregion
|
|
70
70
|
//#region \0@oxc-project+runtime@0.128.0/helpers/toPrimitive.js
|
|
71
|
-
function
|
|
71
|
+
function ie(e, t) {
|
|
72
72
|
if (x(e) != "object" || !e) return e;
|
|
73
73
|
var n = e[Symbol.toPrimitive];
|
|
74
74
|
if (n !== void 0) {
|
|
@@ -80,14 +80,14 @@ function S(e, t) {
|
|
|
80
80
|
}
|
|
81
81
|
//#endregion
|
|
82
82
|
//#region \0@oxc-project+runtime@0.128.0/helpers/toPropertyKey.js
|
|
83
|
-
function
|
|
84
|
-
var t =
|
|
83
|
+
function S(e) {
|
|
84
|
+
var t = ie(e, "string");
|
|
85
85
|
return x(t) == "symbol" ? t : t + "";
|
|
86
86
|
}
|
|
87
87
|
//#endregion
|
|
88
88
|
//#region \0@oxc-project+runtime@0.128.0/helpers/defineProperty.js
|
|
89
|
-
function
|
|
90
|
-
return (t =
|
|
89
|
+
function C(e, t, n) {
|
|
90
|
+
return (t = S(t)) in e ? Object.defineProperty(e, t, {
|
|
91
91
|
value: n,
|
|
92
92
|
enumerable: !0,
|
|
93
93
|
configurable: !0,
|
|
@@ -96,7 +96,7 @@ function w(e, t, n) {
|
|
|
96
96
|
}
|
|
97
97
|
//#endregion
|
|
98
98
|
//#region \0@oxc-project+runtime@0.128.0/helpers/objectSpread2.js
|
|
99
|
-
function
|
|
99
|
+
function w(e, t) {
|
|
100
100
|
var n = Object.keys(e);
|
|
101
101
|
if (Object.getOwnPropertySymbols) {
|
|
102
102
|
var r = Object.getOwnPropertySymbols(e);
|
|
@@ -109,9 +109,9 @@ function ie(e, t) {
|
|
|
109
109
|
function T(e) {
|
|
110
110
|
for (var t = 1; t < arguments.length; t++) {
|
|
111
111
|
var n = arguments[t] == null ? {} : arguments[t];
|
|
112
|
-
t % 2 ?
|
|
113
|
-
|
|
114
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) :
|
|
112
|
+
t % 2 ? w(Object(n), !0).forEach(function(t) {
|
|
113
|
+
C(e, t, n[t]);
|
|
114
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : w(Object(n)).forEach(function(t) {
|
|
115
115
|
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
|
|
116
116
|
});
|
|
117
117
|
}
|
|
@@ -131,95 +131,29 @@ var E = "http://localhost:4318", ae = 60 * 1e3, oe = "unknown_service", D = (e)
|
|
|
131
131
|
headers: l,
|
|
132
132
|
timeoutMillis: s == null ? void 0 : s.timeoutMillis
|
|
133
133
|
};
|
|
134
|
-
}, ce = (e) => typeof e != "number" || !Number.isFinite(e) ? 1 : Math.max(0, Math.min(1, e)),
|
|
135
|
-
var t;
|
|
136
|
-
return e ? j(typeof e == "boolean" ? {
|
|
137
|
-
maxBodySize: 10 * 1024,
|
|
138
|
-
redact: de
|
|
139
|
-
} : {
|
|
140
|
-
maxBodySize: k(e.maxBodySize, 10 * 1024),
|
|
141
|
-
redact: (t = e.redact) == null ? de : t
|
|
142
|
-
}) : A();
|
|
143
|
-
}, he = (e) => {
|
|
144
|
-
var t;
|
|
145
|
-
return {
|
|
146
|
-
action: typeof (e == null ? void 0 : e.action) == "object" ? j({ eventNames: (t = e.action.eventNames) == null ? [
|
|
147
|
-
"click",
|
|
148
|
-
"submit",
|
|
149
|
-
"keydown"
|
|
150
|
-
] : t }) : e != null && e.action ? j({ eventNames: [
|
|
151
|
-
"click",
|
|
152
|
-
"submit",
|
|
153
|
-
"keydown"
|
|
154
|
-
] }) : A(),
|
|
155
|
-
device: typeof (e == null ? void 0 : e.device) == "object" ? j({ storageKey: e.device.storageKey }) : (e == null ? void 0 : e.device) === !1 ? A() : j({}),
|
|
156
|
-
httpBody: me(e == null ? void 0 : e.httpBody),
|
|
157
|
-
session: typeof (e == null ? void 0 : e.session) == "object" ? j({
|
|
158
|
-
inactivityMs: k(e.session.inactivityMs, 1800 * 1e3),
|
|
159
|
-
maxLifetimeMs: k(e.session.maxLifetimeMs, 1440 * 60 * 1e3),
|
|
160
|
-
storageKey: e.session.storageKey
|
|
161
|
-
}) : (e == null ? void 0 : e.session) === !1 ? A() : j({
|
|
162
|
-
inactivityMs: 1800 * 1e3,
|
|
163
|
-
maxLifetimeMs: 1440 * 60 * 1e3
|
|
164
|
-
}),
|
|
165
|
-
pageView: pe(e == null ? void 0 : e.pageView),
|
|
166
|
-
resource: pe(e == null ? void 0 : e.resource),
|
|
167
|
-
error: typeof (e == null ? void 0 : e.error) == "object" ? j({
|
|
168
|
-
maxPerWindow: k(e.error.maxPerWindow, 5),
|
|
169
|
-
windowMs: k(e.error.windowMs, 6e4)
|
|
170
|
-
}) : (e == null ? void 0 : e.error) === !1 ? A() : j({
|
|
171
|
-
maxPerWindow: 5,
|
|
172
|
-
windowMs: 6e4
|
|
173
|
-
}),
|
|
174
|
-
webVitals: pe(e == null ? void 0 : e.webVitals),
|
|
175
|
-
blankScreen: typeof (e == null ? void 0 : e.blankScreen) == "object" ? j({
|
|
176
|
-
checkDelay: le(e.blankScreen.checkDelay, 3e3),
|
|
177
|
-
ignoreSelectors: e.blankScreen.ignoreSelectors,
|
|
178
|
-
rootSelector: e.blankScreen.rootSelector,
|
|
179
|
-
threshold: ue(e.blankScreen.threshold, .8)
|
|
180
|
-
}) : (e == null ? void 0 : e.blankScreen) === !1 ? A() : j({
|
|
181
|
-
checkDelay: 3e3,
|
|
182
|
-
threshold: .8
|
|
183
|
-
}),
|
|
184
|
-
websocket: fe(e == null ? void 0 : e.websocket),
|
|
185
|
-
longTask: typeof (e == null ? void 0 : e.longTask) == "object" ? j({ threshold: le(e.longTask.threshold, 50) }) : e != null && e.longTask ? j({ threshold: 50 }) : A(),
|
|
186
|
-
cspViolation: fe(e == null ? void 0 : e.cspViolation),
|
|
187
|
-
routeTiming: fe(e == null ? void 0 : e.routeTiming)
|
|
188
|
-
};
|
|
189
|
-
}, ge = (e) => {
|
|
190
|
-
var t, n, r, i, a, o, s, c;
|
|
191
|
-
return {
|
|
192
|
-
instrumentations: {
|
|
193
|
-
documentLoad: (t = e == null || (n = e.instrumentations) == null ? void 0 : n.documentLoad) == null ? !0 : t,
|
|
194
|
-
fetch: (r = e == null || (i = e.instrumentations) == null ? void 0 : i.fetch) == null ? !0 : r,
|
|
195
|
-
xhr: (a = e == null || (o = e.instrumentations) == null ? void 0 : o.xhr) == null ? !0 : a,
|
|
196
|
-
userInteraction: (s = e == null || (c = e.instrumentations) == null ? void 0 : c.userInteraction) == null ? !0 : s
|
|
197
|
-
},
|
|
198
|
-
plugins: he(e == null ? void 0 : e.plugins)
|
|
199
|
-
};
|
|
200
|
-
}, _e = (e) => e, ve = (e) => e, ye = (e) => {
|
|
134
|
+
}, ce = (e) => typeof e != "number" || !Number.isFinite(e) ? 1 : Math.max(0, Math.min(1, e)), le = (e) => e, ue = (e) => e, de = (e) => {
|
|
201
135
|
try {
|
|
202
136
|
return new URL(e, typeof location > "u" ? "http://localhost" : location.href).pathname || "/";
|
|
203
137
|
} catch (t) {
|
|
204
138
|
return e || "/";
|
|
205
139
|
}
|
|
206
|
-
},
|
|
140
|
+
}, fe = (e) => {
|
|
207
141
|
var t, n;
|
|
208
142
|
return {
|
|
209
143
|
environment: (t = e == null ? void 0 : e.environment) == null ? "production" : t,
|
|
210
144
|
name: (n = e == null ? void 0 : e.name) == null ? oe : n,
|
|
211
145
|
version: e == null ? void 0 : e.version
|
|
212
146
|
};
|
|
213
|
-
},
|
|
147
|
+
}, pe = (e) => T(T({
|
|
214
148
|
[b.deploymentEnvironmentName]: e.environment,
|
|
215
149
|
"rum.provider": "blueking",
|
|
216
150
|
[b.serviceName]: e.name
|
|
217
|
-
}, e.version ? { [b.serviceVersion]: e.version } : {}), {}, { "telemetry.sdk.language": "webjs" }),
|
|
151
|
+
}, e.version ? { [b.serviceVersion]: e.version } : {}), {}, { "telemetry.sdk.language": "webjs" }), me = (e) => ({
|
|
218
152
|
endpoint: D((e == null ? void 0 : e.endpoint) || E),
|
|
219
153
|
traces: O(e, "traces"),
|
|
220
154
|
metrics: O(e, "metrics"),
|
|
221
155
|
logs: O(e, "logs")
|
|
222
|
-
}),
|
|
156
|
+
}), he = (e) => ({ rate: ce(e == null ? void 0 : e.rate) }), ge = (e) => {
|
|
223
157
|
var t, n, r, i, a, o, s, c, l, u, d, f;
|
|
224
158
|
return {
|
|
225
159
|
getPageAttributes: (t = (n = e.attributes) == null ? void 0 : n.page) == null ? (() => ({
|
|
@@ -231,35 +165,34 @@ var E = "http://localhost:4318", ae = 60 * 1e3, oe = "unknown_service", D = (e)
|
|
|
231
165
|
getCustomAttributes: (s = (c = e.attributes) == null ? void 0 : c.custom) == null ? (() => ({})) : s,
|
|
232
166
|
getViewPathGroup: (t) => {
|
|
233
167
|
var n, r, i;
|
|
234
|
-
return (n = (r = e.route) == null || (i = r.getPathGroup) == null ? void 0 : i.call(r, t)) == null ?
|
|
168
|
+
return (n = (r = e.route) == null || (i = r.getPathGroup) == null ? void 0 : i.call(r, t)) == null ? de(t) : n;
|
|
235
169
|
},
|
|
236
|
-
redactAttributes: (l = (u = e.privacy) == null ? void 0 : u.redactAttributes) == null ?
|
|
237
|
-
redactUrl: (d = (f = e.privacy) == null ? void 0 : f.redactUrl) == null ?
|
|
170
|
+
redactAttributes: (l = (u = e.privacy) == null ? void 0 : u.redactAttributes) == null ? le : l,
|
|
171
|
+
redactUrl: (d = (f = e.privacy) == null ? void 0 : f.redactUrl) == null ? ue : d
|
|
238
172
|
};
|
|
239
|
-
},
|
|
173
|
+
}, _e = (e) => {
|
|
240
174
|
var t, n, r, i, a, o;
|
|
241
|
-
let s =
|
|
175
|
+
let s = fe(e.app);
|
|
242
176
|
return {
|
|
243
177
|
app: s,
|
|
244
178
|
autoStart: (t = e.autoStart) == null ? !0 : t,
|
|
245
179
|
debug: (n = e.debug) == null ? !1 : n,
|
|
246
180
|
enabled: (r = e.enabled) == null ? !0 : r,
|
|
247
|
-
hooks:
|
|
248
|
-
instrumentations: (i = e.instrumentations) == null ?
|
|
181
|
+
hooks: ge(e),
|
|
182
|
+
instrumentations: (i = e.instrumentations) == null ? {} : i,
|
|
249
183
|
metricIntervalMillis: ae,
|
|
250
|
-
plugins: (a = e.plugins) == null ?
|
|
251
|
-
resourceAttributes:
|
|
252
|
-
|
|
253
|
-
sampling: Ce(e.sampling),
|
|
184
|
+
plugins: (a = e.plugins) == null ? {} : a,
|
|
185
|
+
resourceAttributes: pe(s),
|
|
186
|
+
sampling: he(e.sampling),
|
|
254
187
|
spanBatch: e.spanBatch,
|
|
255
188
|
spanProcessor: (o = e.spanProcessor) == null ? "batch" : o,
|
|
256
|
-
transport:
|
|
189
|
+
transport: me(e.transport),
|
|
257
190
|
user: e.user
|
|
258
191
|
};
|
|
259
192
|
};
|
|
260
193
|
//#endregion
|
|
261
194
|
//#region \0@oxc-project+runtime@0.128.0/helpers/asyncToGenerator.js
|
|
262
|
-
function
|
|
195
|
+
function ve(e, t, n, r, i, a, o) {
|
|
263
196
|
try {
|
|
264
197
|
var s = e[a](o), c = s.value;
|
|
265
198
|
} catch (e) {
|
|
@@ -268,16 +201,16 @@ function Ee(e, t, n, r, i, a, o) {
|
|
|
268
201
|
}
|
|
269
202
|
s.done ? t(c) : Promise.resolve(c).then(r, i);
|
|
270
203
|
}
|
|
271
|
-
function
|
|
204
|
+
function k(e) {
|
|
272
205
|
return function() {
|
|
273
206
|
var t = this, n = arguments;
|
|
274
207
|
return new Promise(function(r, i) {
|
|
275
208
|
var a = e.apply(t, n);
|
|
276
209
|
function o(e) {
|
|
277
|
-
|
|
210
|
+
ve(a, r, i, o, s, "next", e);
|
|
278
211
|
}
|
|
279
212
|
function s(e) {
|
|
280
|
-
|
|
213
|
+
ve(a, r, i, o, s, "throw", e);
|
|
281
214
|
}
|
|
282
215
|
o(void 0);
|
|
283
216
|
});
|
|
@@ -285,13 +218,13 @@ function M(e) {
|
|
|
285
218
|
}
|
|
286
219
|
//#endregion
|
|
287
220
|
//#region src/core/plugin.ts
|
|
288
|
-
var
|
|
221
|
+
var ye = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !== !1, be = (e) => e, xe = class {
|
|
289
222
|
constructor(e) {
|
|
290
|
-
|
|
223
|
+
C(this, "plugins", void 0), C(this, "startedPlugins", []), this.plugins = e;
|
|
291
224
|
}
|
|
292
225
|
flush() {
|
|
293
226
|
var e = this;
|
|
294
|
-
return
|
|
227
|
+
return k(function* () {
|
|
295
228
|
yield Promise.all(e.startedPlugins.map((e) => Promise.resolve().then(() => {
|
|
296
229
|
var t;
|
|
297
230
|
return (t = e.flush) == null ? void 0 : t.call(e);
|
|
@@ -300,7 +233,7 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
300
233
|
}
|
|
301
234
|
shutdown() {
|
|
302
235
|
var e = this;
|
|
303
|
-
return
|
|
236
|
+
return k(function* () {
|
|
304
237
|
let t = [...e.startedPlugins].reverse();
|
|
305
238
|
for (let e of t) {
|
|
306
239
|
var n;
|
|
@@ -311,8 +244,8 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
311
244
|
}
|
|
312
245
|
start(e) {
|
|
313
246
|
var t = this;
|
|
314
|
-
return
|
|
315
|
-
for (let r of t.plugins) if (
|
|
247
|
+
return k(function* () {
|
|
248
|
+
for (let r of t.plugins) if (ye(r, e.config)) try {
|
|
316
249
|
yield r.init(e), t.startedPlugins.push(r);
|
|
317
250
|
} catch (t) {
|
|
318
251
|
if (e.config.debug) {
|
|
@@ -322,35 +255,39 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
322
255
|
}
|
|
323
256
|
})();
|
|
324
257
|
}
|
|
325
|
-
},
|
|
258
|
+
}, Se = () => typeof window > "u" ? "http://localhost" : window.location.origin, Ce = (e) => {
|
|
326
259
|
try {
|
|
327
|
-
return new URL(e,
|
|
260
|
+
return new URL(e, Se()).href;
|
|
328
261
|
} catch (t) {
|
|
329
262
|
return e;
|
|
330
263
|
}
|
|
331
|
-
},
|
|
332
|
-
let n = (e) =>
|
|
264
|
+
}, we = (e) => e.length > 1 ? e.replace(/\/+$/, "") : e, Te = (e, t) => {
|
|
265
|
+
let n = (e) => we(e.replace(/[?#].*$/, ""));
|
|
333
266
|
return n(e) === n(t);
|
|
334
|
-
},
|
|
267
|
+
}, Ee = (e) => {
|
|
335
268
|
try {
|
|
336
|
-
return new URL(e,
|
|
269
|
+
return new URL(e, Se()).origin === Se();
|
|
337
270
|
} catch (e) {
|
|
338
271
|
return !1;
|
|
339
272
|
}
|
|
340
|
-
},
|
|
341
|
-
let n =
|
|
273
|
+
}, De = (e, t) => {
|
|
274
|
+
let n = Ce(t);
|
|
342
275
|
return [
|
|
343
276
|
e.transport.traces.endpoint,
|
|
344
277
|
e.transport.metrics.endpoint,
|
|
345
278
|
e.transport.logs.endpoint
|
|
346
|
-
].some((e) =>
|
|
347
|
-
},
|
|
348
|
-
|
|
279
|
+
].some((e) => Te(n, Ce(e)));
|
|
280
|
+
}, A = (e, t) => De(e, t), Oe = (e, t) => e === "all" ? !0 : typeof e == "function" ? e(t) : (Array.isArray(e) ? e : [e]).some((e) => typeof e == "string" ? t.includes(e) : e.test(t)), ke = (e, t) => {
|
|
281
|
+
if (Ee(t)) return !0;
|
|
282
|
+
let n = e.instrumentations.propagateTraceHeaderUrls;
|
|
283
|
+
return n ? Oe(n, Ce(t)) : !1;
|
|
284
|
+
}, Ae = ["http.url", "url.full"], je = (e) => {
|
|
285
|
+
for (let n of Ae) {
|
|
349
286
|
var t;
|
|
350
287
|
let r = (t = e.attributes) == null ? void 0 : t[n];
|
|
351
288
|
if (typeof r == "string") return r;
|
|
352
289
|
}
|
|
353
|
-
},
|
|
290
|
+
}, Me = class {
|
|
354
291
|
constructor(e, t) {
|
|
355
292
|
this.inner = e, this.config = t;
|
|
356
293
|
}
|
|
@@ -358,8 +295,8 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
358
295
|
return this.inner.forceFlush();
|
|
359
296
|
}
|
|
360
297
|
onEnd(e) {
|
|
361
|
-
let t =
|
|
362
|
-
t &&
|
|
298
|
+
let t = je(e);
|
|
299
|
+
t && De(this.config, t) || this.inner.onEnd(e);
|
|
363
300
|
}
|
|
364
301
|
onStart(e, t) {
|
|
365
302
|
this.inner.onStart(e, t);
|
|
@@ -367,15 +304,15 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
367
304
|
shutdown() {
|
|
368
305
|
return this.inner.shutdown();
|
|
369
306
|
}
|
|
370
|
-
},
|
|
307
|
+
}, Ne = class {
|
|
371
308
|
constructor(e = {}, t) {
|
|
372
|
-
|
|
309
|
+
C(this, "attributes", {}), C(this, "setOptionalAttribute", (e, t) => {
|
|
373
310
|
if (t === void 0) {
|
|
374
311
|
delete this.attributes[e];
|
|
375
312
|
return;
|
|
376
313
|
}
|
|
377
314
|
this.attributes[e] = t;
|
|
378
|
-
}),
|
|
315
|
+
}), C(this, "user", {}), C(this, "view", {}), C(this, "getAttributes", () => T({}, this.attributes)), C(this, "getUser", () => T({}, this.user)), C(this, "getView", () => T({}, this.view)), C(this, "setAttributes", (e) => {
|
|
379
316
|
for (let [t, n] of Object.entries(e)) {
|
|
380
317
|
if (n === void 0) {
|
|
381
318
|
delete this.attributes[t];
|
|
@@ -383,7 +320,7 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
383
320
|
}
|
|
384
321
|
this.attributes[t] = n;
|
|
385
322
|
}
|
|
386
|
-
}),
|
|
323
|
+
}), C(this, "setUser", (e) => {
|
|
387
324
|
if (this.user = T(T({}, this.user), e), "id" in e) {
|
|
388
325
|
if (e.id === void 0) {
|
|
389
326
|
delete this.attributes[b.userId];
|
|
@@ -391,17 +328,17 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
391
328
|
}
|
|
392
329
|
this.attributes[b.userId] = e.id;
|
|
393
330
|
}
|
|
394
|
-
}),
|
|
331
|
+
}), C(this, "setView", (e) => {
|
|
395
332
|
this.view = T(T({}, this.view), e), this.setOptionalAttribute(b.viewId, e.id), this.setOptionalAttribute(b.viewUrl, e.url), this.setOptionalAttribute(b.viewUrlPathGroup, e.urlPathGroup), this.setOptionalAttribute(b.viewLoadingType, e.loadingType);
|
|
396
333
|
}), this.setAttributes(e), t && this.setUser(t);
|
|
397
334
|
}
|
|
398
|
-
},
|
|
335
|
+
}, j = {
|
|
399
336
|
abort: "abort",
|
|
400
337
|
error: "error",
|
|
401
338
|
success: "success",
|
|
402
339
|
timeout: "timeout",
|
|
403
340
|
warning: "warning"
|
|
404
|
-
},
|
|
341
|
+
}, M = {
|
|
405
342
|
action: "action",
|
|
406
343
|
custom: "custom",
|
|
407
344
|
document: "document",
|
|
@@ -411,7 +348,7 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
411
348
|
resource: "resource",
|
|
412
349
|
route: "route",
|
|
413
350
|
vital: "vital"
|
|
414
|
-
},
|
|
351
|
+
}, Pe = (e) => e < 100 ? "<100ms" : e < 500 ? "100~500ms" : e < 2e3 ? "500ms~2s" : ">2s", Fe = (e) => `${Math.trunc(e / 100)}xx`, Ie = (e) => e === 408 || e === 504 ? j.timeout : typeof e == "number" && e >= 400 ? j.error : j.success, Le = (e) => e === 408 || e === 504 ? "network_timeout" : typeof e != "number" || e < 400 ? "none" : e >= 500 ? "http_5xx" : "http_4xx", Re = (e) => e === "good" ? j.success : j.warning, ze = (e, t) => {
|
|
415
352
|
if (!e) return {};
|
|
416
353
|
try {
|
|
417
354
|
let n = new URL(e, typeof location > "u" ? "http://localhost" : location.href), r = t == null ? n.pathname : t;
|
|
@@ -426,78 +363,114 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
426
363
|
pathTemplate: t == null ? e : t
|
|
427
364
|
};
|
|
428
365
|
}
|
|
429
|
-
},
|
|
366
|
+
}, N = ({ duration: e, errorType: t = "none", eventLabel: n, result: r = j.success, spanSubtype: i, spanType: a, targetLabel: o, targetValue: s, traceScene: c }) => T(T(T(T(T({
|
|
430
367
|
[b.spanType]: a,
|
|
431
368
|
[b.spanSubtype]: i,
|
|
432
369
|
[b.result]: r,
|
|
433
370
|
[b.errorType]: t
|
|
434
|
-
}, e === void 0 ? {} : { [b.durationBucket]:
|
|
435
|
-
let o =
|
|
436
|
-
return T(T(T(T(T({},
|
|
371
|
+
}, e === void 0 ? {} : { [b.durationBucket]: Pe(e) }), n === void 0 ? {} : { [b.eventLabel]: n }), o === void 0 ? {} : { [b.targetLabel]: o }), s === void 0 ? {} : { [b.targetValue]: s }), c === void 0 ? {} : { [b.traceScene]: c }), Be = ({ duration: e, method: t, statusCode: n, subtype: r, url: i, urlPathTemplate: a }) => {
|
|
372
|
+
let o = ze(i, a);
|
|
373
|
+
return T(T(T(T(T({}, N({
|
|
437
374
|
duration: e,
|
|
438
|
-
errorType:
|
|
375
|
+
errorType: Le(n),
|
|
439
376
|
eventLabel: "API 调用",
|
|
440
|
-
result:
|
|
377
|
+
result: Ie(n),
|
|
441
378
|
spanSubtype: r,
|
|
442
|
-
spanType:
|
|
379
|
+
spanType: M.http,
|
|
443
380
|
targetLabel: o.label,
|
|
444
381
|
targetValue: n
|
|
445
382
|
})), t ? { "http.request.method": t.toUpperCase() } : {}), o.domain ? { [b.targetDomain]: o.domain } : {}), o.pathTemplate ? { [b.targetPathTemplate]: o.pathTemplate } : {}), typeof n == "number" ? {
|
|
446
383
|
"http.response.status_code": n,
|
|
447
|
-
[b.statusClass]:
|
|
384
|
+
[b.statusClass]: Fe(n)
|
|
448
385
|
} : {});
|
|
449
|
-
},
|
|
386
|
+
}, Ve = ({ duration: e, initiatorType: t = "other", responseStatus: n, transferSize: r, url: i, urlPathTemplate: a }) => {
|
|
450
387
|
var o;
|
|
451
|
-
let s =
|
|
452
|
-
return T(T(T(T({},
|
|
388
|
+
let s = ze(i, a), c = typeof n == "number" ? Ie(n) : j.success;
|
|
389
|
+
return T(T(T(T({}, N({
|
|
453
390
|
duration: e,
|
|
454
|
-
errorType: typeof n == "number" ?
|
|
391
|
+
errorType: typeof n == "number" ? Le(n) : "none",
|
|
455
392
|
eventLabel: "静态资源",
|
|
456
393
|
result: c,
|
|
457
394
|
spanSubtype: t,
|
|
458
|
-
spanType:
|
|
395
|
+
spanType: M.resource,
|
|
459
396
|
targetLabel: (o = s.label) == null ? i : o,
|
|
460
397
|
targetValue: r
|
|
461
398
|
})), s.domain ? { [b.targetDomain]: s.domain } : {}), s.pathTemplate ? { [b.targetPathTemplate]: s.pathTemplate } : {}), typeof n == "number" ? {
|
|
462
399
|
"http.response.status_code": n,
|
|
463
|
-
[b.statusClass]:
|
|
400
|
+
[b.statusClass]: Fe(n)
|
|
464
401
|
} : {});
|
|
465
|
-
},
|
|
402
|
+
}, He = [
|
|
403
|
+
"click",
|
|
404
|
+
"submit",
|
|
405
|
+
"keydown"
|
|
406
|
+
], Ue = (e) => e instanceof Element ? e : void 0, We = (e) => {
|
|
466
407
|
var t;
|
|
467
408
|
if (!e) return;
|
|
468
409
|
let n = ((t = e.textContent) == null ? void 0 : t.trim()) || e.getAttribute("aria-label") || e.getAttribute("title") || "";
|
|
469
410
|
return n ? n.slice(0, 32) : void 0;
|
|
470
|
-
},
|
|
471
|
-
|
|
411
|
+
}, Ge = (e = {}) => {
|
|
412
|
+
var t;
|
|
413
|
+
let n = [], r = (t = e.eventNames) == null ? He : t;
|
|
472
414
|
return {
|
|
473
415
|
name: "action",
|
|
474
|
-
|
|
475
|
-
init(n) {
|
|
416
|
+
init(e) {
|
|
476
417
|
if (typeof window > "u") return;
|
|
477
|
-
let
|
|
418
|
+
let t = {
|
|
478
419
|
capture: !0,
|
|
479
420
|
passive: !0
|
|
480
|
-
}, i = (
|
|
481
|
-
var
|
|
482
|
-
let r =
|
|
483
|
-
|
|
421
|
+
}, i = (t) => {
|
|
422
|
+
var n;
|
|
423
|
+
let r = Ue(t.target), i = We(r), a = r == null ? void 0 : r.tagName.toLowerCase();
|
|
424
|
+
e.startSpan(`action.${t.type}`, T(T(T(T({}, e.config.hooks.getPageAttributes()), N({
|
|
484
425
|
errorType: "none",
|
|
485
426
|
eventLabel: "用户操作",
|
|
486
|
-
spanSubtype:
|
|
487
|
-
spanType:
|
|
488
|
-
targetLabel: (
|
|
489
|
-
})), {}, { [b.actionType]:
|
|
427
|
+
spanSubtype: t.type,
|
|
428
|
+
spanType: M.action,
|
|
429
|
+
targetLabel: (n = i == null ? a : i) == null ? t.type : n
|
|
430
|
+
})), {}, { [b.actionType]: t.type }, i ? { [b.targetTextShort]: i } : {}), a ? { [b.targetTag]: a } : {})).end();
|
|
490
431
|
};
|
|
491
|
-
for (let
|
|
432
|
+
for (let e of r) window.addEventListener(e, i, t), n.push(() => window.removeEventListener(e, i, t));
|
|
492
433
|
},
|
|
493
434
|
shutdown() {
|
|
494
|
-
for (;
|
|
435
|
+
for (; n.length;) {
|
|
495
436
|
var e;
|
|
496
|
-
(e =
|
|
437
|
+
(e = n.pop()) == null || e();
|
|
497
438
|
}
|
|
498
439
|
}
|
|
499
440
|
};
|
|
500
|
-
}
|
|
441
|
+
};
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region \0@oxc-project+runtime@0.128.0/helpers/objectWithoutPropertiesLoose.js
|
|
444
|
+
function Ke(e, t) {
|
|
445
|
+
if (e == null) return {};
|
|
446
|
+
var n = {};
|
|
447
|
+
for (var r in e) if ({}.hasOwnProperty.call(e, r)) {
|
|
448
|
+
if (t.includes(r)) continue;
|
|
449
|
+
n[r] = e[r];
|
|
450
|
+
}
|
|
451
|
+
return n;
|
|
452
|
+
}
|
|
453
|
+
//#endregion
|
|
454
|
+
//#region \0@oxc-project+runtime@0.128.0/helpers/objectWithoutProperties.js
|
|
455
|
+
function qe(e, t) {
|
|
456
|
+
if (e == null) return {};
|
|
457
|
+
var n, r, i = Ke(e, t);
|
|
458
|
+
if (Object.getOwnPropertySymbols) {
|
|
459
|
+
var a = Object.getOwnPropertySymbols(e);
|
|
460
|
+
for (r = 0; r < a.length; r++) n = a[r], t.includes(n) || {}.propertyIsEnumerable.call(e, n) && (i[n] = e[n]);
|
|
461
|
+
}
|
|
462
|
+
return i;
|
|
463
|
+
}
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region src/core/telemetry-attributes.ts
|
|
466
|
+
var Je = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Ye = (e) => {
|
|
467
|
+
let t = Je(e);
|
|
468
|
+
return t ? { [b.viewUrlPathGroup]: t } : {};
|
|
469
|
+
}, P = (e) => Ye(e[b.viewUrlPathGroup]), F = (e, t) => {
|
|
470
|
+
var n;
|
|
471
|
+
let r = b.viewUrlPathGroup, { [r]: i } = e;
|
|
472
|
+
return T(T({}, qe(e, [r].map(S))), Ye((n = Je(i)) == null ? t : n));
|
|
473
|
+
}, Xe = "body", Ze = 3e3, Qe = .8, $e = [
|
|
501
474
|
"[data-loading=\"true\"]",
|
|
502
475
|
"[aria-busy=\"true\"]",
|
|
503
476
|
".loading",
|
|
@@ -505,13 +478,13 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
505
478
|
".spinner",
|
|
506
479
|
".skeleton",
|
|
507
480
|
".bk-loading"
|
|
508
|
-
],
|
|
481
|
+
], I = [
|
|
509
482
|
[.5, .5],
|
|
510
483
|
[.25, .25],
|
|
511
484
|
[.75, .25],
|
|
512
485
|
[.25, .75],
|
|
513
486
|
[.75, .75]
|
|
514
|
-
], nt = (e) => {
|
|
487
|
+
], et = (e, t) => typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : t, tt = (e, t) => typeof e != "number" || !Number.isFinite(e) ? t : Math.max(0, Math.min(1, e)), nt = (e) => {
|
|
515
488
|
if (!e) return "";
|
|
516
489
|
let t = e.tagName.toLowerCase();
|
|
517
490
|
return e.id ? `${t}#${e.id}` : t;
|
|
@@ -528,66 +501,70 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
528
501
|
document.removeEventListener("DOMContentLoaded", t), e();
|
|
529
502
|
};
|
|
530
503
|
return document.addEventListener("DOMContentLoaded", t), () => document.removeEventListener("DOMContentLoaded", t);
|
|
531
|
-
}, at = (e) => {
|
|
532
|
-
|
|
504
|
+
}, at = (e = {}) => {
|
|
505
|
+
var t, n;
|
|
506
|
+
let r, i, a = !1, o = {
|
|
507
|
+
checkDelay: et(e.checkDelay, Ze),
|
|
508
|
+
ignoreSelectors: (t = e.ignoreSelectors) == null ? [] : t,
|
|
509
|
+
rootSelector: (n = e.rootSelector) == null ? Xe : n,
|
|
510
|
+
threshold: tt(e.threshold, Qe)
|
|
511
|
+
};
|
|
533
512
|
return {
|
|
534
513
|
name: "blank-screen",
|
|
535
|
-
|
|
536
|
-
init(i) {
|
|
537
|
-
var a, o;
|
|
514
|
+
init(e) {
|
|
538
515
|
if (typeof window > "u" || typeof document > "u") return;
|
|
539
|
-
let
|
|
516
|
+
let { checkDelay: t, rootSelector: n, threshold: s } = o, c = [...$e, ...o.ignoreSelectors], l = e.meter.createCounter("browser.blank_screen.count", { description: "Number of suspected blank screen detections" }), u = () => {
|
|
540
517
|
try {
|
|
541
|
-
var
|
|
542
|
-
let
|
|
543
|
-
for (let [e, t] of
|
|
544
|
-
let
|
|
545
|
-
if (rt(
|
|
546
|
-
|
|
518
|
+
var t, r;
|
|
519
|
+
let i = document.querySelector(n), a = 0, o = 0;
|
|
520
|
+
for (let [e, t] of I) {
|
|
521
|
+
let n = document.elementFromPoint(window.innerWidth * e, window.innerHeight * t);
|
|
522
|
+
if (rt(n, c)) {
|
|
523
|
+
o += 1;
|
|
547
524
|
continue;
|
|
548
525
|
}
|
|
549
|
-
(
|
|
526
|
+
(n === i || n === document.body || n === document.documentElement) && (a += 1);
|
|
550
527
|
}
|
|
551
|
-
let
|
|
552
|
-
if (
|
|
553
|
-
let
|
|
528
|
+
let u = I.length - o;
|
|
529
|
+
if (u === 0) return;
|
|
530
|
+
let d = a / u, f = d >= s, p = nt(document.elementFromPoint(window.innerWidth / 2, window.innerHeight / 2)), m = T(T({}, N({
|
|
554
531
|
errorType: f ? "blank_screen" : "none",
|
|
555
532
|
eventLabel: "白屏",
|
|
556
|
-
result: f ?
|
|
533
|
+
result: f ? j.error : j.success,
|
|
557
534
|
spanSubtype: "blank_screen",
|
|
558
|
-
spanType:
|
|
559
|
-
targetLabel:
|
|
560
|
-
targetValue:
|
|
535
|
+
spanType: M.error,
|
|
536
|
+
targetLabel: n,
|
|
537
|
+
targetValue: d
|
|
561
538
|
})), {}, {
|
|
562
|
-
"blank_screen.score":
|
|
563
|
-
"blank_screen.threshold":
|
|
564
|
-
"blank_screen.root":
|
|
539
|
+
"blank_screen.score": d,
|
|
540
|
+
"blank_screen.threshold": s,
|
|
541
|
+
"blank_screen.root": n,
|
|
565
542
|
"blank_screen.detected": f,
|
|
566
|
-
"blank_screen.sample_total":
|
|
567
|
-
"blank_screen.sample_valid":
|
|
568
|
-
"blank_screen.sample_loading":
|
|
543
|
+
"blank_screen.sample_total": I.length,
|
|
544
|
+
"blank_screen.sample_valid": u,
|
|
545
|
+
"blank_screen.sample_loading": o,
|
|
569
546
|
"blank_screen.center_element": p,
|
|
570
|
-
"blank_screen.dom_node_count": (
|
|
547
|
+
"blank_screen.dom_node_count": (t = (r = document.body) == null ? void 0 : r.getElementsByTagName("*").length) == null ? 0 : t
|
|
571
548
|
});
|
|
572
|
-
f && (
|
|
573
|
-
} catch (
|
|
574
|
-
if (
|
|
575
|
-
var
|
|
576
|
-
(
|
|
549
|
+
f && (l.add(1, e.applyRedact(T(T({}, P(e.getRuntimeAttributes())), {}, { "blank_screen.root": n }))), e.startSpan("browser.blank_screen", m).end());
|
|
550
|
+
} catch (t) {
|
|
551
|
+
if (e.config.debug) {
|
|
552
|
+
var i;
|
|
553
|
+
(i = globalThis.console) == null || i.warn("[bk-ot][blank-screen] detection failed:", t);
|
|
577
554
|
}
|
|
578
555
|
}
|
|
579
556
|
};
|
|
580
|
-
|
|
581
|
-
|
|
557
|
+
i = it(() => {
|
|
558
|
+
a || (r = window.setTimeout(u, t));
|
|
582
559
|
});
|
|
583
560
|
},
|
|
584
561
|
shutdown() {
|
|
585
|
-
|
|
562
|
+
a = !0, i == null || i(), i = void 0, r !== void 0 && typeof window < "u" && (window.clearTimeout(r), r = void 0);
|
|
586
563
|
}
|
|
587
564
|
};
|
|
588
|
-
}, ot = ["http.url", "url.full"], st = ["http.status_code", "http.response.status_code"], ct = ["http.method", "http.request.method"], lt = (e) => ({ test: e }), ut = (e, t, n) => {
|
|
565
|
+
}, ot = ["http.url", "url.full"], st = ["http.status_code", "http.response.status_code"], ct = ["http.method", "http.request.method"], lt = (e) => ({ test: e }), L = (e) => typeof location > "u" ? void 0 : e.config.hooks.getViewPathGroup(location.href), ut = (e, t, n) => {
|
|
589
566
|
var r;
|
|
590
|
-
t.setAttributes(e.applyRedact(e.config.hooks.getPageAttributes()));
|
|
567
|
+
t.setAttributes(e.applyRedact(T(T({}, F(e.getRuntimeAttributes(), L(e))), e.config.hooks.getPageAttributes())));
|
|
591
568
|
let i;
|
|
592
569
|
for (let n of ot) {
|
|
593
570
|
var a;
|
|
@@ -607,7 +584,7 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
607
584
|
var n;
|
|
608
585
|
return (n = t.attributes) == null ? void 0 : n[e];
|
|
609
586
|
}).find((e) => typeof e == "string") : r;
|
|
610
|
-
t.setAttributes(e.applyRedact(
|
|
587
|
+
t.setAttributes(e.applyRedact(Be({
|
|
611
588
|
method: s,
|
|
612
589
|
statusCode: o,
|
|
613
590
|
subtype: n,
|
|
@@ -615,17 +592,18 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
615
592
|
urlPathTemplate: c ? e.config.hooks.getViewPathGroup(c) : void 0
|
|
616
593
|
})));
|
|
617
594
|
}, dt = (e, t, n) => {
|
|
618
|
-
|
|
595
|
+
let r = L(e);
|
|
596
|
+
t.setAttributes(e.applyRedact(T(T(T({}, F(e.getRuntimeAttributes(), r)), e.config.hooks.getPageAttributes()), N({
|
|
619
597
|
errorType: "none",
|
|
620
598
|
eventLabel: "文档加载",
|
|
621
599
|
spanSubtype: n,
|
|
622
|
-
spanType:
|
|
623
|
-
targetLabel:
|
|
600
|
+
spanType: M.document,
|
|
601
|
+
targetLabel: r,
|
|
624
602
|
traceScene: "page_load"
|
|
625
603
|
}))));
|
|
626
604
|
}, ft = (e, t, n) => {
|
|
627
605
|
let r = e.config.hooks.redactUrl(n.name);
|
|
628
|
-
t.setAttributes(e.applyRedact(T(T(T({}, e.config.hooks.getPageAttributes()),
|
|
606
|
+
t.setAttributes(e.applyRedact(T(T(T(T({}, F(e.getRuntimeAttributes(), L(e))), e.config.hooks.getPageAttributes()), Ve({
|
|
629
607
|
duration: n.duration,
|
|
630
608
|
initiatorType: n.initiatorType || "other",
|
|
631
609
|
responseStatus: n.responseStatus,
|
|
@@ -633,49 +611,55 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
633
611
|
url: r,
|
|
634
612
|
urlPathTemplate: e.config.hooks.getViewPathGroup(n.name)
|
|
635
613
|
})), {}, { "url.full": r })));
|
|
636
|
-
}, pt = (e) => {
|
|
637
|
-
|
|
614
|
+
}, pt = (e = {}) => {
|
|
615
|
+
var t, n, r, i;
|
|
616
|
+
let a = [], o = {
|
|
617
|
+
documentLoad: (t = e.documentLoad) == null ? !0 : t,
|
|
618
|
+
fetch: (n = e.fetch) == null ? !0 : n,
|
|
619
|
+
xhr: (r = e.xhr) == null ? !0 : r,
|
|
620
|
+
userInteraction: (i = e.userInteraction) == null ? !0 : i
|
|
621
|
+
};
|
|
638
622
|
return {
|
|
639
623
|
name: "official-instrumentations",
|
|
640
|
-
enabled: !!(
|
|
641
|
-
init(
|
|
642
|
-
return
|
|
643
|
-
let
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
624
|
+
enabled: !!(o.documentLoad || o.fetch || o.xhr || o.userInteraction),
|
|
625
|
+
init(e) {
|
|
626
|
+
return k(function* () {
|
|
627
|
+
let t = [lt((t) => A(e.config, t))], n = [lt((t) => ke(e.config, t))], [r, i, s, c] = yield Promise.all([
|
|
628
|
+
o.documentLoad ? import("@opentelemetry/instrumentation-document-load") : Promise.resolve(null),
|
|
629
|
+
o.fetch ? import("@opentelemetry/instrumentation-fetch") : Promise.resolve(null),
|
|
630
|
+
o.xhr ? import("@opentelemetry/instrumentation-xml-http-request") : Promise.resolve(null),
|
|
631
|
+
o.userInteraction ? import("@opentelemetry/instrumentation-user-interaction") : Promise.resolve(null)
|
|
648
632
|
]);
|
|
649
|
-
if (
|
|
633
|
+
if (r && a.push(new r.DocumentLoadInstrumentation({
|
|
650
634
|
semconvStabilityOptIn: "http",
|
|
651
635
|
applyCustomAttributesOnSpan: {
|
|
652
|
-
documentLoad: (
|
|
653
|
-
documentFetch: (
|
|
654
|
-
resourceFetch: (
|
|
636
|
+
documentLoad: (t) => dt(e, t, "navigate"),
|
|
637
|
+
documentFetch: (t) => dt(e, t, "document_fetch"),
|
|
638
|
+
resourceFetch: (t, n) => ft(e, t, n)
|
|
655
639
|
}
|
|
656
|
-
})),
|
|
657
|
-
applyCustomAttributesOnSpan: (
|
|
658
|
-
ignoreUrls:
|
|
659
|
-
propagateTraceHeaderCorsUrls:
|
|
640
|
+
})), i && a.push(new i.FetchInstrumentation({
|
|
641
|
+
applyCustomAttributesOnSpan: (t) => ut(e, t, "fetch"),
|
|
642
|
+
ignoreUrls: t,
|
|
643
|
+
propagateTraceHeaderCorsUrls: n,
|
|
660
644
|
semconvStabilityOptIn: "http",
|
|
661
645
|
ignoreNetworkEvents: !1
|
|
662
|
-
})), s &&
|
|
663
|
-
applyCustomAttributesOnSpan: (
|
|
664
|
-
ignoreUrls:
|
|
665
|
-
propagateTraceHeaderCorsUrls:
|
|
646
|
+
})), s && a.push(new s.XMLHttpRequestInstrumentation({
|
|
647
|
+
applyCustomAttributesOnSpan: (t) => ut(e, t, "xhr"),
|
|
648
|
+
ignoreUrls: t,
|
|
649
|
+
propagateTraceHeaderCorsUrls: n,
|
|
666
650
|
semconvStabilityOptIn: "http",
|
|
667
651
|
ignoreNetworkEvents: !1
|
|
668
652
|
})), c) {
|
|
669
|
-
let
|
|
670
|
-
|
|
653
|
+
let e = o.userInteraction !== null && typeof o.userInteraction == "object" ? { eventNames: o.userInteraction.eventNames } : void 0;
|
|
654
|
+
a.push(new c.UserInteractionInstrumentation(e));
|
|
671
655
|
}
|
|
672
|
-
p({ instrumentations:
|
|
656
|
+
p({ instrumentations: a });
|
|
673
657
|
})();
|
|
674
658
|
},
|
|
675
659
|
shutdown() {
|
|
676
|
-
for (;
|
|
677
|
-
var e,
|
|
678
|
-
(e =
|
|
660
|
+
for (; a.length;) {
|
|
661
|
+
var e, t;
|
|
662
|
+
(e = a.pop()) == null || (t = e.disable) == null || t.call(e);
|
|
679
663
|
}
|
|
680
664
|
}
|
|
681
665
|
};
|
|
@@ -707,44 +691,43 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
707
691
|
} };
|
|
708
692
|
}, mt = 6e4, ht = 5, gt = /^https?:|^\/\//i, _t = (e, t) => {
|
|
709
693
|
if (t) return gt.test(t) ? e(t) : t;
|
|
710
|
-
}, vt = (
|
|
711
|
-
let
|
|
694
|
+
}, vt = () => {
|
|
695
|
+
let e;
|
|
712
696
|
return {
|
|
713
697
|
name: "csp-violation",
|
|
714
|
-
|
|
715
|
-
init(e) {
|
|
698
|
+
init(t) {
|
|
716
699
|
if (typeof window > "u" || typeof document > "u") return;
|
|
717
|
-
let n = z(mt, ht), r = (
|
|
718
|
-
let r = R(`${
|
|
700
|
+
let n = z(mt, ht), r = (e) => {
|
|
701
|
+
let r = R(`${e.violatedDirective}|${e.blockedURI}|${e.sourceFile}|${e.lineNumber}`), i = n.allow(r);
|
|
719
702
|
if (!i.allowed) return;
|
|
720
|
-
let a = _t(
|
|
721
|
-
|
|
703
|
+
let a = _t(t.config.hooks.redactUrl, e.blockedURI), o = e.sourceFile ? t.config.hooks.redactUrl(e.sourceFile) : void 0, s = i.count === 1;
|
|
704
|
+
t.startSpan("csp.violation", T(T(T({}, t.config.hooks.getPageAttributes()), N({
|
|
722
705
|
errorType: "csp",
|
|
723
706
|
eventLabel: "CSP 错误",
|
|
724
|
-
result:
|
|
707
|
+
result: j.error,
|
|
725
708
|
spanSubtype: "csp",
|
|
726
|
-
spanType:
|
|
727
|
-
targetLabel: a == null ?
|
|
728
|
-
targetValue:
|
|
709
|
+
spanType: M.error,
|
|
710
|
+
targetLabel: a == null ? e.effectiveDirective : a,
|
|
711
|
+
targetValue: e.statusCode
|
|
729
712
|
})), {}, {
|
|
730
713
|
"csp.blocked_uri": a,
|
|
731
|
-
"csp.violated_directive":
|
|
732
|
-
"csp.effective_directive":
|
|
733
|
-
"csp.disposition":
|
|
714
|
+
"csp.violated_directive": e.violatedDirective,
|
|
715
|
+
"csp.effective_directive": e.effectiveDirective,
|
|
716
|
+
"csp.disposition": e.disposition,
|
|
734
717
|
"csp.source_file": o,
|
|
735
|
-
"csp.line_number":
|
|
736
|
-
"csp.column_number":
|
|
737
|
-
"csp.status_code":
|
|
718
|
+
"csp.line_number": e.lineNumber,
|
|
719
|
+
"csp.column_number": e.columnNumber,
|
|
720
|
+
"csp.status_code": e.statusCode,
|
|
738
721
|
"csp.fingerprint": r,
|
|
739
722
|
"csp.window_count": i.count,
|
|
740
723
|
[b.exceptionFingerprint]: r,
|
|
741
724
|
"error.source": "csp"
|
|
742
|
-
}, s ? { "csp.original_policy":
|
|
725
|
+
}, s ? { "csp.original_policy": e.originalPolicy } : {})).end();
|
|
743
726
|
};
|
|
744
|
-
document.addEventListener("securitypolicyviolation", r),
|
|
727
|
+
document.addEventListener("securitypolicyviolation", r), e = () => document.removeEventListener("securitypolicyviolation", r);
|
|
745
728
|
},
|
|
746
729
|
shutdown() {
|
|
747
|
-
|
|
730
|
+
e == null || e(), e = void 0;
|
|
748
731
|
}
|
|
749
732
|
};
|
|
750
733
|
}, B = (e) => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`, yt = "BK_RUM_DEVICE_ID", bt = 250, xt = () => navigator.connection, St = () => navigator.userAgentData, Ct = (e) => {
|
|
@@ -818,38 +801,37 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
818
801
|
n = void 0, e();
|
|
819
802
|
}, t);
|
|
820
803
|
};
|
|
821
|
-
}, At = (e) => {
|
|
822
|
-
|
|
804
|
+
}, At = (e = {}) => {
|
|
805
|
+
var t;
|
|
806
|
+
let n = [], r = (t = e.storageKey) == null ? yt : t;
|
|
823
807
|
return {
|
|
824
808
|
name: "device",
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
let i =
|
|
829
|
-
|
|
830
|
-
let o = kt(() => {
|
|
831
|
-
n.setRuntimeAttributes(Et());
|
|
809
|
+
init(e) {
|
|
810
|
+
let t = typeof window > "u" ? B("device") : Tt(r);
|
|
811
|
+
if (e.setRuntimeAttributes(T(T(T({ "device.id": t }, Ot()), Et()), Dt())), typeof window > "u") return;
|
|
812
|
+
let i = kt(() => {
|
|
813
|
+
e.setRuntimeAttributes(Et());
|
|
832
814
|
}, bt);
|
|
833
|
-
window.addEventListener("resize",
|
|
834
|
-
let
|
|
835
|
-
if (
|
|
836
|
-
let
|
|
837
|
-
|
|
815
|
+
window.addEventListener("resize", i), window.addEventListener("orientationchange", i), n.push(() => window.removeEventListener("resize", i), () => window.removeEventListener("orientationchange", i));
|
|
816
|
+
let a = xt();
|
|
817
|
+
if (a && typeof a.addEventListener == "function") {
|
|
818
|
+
let t = () => {
|
|
819
|
+
e.setRuntimeAttributes(Dt());
|
|
838
820
|
};
|
|
839
|
-
|
|
840
|
-
var
|
|
841
|
-
(
|
|
821
|
+
a.addEventListener("change", t), n.push(() => {
|
|
822
|
+
var e;
|
|
823
|
+
(e = a.removeEventListener) == null || e.call(a, "change", t);
|
|
842
824
|
});
|
|
843
825
|
}
|
|
844
826
|
},
|
|
845
827
|
shutdown() {
|
|
846
|
-
for (;
|
|
828
|
+
for (; n.length;) {
|
|
847
829
|
var e;
|
|
848
|
-
(e =
|
|
830
|
+
(e = n.pop()) == null || e();
|
|
849
831
|
}
|
|
850
832
|
}
|
|
851
833
|
};
|
|
852
|
-
}, jt = 6e4, Mt = 5, Nt = (e) => {
|
|
834
|
+
}, jt = 6e4, Mt = 5, Nt = (e, t) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : t, Pt = (e) => {
|
|
853
835
|
if (e instanceof Error) return e.message;
|
|
854
836
|
if (typeof e == "string") return e;
|
|
855
837
|
try {
|
|
@@ -857,30 +839,30 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
857
839
|
} catch (t) {
|
|
858
840
|
return String(e);
|
|
859
841
|
}
|
|
860
|
-
},
|
|
842
|
+
}, Ft = (e) => {
|
|
861
843
|
var t;
|
|
862
844
|
return e instanceof Error ? (t = e.stack) == null ? "" : t : "";
|
|
863
|
-
},
|
|
845
|
+
}, It = (e) => e.slice(0, 80), Lt = (e) => {
|
|
864
846
|
var t, n;
|
|
865
847
|
return (t = (n = e.split("\n").find((e) => e.trim().startsWith("at "))) == null ? void 0 : n.trim()) == null ? "" : t;
|
|
866
|
-
},
|
|
867
|
-
let c =
|
|
848
|
+
}, Rt = (e) => e === "unhandledrejection" ? "promise" : e === "resource" ? "resource_load" : "js", V = ({ context: e, error: n, exceptionType: r, extra: i = {}, source: a, spanName: o, throttle: s }) => {
|
|
849
|
+
let c = Pt(n), l = Ft(n), u = R(`${a}|${c}|${l.slice(0, 256)}`), d = s.allow(u);
|
|
868
850
|
if (!d.allowed) return;
|
|
869
851
|
let f = n instanceof Error ? n : {
|
|
870
852
|
message: c,
|
|
871
853
|
name: r == null ? a : r
|
|
872
|
-
}, p = T(T(T(T({}, e.config.hooks.getPageAttributes()), e.config.hooks.getErrorAttributes()),
|
|
873
|
-
errorType:
|
|
854
|
+
}, p = T(T(T(T({}, e.config.hooks.getPageAttributes()), e.config.hooks.getErrorAttributes()), N({
|
|
855
|
+
errorType: Rt(a),
|
|
874
856
|
eventLabel: "错误",
|
|
875
|
-
result:
|
|
876
|
-
spanSubtype:
|
|
877
|
-
spanType:
|
|
857
|
+
result: j.error,
|
|
858
|
+
spanSubtype: Rt(a),
|
|
859
|
+
spanType: M.error,
|
|
878
860
|
targetLabel: n instanceof Error ? n.name : r == null ? a : r
|
|
879
861
|
})), {}, {
|
|
880
862
|
"exception.message": c,
|
|
881
|
-
[b.exceptionMessageShort]:
|
|
863
|
+
[b.exceptionMessageShort]: It(c),
|
|
882
864
|
"exception.stacktrace": l,
|
|
883
|
-
[b.exceptionStackTopFrame]:
|
|
865
|
+
[b.exceptionStackTopFrame]: Lt(l),
|
|
884
866
|
"exception.type": n instanceof Error ? n.name : r == null ? a : r,
|
|
885
867
|
[b.exceptionFingerprint]: u,
|
|
886
868
|
"error.handled": !1,
|
|
@@ -891,56 +873,55 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
891
873
|
code: t.ERROR,
|
|
892
874
|
message: c
|
|
893
875
|
}), m.end();
|
|
894
|
-
},
|
|
895
|
-
let t = [];
|
|
876
|
+
}, zt = (e = {}) => {
|
|
877
|
+
let t = [], n = Nt(e.windowMs, jt), r = Nt(e.maxPerWindow, Mt);
|
|
896
878
|
return {
|
|
897
879
|
name: "error",
|
|
898
|
-
|
|
899
|
-
init(n) {
|
|
880
|
+
init(e) {
|
|
900
881
|
if (typeof window > "u") return;
|
|
901
|
-
let
|
|
902
|
-
var
|
|
903
|
-
let
|
|
882
|
+
let i = z(n, r), a = (t) => {
|
|
883
|
+
var n;
|
|
884
|
+
let r = !t.error && !t.filename && t.message === "Script error.";
|
|
904
885
|
V({
|
|
905
|
-
context:
|
|
906
|
-
throttle:
|
|
886
|
+
context: e,
|
|
887
|
+
throttle: i,
|
|
907
888
|
spanName: "browser.error",
|
|
908
889
|
source: "window.error",
|
|
909
|
-
error: (
|
|
890
|
+
error: (n = t.error) == null ? t.message : n,
|
|
910
891
|
extra: T({
|
|
911
|
-
"code.filepath":
|
|
912
|
-
"code.lineno":
|
|
913
|
-
"code.column":
|
|
914
|
-
},
|
|
892
|
+
"code.filepath": t.filename,
|
|
893
|
+
"code.lineno": t.lineno,
|
|
894
|
+
"code.column": t.colno
|
|
895
|
+
}, r ? { "error.cross_origin": !0 } : {})
|
|
915
896
|
});
|
|
916
|
-
},
|
|
897
|
+
}, o = (t) => {
|
|
917
898
|
V({
|
|
918
|
-
context:
|
|
919
|
-
throttle:
|
|
899
|
+
context: e,
|
|
900
|
+
throttle: i,
|
|
920
901
|
spanName: "browser.unhandledrejection",
|
|
921
902
|
source: "unhandledrejection",
|
|
922
|
-
error:
|
|
923
|
-
exceptionType:
|
|
903
|
+
error: t.reason,
|
|
904
|
+
exceptionType: t.reason instanceof Error ? t.reason.name : "UnhandledRejection"
|
|
924
905
|
});
|
|
925
|
-
},
|
|
926
|
-
if (
|
|
927
|
-
let
|
|
928
|
-
if (!(
|
|
929
|
-
let
|
|
906
|
+
}, s = (t) => {
|
|
907
|
+
if (t instanceof ErrorEvent) return;
|
|
908
|
+
let n = t.target;
|
|
909
|
+
if (!(n instanceof Element)) return;
|
|
910
|
+
let r = n, a = r.src || r.href || n.currentSrc || "";
|
|
930
911
|
V({
|
|
931
|
-
context:
|
|
932
|
-
throttle:
|
|
912
|
+
context: e,
|
|
913
|
+
throttle: i,
|
|
933
914
|
spanName: "browser.resource_error",
|
|
934
915
|
source: "resource",
|
|
935
|
-
error: /* @__PURE__ */ Error(`Resource load failed: ${
|
|
916
|
+
error: /* @__PURE__ */ Error(`Resource load failed: ${n.tagName.toLowerCase()} ${a}`),
|
|
936
917
|
exceptionType: "ResourceError",
|
|
937
918
|
extra: {
|
|
938
|
-
"url.full":
|
|
939
|
-
"html.tag":
|
|
919
|
+
"url.full": e.config.hooks.redactUrl(a),
|
|
920
|
+
"html.tag": n.tagName
|
|
940
921
|
}
|
|
941
922
|
});
|
|
942
923
|
};
|
|
943
|
-
window.addEventListener("error",
|
|
924
|
+
window.addEventListener("error", a), window.addEventListener("unhandledrejection", o), window.addEventListener("error", s, !0), t.push(() => window.removeEventListener("error", a), () => window.removeEventListener("unhandledrejection", o), () => window.removeEventListener("error", s, !0));
|
|
944
925
|
},
|
|
945
926
|
shutdown() {
|
|
946
927
|
for (; t.length;) {
|
|
@@ -949,13 +930,13 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
949
930
|
}
|
|
950
931
|
}
|
|
951
932
|
};
|
|
952
|
-
},
|
|
933
|
+
}, Bt = 10 * 1024, Vt = 10, Ht = (e) => e.body, Ut = (e, t) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : t, H = /* @__PURE__ */ new WeakMap(), U = (e, t) => e.length <= t ? {
|
|
953
934
|
body: e,
|
|
954
935
|
truncated: !1
|
|
955
936
|
} : {
|
|
956
937
|
body: e.slice(0, t),
|
|
957
938
|
truncated: !0
|
|
958
|
-
},
|
|
939
|
+
}, Wt = (e, t) => {
|
|
959
940
|
if (!e) return;
|
|
960
941
|
if (e instanceof Headers) return e.get(t) || void 0;
|
|
961
942
|
let n = t.toLowerCase();
|
|
@@ -965,30 +946,30 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
965
946
|
}
|
|
966
947
|
let i = Object.keys(e).find((e) => e.toLowerCase() === n);
|
|
967
948
|
return i ? e[i] : void 0;
|
|
968
|
-
},
|
|
949
|
+
}, Gt = (e) => {
|
|
969
950
|
let t = {};
|
|
970
951
|
return e.forEach((e, n) => {
|
|
971
952
|
t[n] = e instanceof File ? `[File name=${e.name} type=${e.type || "unknown"} size=${e.size}]` : e;
|
|
972
953
|
}), JSON.stringify(t);
|
|
973
|
-
},
|
|
974
|
-
var e =
|
|
975
|
-
return e == null ? "" : typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : e instanceof FormData ?
|
|
954
|
+
}, Kt = function() {
|
|
955
|
+
var e = k(function* (e) {
|
|
956
|
+
return e == null ? "" : typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : e instanceof FormData ? Gt(e) : e instanceof Blob ? e.text() : e instanceof ArrayBuffer || ArrayBuffer.isView(e) ? new TextDecoder().decode(e) : e instanceof Document ? new XMLSerializer().serializeToString(e) : String(e);
|
|
976
957
|
});
|
|
977
958
|
return function(t) {
|
|
978
959
|
return e.apply(this, arguments);
|
|
979
960
|
};
|
|
980
|
-
}(),
|
|
981
|
-
var e =
|
|
982
|
-
let r = yield
|
|
961
|
+
}(), qt = function() {
|
|
962
|
+
var e = k(function* (e, t, n) {
|
|
963
|
+
let r = yield Kt(e);
|
|
983
964
|
if (r) return T(T({}, U(r, t)), {}, { contentType: n });
|
|
984
965
|
});
|
|
985
966
|
return function(t, n, r) {
|
|
986
967
|
return e.apply(this, arguments);
|
|
987
968
|
};
|
|
988
969
|
}(), W = function() {
|
|
989
|
-
var e =
|
|
970
|
+
var e = k(function* (e, t, n) {
|
|
990
971
|
try {
|
|
991
|
-
return yield
|
|
972
|
+
return yield qt(e, t, n);
|
|
992
973
|
} catch (e) {
|
|
993
974
|
return;
|
|
994
975
|
}
|
|
@@ -996,13 +977,13 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
996
977
|
return function(t, n, r) {
|
|
997
978
|
return e.apply(this, arguments);
|
|
998
979
|
};
|
|
999
|
-
}(),
|
|
1000
|
-
var e =
|
|
980
|
+
}(), Jt = (e) => e instanceof Request ? e.url : String(e), Yt = (e, t) => t != null && t.method ? t.method : e instanceof Request ? e.method : "GET", Xt = (e, t, n) => t != null && t.body ? () => W(t.body, n, Wt(t.headers, "content-type")) : (e instanceof Request, () => Promise.resolve(void 0)), Zt = function() {
|
|
981
|
+
var e = k(function* (e, t) {
|
|
1001
982
|
try {
|
|
1002
983
|
let n = e.headers.get("content-type") || void 0, r = e.headers.get("content-length");
|
|
1003
984
|
if (r) {
|
|
1004
985
|
let e = Number(r);
|
|
1005
|
-
if (Number.isFinite(e) && e > t *
|
|
986
|
+
if (Number.isFinite(e) && e > t * Vt) return {
|
|
1006
987
|
body: "",
|
|
1007
988
|
contentType: n,
|
|
1008
989
|
truncated: !0
|
|
@@ -1017,100 +998,103 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1017
998
|
return function(t, n) {
|
|
1018
999
|
return e.apply(this, arguments);
|
|
1019
1000
|
};
|
|
1020
|
-
}(),
|
|
1001
|
+
}(), Qt = (e, t) => {
|
|
1021
1002
|
if (e.responseType === "" || e.responseType === "text") return T(T({}, U(e.responseText || "", t)), {}, { contentType: e.getResponseHeader("content-type") || void 0 });
|
|
1022
1003
|
if (e.responseType === "json") return T(T({}, U(JSON.stringify(e.response), t)), {}, { contentType: e.getResponseHeader("content-type") || void 0 });
|
|
1023
|
-
},
|
|
1004
|
+
}, $t = (e, t, n) => {
|
|
1024
1005
|
if (n) return e.redact(T(T({}, t), {}, {
|
|
1025
1006
|
body: n.body,
|
|
1026
1007
|
truncated: n.truncated
|
|
1027
1008
|
}));
|
|
1028
|
-
},
|
|
1029
|
-
let
|
|
1030
|
-
|
|
1031
|
-
let d = !!n || typeof s == "number" && s >= 400, f = r.toUpperCase(), p = d ? Xt(u, {
|
|
1032
|
-
contentType: i == null ? void 0 : i.contentType,
|
|
1009
|
+
}, en = ({ config: e, context: t, duration: n, error: r, method: i, request: a, response: s, status: c, subtype: l, url: u }) => {
|
|
1010
|
+
let d = !!r || typeof c == "number" && c >= 400, f = i.toUpperCase(), p = d ? $t(e, {
|
|
1011
|
+
contentType: a == null ? void 0 : a.contentType,
|
|
1033
1012
|
method: f,
|
|
1034
|
-
status:
|
|
1013
|
+
status: c,
|
|
1035
1014
|
type: "request",
|
|
1036
|
-
url:
|
|
1037
|
-
},
|
|
1038
|
-
contentType:
|
|
1015
|
+
url: u
|
|
1016
|
+
}, a) : void 0, m = d ? $t(e, {
|
|
1017
|
+
contentType: s == null ? void 0 : s.contentType,
|
|
1039
1018
|
method: f,
|
|
1040
|
-
status:
|
|
1019
|
+
status: c,
|
|
1041
1020
|
type: "response",
|
|
1042
|
-
url:
|
|
1043
|
-
},
|
|
1044
|
-
duration:
|
|
1021
|
+
url: u
|
|
1022
|
+
}, s) : void 0, h = T(T(T({}, t.config.hooks.getPageAttributes()), Be({
|
|
1023
|
+
duration: n,
|
|
1045
1024
|
method: f,
|
|
1046
|
-
statusCode:
|
|
1047
|
-
subtype:
|
|
1048
|
-
url:
|
|
1049
|
-
urlPathTemplate:
|
|
1025
|
+
statusCode: c,
|
|
1026
|
+
subtype: l,
|
|
1027
|
+
url: t.config.hooks.redactUrl(u),
|
|
1028
|
+
urlPathTemplate: t.config.hooks.getViewPathGroup(u)
|
|
1050
1029
|
})), {}, {
|
|
1051
|
-
"http.duration":
|
|
1030
|
+
"http.duration": n,
|
|
1052
1031
|
"http.request.method": f,
|
|
1053
|
-
"url.full":
|
|
1032
|
+
"url.full": t.config.hooks.redactUrl(u)
|
|
1054
1033
|
});
|
|
1055
|
-
if (typeof
|
|
1034
|
+
if (typeof c == "number" && (h["http.response.status_code"] = c), p != null && (h["http.request.body"] = p), m != null && (h["http.response.body"] = m), d) {
|
|
1056
1035
|
var g, _;
|
|
1057
|
-
h["http_body.request.truncated"] = (g =
|
|
1036
|
+
h["http_body.request.truncated"] = (g = a == null ? void 0 : a.truncated) == null ? !1 : g, h["http_body.response.truncated"] = (_ = s == null ? void 0 : s.truncated) == null ? !1 : _;
|
|
1058
1037
|
}
|
|
1059
|
-
if (
|
|
1038
|
+
if (r instanceof Error) {
|
|
1060
1039
|
var v;
|
|
1061
|
-
h["exception.message"] =
|
|
1040
|
+
h["exception.message"] = r.message, h["exception.type"] = r.name, h["exception.stacktrace"] = (v = r.stack) == null ? "" : v;
|
|
1062
1041
|
}
|
|
1063
|
-
|
|
1042
|
+
t.emitLog({
|
|
1064
1043
|
severityNumber: d ? o.ERROR : o.INFO,
|
|
1065
1044
|
severityText: d ? "ERROR" : "INFO",
|
|
1066
1045
|
body: d ? "HTTP request completed with error" : "HTTP request completed",
|
|
1067
1046
|
attributes: h
|
|
1068
1047
|
});
|
|
1069
|
-
},
|
|
1070
|
-
|
|
1048
|
+
}, tn = (e = {}) => {
|
|
1049
|
+
var t;
|
|
1050
|
+
let n = [], r = {
|
|
1051
|
+
maxBodySize: Ut(e.maxBodySize, Bt),
|
|
1052
|
+
redact: (t = e.redact) == null ? Ht : t
|
|
1053
|
+
};
|
|
1071
1054
|
return {
|
|
1072
1055
|
name: "http-body",
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
let r = e.enabled ? e.maxBodySize : zt, i = window.fetch;
|
|
1056
|
+
init(e) {
|
|
1057
|
+
if (typeof window > "u") return;
|
|
1058
|
+
let { maxBodySize: t } = r, i = window.fetch;
|
|
1077
1059
|
if (typeof i == "function") {
|
|
1078
|
-
let
|
|
1079
|
-
var
|
|
1080
|
-
let
|
|
1081
|
-
if (
|
|
1082
|
-
let
|
|
1060
|
+
let a = function() {
|
|
1061
|
+
var n = k(function* (n, a) {
|
|
1062
|
+
let o = Jt(n);
|
|
1063
|
+
if (A(e.config, o)) return i(n, a);
|
|
1064
|
+
let s = Yt(n, a), c = Xt(n, a, t), l = performance.now();
|
|
1083
1065
|
try {
|
|
1084
|
-
let
|
|
1085
|
-
return
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1066
|
+
let u = yield i(n, a), d = performance.now() - l, f = u.status >= 400;
|
|
1067
|
+
return en({
|
|
1068
|
+
config: r,
|
|
1069
|
+
context: e,
|
|
1070
|
+
duration: d,
|
|
1071
|
+
method: s,
|
|
1072
|
+
request: f ? yield c() : void 0,
|
|
1073
|
+
response: f ? yield Zt(u, t) : void 0,
|
|
1074
|
+
status: u.status,
|
|
1092
1075
|
subtype: "fetch",
|
|
1093
|
-
url:
|
|
1094
|
-
}),
|
|
1095
|
-
} catch (
|
|
1096
|
-
let
|
|
1097
|
-
throw
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1076
|
+
url: o
|
|
1077
|
+
}), u;
|
|
1078
|
+
} catch (t) {
|
|
1079
|
+
let n = yield c();
|
|
1080
|
+
throw en({
|
|
1081
|
+
config: r,
|
|
1082
|
+
context: e,
|
|
1083
|
+
duration: performance.now() - l,
|
|
1084
|
+
error: t,
|
|
1085
|
+
method: s,
|
|
1086
|
+
request: n,
|
|
1103
1087
|
subtype: "fetch",
|
|
1104
|
-
url:
|
|
1105
|
-
}),
|
|
1088
|
+
url: o
|
|
1089
|
+
}), t;
|
|
1106
1090
|
}
|
|
1107
1091
|
});
|
|
1108
|
-
return function(
|
|
1109
|
-
return
|
|
1092
|
+
return function(e, t) {
|
|
1093
|
+
return n.apply(this, arguments);
|
|
1110
1094
|
};
|
|
1111
1095
|
}();
|
|
1112
|
-
window.fetch =
|
|
1113
|
-
window.fetch ===
|
|
1096
|
+
window.fetch = a, n.push(() => {
|
|
1097
|
+
window.fetch === a && (window.fetch = i);
|
|
1114
1098
|
});
|
|
1115
1099
|
}
|
|
1116
1100
|
let a = XMLHttpRequest.prototype.open, o = XMLHttpRequest.prototype.send, s = XMLHttpRequest.prototype.setRequestHeader, c = function(e, t, ...n) {
|
|
@@ -1128,12 +1112,12 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1128
1112
|
a[i] = o ? `${o}, ${t}` : t, n.requestHeaders = a;
|
|
1129
1113
|
}
|
|
1130
1114
|
return s.call(this, e, t);
|
|
1131
|
-
}, u = function(
|
|
1132
|
-
var
|
|
1133
|
-
let
|
|
1134
|
-
if (
|
|
1135
|
-
var
|
|
1136
|
-
|
|
1115
|
+
}, u = function(n) {
|
|
1116
|
+
var i = this;
|
|
1117
|
+
let a = H.get(this);
|
|
1118
|
+
if (a) {
|
|
1119
|
+
var s;
|
|
1120
|
+
a.requestBody = n, a.requestContentType = (s = a.requestHeaders) == null ? void 0 : s["content-type"];
|
|
1137
1121
|
}
|
|
1138
1122
|
return this.addEventListener("abort", () => {
|
|
1139
1123
|
let e = H.get(this);
|
|
@@ -1142,67 +1126,67 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1142
1126
|
let e = H.get(this);
|
|
1143
1127
|
e && (e.networkError = !0);
|
|
1144
1128
|
}, { once: !0 }), this.addEventListener("loadend", () => {
|
|
1145
|
-
|
|
1146
|
-
let
|
|
1147
|
-
if (!
|
|
1148
|
-
let
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1129
|
+
k(function* () {
|
|
1130
|
+
let n = H.get(i);
|
|
1131
|
+
if (!n || A(e.config, n.url) || n.aborted) return;
|
|
1132
|
+
let a = n.networkError || i.status >= 400, o = a ? Qt(i, t) : void 0, s = a ? yield W(n.requestBody, t, n.requestContentType) : void 0;
|
|
1133
|
+
en({
|
|
1134
|
+
config: r,
|
|
1135
|
+
context: e,
|
|
1136
|
+
duration: performance.now() - n.startTime,
|
|
1137
|
+
error: n.networkError ? /* @__PURE__ */ Error("XHR network error") : void 0,
|
|
1138
|
+
method: n.method,
|
|
1139
|
+
request: s,
|
|
1140
|
+
response: o,
|
|
1141
|
+
status: i.status,
|
|
1157
1142
|
subtype: "xhr",
|
|
1158
|
-
url:
|
|
1143
|
+
url: n.url
|
|
1159
1144
|
});
|
|
1160
1145
|
})();
|
|
1161
|
-
}, { once: !0 }), o.call(this,
|
|
1146
|
+
}, { once: !0 }), o.call(this, n);
|
|
1162
1147
|
};
|
|
1163
|
-
XMLHttpRequest.prototype.open = c, XMLHttpRequest.prototype.setRequestHeader = l, XMLHttpRequest.prototype.send = u,
|
|
1148
|
+
XMLHttpRequest.prototype.open = c, XMLHttpRequest.prototype.setRequestHeader = l, XMLHttpRequest.prototype.send = u, n.push(() => {
|
|
1164
1149
|
XMLHttpRequest.prototype.open === c && (XMLHttpRequest.prototype.open = a), XMLHttpRequest.prototype.setRequestHeader === l && (XMLHttpRequest.prototype.setRequestHeader = s), XMLHttpRequest.prototype.send === u && (XMLHttpRequest.prototype.send = o);
|
|
1165
1150
|
});
|
|
1166
1151
|
},
|
|
1167
1152
|
shutdown() {
|
|
1168
|
-
for (;
|
|
1153
|
+
for (; n.length;) {
|
|
1169
1154
|
var e;
|
|
1170
|
-
(e =
|
|
1155
|
+
(e = n.pop()) == null || e();
|
|
1171
1156
|
}
|
|
1172
1157
|
}
|
|
1173
1158
|
};
|
|
1174
|
-
},
|
|
1175
|
-
let t;
|
|
1159
|
+
}, nn = 50, rn = (e, t) => typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : t, an = (e = {}) => {
|
|
1160
|
+
let t, n = rn(e.threshold, nn);
|
|
1176
1161
|
return {
|
|
1177
1162
|
name: "long-task",
|
|
1178
|
-
|
|
1179
|
-
init(n) {
|
|
1163
|
+
init(e) {
|
|
1180
1164
|
var r;
|
|
1181
1165
|
if (typeof PerformanceObserver > "u" || !((r = PerformanceObserver.supportedEntryTypes) != null && r.includes("longtask"))) return;
|
|
1182
|
-
let i = e.
|
|
1166
|
+
let i = e.meter.createCounter("browser.long_task.count", { description: "Number of long tasks observed (duration >= threshold)" }), a = e.meter.createHistogram("browser.long_task.duration", {
|
|
1183
1167
|
unit: "ms",
|
|
1184
1168
|
description: "Duration of long tasks"
|
|
1185
1169
|
});
|
|
1186
1170
|
try {
|
|
1187
|
-
t = new PerformanceObserver((
|
|
1188
|
-
let
|
|
1189
|
-
for (let h of
|
|
1190
|
-
var
|
|
1191
|
-
if (h.duration <
|
|
1192
|
-
let
|
|
1193
|
-
|
|
1171
|
+
t = new PerformanceObserver((t) => {
|
|
1172
|
+
let r = e.applyRedact(T(T(T({}, e.config.hooks.getPageAttributes()), e.config.hooks.getMetricAttributes()), P(e.getRuntimeAttributes())));
|
|
1173
|
+
for (let h of t.getEntries()) {
|
|
1174
|
+
var o, s, c, l, u, d, f, p, m;
|
|
1175
|
+
if (h.duration < n) continue;
|
|
1176
|
+
let t = (o = h.attribution) == null ? void 0 : o[0], g = T(T({}, r), {}, { [b.longtaskAttributionScript]: (s = (c = t == null ? void 0 : t.containerSrc) == null ? t == null ? void 0 : t.name : c) == null ? "unknown" : s }), _ = h.duration > 100 ? j.warning : j.success;
|
|
1177
|
+
e.startSpan("browser.long_task", T(T(T({}, r), N({
|
|
1194
1178
|
duration: h.duration,
|
|
1195
|
-
errorType: _ ===
|
|
1179
|
+
errorType: _ === j.warning ? "longtask_blocking" : "none",
|
|
1196
1180
|
eventLabel: "长任务",
|
|
1197
1181
|
result: _,
|
|
1198
|
-
spanSubtype: (l =
|
|
1199
|
-
spanType:
|
|
1200
|
-
targetLabel: (u = (d = (f =
|
|
1182
|
+
spanSubtype: (l = t == null ? void 0 : t.name) == null ? "unknown" : l,
|
|
1183
|
+
spanType: M.longtask,
|
|
1184
|
+
targetLabel: (u = (d = (f = t == null ? void 0 : t.containerSrc) == null ? t == null ? void 0 : t.containerName : f) == null ? t == null ? void 0 : t.name : d) == null ? "unknown" : u,
|
|
1201
1185
|
targetValue: h.duration
|
|
1202
1186
|
})), {}, {
|
|
1203
1187
|
[b.longtaskBlockingDuration]: h.duration,
|
|
1204
|
-
[b.longtaskAttributionScript]: (p = (m =
|
|
1205
|
-
}), { startTime: performance.timeOrigin + h.startTime }).end(performance.timeOrigin + h.startTime + h.duration),
|
|
1188
|
+
[b.longtaskAttributionScript]: (p = (m = t == null ? void 0 : t.containerSrc) == null ? t == null ? void 0 : t.name : m) == null ? "unknown" : p
|
|
1189
|
+
}), { startTime: performance.timeOrigin + h.startTime }).end(performance.timeOrigin + h.startTime + h.duration), i.add(1, g), a.record(h.duration, g);
|
|
1206
1190
|
}
|
|
1207
1191
|
}), t.observe({
|
|
1208
1192
|
type: "longtask",
|
|
@@ -1216,62 +1200,61 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1216
1200
|
t == null || t.disconnect(), t = void 0;
|
|
1217
1201
|
}
|
|
1218
1202
|
};
|
|
1219
|
-
},
|
|
1220
|
-
let n =
|
|
1221
|
-
|
|
1203
|
+
}, G = /* @__PURE__ */ new Set(), K = "", q, J, Y = !1, X = () => typeof location > "u" ? "" : location.href, Z = (e, t) => {
|
|
1204
|
+
let n = X();
|
|
1205
|
+
K = n;
|
|
1222
1206
|
let r = {
|
|
1223
1207
|
fromUrl: t,
|
|
1224
1208
|
source: e,
|
|
1225
1209
|
toUrl: n
|
|
1226
1210
|
};
|
|
1227
|
-
for (let e of Array.from(
|
|
1228
|
-
},
|
|
1229
|
-
|
|
1230
|
-
},
|
|
1231
|
-
|
|
1232
|
-
},
|
|
1233
|
-
|
|
1234
|
-
let r =
|
|
1211
|
+
for (let e of Array.from(G)) e(r);
|
|
1212
|
+
}, on = () => {
|
|
1213
|
+
Z("popstate", K || X());
|
|
1214
|
+
}, sn = () => {
|
|
1215
|
+
Z("hashchange", K || X());
|
|
1216
|
+
}, cn = () => {
|
|
1217
|
+
Y || typeof window > "u" || typeof history > "u" || (Y = !0, K = X(), q = history.pushState, J = history.replaceState, history.pushState = function(e, t, n) {
|
|
1218
|
+
let r = K || X(), i = q == null ? void 0 : q.apply(this, [
|
|
1235
1219
|
e,
|
|
1236
1220
|
t,
|
|
1237
1221
|
n
|
|
1238
1222
|
]);
|
|
1239
|
-
return
|
|
1223
|
+
return Z("pushState", r), i;
|
|
1240
1224
|
}, history.replaceState = function(e, t, n) {
|
|
1241
|
-
let r =
|
|
1225
|
+
let r = K || X(), i = J == null ? void 0 : J.apply(this, [
|
|
1242
1226
|
e,
|
|
1243
1227
|
t,
|
|
1244
1228
|
n
|
|
1245
1229
|
]);
|
|
1246
|
-
return
|
|
1247
|
-
}, window.addEventListener("popstate",
|
|
1248
|
-
},
|
|
1249
|
-
!
|
|
1250
|
-
},
|
|
1251
|
-
|
|
1252
|
-
}),
|
|
1253
|
-
let
|
|
1230
|
+
return Z("replaceState", r), i;
|
|
1231
|
+
}, window.addEventListener("popstate", on), window.addEventListener("hashchange", sn));
|
|
1232
|
+
}, ln = () => {
|
|
1233
|
+
!Y || typeof window > "u" || typeof history > "u" || (q && (history.pushState = q), J && (history.replaceState = J), window.removeEventListener("popstate", on), window.removeEventListener("hashchange", sn), q = void 0, J = void 0, Y = !1, K = "");
|
|
1234
|
+
}, un = (e) => typeof window > "u" || typeof history > "u" ? () => {} : (cn(), G.add(e), () => {
|
|
1235
|
+
G.delete(e), G.size === 0 && ln();
|
|
1236
|
+
}), dn = () => typeof location > "u" ? "" : location.href, fn = () => {
|
|
1237
|
+
let e = [];
|
|
1254
1238
|
return {
|
|
1255
1239
|
name: "page-view",
|
|
1256
|
-
|
|
1257
|
-
init(e) {
|
|
1240
|
+
init(t) {
|
|
1258
1241
|
if (typeof window > "u") return;
|
|
1259
|
-
let n = "", r, i = (
|
|
1260
|
-
let a =
|
|
1242
|
+
let n = "", r, i = (e, i = n) => {
|
|
1243
|
+
let a = dn();
|
|
1261
1244
|
if (a === n) return;
|
|
1262
|
-
r == null || r.setAttribute("view.end_reason",
|
|
1263
|
-
let o = B("view"), s =
|
|
1264
|
-
|
|
1245
|
+
r == null || r.setAttribute("view.end_reason", e), r == null || r.end(), n = a;
|
|
1246
|
+
let o = B("view"), s = t.config.hooks.getViewPathGroup(a), c = e === "load" ? "initial_load" : "route_change", l = t.config.hooks.redactUrl(a), u = t.config.hooks.redactUrl(i);
|
|
1247
|
+
t.setView({
|
|
1265
1248
|
id: o,
|
|
1266
1249
|
loadingType: c,
|
|
1267
1250
|
url: l,
|
|
1268
1251
|
urlPathGroup: s
|
|
1269
1252
|
});
|
|
1270
|
-
let d =
|
|
1253
|
+
let d = e === "load", f = T(T(T({}, t.config.hooks.getPageAttributes()), N({
|
|
1271
1254
|
errorType: "none",
|
|
1272
1255
|
eventLabel: d ? "文档加载" : "路由切换",
|
|
1273
|
-
spanSubtype: d ? "navigate" :
|
|
1274
|
-
spanType: d ?
|
|
1256
|
+
spanSubtype: d ? "navigate" : e,
|
|
1257
|
+
spanType: d ? M.document : M.route,
|
|
1275
1258
|
targetLabel: s,
|
|
1276
1259
|
traceScene: d ? "page_load" : "route_change"
|
|
1277
1260
|
})), {}, {
|
|
@@ -1280,140 +1263,138 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1280
1263
|
[b.viewUrlPathGroup]: s,
|
|
1281
1264
|
[b.viewLoadingType]: c,
|
|
1282
1265
|
"url.previous": u,
|
|
1283
|
-
"event.source":
|
|
1284
|
-
}, d ? { "document.referrer":
|
|
1285
|
-
r =
|
|
1286
|
-
}, a =
|
|
1266
|
+
"event.source": e
|
|
1267
|
+
}, d ? { "document.referrer": t.config.hooks.redactUrl(document.referrer || "") } : {});
|
|
1268
|
+
r = t.startSpan("browser.view", f), t.startSpan("browser.page_view", T({}, f)).end();
|
|
1269
|
+
}, a = un((e) => {
|
|
1287
1270
|
i(e.source, e.fromUrl);
|
|
1288
1271
|
});
|
|
1289
1272
|
i("load");
|
|
1290
1273
|
let o = () => {
|
|
1291
1274
|
r == null || r.setAttribute("view.end_reason", "shutdown"), r == null || r.end(), r = void 0;
|
|
1292
1275
|
};
|
|
1293
|
-
window.addEventListener("pagehide", o),
|
|
1276
|
+
window.addEventListener("pagehide", o), e.push(a, () => window.removeEventListener("pagehide", o), o);
|
|
1294
1277
|
},
|
|
1295
1278
|
shutdown() {
|
|
1296
|
-
for (;
|
|
1297
|
-
var
|
|
1298
|
-
(
|
|
1279
|
+
for (; e.length;) {
|
|
1280
|
+
var t;
|
|
1281
|
+
(t = e.pop()) == null || t();
|
|
1299
1282
|
}
|
|
1300
1283
|
}
|
|
1301
1284
|
};
|
|
1302
|
-
},
|
|
1303
|
-
let
|
|
1285
|
+
}, pn = (e) => e.transferSize === 0 && e.decodedBodySize > 0 ? !0 : void 0, mn = () => {
|
|
1286
|
+
let e, t = /* @__PURE__ */ new Set();
|
|
1304
1287
|
return {
|
|
1305
1288
|
name: "resource",
|
|
1306
|
-
|
|
1307
|
-
init(e) {
|
|
1289
|
+
init(n) {
|
|
1308
1290
|
var r;
|
|
1309
1291
|
if (typeof PerformanceObserver > "u" || !((r = PerformanceObserver.supportedEntryTypes) != null && r.includes("resource"))) return;
|
|
1310
|
-
let i = (
|
|
1311
|
-
if (!
|
|
1312
|
-
let r = `${
|
|
1313
|
-
if (
|
|
1314
|
-
|
|
1315
|
-
let i =
|
|
1316
|
-
|
|
1292
|
+
let i = (e) => {
|
|
1293
|
+
if (!e.name || A(n.config, e.name)) return;
|
|
1294
|
+
let r = `${e.name}|${e.startTime}`;
|
|
1295
|
+
if (t.has(r)) return;
|
|
1296
|
+
t.add(r);
|
|
1297
|
+
let i = n.config.hooks.redactUrl(e.name), a = e.duration;
|
|
1298
|
+
n.startSpan("browser.resource", T(T(T({}, n.config.hooks.getPageAttributes()), Ve({
|
|
1317
1299
|
duration: a,
|
|
1318
|
-
initiatorType:
|
|
1319
|
-
responseStatus:
|
|
1320
|
-
transferSize:
|
|
1300
|
+
initiatorType: e.initiatorType || "other",
|
|
1301
|
+
responseStatus: e.responseStatus,
|
|
1302
|
+
transferSize: e.transferSize,
|
|
1321
1303
|
url: i,
|
|
1322
|
-
urlPathTemplate:
|
|
1304
|
+
urlPathTemplate: n.config.hooks.getViewPathGroup(e.name)
|
|
1323
1305
|
})), {}, {
|
|
1324
1306
|
"url.full": i,
|
|
1325
|
-
[b.transferSize]:
|
|
1326
|
-
[b.cacheHit]:
|
|
1327
|
-
[b.nextHopProtocol]:
|
|
1328
|
-
initiator_type:
|
|
1329
|
-
"resource.encoded_body_size":
|
|
1330
|
-
"resource.decoded_body_size":
|
|
1331
|
-
}), { startTime: performance.timeOrigin +
|
|
1307
|
+
[b.transferSize]: e.transferSize,
|
|
1308
|
+
[b.cacheHit]: pn(e),
|
|
1309
|
+
[b.nextHopProtocol]: e.nextHopProtocol,
|
|
1310
|
+
initiator_type: e.initiatorType || "other",
|
|
1311
|
+
"resource.encoded_body_size": e.encodedBodySize,
|
|
1312
|
+
"resource.decoded_body_size": e.decodedBodySize
|
|
1313
|
+
}), { startTime: performance.timeOrigin + e.startTime }).end(performance.timeOrigin + e.startTime + a);
|
|
1332
1314
|
};
|
|
1333
1315
|
try {
|
|
1334
|
-
|
|
1316
|
+
e = new PerformanceObserver((e) => {
|
|
1335
1317
|
for (let t of e.getEntries()) i(t);
|
|
1336
|
-
}),
|
|
1318
|
+
}), e.observe({
|
|
1337
1319
|
type: "resource",
|
|
1338
1320
|
buffered: !0
|
|
1339
1321
|
});
|
|
1340
|
-
} catch (
|
|
1341
|
-
|
|
1322
|
+
} catch (t) {
|
|
1323
|
+
e = void 0;
|
|
1342
1324
|
}
|
|
1343
1325
|
},
|
|
1344
1326
|
shutdown() {
|
|
1345
|
-
|
|
1327
|
+
e == null || e.disconnect(), e = void 0, t.clear();
|
|
1346
1328
|
}
|
|
1347
1329
|
};
|
|
1348
|
-
},
|
|
1349
|
-
let
|
|
1330
|
+
}, hn = () => {
|
|
1331
|
+
let e = [], t = !1;
|
|
1350
1332
|
return {
|
|
1351
1333
|
name: "route-timing",
|
|
1352
|
-
|
|
1353
|
-
init(e) {
|
|
1334
|
+
init(n) {
|
|
1354
1335
|
if (typeof window > "u" || typeof history > "u") return;
|
|
1355
|
-
let r =
|
|
1336
|
+
let r = n.meter.createHistogram("browser.route_change.duration", {
|
|
1356
1337
|
unit: "ms",
|
|
1357
1338
|
description: "Estimated SPA route change duration (route start to next idle)"
|
|
1358
|
-
}), i = (
|
|
1359
|
-
if (
|
|
1339
|
+
}), i = (e, i, a) => {
|
|
1340
|
+
if (t) return;
|
|
1360
1341
|
let o = performance.now(), s = performance.timeOrigin + o, c = () => {
|
|
1361
|
-
if (
|
|
1362
|
-
let c = performance.now() - o, l = c > 500 ?
|
|
1363
|
-
r.record(c, u),
|
|
1342
|
+
if (t || typeof document < "u" && document.visibilityState === "hidden") return;
|
|
1343
|
+
let c = performance.now() - o, l = c > 500 ? j.warning : j.success, u = n.applyRedact(T(T(T(T({}, n.config.hooks.getPageAttributes()), n.config.hooks.getMetricAttributes()), P(n.getRuntimeAttributes())), {}, { "route.change.source": e }));
|
|
1344
|
+
r.record(c, u), n.startSpan("browser.route_change", T(T(T({}, u), N({
|
|
1364
1345
|
duration: c,
|
|
1365
|
-
errorType: l ===
|
|
1346
|
+
errorType: l === j.warning ? "slow" : "none",
|
|
1366
1347
|
eventLabel: "路由切换",
|
|
1367
1348
|
result: l,
|
|
1368
|
-
spanSubtype:
|
|
1369
|
-
spanType:
|
|
1370
|
-
targetLabel:
|
|
1349
|
+
spanSubtype: e,
|
|
1350
|
+
spanType: M.route,
|
|
1351
|
+
targetLabel: n.config.hooks.getViewPathGroup(a),
|
|
1371
1352
|
targetValue: c,
|
|
1372
1353
|
traceScene: "route_change"
|
|
1373
1354
|
})), {}, {
|
|
1374
|
-
"url.full":
|
|
1375
|
-
"url.previous":
|
|
1355
|
+
"url.full": n.config.hooks.redactUrl(a),
|
|
1356
|
+
"url.previous": n.config.hooks.redactUrl(i)
|
|
1376
1357
|
}), { startTime: s }).end();
|
|
1377
1358
|
};
|
|
1378
1359
|
requestAnimationFrame(() => requestAnimationFrame(() => setTimeout(c, 0)));
|
|
1379
|
-
}, a =
|
|
1360
|
+
}, a = un((e) => {
|
|
1380
1361
|
e.fromUrl !== e.toUrl && i(e.source, e.fromUrl, e.toUrl);
|
|
1381
1362
|
});
|
|
1382
|
-
|
|
1363
|
+
e.push(a);
|
|
1383
1364
|
},
|
|
1384
1365
|
shutdown() {
|
|
1385
|
-
for (
|
|
1386
|
-
var
|
|
1387
|
-
(
|
|
1366
|
+
for (t = !0; e.length;) {
|
|
1367
|
+
var n;
|
|
1368
|
+
(n = e.pop()) == null || n();
|
|
1388
1369
|
}
|
|
1389
1370
|
}
|
|
1390
1371
|
};
|
|
1391
|
-
},
|
|
1372
|
+
}, gn = 1800 * 1e3, _n = 1440 * 60 * 1e3, vn = 6e4, yn = 5e3, bn = [
|
|
1392
1373
|
"click",
|
|
1393
1374
|
"keydown",
|
|
1394
1375
|
"scroll",
|
|
1395
1376
|
"mousemove",
|
|
1396
1377
|
"touchstart"
|
|
1397
|
-
],
|
|
1378
|
+
], xn = (e, t) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : t, Sn = (e, t) => typeof e == "number" && Number.isFinite(e) && e > 0 && e <= t + yn, Cn = (e, t) => {
|
|
1398
1379
|
if (!e) return null;
|
|
1399
1380
|
try {
|
|
1400
1381
|
let n = JSON.parse(e);
|
|
1401
|
-
if (typeof (n == null ? void 0 : n.id) == "string" &&
|
|
1382
|
+
if (typeof (n == null ? void 0 : n.id) == "string" && Sn(n.ts, t) && Sn(n.startedAt, t)) return n;
|
|
1402
1383
|
} catch (e) {}
|
|
1403
1384
|
return null;
|
|
1404
|
-
},
|
|
1385
|
+
}, wn = (e, t) => {
|
|
1405
1386
|
if (typeof window > "u") return null;
|
|
1406
1387
|
let n = null;
|
|
1407
1388
|
try {
|
|
1408
1389
|
n = window.localStorage.getItem(e);
|
|
1409
1390
|
} catch (e) {}
|
|
1410
|
-
let r =
|
|
1391
|
+
let r = Cn(n, t);
|
|
1411
1392
|
if (r) return r;
|
|
1412
1393
|
try {
|
|
1413
1394
|
n = window.sessionStorage.getItem(e);
|
|
1414
1395
|
} catch (e) {}
|
|
1415
|
-
return r =
|
|
1416
|
-
},
|
|
1396
|
+
return r = Cn(n, t), r;
|
|
1397
|
+
}, Tn = (e, t) => {
|
|
1417
1398
|
if (typeof window > "u") return;
|
|
1418
1399
|
let n = JSON.stringify(t);
|
|
1419
1400
|
try {
|
|
@@ -1422,13 +1403,13 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1422
1403
|
try {
|
|
1423
1404
|
window.localStorage.setItem(e, n);
|
|
1424
1405
|
} catch (e) {}
|
|
1425
|
-
},
|
|
1426
|
-
let r = Date.now(), i =
|
|
1406
|
+
}, En = (e, t, n) => {
|
|
1407
|
+
let r = Date.now(), i = wn(e, r);
|
|
1427
1408
|
if (i) {
|
|
1428
1409
|
let a = r - i.ts >= t, o = r - i.startedAt >= n;
|
|
1429
1410
|
if (!a && !o) {
|
|
1430
1411
|
let t = T(T({}, i), {}, { ts: r });
|
|
1431
|
-
return
|
|
1412
|
+
return Tn(e, t), {
|
|
1432
1413
|
id: t.id,
|
|
1433
1414
|
rotated: !1
|
|
1434
1415
|
};
|
|
@@ -1438,7 +1419,7 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1438
1419
|
startedAt: r,
|
|
1439
1420
|
ts: r
|
|
1440
1421
|
};
|
|
1441
|
-
return
|
|
1422
|
+
return Tn(e, c), {
|
|
1442
1423
|
id: c.id,
|
|
1443
1424
|
prevId: i.id,
|
|
1444
1425
|
reason: s,
|
|
@@ -1450,12 +1431,12 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1450
1431
|
startedAt: r,
|
|
1451
1432
|
ts: r
|
|
1452
1433
|
};
|
|
1453
|
-
return
|
|
1434
|
+
return Tn(e, a), {
|
|
1454
1435
|
id: a.id,
|
|
1455
1436
|
reason: "init",
|
|
1456
1437
|
rotated: !0
|
|
1457
1438
|
};
|
|
1458
|
-
},
|
|
1439
|
+
}, Dn = (e) => {
|
|
1459
1440
|
let t = "";
|
|
1460
1441
|
try {
|
|
1461
1442
|
t = new URL(e).host;
|
|
@@ -1463,7 +1444,7 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1463
1444
|
t = e;
|
|
1464
1445
|
}
|
|
1465
1446
|
return `bk_ot_session__${R(t || "default")}`;
|
|
1466
|
-
},
|
|
1447
|
+
}, On = (e, t) => {
|
|
1467
1448
|
if (!t.rotated || !t.reason) return;
|
|
1468
1449
|
let n = Date.now();
|
|
1469
1450
|
e.emitLog({
|
|
@@ -1477,39 +1458,38 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1477
1458
|
"session.rotate.reason": t.reason
|
|
1478
1459
|
}, t.prevId ? { "session.previous_id": t.prevId } : {})
|
|
1479
1460
|
});
|
|
1480
|
-
},
|
|
1481
|
-
let t = [];
|
|
1461
|
+
}, kn = (e = {}) => {
|
|
1462
|
+
let t = [], n = xn(e.inactivityMs, gn), r = xn(e.maxLifetimeMs, _n);
|
|
1482
1463
|
return {
|
|
1483
1464
|
name: "session",
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
let i = e.enabled ? (r = e.storageKey) == null ? xn(n.config.transport.endpoint) : r : xn(n.config.transport.endpoint), a = e.enabled ? e.inactivityMs : dn, o = e.enabled ? e.maxLifetimeMs : fn, s = "", c = () => {
|
|
1465
|
+
init(i) {
|
|
1466
|
+
var a;
|
|
1467
|
+
let o = (a = e.storageKey) == null ? Dn(i.config.transport.endpoint) : a, s = "", c = () => {
|
|
1488
1468
|
if (typeof window > "u") {
|
|
1489
|
-
s || (s = B("session"),
|
|
1469
|
+
s || (s = B("session"), i.setRuntimeAttributes({
|
|
1490
1470
|
[b.sessionHasReplay]: !1,
|
|
1491
1471
|
[b.sessionId]: s
|
|
1492
1472
|
}));
|
|
1493
1473
|
return;
|
|
1494
1474
|
}
|
|
1495
|
-
let e =
|
|
1496
|
-
|
|
1475
|
+
let e = En(o, n, r);
|
|
1476
|
+
i.setRuntimeAttributes({
|
|
1497
1477
|
[b.sessionHasReplay]: !1,
|
|
1498
1478
|
[b.sessionId]: e.id
|
|
1499
|
-
}), e.id !== s && (s = e.id,
|
|
1479
|
+
}), e.id !== s && (s = e.id, On(i, e));
|
|
1500
1480
|
};
|
|
1501
1481
|
if (c(), typeof window > "u" || typeof document > "u") return;
|
|
1502
1482
|
let l = Date.now(), u = () => {
|
|
1503
1483
|
let e = Date.now();
|
|
1504
|
-
e - l <
|
|
1484
|
+
e - l < vn || (l = e, c());
|
|
1505
1485
|
}, d = {
|
|
1506
1486
|
capture: !0,
|
|
1507
1487
|
passive: !0
|
|
1508
1488
|
};
|
|
1509
|
-
|
|
1489
|
+
bn.forEach((e) => {
|
|
1510
1490
|
window.addEventListener(e, u, d);
|
|
1511
1491
|
}), t.push(() => {
|
|
1512
|
-
|
|
1492
|
+
bn.forEach((e) => {
|
|
1513
1493
|
window.removeEventListener(e, u, d);
|
|
1514
1494
|
});
|
|
1515
1495
|
});
|
|
@@ -1518,14 +1498,14 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1518
1498
|
};
|
|
1519
1499
|
document.addEventListener("visibilitychange", f), t.push(() => document.removeEventListener("visibilitychange", f));
|
|
1520
1500
|
let p = (e) => {
|
|
1521
|
-
if (e.storageArea !== window.localStorage || e.key !==
|
|
1522
|
-
let t = Date.now(),
|
|
1523
|
-
if (!(!
|
|
1524
|
-
s =
|
|
1501
|
+
if (e.storageArea !== window.localStorage || e.key !== o || !e.newValue) return;
|
|
1502
|
+
let t = Date.now(), n = Cn(e.newValue, t);
|
|
1503
|
+
if (!(!n || n.id === s)) {
|
|
1504
|
+
s = n.id;
|
|
1525
1505
|
try {
|
|
1526
|
-
window.sessionStorage.setItem(
|
|
1506
|
+
window.sessionStorage.setItem(o, e.newValue);
|
|
1527
1507
|
} catch (e) {}
|
|
1528
|
-
|
|
1508
|
+
i.setRuntimeAttributes({ [b.sessionId]: n.id });
|
|
1529
1509
|
}
|
|
1530
1510
|
};
|
|
1531
1511
|
window.addEventListener("storage", p), t.push(() => window.removeEventListener("storage", p));
|
|
@@ -1537,18 +1517,18 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1537
1517
|
}
|
|
1538
1518
|
}
|
|
1539
1519
|
};
|
|
1540
|
-
},
|
|
1541
|
-
if (typeof performance > "u") return
|
|
1520
|
+
}, An = "unknown", jn = (e) => e ? e.replace(/_/g, "-") : An, Mn = () => {
|
|
1521
|
+
if (typeof performance > "u") return An;
|
|
1542
1522
|
let e = performance.getEntriesByType("navigation")[0];
|
|
1543
|
-
return
|
|
1544
|
-
},
|
|
1523
|
+
return jn(e == null ? void 0 : e.type);
|
|
1524
|
+
}, Nn = (e, t) => {
|
|
1545
1525
|
var n;
|
|
1546
1526
|
return {
|
|
1547
1527
|
"rum.navigation.type": (n = e.navigationType) == null ? t : n,
|
|
1548
1528
|
[b.vitalMetric]: e.name.toLowerCase(),
|
|
1549
1529
|
[b.vitalRating]: e.rating
|
|
1550
1530
|
};
|
|
1551
|
-
},
|
|
1531
|
+
}, Pn = (e, t) => {
|
|
1552
1532
|
var n;
|
|
1553
1533
|
let r = (n = e.attribution) == null ? {} : n, i = {}, a = (e) => r[e], o = (e, t, n) => {
|
|
1554
1534
|
t != null && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") && (i[e] = typeof t == "string" && n ? n(t) : t);
|
|
@@ -1572,61 +1552,60 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1572
1552
|
default: break;
|
|
1573
1553
|
}
|
|
1574
1554
|
return i;
|
|
1575
|
-
},
|
|
1576
|
-
let
|
|
1555
|
+
}, Fn = () => {
|
|
1556
|
+
let e = !1;
|
|
1577
1557
|
return {
|
|
1578
1558
|
name: "web-vitals",
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
return M(function* () {
|
|
1559
|
+
init(t) {
|
|
1560
|
+
return k(function* () {
|
|
1582
1561
|
if (typeof window > "u") return;
|
|
1583
1562
|
let n;
|
|
1584
1563
|
try {
|
|
1585
1564
|
n = yield import("web-vitals/attribution");
|
|
1586
|
-
} catch (
|
|
1587
|
-
if (
|
|
1565
|
+
} catch (e) {
|
|
1566
|
+
if (t.config.debug) {
|
|
1588
1567
|
var r;
|
|
1589
|
-
(r = globalThis.console) == null || r.warn("[bk-ot] web-vitals load failed:",
|
|
1568
|
+
(r = globalThis.console) == null || r.warn("[bk-ot] web-vitals load failed:", e);
|
|
1590
1569
|
}
|
|
1591
1570
|
return;
|
|
1592
1571
|
}
|
|
1593
|
-
if (
|
|
1594
|
-
let { onCLS: i, onFCP: a, onINP: o, onLCP: s, onTTFB: c } = n, l =
|
|
1572
|
+
if (e) return;
|
|
1573
|
+
let { onCLS: i, onFCP: a, onINP: o, onLCP: s, onTTFB: c } = n, l = Mn(), u = t.meter.createHistogram("browser.web_vital.cls", {
|
|
1595
1574
|
unit: "1",
|
|
1596
1575
|
description: "Cumulative Layout Shift"
|
|
1597
|
-
}), d =
|
|
1576
|
+
}), d = t.meter.createHistogram("browser.web_vital.duration", {
|
|
1598
1577
|
unit: "ms",
|
|
1599
1578
|
description: "Web Vitals duration metrics, including FCP, INP, LCP and TTFB"
|
|
1600
|
-
}), f = (
|
|
1601
|
-
let n =
|
|
1602
|
-
|
|
1603
|
-
duration:
|
|
1604
|
-
errorType:
|
|
1579
|
+
}), f = (e) => {
|
|
1580
|
+
let n = e.name.toLowerCase();
|
|
1581
|
+
t.startSpan("browser.web_vital", T(T(T(T(T({}, t.config.hooks.getPageAttributes()), t.config.hooks.getMetricAttributes()), Nn(e, l)), N({
|
|
1582
|
+
duration: e.name === "CLS" ? void 0 : e.value,
|
|
1583
|
+
errorType: e.rating === "good" ? "none" : "slow",
|
|
1605
1584
|
eventLabel: "Web 指标",
|
|
1606
|
-
result:
|
|
1585
|
+
result: Re(e.rating),
|
|
1607
1586
|
spanSubtype: n,
|
|
1608
|
-
spanType:
|
|
1587
|
+
spanType: M.vital,
|
|
1609
1588
|
targetLabel: n,
|
|
1610
|
-
targetValue:
|
|
1589
|
+
targetValue: e.value
|
|
1611
1590
|
})), {}, {
|
|
1612
1591
|
[b.vitalMetric]: n,
|
|
1613
|
-
[b.vitalValue]:
|
|
1614
|
-
[b.vitalRating]:
|
|
1615
|
-
"vital.id":
|
|
1616
|
-
},
|
|
1592
|
+
[b.vitalValue]: e.value,
|
|
1593
|
+
[b.vitalRating]: e.rating,
|
|
1594
|
+
"vital.id": e.id
|
|
1595
|
+
}, Pn(e, t.config.hooks.redactUrl))).end();
|
|
1617
1596
|
}, p = (n) => {
|
|
1618
|
-
|
|
1597
|
+
e || !Number.isFinite(n.value) || (d.record(n.value, t.applyRedact(T(T(T(T({}, t.config.hooks.getPageAttributes()), t.config.hooks.getMetricAttributes()), P(t.getRuntimeAttributes())), Nn(n, l)))), f(n));
|
|
1619
1598
|
};
|
|
1620
1599
|
i((n) => {
|
|
1621
|
-
|
|
1600
|
+
e || !Number.isFinite(n.value) || (u.record(n.value, t.applyRedact(T(T(T(T({}, t.config.hooks.getPageAttributes()), t.config.hooks.getMetricAttributes()), P(t.getRuntimeAttributes())), Nn(n, l)))), f(n));
|
|
1622
1601
|
}), a(p), o(p), s(p), c(p);
|
|
1623
1602
|
})();
|
|
1624
1603
|
},
|
|
1625
1604
|
shutdown() {
|
|
1626
|
-
|
|
1605
|
+
e = !0;
|
|
1627
1606
|
}
|
|
1628
1607
|
};
|
|
1629
|
-
},
|
|
1608
|
+
}, In = 64 * 1024, Ln = 6e4, Rn = 5, zn = (e) => e == null ? 0 : typeof e == "string" ? e.length > In || typeof TextEncoder > "u" ? e.length : new TextEncoder().encode(e).byteLength : e instanceof ArrayBuffer || ArrayBuffer.isView(e) ? e.byteLength : typeof Blob < "u" && e instanceof Blob ? e.size : 0, Bn = (e, t) => {
|
|
1630
1609
|
let n = {
|
|
1631
1610
|
"network.protocol.name": "websocket",
|
|
1632
1611
|
"url.full": t(e)
|
|
@@ -1639,13 +1618,13 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1639
1618
|
metricAttributes: r,
|
|
1640
1619
|
spanAttributes: n
|
|
1641
1620
|
};
|
|
1642
|
-
},
|
|
1621
|
+
}, Vn = (e, n) => {
|
|
1643
1622
|
var r;
|
|
1644
|
-
let { bytesCounter: i, connectDurationHistogram: a, context: s, errorCounter: c, errorThrottle: l, isDisposed: u, messageCounter: d, url: f } = n, { metricAttributes: p, spanAttributes: m } =
|
|
1623
|
+
let { bytesCounter: i, connectDurationHistogram: a, context: s, errorCounter: c, errorThrottle: l, isDisposed: u, messageCounter: d, url: f } = n, { metricAttributes: p, spanAttributes: m } = Bn(f, s.config.hooks.redactUrl), h = (r = m["server.address"]) == null ? m["url.full"] : r, g = s.startSpan("websocket.connect", T(T(T({}, m), N({
|
|
1645
1624
|
errorType: "none",
|
|
1646
1625
|
eventLabel: "WebSocket",
|
|
1647
1626
|
spanSubtype: "websocket",
|
|
1648
|
-
spanType:
|
|
1627
|
+
spanType: M.custom,
|
|
1649
1628
|
targetLabel: h
|
|
1650
1629
|
})), m["server.address"] ? { [b.targetDomain]: m["server.address"] } : {})), _ = performance.now(), v = !1, y = (e) => {
|
|
1651
1630
|
if (v) return;
|
|
@@ -1654,13 +1633,13 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1654
1633
|
e === "error" && g.setStatus({
|
|
1655
1634
|
code: t.ERROR,
|
|
1656
1635
|
message: "websocket connect failed"
|
|
1657
|
-
}), g.setAttributes(
|
|
1636
|
+
}), g.setAttributes(N({
|
|
1658
1637
|
duration: n,
|
|
1659
1638
|
errorType: e === "error" ? "network" : "none",
|
|
1660
1639
|
eventLabel: "WebSocket",
|
|
1661
|
-
result: e === "error" ?
|
|
1640
|
+
result: e === "error" ? j.error : j.success,
|
|
1662
1641
|
spanSubtype: "websocket",
|
|
1663
|
-
spanType:
|
|
1642
|
+
spanType: M.custom,
|
|
1664
1643
|
targetLabel: h,
|
|
1665
1644
|
targetValue: n
|
|
1666
1645
|
})), g.end(), e === "opened" && !u() && a.record(n, p);
|
|
@@ -1670,7 +1649,7 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1670
1649
|
}), e.addEventListener("message", (e) => {
|
|
1671
1650
|
if (u()) return;
|
|
1672
1651
|
let t = T(T({}, p), {}, { "websocket.direction": "in" });
|
|
1673
|
-
d.add(1, t), i.add(
|
|
1652
|
+
d.add(1, t), i.add(zn(e.data), t);
|
|
1674
1653
|
}), e.addEventListener("error", () => {
|
|
1675
1654
|
if (u()) return;
|
|
1676
1655
|
let e = v ? "runtime" : "connect";
|
|
@@ -1680,12 +1659,12 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1680
1659
|
severityNumber: o.ERROR,
|
|
1681
1660
|
severityText: "ERROR",
|
|
1682
1661
|
body: "websocket.error",
|
|
1683
|
-
attributes: T(T(T({}, m),
|
|
1662
|
+
attributes: T(T(T({}, m), N({
|
|
1684
1663
|
errorType: "network",
|
|
1685
1664
|
eventLabel: "WebSocket 错误",
|
|
1686
|
-
result:
|
|
1665
|
+
result: j.error,
|
|
1687
1666
|
spanSubtype: "websocket",
|
|
1688
|
-
spanType:
|
|
1667
|
+
spanType: M.custom,
|
|
1689
1668
|
targetLabel: h
|
|
1690
1669
|
})), {}, {
|
|
1691
1670
|
"websocket.error.phase": e,
|
|
@@ -1697,12 +1676,12 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1697
1676
|
severityNumber: o.INFO,
|
|
1698
1677
|
severityText: "INFO",
|
|
1699
1678
|
body: "websocket.close",
|
|
1700
|
-
attributes: T(T(T({}, m),
|
|
1679
|
+
attributes: T(T(T({}, m), N({
|
|
1701
1680
|
errorType: e.wasClean ? "none" : "network",
|
|
1702
1681
|
eventLabel: "WebSocket 关闭",
|
|
1703
|
-
result: e.wasClean ?
|
|
1682
|
+
result: e.wasClean ? j.success : j.warning,
|
|
1704
1683
|
spanSubtype: "websocket",
|
|
1705
|
-
spanType:
|
|
1684
|
+
spanType: M.custom,
|
|
1706
1685
|
targetLabel: h,
|
|
1707
1686
|
targetValue: e.code
|
|
1708
1687
|
})), {}, {
|
|
@@ -1716,108 +1695,107 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1716
1695
|
e.send = (e) => {
|
|
1717
1696
|
if (!u()) {
|
|
1718
1697
|
let t = T(T({}, p), {}, { "websocket.direction": "out" });
|
|
1719
|
-
d.add(1, t), i.add(
|
|
1698
|
+
d.add(1, t), i.add(zn(e), t);
|
|
1720
1699
|
}
|
|
1721
1700
|
return ee(e);
|
|
1722
1701
|
};
|
|
1723
|
-
},
|
|
1724
|
-
let t, n
|
|
1702
|
+
}, Hn = () => {
|
|
1703
|
+
let e, t, n = !1;
|
|
1725
1704
|
return {
|
|
1726
1705
|
name: "websocket",
|
|
1727
|
-
|
|
1728
|
-
init(e) {
|
|
1706
|
+
init(r) {
|
|
1729
1707
|
if (typeof window > "u" || window.WebSocket === void 0) return;
|
|
1730
1708
|
let i = window.WebSocket;
|
|
1731
|
-
|
|
1732
|
-
let a =
|
|
1709
|
+
e = i;
|
|
1710
|
+
let a = r.meter.createCounter("browser.websocket.message.count", { description: "Total number of WebSocket messages observed" }), o = r.meter.createCounter("browser.websocket.message.bytes", {
|
|
1733
1711
|
unit: "By",
|
|
1734
1712
|
description: "Total bytes transferred over WebSocket (best-effort)"
|
|
1735
|
-
}), s =
|
|
1713
|
+
}), s = r.meter.createCounter("browser.websocket.error.count", { description: "Total number of WebSocket error events" }), c = r.meter.createHistogram("browser.websocket.connect.duration", {
|
|
1736
1714
|
unit: "ms",
|
|
1737
1715
|
description: "WebSocket connection establishment duration (only successful connects)"
|
|
1738
|
-
}), l = z(
|
|
1739
|
-
|
|
1740
|
-
let d = Reflect.construct(
|
|
1741
|
-
if (
|
|
1742
|
-
let f =
|
|
1743
|
-
return !f ||
|
|
1716
|
+
}), l = z(Ln, Rn), u = () => n;
|
|
1717
|
+
t = new Proxy(i, { construct(e, t, i) {
|
|
1718
|
+
let d = Reflect.construct(e, t, i);
|
|
1719
|
+
if (n) return d;
|
|
1720
|
+
let f = t[0] == null ? "" : String(t[0]);
|
|
1721
|
+
return !f || A(r.config, f) || Vn(d, {
|
|
1744
1722
|
bytesCounter: o,
|
|
1745
1723
|
connectDurationHistogram: c,
|
|
1746
|
-
context:
|
|
1724
|
+
context: r,
|
|
1747
1725
|
errorCounter: s,
|
|
1748
1726
|
errorThrottle: l,
|
|
1749
1727
|
isDisposed: u,
|
|
1750
1728
|
messageCounter: a,
|
|
1751
1729
|
url: f
|
|
1752
1730
|
}), d;
|
|
1753
|
-
} }), window.WebSocket =
|
|
1731
|
+
} }), window.WebSocket = t;
|
|
1754
1732
|
},
|
|
1755
1733
|
shutdown() {
|
|
1756
|
-
|
|
1734
|
+
n = !0, typeof window < "u" && e && window.WebSocket === t && (window.WebSocket = e), t = void 0, e = void 0;
|
|
1757
1735
|
}
|
|
1758
1736
|
};
|
|
1759
|
-
},
|
|
1737
|
+
}, Q = "BK_RUM_SAMPLING", Un = /* @__PURE__ */ new Map(), Wn = (e) => Un.get(e), Gn = (e, t) => (Un.set(e, t), t), Kn = ({ sampling: e }) => {
|
|
1760
1738
|
if (e.rate <= 0) return !1;
|
|
1761
1739
|
if (e.rate >= 1) return !0;
|
|
1762
1740
|
try {
|
|
1763
|
-
let t = sessionStorage.getItem(
|
|
1741
|
+
let t = sessionStorage.getItem(Q);
|
|
1764
1742
|
if (t) return t === "1";
|
|
1765
1743
|
let n = Math.random() < e.rate;
|
|
1766
|
-
return sessionStorage.setItem(
|
|
1744
|
+
return sessionStorage.setItem(Q, n ? "1" : "0"), Gn(Q, n), n;
|
|
1767
1745
|
} catch (t) {
|
|
1768
|
-
let n =
|
|
1769
|
-
return typeof n == "boolean" ? n :
|
|
1746
|
+
let n = Wn(Q);
|
|
1747
|
+
return typeof n == "boolean" ? n : Gn(Q, Math.random() < e.rate);
|
|
1770
1748
|
}
|
|
1771
|
-
},
|
|
1749
|
+
}, qn = (e) => ({
|
|
1772
1750
|
url: e.endpoint,
|
|
1773
1751
|
headers: e.headers,
|
|
1774
1752
|
concurrencyLimit: e.concurrencyLimit,
|
|
1775
1753
|
timeoutMillis: e.timeoutMillis
|
|
1776
|
-
}),
|
|
1754
|
+
}), Jn = "bk-rum", Yn = (e, t, n) => n ? new Proxy(e, { get(e, n, r) {
|
|
1777
1755
|
if (n === "export") return (n, r) => {
|
|
1778
1756
|
var i;
|
|
1779
1757
|
return (i = globalThis.console) == null || i.log(`[bk-ot][${t}]`, n), e.export(n, r);
|
|
1780
1758
|
};
|
|
1781
1759
|
let i = Reflect.get(e, n, r);
|
|
1782
1760
|
return typeof i == "function" ? i.bind(e) : i;
|
|
1783
|
-
} }) : e,
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
],
|
|
1761
|
+
} }) : e, Xn = (e) => [pt(e.instrumentations)], Zn = (e, t) => e === void 0 ? t : e !== !1, Qn = (e) => typeof e == "object" && e ? e : void 0, $ = (e, t, n) => Zn(e, t) ? [n(Qn(e))] : [], $n = (e) => [
|
|
1762
|
+
...$(e.device, !0, At),
|
|
1763
|
+
...$(e.session, !0, kn),
|
|
1764
|
+
...$(e.pageView, !0, fn),
|
|
1765
|
+
...$(e.httpBody, !1, tn),
|
|
1766
|
+
...$(e.error, !0, zt),
|
|
1767
|
+
...$(e.webVitals, !0, Fn),
|
|
1768
|
+
...$(e.resource, !0, mn),
|
|
1769
|
+
...$(e.blankScreen, !0, at),
|
|
1770
|
+
...$(e.action, !1, Ge),
|
|
1771
|
+
...$(e.websocket, !1, Hn),
|
|
1772
|
+
...$(e.longTask, !1, an),
|
|
1773
|
+
...$(e.cspViolation, !1, vt),
|
|
1774
|
+
...$(e.routeTiming, !1, hn)
|
|
1775
|
+
], er = class {
|
|
1798
1776
|
assertBeforeStart(e) {
|
|
1799
1777
|
if (this.phase !== "idle") throw Error(`[bk-ot] ${e}() must be called before start(); set autoStart: false before registration.`);
|
|
1800
1778
|
}
|
|
1801
1779
|
constructor(o) {
|
|
1802
|
-
var x = this;
|
|
1803
|
-
|
|
1780
|
+
var x = this, ie, S;
|
|
1781
|
+
C(this, "loggerProvider", void 0), C(this, "meterProvider", void 0), C(this, "phase", "idle"), C(this, "pluginManager", void 0), C(this, "plugins", void 0), C(this, "registeredInstrumentations", void 0), C(this, "runtimeContext", void 0), C(this, "sampled", void 0), C(this, "teardownCallbacks", []), C(this, "tracerProvider", void 0), C(this, "applyRedact", (e) => this.config.hooks.redactAttributes(e)), C(this, "config", void 0), C(this, "emitLog", (e) => {
|
|
1804
1782
|
var t;
|
|
1805
1783
|
let n = T(T({}, e), {}, { attributes: this.applyRedact(T(T({}, this.getRuntimeAttributes()), (t = e.attributes) == null ? {} : t)) });
|
|
1806
1784
|
this.logger.emit(n);
|
|
1807
|
-
}),
|
|
1785
|
+
}), C(this, "flush", k(function* () {
|
|
1808
1786
|
yield x.pluginManager.flush(), yield x.tracerProvider.forceFlush(), yield x.meterProvider.forceFlush(), yield x.loggerProvider.forceFlush();
|
|
1809
|
-
})),
|
|
1787
|
+
})), C(this, "getRuntimeAttributes", () => this.runtimeContext.getAttributes()), C(this, "logger", void 0), C(this, "meter", void 0), C(this, "reportAction", ({ attributes: e = {}, targetTag: t, targetText: n, type: r }) => {
|
|
1810
1788
|
var i;
|
|
1811
1789
|
if (!this.sampled) return;
|
|
1812
1790
|
let a = n == null ? void 0 : n.slice(0, 32);
|
|
1813
|
-
this.startSpan(`action.${r}`, T(T(T(T(T({}, this.config.hooks.getPageAttributes()),
|
|
1791
|
+
this.startSpan(`action.${r}`, T(T(T(T(T({}, this.config.hooks.getPageAttributes()), N({
|
|
1814
1792
|
errorType: "none",
|
|
1815
1793
|
eventLabel: "用户操作",
|
|
1816
1794
|
spanSubtype: r,
|
|
1817
|
-
spanType:
|
|
1795
|
+
spanType: M.action,
|
|
1818
1796
|
targetLabel: (i = a == null ? t : a) == null ? r : i
|
|
1819
1797
|
})), {}, { [b.actionType]: r }, a ? { [b.targetTextShort]: a } : {}), t ? { [b.targetTag]: t } : {}), e)).end();
|
|
1820
|
-
}),
|
|
1798
|
+
}), C(this, "reportCustomEvent", ({ attributes: e = {}, error: n, name: r }) => {
|
|
1821
1799
|
if (!this.sampled) {
|
|
1822
1800
|
if (this.config.debug) {
|
|
1823
1801
|
var i;
|
|
@@ -1825,25 +1803,25 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1825
1803
|
}
|
|
1826
1804
|
return;
|
|
1827
1805
|
}
|
|
1828
|
-
let a = this.startSpan(`custom.${r}`, T(T(T(T(T({}, this.config.hooks.getPageAttributes()), this.config.hooks.getCustomAttributes()),
|
|
1806
|
+
let a = this.startSpan(`custom.${r}`, T(T(T(T(T({}, this.config.hooks.getPageAttributes()), this.config.hooks.getCustomAttributes()), N({
|
|
1829
1807
|
errorType: n ? "custom" : "none",
|
|
1830
1808
|
eventLabel: "自定义事件",
|
|
1831
|
-
result: n ?
|
|
1809
|
+
result: n ? j.error : j.success,
|
|
1832
1810
|
spanSubtype: r,
|
|
1833
|
-
spanType:
|
|
1811
|
+
spanType: M.custom,
|
|
1834
1812
|
targetLabel: r
|
|
1835
1813
|
})), e), {}, { "rum.custom.name": r }));
|
|
1836
1814
|
n && (a.recordException(n), a.setStatus({
|
|
1837
1815
|
code: t.ERROR,
|
|
1838
1816
|
message: n.message
|
|
1839
1817
|
})), a.end();
|
|
1840
|
-
}),
|
|
1818
|
+
}), C(this, "setRuntimeAttributes", (e) => {
|
|
1841
1819
|
this.runtimeContext.setAttributes(e);
|
|
1842
|
-
}),
|
|
1820
|
+
}), C(this, "setUser", (e) => {
|
|
1843
1821
|
this.runtimeContext.setUser(e);
|
|
1844
|
-
}),
|
|
1822
|
+
}), C(this, "setView", (e) => {
|
|
1845
1823
|
this.runtimeContext.setView(e);
|
|
1846
|
-
}),
|
|
1824
|
+
}), C(this, "shutdown", k(function* () {
|
|
1847
1825
|
if (x.phase !== "stopped") {
|
|
1848
1826
|
for (yield x.flush(); x.teardownCallbacks.length;) {
|
|
1849
1827
|
var e;
|
|
@@ -1855,7 +1833,7 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1855
1833
|
}
|
|
1856
1834
|
yield x.tracerProvider.shutdown(), yield x.meterProvider.shutdown(), yield x.loggerProvider.shutdown(), a.disable(), r.disable(), n.disable(), x.phase = "stopped";
|
|
1857
1835
|
}
|
|
1858
|
-
})),
|
|
1836
|
+
})), C(this, "start", k(function* () {
|
|
1859
1837
|
if (!(x.phase === "started" || x.phase === "starting")) {
|
|
1860
1838
|
if (x.phase === "stopped") throw Error("[bk-ot] instance has been shut down and cannot be restarted; create a new instance instead.");
|
|
1861
1839
|
if (!x.config.enabled) {
|
|
@@ -1890,30 +1868,30 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1890
1868
|
}
|
|
1891
1869
|
x.phase = "started";
|
|
1892
1870
|
}
|
|
1893
|
-
})),
|
|
1871
|
+
})), C(this, "startSpan", (t, n = {}, r) => this.tracer.startSpan(t, {
|
|
1894
1872
|
kind: e.INTERNAL,
|
|
1895
1873
|
startTime: r == null ? void 0 : r.startTime,
|
|
1896
1874
|
attributes: this.applyRedact(T(T({}, this.getRuntimeAttributes()), n))
|
|
1897
|
-
})),
|
|
1898
|
-
let
|
|
1899
|
-
exporter:
|
|
1875
|
+
})), C(this, "tracer", void 0), C(this, "use", (e) => (this.assertBeforeStart("use"), this.sampled && this.plugins.push(e), this)), C(this, "useInstrumentation", (e) => (this.assertBeforeStart("useInstrumentation"), this.config.enabled && this.registeredInstrumentations.push(e), this)), this.config = _e(o), this.sampled = this.config.enabled && Kn(this.config);
|
|
1876
|
+
let w = m(this.config.resourceAttributes), E = Yn(new f(qn(this.config.transport.traces)), "traces", this.config.debug), ae = Yn(new d(qn(this.config.transport.metrics)), "metrics", this.config.debug), oe = Yn(new u(qn(this.config.transport.logs)), "logs", this.config.debug), D = new Me(this.config.spanProcessor === "simple" ? new te(E) : new y(E, this.config.spanBatch), this.config), se = new v({
|
|
1877
|
+
exporter: ae,
|
|
1900
1878
|
exportIntervalMillis: this.config.metricIntervalMillis
|
|
1901
|
-
}),
|
|
1879
|
+
}), O = new h(oe);
|
|
1902
1880
|
this.tracerProvider = new re({
|
|
1903
|
-
resource:
|
|
1881
|
+
resource: w,
|
|
1904
1882
|
sampler: new ee({ root: new ne(+!!this.sampled) }),
|
|
1905
|
-
spanProcessors: [
|
|
1883
|
+
spanProcessors: [D]
|
|
1906
1884
|
}), this.meterProvider = new _({
|
|
1907
|
-
resource:
|
|
1908
|
-
readers: [
|
|
1885
|
+
resource: w,
|
|
1886
|
+
readers: [se]
|
|
1909
1887
|
}), this.loggerProvider = new g({
|
|
1910
|
-
resource:
|
|
1911
|
-
processors: [
|
|
1912
|
-
}), this.tracer = this.tracerProvider.getTracer(
|
|
1888
|
+
resource: w,
|
|
1889
|
+
processors: [O]
|
|
1890
|
+
}), this.tracer = this.tracerProvider.getTracer(Jn), this.meter = this.meterProvider.getMeter(Jn), this.logger = this.loggerProvider.getLogger(Jn), this.runtimeContext = new Ne({ "rum.sampled": this.sampled }, this.config.user), this.registeredInstrumentations = this.config.enabled ? [...(ie = this.config.instrumentations.custom) == null ? [] : ie] : [], this.plugins = [...this.config.enabled ? Xn(this.config) : [], ...this.sampled ? [...$n(this.config.plugins), ...(S = this.config.plugins.custom) == null ? [] : S] : []], this.pluginManager = new xe(this.plugins), this.config.autoStart && this.start().catch((e) => {
|
|
1913
1891
|
var t;
|
|
1914
1892
|
(t = globalThis.console) == null || t.warn("[bk-ot] auto start failed:", e);
|
|
1915
1893
|
});
|
|
1916
1894
|
}
|
|
1917
1895
|
};
|
|
1918
1896
|
//#endregion
|
|
1919
|
-
export {
|
|
1897
|
+
export { er as BkOpenTelemetry, Me as FilteringSpanProcessor, b as RUM_ATTRIBUTES, j as RUM_SPAN_RESULT, M as RUM_SPAN_TYPE, Ne as RumRuntimeContext, N as buildRumSpanAttributes, Ge as createActionPlugin, at as createBlankScreenPlugin, pt as createCommonInstrumentationsPlugin, vt as createCspViolationPlugin, At as createDevicePlugin, zt as createErrorPlugin, tn as createHttpBodyPlugin, an as createLongTaskPlugin, fn as createPageViewPlugin, be as createPlugin, mn as createResourcePlugin, hn as createRouteTimingPlugin, kn as createSessionPlugin, Hn as createWebSocketPlugin, Fn as createWebVitalsPlugin, Pe as getDurationBucket, _e as resolveConfig };
|