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