@blueking/open-telemetry 0.0.1
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 +0 -0
- package/dist/bk-rum.global.js +11 -0
- package/dist/bk-rum.global.js.map +1 -0
- package/dist/index.js +1186 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
- package/playground/App.vue +148 -0
- package/playground/bk-ot.ts +110 -0
- package/playground/components/DemoLogPanel.vue +89 -0
- package/playground/composables/use-demo-log.ts +39 -0
- package/playground/index.html +13 -0
- package/playground/main.ts +36 -0
- package/playground/mock/index.ts +43 -0
- package/playground/pages/BlankScreenDemo.vue +97 -0
- package/playground/pages/BusinessDemo.vue +74 -0
- package/playground/pages/CustomPluginDemo.vue +104 -0
- package/playground/pages/ErrorDemo.vue +75 -0
- package/playground/pages/Home.vue +133 -0
- package/playground/pages/HttpDemo.vue +120 -0
- package/playground/pages/LongTaskDemo.vue +66 -0
- package/playground/pages/WebSocketDemo.vue +100 -0
- package/playground/router/index.ts +92 -0
- package/playground/style.css +180 -0
- package/src/browser.ts +44 -0
- package/src/core/config.ts +327 -0
- package/src/core/plugin.ts +97 -0
- package/src/core/processor.ts +74 -0
- package/src/core/route-observer.ts +128 -0
- package/src/core/sampling.ts +64 -0
- package/src/core/sdk.ts +327 -0
- package/src/core/url.ts +66 -0
- package/src/index.ts +55 -0
- package/src/plugins/blank-screen.ts +170 -0
- package/src/plugins/common.ts +131 -0
- package/src/plugins/csp-violation.ts +74 -0
- package/src/plugins/device.ts +91 -0
- package/src/plugins/error.ts +211 -0
- package/src/plugins/http-body.ts +437 -0
- package/src/plugins/long-task.ts +99 -0
- package/src/plugins/page-view.ts +83 -0
- package/src/plugins/route-timing.ts +89 -0
- package/src/plugins/session.ts +127 -0
- package/src/plugins/web-vitals.ts +159 -0
- package/src/plugins/websocket.ts +179 -0
- package/tsconfig.app.json +27 -0
- package/tsconfig.dts.json +13 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +26 -0
- package/vite.config.ts +70 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1186 @@
|
|
|
1
|
+
import { SpanKind as e, SpanStatusCode as t, context as n, metrics as r, propagation as i, trace as a } from "@opentelemetry/api";
|
|
2
|
+
import { SeverityNumber as o, logs as s } from "@opentelemetry/api-logs";
|
|
3
|
+
import { ZoneContextManager as c } from "@opentelemetry/context-zone";
|
|
4
|
+
import { W3CTraceContextPropagator as l } from "@opentelemetry/core";
|
|
5
|
+
import { OTLPLogExporter as u } from "@opentelemetry/exporter-logs-otlp-http";
|
|
6
|
+
import { OTLPMetricExporter as d } from "@opentelemetry/exporter-metrics-otlp-http";
|
|
7
|
+
import { OTLPTraceExporter as f } from "@opentelemetry/exporter-trace-otlp-http";
|
|
8
|
+
import { resourceFromAttributes as p } from "@opentelemetry/resources";
|
|
9
|
+
import { BatchLogRecordProcessor as m, LoggerProvider as h } from "@opentelemetry/sdk-logs";
|
|
10
|
+
import { MeterProvider as g, PeriodicExportingMetricReader as _ } from "@opentelemetry/sdk-metrics";
|
|
11
|
+
import { BatchSpanProcessor as v, ParentBasedSampler as ee, TraceIdRatioBasedSampler as te } from "@opentelemetry/sdk-trace-base";
|
|
12
|
+
import { WebTracerProvider as y } from "@opentelemetry/sdk-trace-web";
|
|
13
|
+
import { registerInstrumentations as b } from "@opentelemetry/instrumentation";
|
|
14
|
+
//#region \0@oxc-project+runtime@0.128.0/helpers/typeof.js
|
|
15
|
+
function x(e) {
|
|
16
|
+
"@babel/helpers - typeof";
|
|
17
|
+
return x = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
18
|
+
return typeof e;
|
|
19
|
+
} : function(e) {
|
|
20
|
+
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
21
|
+
}, x(e);
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region \0@oxc-project+runtime@0.128.0/helpers/toPrimitive.js
|
|
25
|
+
function S(e, t) {
|
|
26
|
+
if (x(e) != "object" || !e) return e;
|
|
27
|
+
var n = e[Symbol.toPrimitive];
|
|
28
|
+
if (n !== void 0) {
|
|
29
|
+
var r = n.call(e, t || "default");
|
|
30
|
+
if (x(r) != "object") return r;
|
|
31
|
+
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
32
|
+
}
|
|
33
|
+
return (t === "string" ? String : Number)(e);
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region \0@oxc-project+runtime@0.128.0/helpers/toPropertyKey.js
|
|
37
|
+
function C(e) {
|
|
38
|
+
var t = S(e, "string");
|
|
39
|
+
return x(t) == "symbol" ? t : t + "";
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region \0@oxc-project+runtime@0.128.0/helpers/defineProperty.js
|
|
43
|
+
function w(e, t, n) {
|
|
44
|
+
return (t = C(t)) in e ? Object.defineProperty(e, t, {
|
|
45
|
+
value: n,
|
|
46
|
+
enumerable: !0,
|
|
47
|
+
configurable: !0,
|
|
48
|
+
writable: !0
|
|
49
|
+
}) : e[t] = n, e;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region \0@oxc-project+runtime@0.128.0/helpers/objectSpread2.js
|
|
53
|
+
function T(e, t) {
|
|
54
|
+
var n = Object.keys(e);
|
|
55
|
+
if (Object.getOwnPropertySymbols) {
|
|
56
|
+
var r = Object.getOwnPropertySymbols(e);
|
|
57
|
+
t && (r = r.filter(function(t) {
|
|
58
|
+
return Object.getOwnPropertyDescriptor(e, t).enumerable;
|
|
59
|
+
})), n.push.apply(n, r);
|
|
60
|
+
}
|
|
61
|
+
return n;
|
|
62
|
+
}
|
|
63
|
+
function E(e) {
|
|
64
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
65
|
+
var n = arguments[t] == null ? {} : arguments[t];
|
|
66
|
+
t % 2 ? T(Object(n), !0).forEach(function(t) {
|
|
67
|
+
w(e, t, n[t]);
|
|
68
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : T(Object(n)).forEach(function(t) {
|
|
69
|
+
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return e;
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/core/config.ts
|
|
76
|
+
var D = "http://localhost:4318", ne = 10 * 1e3, re = (e) => e.replace(/\/+$/, ""), O = (e, t) => {
|
|
77
|
+
let n = re(e || D);
|
|
78
|
+
return n.endsWith(`/v1/${t}`) ? n : n.endsWith("/v1") ? `${n}/${t}` : `${n}/v1/${t}`;
|
|
79
|
+
}, k = (e, t) => {
|
|
80
|
+
var n;
|
|
81
|
+
let r = e.token || e.headers ? E(E({}, e.token ? { Authorization: `Bearer ${e.token}` } : {}), (n = e.headers) == null ? {} : n) : void 0;
|
|
82
|
+
return {
|
|
83
|
+
endpoint: O(e.endpoint, t),
|
|
84
|
+
headers: r
|
|
85
|
+
};
|
|
86
|
+
}, A = (e) => typeof e != "number" || !Number.isFinite(e) ? 1 : Math.max(0, Math.min(1, e)), j = (e, t) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : t, M = (e, t) => typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : t, N = (e, t) => typeof e != "number" || !Number.isFinite(e) ? t : Math.max(0, Math.min(1, e)), P = (e) => e.body, F = (e) => {
|
|
87
|
+
var t;
|
|
88
|
+
return e ? typeof e == "boolean" ? {
|
|
89
|
+
maxBodySize: 10 * 1024,
|
|
90
|
+
redact: P
|
|
91
|
+
} : {
|
|
92
|
+
maxBodySize: j(e.maxBodySize, 10 * 1024),
|
|
93
|
+
redact: (t = e.redact) == null ? P : t
|
|
94
|
+
} : !1;
|
|
95
|
+
}, I = (e) => {
|
|
96
|
+
var t, n, r, i, a, o, s, c, l, u;
|
|
97
|
+
return {
|
|
98
|
+
device: (t = e == null ? void 0 : e.device) == null ? !0 : t,
|
|
99
|
+
httpBody: F(e == null ? void 0 : e.httpBody),
|
|
100
|
+
session: typeof (e == null ? void 0 : e.session) == "object" ? E(E({}, e.session), {}, { inactivityMs: j(e.session.inactivityMs, 1800 * 1e3) }) : (n = e == null ? void 0 : e.session) == null ? !0 : n,
|
|
101
|
+
pageView: (r = e == null ? void 0 : e.pageView) == null ? !0 : r,
|
|
102
|
+
error: typeof (e == null ? void 0 : e.error) == "object" ? E(E({}, e.error), {}, {
|
|
103
|
+
maxPerWindow: j(e.error.maxPerWindow, 5),
|
|
104
|
+
windowMs: j(e.error.windowMs, 6e4)
|
|
105
|
+
}) : (i = e == null ? void 0 : e.error) == null ? !0 : i,
|
|
106
|
+
webVitals: (a = e == null ? void 0 : e.webVitals) == null ? !0 : a,
|
|
107
|
+
blankScreen: typeof (e == null ? void 0 : e.blankScreen) == "object" ? E(E({}, e.blankScreen), {}, {
|
|
108
|
+
checkDelay: M(e.blankScreen.checkDelay, 3e3),
|
|
109
|
+
threshold: N(e.blankScreen.threshold, .8)
|
|
110
|
+
}) : (o = e == null ? void 0 : e.blankScreen) == null ? !0 : o,
|
|
111
|
+
websocket: (s = e == null ? void 0 : e.websocket) == null ? !0 : s,
|
|
112
|
+
longTask: typeof (e == null ? void 0 : e.longTask) == "object" ? E(E({}, e.longTask), {}, { threshold: M(e.longTask.threshold, 50) }) : (c = e == null ? void 0 : e.longTask) == null ? !1 : c,
|
|
113
|
+
cspViolation: (l = e == null ? void 0 : e.cspViolation) == null ? !1 : l,
|
|
114
|
+
routeTiming: (u = e == null ? void 0 : e.routeTiming) == null ? !1 : u
|
|
115
|
+
};
|
|
116
|
+
}, L = (e) => e, R = (e) => e, ie = (e) => {
|
|
117
|
+
var t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _, v, ee, te, y, b, x, S, C, w;
|
|
118
|
+
let T = {
|
|
119
|
+
"deployment.environment.name": (t = e.environment) == null ? "production" : t,
|
|
120
|
+
"rum.provider": "blueking",
|
|
121
|
+
"telemetry.sdk.language": "webjs"
|
|
122
|
+
};
|
|
123
|
+
return E(E({}, e), {}, {
|
|
124
|
+
debug: (n = e.debug) == null ? !1 : n,
|
|
125
|
+
enabled: (r = e.enabled) == null ? !0 : r,
|
|
126
|
+
environment: (i = e.environment) == null ? "production" : i,
|
|
127
|
+
endpoint: re(e.endpoint || D),
|
|
128
|
+
traces: k(e, "traces"),
|
|
129
|
+
metrics: k(e, "metrics"),
|
|
130
|
+
logs: k(e, "logs"),
|
|
131
|
+
sampleRate: A(e.sampleRate),
|
|
132
|
+
resourceAttributes: T,
|
|
133
|
+
metricIntervalMillis: ne,
|
|
134
|
+
instrumentations: {
|
|
135
|
+
documentLoad: (a = (o = e.rum) == null ? void 0 : o.documentLoad) == null ? !0 : a,
|
|
136
|
+
fetch: (s = (c = e.rum) == null ? void 0 : c.fetch) == null ? !0 : s,
|
|
137
|
+
xhr: (l = (u = e.rum) == null ? void 0 : u.xhr) == null ? !0 : l,
|
|
138
|
+
userInteraction: (d = (f = e.rum) == null ? void 0 : f.userInteraction) == null ? !0 : d
|
|
139
|
+
},
|
|
140
|
+
rum: I(e.rum),
|
|
141
|
+
plugins: (p = e.plugins) == null ? [] : p,
|
|
142
|
+
autoStart: (m = e.autoStart) == null ? !0 : m,
|
|
143
|
+
getPageAttributes: (h = (g = e.attributes) == null ? void 0 : g.page) == null ? (() => ({
|
|
144
|
+
"rum.page.host": typeof window > "u" ? "" : window.location.host,
|
|
145
|
+
"rum.page.path": typeof window > "u" ? "" : window.location.pathname
|
|
146
|
+
})) : h,
|
|
147
|
+
getMetricAttributes: (_ = (v = e.attributes) == null ? void 0 : v.metric) == null ? (() => ({})) : _,
|
|
148
|
+
getErrorAttributes: (ee = (te = e.attributes) == null ? void 0 : te.error) == null ? (() => ({})) : ee,
|
|
149
|
+
getCustomAttributes: (y = (b = e.attributes) == null ? void 0 : b.custom) == null ? (() => ({})) : y,
|
|
150
|
+
redactAttributes: (x = (S = e.redact) == null ? void 0 : S.attributes) == null ? L : x,
|
|
151
|
+
redactUrl: (C = (w = e.redact) == null ? void 0 : w.url) == null ? R : C
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region \0@oxc-project+runtime@0.128.0/helpers/asyncToGenerator.js
|
|
156
|
+
function z(e, t, n, r, i, a, o) {
|
|
157
|
+
try {
|
|
158
|
+
var s = e[a](o), c = s.value;
|
|
159
|
+
} catch (e) {
|
|
160
|
+
n(e);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
s.done ? t(c) : Promise.resolve(c).then(r, i);
|
|
164
|
+
}
|
|
165
|
+
function B(e) {
|
|
166
|
+
return function() {
|
|
167
|
+
var t = this, n = arguments;
|
|
168
|
+
return new Promise(function(r, i) {
|
|
169
|
+
var a = e.apply(t, n);
|
|
170
|
+
function o(e) {
|
|
171
|
+
z(a, r, i, o, s, "next", e);
|
|
172
|
+
}
|
|
173
|
+
function s(e) {
|
|
174
|
+
z(a, r, i, o, s, "throw", e);
|
|
175
|
+
}
|
|
176
|
+
o(void 0);
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/core/plugin.ts
|
|
182
|
+
var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !== !1, H = (e) => e, ae = class {
|
|
183
|
+
constructor(e) {
|
|
184
|
+
w(this, "plugins", void 0), w(this, "startedPlugins", []), this.plugins = e;
|
|
185
|
+
}
|
|
186
|
+
flush() {
|
|
187
|
+
var e = this;
|
|
188
|
+
return B(function* () {
|
|
189
|
+
yield Promise.all(e.startedPlugins.map((e) => Promise.resolve().then(() => {
|
|
190
|
+
var t;
|
|
191
|
+
return (t = e.flush) == null ? void 0 : t.call(e);
|
|
192
|
+
})));
|
|
193
|
+
})();
|
|
194
|
+
}
|
|
195
|
+
shutdown() {
|
|
196
|
+
var e = this;
|
|
197
|
+
return B(function* () {
|
|
198
|
+
let t = [...e.startedPlugins].reverse();
|
|
199
|
+
for (let e of t) {
|
|
200
|
+
var n;
|
|
201
|
+
yield (n = e.shutdown) == null ? void 0 : n.call(e);
|
|
202
|
+
}
|
|
203
|
+
e.startedPlugins = [];
|
|
204
|
+
})();
|
|
205
|
+
}
|
|
206
|
+
start(e) {
|
|
207
|
+
var t = this;
|
|
208
|
+
return B(function* () {
|
|
209
|
+
try {
|
|
210
|
+
for (let n of t.plugins) V(n, e.config) && (yield n.init(e), t.startedPlugins.push(n));
|
|
211
|
+
} catch (e) {
|
|
212
|
+
throw yield t.shutdown(), e;
|
|
213
|
+
}
|
|
214
|
+
})();
|
|
215
|
+
}
|
|
216
|
+
}, U = () => typeof window > "u" ? "http://localhost" : window.location.origin, oe = (e) => {
|
|
217
|
+
try {
|
|
218
|
+
return new URL(e, U()).href;
|
|
219
|
+
} catch (t) {
|
|
220
|
+
return e;
|
|
221
|
+
}
|
|
222
|
+
}, se = (e) => e.length > 1 ? e.replace(/\/+$/, "") : e, ce = (e, t) => {
|
|
223
|
+
let n = (e) => se(e.replace(/[?#].*$/, ""));
|
|
224
|
+
return n(e) === n(t);
|
|
225
|
+
}, le = (e) => {
|
|
226
|
+
try {
|
|
227
|
+
return new URL(e, U()).origin === U();
|
|
228
|
+
} catch (e) {
|
|
229
|
+
return !1;
|
|
230
|
+
}
|
|
231
|
+
}, ue = (e, t) => {
|
|
232
|
+
let n = oe(t);
|
|
233
|
+
return [
|
|
234
|
+
e.traces.endpoint,
|
|
235
|
+
e.metrics.endpoint,
|
|
236
|
+
e.logs.endpoint
|
|
237
|
+
].some((e) => ce(n, oe(e)));
|
|
238
|
+
}, W = (e, t) => ue(e, t), de = (e, t) => le(t), fe = ["http.url", "url.full"], pe = (e) => {
|
|
239
|
+
for (let n of fe) {
|
|
240
|
+
var t;
|
|
241
|
+
let r = (t = e.attributes) == null ? void 0 : t[n];
|
|
242
|
+
if (typeof r == "string") return r;
|
|
243
|
+
}
|
|
244
|
+
}, me = class {
|
|
245
|
+
constructor(e, t) {
|
|
246
|
+
this.inner = e, this.config = t;
|
|
247
|
+
}
|
|
248
|
+
forceFlush() {
|
|
249
|
+
return this.inner.forceFlush();
|
|
250
|
+
}
|
|
251
|
+
onEnd(e) {
|
|
252
|
+
let t = pe(e);
|
|
253
|
+
t && ue(this.config, t) || this.inner.onEnd(e);
|
|
254
|
+
}
|
|
255
|
+
onStart(e, t) {
|
|
256
|
+
this.inner.onStart(e, t);
|
|
257
|
+
}
|
|
258
|
+
shutdown() {
|
|
259
|
+
return this.inner.shutdown();
|
|
260
|
+
}
|
|
261
|
+
}, he = "body", ge = 3e3, _e = .8, ve = [
|
|
262
|
+
"[data-loading=\"true\"]",
|
|
263
|
+
"[aria-busy=\"true\"]",
|
|
264
|
+
".loading",
|
|
265
|
+
".is-loading",
|
|
266
|
+
".spinner",
|
|
267
|
+
".skeleton",
|
|
268
|
+
".bk-loading"
|
|
269
|
+
], ye = [
|
|
270
|
+
[.5, .5],
|
|
271
|
+
[.25, .25],
|
|
272
|
+
[.75, .25],
|
|
273
|
+
[.25, .75],
|
|
274
|
+
[.75, .75]
|
|
275
|
+
], be = (e) => {
|
|
276
|
+
if (!e) return "";
|
|
277
|
+
let t = e.tagName.toLowerCase();
|
|
278
|
+
return e.id ? `${t}#${e.id}` : t;
|
|
279
|
+
}, xe = (e, t) => e ? t.some((t) => {
|
|
280
|
+
try {
|
|
281
|
+
return e.matches(t) || !!e.closest(t);
|
|
282
|
+
} catch (e) {
|
|
283
|
+
return !1;
|
|
284
|
+
}
|
|
285
|
+
}) : !1, Se = (e) => {
|
|
286
|
+
if (typeof document > "u") return;
|
|
287
|
+
if (document.readyState === "complete" || document.readyState === "interactive") {
|
|
288
|
+
e();
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
let t = () => {
|
|
292
|
+
document.removeEventListener("DOMContentLoaded", t), e();
|
|
293
|
+
};
|
|
294
|
+
document.addEventListener("DOMContentLoaded", t);
|
|
295
|
+
}, Ce = (e) => {
|
|
296
|
+
let t;
|
|
297
|
+
return {
|
|
298
|
+
name: "blank-screen",
|
|
299
|
+
enabled: !!e,
|
|
300
|
+
init(n) {
|
|
301
|
+
var r, i, a, s;
|
|
302
|
+
if (typeof window > "u" || typeof document > "u") return;
|
|
303
|
+
let c = typeof e == "object" ? e : {}, l = (r = c.rootSelector) == null ? he : r, u = (i = c.checkDelay) == null ? ge : i, d = (a = c.threshold) == null ? _e : a, f = [...ve, ...(s = c.ignoreSelectors) == null ? [] : s], p = n.meter.createCounter("browser.blank_screen.count", { description: "Number of suspected blank screen detections" });
|
|
304
|
+
Se(() => {
|
|
305
|
+
t = window.setTimeout(() => {
|
|
306
|
+
var e, t;
|
|
307
|
+
let r = document.querySelector(l), i = 0, a = 0;
|
|
308
|
+
for (let [e, t] of ye) {
|
|
309
|
+
let n = document.elementFromPoint(window.innerWidth * e, window.innerHeight * t);
|
|
310
|
+
if (xe(n, f)) {
|
|
311
|
+
a += 1;
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
(n === r || n === document.body || n === document.documentElement) && (i += 1);
|
|
315
|
+
}
|
|
316
|
+
let s = i / ye.length;
|
|
317
|
+
if (a === ye.length) return;
|
|
318
|
+
let c = s >= d, u = {
|
|
319
|
+
"bk.rum.blank_screen.score": s,
|
|
320
|
+
"bk.rum.blank_screen.threshold": d,
|
|
321
|
+
"bk.rum.blank_screen.root": l,
|
|
322
|
+
"bk.rum.blank_screen.detected": c,
|
|
323
|
+
"bk.rum.blank_screen.center_element": be(document.elementFromPoint(window.innerWidth / 2, window.innerHeight / 2)),
|
|
324
|
+
"bk.rum.blank_screen.dom_node_count": (e = (t = document.body) == null ? void 0 : t.getElementsByTagName("*").length) == null ? 0 : e
|
|
325
|
+
};
|
|
326
|
+
c && (p.add(1, n.applyRedact({ "bk.rum.blank_screen.root": l })), n.emitLog({
|
|
327
|
+
severityNumber: o.ERROR,
|
|
328
|
+
severityText: "ERROR",
|
|
329
|
+
body: "browser.blank_screen",
|
|
330
|
+
attributes: u
|
|
331
|
+
}));
|
|
332
|
+
}, u);
|
|
333
|
+
});
|
|
334
|
+
},
|
|
335
|
+
shutdown() {
|
|
336
|
+
t !== void 0 && typeof window < "u" && window.clearTimeout(t);
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
}, we = ["http.url", "url.full"], Te = (e) => ({ test: e }), Ee = (e, t) => {
|
|
340
|
+
t.setAttributes(e.applyRedact(e.config.getPageAttributes()));
|
|
341
|
+
for (let r of we) {
|
|
342
|
+
var n;
|
|
343
|
+
let i = (n = t.attributes) == null ? void 0 : n[r];
|
|
344
|
+
if (typeof i == "string") {
|
|
345
|
+
let n = e.applyRedact({ [r]: e.config.redactUrl(i) })[r];
|
|
346
|
+
typeof n == "string" && t.setAttribute(r, n);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}, De = (e) => {
|
|
350
|
+
let t = [];
|
|
351
|
+
return {
|
|
352
|
+
name: "official-instrumentations",
|
|
353
|
+
enabled: !!(e.documentLoad || e.fetch || e.xhr || e.userInteraction),
|
|
354
|
+
init(n) {
|
|
355
|
+
return B(function* () {
|
|
356
|
+
let r = [], i = [Te((e) => W(n.config, e))], a = [Te((e) => de(n.config, e))];
|
|
357
|
+
if (e.documentLoad) {
|
|
358
|
+
let { DocumentLoadInstrumentation: e } = yield import("@opentelemetry/instrumentation-document-load");
|
|
359
|
+
r.push(new e({ semconvStabilityOptIn: "http" }));
|
|
360
|
+
}
|
|
361
|
+
if (e.fetch) {
|
|
362
|
+
let { FetchInstrumentation: e } = yield import("@opentelemetry/instrumentation-fetch");
|
|
363
|
+
r.push(new e({
|
|
364
|
+
applyCustomAttributesOnSpan: (e) => Ee(n, e),
|
|
365
|
+
ignoreUrls: i,
|
|
366
|
+
propagateTraceHeaderCorsUrls: a,
|
|
367
|
+
semconvStabilityOptIn: "http",
|
|
368
|
+
ignoreNetworkEvents: !1
|
|
369
|
+
}));
|
|
370
|
+
}
|
|
371
|
+
if (e.xhr) {
|
|
372
|
+
let { XMLHttpRequestInstrumentation: e } = yield import("@opentelemetry/instrumentation-xml-http-request");
|
|
373
|
+
r.push(new e({
|
|
374
|
+
applyCustomAttributesOnSpan: (e) => Ee(n, e),
|
|
375
|
+
ignoreUrls: i,
|
|
376
|
+
propagateTraceHeaderCorsUrls: a,
|
|
377
|
+
semconvStabilityOptIn: "http",
|
|
378
|
+
ignoreNetworkEvents: !1
|
|
379
|
+
}));
|
|
380
|
+
}
|
|
381
|
+
if (e.userInteraction) {
|
|
382
|
+
let { UserInteractionInstrumentation: t } = yield import("@opentelemetry/instrumentation-user-interaction"), n = typeof e.userInteraction == "object" ? { eventNames: e.userInteraction.eventNames } : void 0;
|
|
383
|
+
r.push(new t(n));
|
|
384
|
+
}
|
|
385
|
+
t.push(...r), b({ instrumentations: r });
|
|
386
|
+
})();
|
|
387
|
+
},
|
|
388
|
+
shutdown() {
|
|
389
|
+
for (; t.length;) {
|
|
390
|
+
var e, n;
|
|
391
|
+
(e = t.pop()) == null || (n = e.disable) == null || n.call(e);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}, Oe = (e) => {
|
|
396
|
+
let t;
|
|
397
|
+
return {
|
|
398
|
+
name: "csp-violation",
|
|
399
|
+
enabled: !!e,
|
|
400
|
+
init(e) {
|
|
401
|
+
if (typeof window > "u" || typeof document > "u") return;
|
|
402
|
+
let n = (t) => {
|
|
403
|
+
e.emitLog({
|
|
404
|
+
severityNumber: o.WARN,
|
|
405
|
+
severityText: "WARN",
|
|
406
|
+
body: "csp.violation",
|
|
407
|
+
attributes: E(E({}, e.config.getPageAttributes()), {}, {
|
|
408
|
+
"csp.blocked_uri": e.config.redactUrl(t.blockedURI || ""),
|
|
409
|
+
"csp.violated_directive": t.violatedDirective,
|
|
410
|
+
"csp.effective_directive": t.effectiveDirective,
|
|
411
|
+
"csp.original_policy": t.originalPolicy,
|
|
412
|
+
"csp.disposition": t.disposition,
|
|
413
|
+
"csp.source_file": e.config.redactUrl(t.sourceFile || ""),
|
|
414
|
+
"csp.line_number": t.lineNumber,
|
|
415
|
+
"csp.column_number": t.columnNumber,
|
|
416
|
+
"csp.status_code": t.statusCode
|
|
417
|
+
})
|
|
418
|
+
});
|
|
419
|
+
};
|
|
420
|
+
document.addEventListener("securitypolicyviolation", n), t = () => document.removeEventListener("securitypolicyviolation", n);
|
|
421
|
+
},
|
|
422
|
+
shutdown() {
|
|
423
|
+
t == null || t(), t = void 0;
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
}, ke = "bk_ot_session_id", Ae = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `device-${Date.now()}-${Math.random().toString(16).slice(2)}`, je = (e) => {
|
|
427
|
+
try {
|
|
428
|
+
let t = window.localStorage.getItem(e);
|
|
429
|
+
if (t) return t;
|
|
430
|
+
let n = Ae();
|
|
431
|
+
return window.localStorage.setItem(e, n), n;
|
|
432
|
+
} catch (e) {
|
|
433
|
+
return Ae();
|
|
434
|
+
}
|
|
435
|
+
}, Me = () => {
|
|
436
|
+
var e, t, n;
|
|
437
|
+
if (typeof window > "u") return {};
|
|
438
|
+
let r = navigator.connection;
|
|
439
|
+
return {
|
|
440
|
+
"browser.viewport.width": window.innerWidth,
|
|
441
|
+
"browser.viewport.height": window.innerHeight,
|
|
442
|
+
"browser.screen.width": (e = window.screen) == null ? void 0 : e.width,
|
|
443
|
+
"browser.screen.height": (t = window.screen) == null ? void 0 : t.height,
|
|
444
|
+
"network.effective_type": (n = r == null ? void 0 : r.effectiveType) == null ? r == null ? void 0 : r.type : n
|
|
445
|
+
};
|
|
446
|
+
}, Ne = (e) => ({
|
|
447
|
+
name: "device",
|
|
448
|
+
enabled: !!e,
|
|
449
|
+
init(t) {
|
|
450
|
+
var n;
|
|
451
|
+
let r = typeof e == "object" ? (n = e.storageKey) == null ? ke : n : ke, i = typeof window > "u" ? Ae() : je(r);
|
|
452
|
+
t.setRuntimeAttributes(E({ "device.id": i }, Me()));
|
|
453
|
+
}
|
|
454
|
+
}), Pe = 6e4, Fe = 5, Ie = (e) => {
|
|
455
|
+
if (e instanceof Error) return e.message;
|
|
456
|
+
if (typeof e == "string") return e;
|
|
457
|
+
try {
|
|
458
|
+
return JSON.stringify(e);
|
|
459
|
+
} catch (t) {
|
|
460
|
+
return String(e);
|
|
461
|
+
}
|
|
462
|
+
}, Le = (e) => {
|
|
463
|
+
var t;
|
|
464
|
+
return e instanceof Error ? (t = e.stack) == null ? "" : t : "";
|
|
465
|
+
}, Re = (e) => {
|
|
466
|
+
let t = 5381;
|
|
467
|
+
for (let n = 0; n < e.length; n++) t = t * 33 ^ e.charCodeAt(n);
|
|
468
|
+
return (t >>> 0).toString(36);
|
|
469
|
+
}, ze = (e, t) => {
|
|
470
|
+
let n = /* @__PURE__ */ new Map();
|
|
471
|
+
return { allow(r) {
|
|
472
|
+
let i = Date.now(), a = n.get(r);
|
|
473
|
+
return !a || i - a.windowStart > e ? (n.set(r, {
|
|
474
|
+
count: 1,
|
|
475
|
+
windowStart: i
|
|
476
|
+
}), !0) : a.count >= t ? !1 : (a.count += 1, !0);
|
|
477
|
+
} };
|
|
478
|
+
}, Be = ({ context: e, error: n, exceptionType: r, extra: i = {}, source: s, spanName: c, throttle: l }) => {
|
|
479
|
+
let u = Ie(n), d = Le(n), f = Re(`${s}|${u}|${d.slice(0, 256)}`);
|
|
480
|
+
if (!l.allow(f)) return;
|
|
481
|
+
let p = a.getActiveSpan(), m = n instanceof Error ? n : {
|
|
482
|
+
message: u,
|
|
483
|
+
name: r == null ? s : r
|
|
484
|
+
}, h = E(E(E({}, e.config.getPageAttributes()), e.config.getErrorAttributes()), {}, {
|
|
485
|
+
"exception.message": u,
|
|
486
|
+
"exception.stacktrace": d,
|
|
487
|
+
"exception.type": n instanceof Error ? n.name : r == null ? s : r,
|
|
488
|
+
"bk.rum.error.source": s,
|
|
489
|
+
"bk.rum.error.fingerprint": f
|
|
490
|
+
}, i), g = e.startSpan(c, h);
|
|
491
|
+
p == null || p.recordException(m), p == null || p.setStatus({
|
|
492
|
+
code: t.ERROR,
|
|
493
|
+
message: u
|
|
494
|
+
}), g.recordException(m), g.setStatus({
|
|
495
|
+
code: t.ERROR,
|
|
496
|
+
message: u
|
|
497
|
+
}), g.end(), e.emitLog({
|
|
498
|
+
severityNumber: o.ERROR,
|
|
499
|
+
severityText: "ERROR",
|
|
500
|
+
body: u,
|
|
501
|
+
attributes: h
|
|
502
|
+
});
|
|
503
|
+
}, Ve = (e) => {
|
|
504
|
+
let t = [];
|
|
505
|
+
return {
|
|
506
|
+
name: "error",
|
|
507
|
+
enabled: !!e,
|
|
508
|
+
init(n) {
|
|
509
|
+
var r, i;
|
|
510
|
+
if (typeof window > "u") return;
|
|
511
|
+
let a = ze(typeof e == "object" ? (r = e.windowMs) == null ? Pe : r : Pe, typeof e == "object" ? (i = e.maxPerWindow) == null ? Fe : i : Fe), o = (e) => {
|
|
512
|
+
var t;
|
|
513
|
+
Be({
|
|
514
|
+
context: n,
|
|
515
|
+
throttle: a,
|
|
516
|
+
spanName: "browser.error",
|
|
517
|
+
source: "window.error",
|
|
518
|
+
error: (t = e.error) == null ? e.message : t,
|
|
519
|
+
extra: {
|
|
520
|
+
"code.filepath": e.filename,
|
|
521
|
+
"code.lineno": e.lineno,
|
|
522
|
+
"code.column": e.colno
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
}, s = (e) => {
|
|
526
|
+
Be({
|
|
527
|
+
context: n,
|
|
528
|
+
throttle: a,
|
|
529
|
+
spanName: "browser.unhandledrejection",
|
|
530
|
+
source: "unhandledrejection",
|
|
531
|
+
error: e.reason,
|
|
532
|
+
exceptionType: e.reason instanceof Error ? e.reason.name : "UnhandledRejection"
|
|
533
|
+
});
|
|
534
|
+
}, c = (e) => {
|
|
535
|
+
var t;
|
|
536
|
+
let r = e.target;
|
|
537
|
+
if (r === window) return;
|
|
538
|
+
let i = r.src || r.href || "";
|
|
539
|
+
Be({
|
|
540
|
+
context: n,
|
|
541
|
+
throttle: a,
|
|
542
|
+
spanName: "browser.resource_error",
|
|
543
|
+
source: "resource",
|
|
544
|
+
error: /* @__PURE__ */ Error(`Resource load failed: ${((t = r.tagName) == null ? void 0 : t.toLowerCase()) || "unknown"} ${i}`),
|
|
545
|
+
exceptionType: "ResourceError",
|
|
546
|
+
extra: {
|
|
547
|
+
"url.full": n.config.redactUrl(i),
|
|
548
|
+
"html.tag": r.tagName || ""
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
};
|
|
552
|
+
window.addEventListener("error", o), window.addEventListener("unhandledrejection", s), window.addEventListener("error", c, !0), t.push(() => window.removeEventListener("error", o), () => window.removeEventListener("unhandledrejection", s), () => window.removeEventListener("error", c, !0));
|
|
553
|
+
},
|
|
554
|
+
shutdown() {
|
|
555
|
+
for (; t.length;) {
|
|
556
|
+
var e;
|
|
557
|
+
(e = t.pop()) == null || e();
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
}, He = 10 * 1024, Ue = (e, t) => e.length <= t ? {
|
|
562
|
+
body: e,
|
|
563
|
+
truncated: !1
|
|
564
|
+
} : {
|
|
565
|
+
body: e.slice(0, t),
|
|
566
|
+
truncated: !0
|
|
567
|
+
}, We = (e, t) => {
|
|
568
|
+
if (!e) return;
|
|
569
|
+
if (e instanceof Headers) return e.get(t) || void 0;
|
|
570
|
+
let n = t.toLowerCase();
|
|
571
|
+
if (Array.isArray(e)) {
|
|
572
|
+
var r;
|
|
573
|
+
return (r = e.find(([e]) => e.toLowerCase() === n)) == null ? void 0 : r[1];
|
|
574
|
+
}
|
|
575
|
+
let i = Object.keys(e).find((e) => e.toLowerCase() === n);
|
|
576
|
+
return i ? e[i] : void 0;
|
|
577
|
+
}, Ge = (e) => {
|
|
578
|
+
let t = {};
|
|
579
|
+
return e.forEach((e, n) => {
|
|
580
|
+
t[n] = e instanceof File ? `[File name=${e.name} type=${e.type || "unknown"} size=${e.size}]` : e;
|
|
581
|
+
}), JSON.stringify(t);
|
|
582
|
+
}, Ke = function() {
|
|
583
|
+
var e = B(function* (e) {
|
|
584
|
+
return e == null ? "" : typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : e instanceof FormData ? Ge(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);
|
|
585
|
+
});
|
|
586
|
+
return function(t) {
|
|
587
|
+
return e.apply(this, arguments);
|
|
588
|
+
};
|
|
589
|
+
}(), qe = function() {
|
|
590
|
+
var e = B(function* (e, t, n) {
|
|
591
|
+
let r = yield Ke(e);
|
|
592
|
+
if (r) return E(E({}, Ue(r, t)), {}, { contentType: n });
|
|
593
|
+
});
|
|
594
|
+
return function(t, n, r) {
|
|
595
|
+
return e.apply(this, arguments);
|
|
596
|
+
};
|
|
597
|
+
}(), G = function() {
|
|
598
|
+
var e = B(function* (e, t, n) {
|
|
599
|
+
try {
|
|
600
|
+
return yield qe(e, t, n);
|
|
601
|
+
} catch (e) {
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
return function(t, n, r) {
|
|
606
|
+
return e.apply(this, arguments);
|
|
607
|
+
};
|
|
608
|
+
}(), Je = (e) => e instanceof Request ? e.url : String(e), Ye = (e, t) => t != null && t.method ? t.method : e instanceof Request ? e.method : "GET", Xe = function() {
|
|
609
|
+
var e = B(function* (e, t, n) {
|
|
610
|
+
if (t != null && t.body) return G(t.body, n, We(t.headers, "content-type"));
|
|
611
|
+
if (e instanceof Request) try {
|
|
612
|
+
return G(yield e.clone().text(), n, e.headers.get("content-type") || void 0);
|
|
613
|
+
} catch (e) {
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
return function(t, n, r) {
|
|
618
|
+
return e.apply(this, arguments);
|
|
619
|
+
};
|
|
620
|
+
}(), Ze = function() {
|
|
621
|
+
var e = B(function* (e, t) {
|
|
622
|
+
try {
|
|
623
|
+
let n = e.clone();
|
|
624
|
+
return G(n.body ? yield n.text() : "", t, e.headers.get("content-type") || void 0);
|
|
625
|
+
} catch (e) {
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
return function(t, n) {
|
|
630
|
+
return e.apply(this, arguments);
|
|
631
|
+
};
|
|
632
|
+
}(), Qe = (e, t) => {
|
|
633
|
+
if (e.responseType === "" || e.responseType === "text") return E(E({}, Ue(e.responseText || "", t)), {}, { contentType: e.getResponseHeader("content-type") || void 0 });
|
|
634
|
+
if (e.responseType === "json") return E(E({}, Ue(JSON.stringify(e.response), t)), {}, { contentType: e.getResponseHeader("content-type") || void 0 });
|
|
635
|
+
}, $e = (e, t, n) => {
|
|
636
|
+
if (n) return e.redact(E(E({}, t), {}, {
|
|
637
|
+
body: n.body,
|
|
638
|
+
truncated: n.truncated
|
|
639
|
+
}));
|
|
640
|
+
}, et = ({ context: e, duration: t, error: n, method: r, request: i, response: a, status: s, url: c }) => {
|
|
641
|
+
let l = e.config.rum.httpBody;
|
|
642
|
+
if (!l) return;
|
|
643
|
+
let u = !!n || typeof s == "number" && s >= 400, d = r.toUpperCase(), f = u ? $e(l, {
|
|
644
|
+
contentType: i == null ? void 0 : i.contentType,
|
|
645
|
+
method: d,
|
|
646
|
+
status: s,
|
|
647
|
+
type: "request",
|
|
648
|
+
url: c
|
|
649
|
+
}, i) : void 0, p = u ? $e(l, {
|
|
650
|
+
contentType: a == null ? void 0 : a.contentType,
|
|
651
|
+
method: d,
|
|
652
|
+
status: s,
|
|
653
|
+
type: "response",
|
|
654
|
+
url: c
|
|
655
|
+
}, a) : void 0, m = E(E({}, e.config.getPageAttributes()), {}, {
|
|
656
|
+
"http.duration": t,
|
|
657
|
+
"http.request.method": d,
|
|
658
|
+
"url.full": e.config.redactUrl(c)
|
|
659
|
+
});
|
|
660
|
+
if (typeof s == "number" && (m["http.response.status_code"] = s), f != null && (m["http.request.body"] = f), p != null && (m["http.response.body"] = p), u) {
|
|
661
|
+
var h, g;
|
|
662
|
+
m["bk.rum.http_body.request.truncated"] = (h = i == null ? void 0 : i.truncated) == null ? !1 : h, m["bk.rum.http_body.response.truncated"] = (g = a == null ? void 0 : a.truncated) == null ? !1 : g;
|
|
663
|
+
}
|
|
664
|
+
if (n instanceof Error) {
|
|
665
|
+
var _;
|
|
666
|
+
m["exception.message"] = n.message, m["exception.type"] = n.name, m["exception.stacktrace"] = (_ = n.stack) == null ? "" : _;
|
|
667
|
+
}
|
|
668
|
+
e.emitLog({
|
|
669
|
+
severityNumber: u ? o.ERROR : o.INFO,
|
|
670
|
+
severityText: u ? "ERROR" : "INFO",
|
|
671
|
+
body: u ? "HTTP request completed with error" : "HTTP request completed",
|
|
672
|
+
attributes: m
|
|
673
|
+
});
|
|
674
|
+
}, tt = (e) => {
|
|
675
|
+
let t = [];
|
|
676
|
+
return {
|
|
677
|
+
name: "http-body",
|
|
678
|
+
enabled: !!e,
|
|
679
|
+
init(n) {
|
|
680
|
+
if (!e || typeof window > "u") return;
|
|
681
|
+
let r = e.maxBodySize || He, i = window.fetch;
|
|
682
|
+
typeof i == "function" && (window.fetch = function() {
|
|
683
|
+
var e = B(function* (e, t) {
|
|
684
|
+
let a = Je(e);
|
|
685
|
+
if (W(n.config, a)) return i(e, t);
|
|
686
|
+
let o = Ye(e, t), s = yield Xe(e, t, r), c = performance.now();
|
|
687
|
+
try {
|
|
688
|
+
let l = yield i(e, t);
|
|
689
|
+
return et({
|
|
690
|
+
context: n,
|
|
691
|
+
duration: performance.now() - c,
|
|
692
|
+
method: o,
|
|
693
|
+
request: s,
|
|
694
|
+
response: l.status >= 400 ? yield Ze(l, r) : void 0,
|
|
695
|
+
status: l.status,
|
|
696
|
+
url: a
|
|
697
|
+
}), l;
|
|
698
|
+
} catch (e) {
|
|
699
|
+
throw et({
|
|
700
|
+
context: n,
|
|
701
|
+
duration: performance.now() - c,
|
|
702
|
+
error: e,
|
|
703
|
+
method: o,
|
|
704
|
+
request: s,
|
|
705
|
+
url: a
|
|
706
|
+
}), e;
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
return function(t, n) {
|
|
710
|
+
return e.apply(this, arguments);
|
|
711
|
+
};
|
|
712
|
+
}(), t.push(() => {
|
|
713
|
+
window.fetch = i;
|
|
714
|
+
}));
|
|
715
|
+
let a = XMLHttpRequest.prototype.open, o = XMLHttpRequest.prototype.send, s = XMLHttpRequest.prototype.setRequestHeader;
|
|
716
|
+
XMLHttpRequest.prototype.open = function(e, t, ...n) {
|
|
717
|
+
return this.__bkOtHttpBodyMeta__ = {
|
|
718
|
+
method: e,
|
|
719
|
+
startTime: performance.now(),
|
|
720
|
+
url: String(t)
|
|
721
|
+
}, a.call(this, e, t, ...n);
|
|
722
|
+
}, XMLHttpRequest.prototype.setRequestHeader = function(e, t) {
|
|
723
|
+
var n;
|
|
724
|
+
return this.__bkOtHttpBodyRequestHeaders__ = E(E({}, (n = this.__bkOtHttpBodyRequestHeaders__) == null ? {} : n), {}, { [e]: t }), s.call(this, e, t);
|
|
725
|
+
}, XMLHttpRequest.prototype.send = function(e) {
|
|
726
|
+
return G(e, r, We(this.__bkOtHttpBodyRequestHeaders__, "content-type")).then((e) => {
|
|
727
|
+
this.__bkOtHttpBodyRequest__ = e;
|
|
728
|
+
}), this.addEventListener("loadend", () => {
|
|
729
|
+
let e = this.__bkOtHttpBodyMeta__;
|
|
730
|
+
if (!e || W(n.config, e.url)) return;
|
|
731
|
+
let t = this.status >= 400 ? Qe(this, r) : void 0;
|
|
732
|
+
et({
|
|
733
|
+
context: n,
|
|
734
|
+
duration: performance.now() - e.startTime,
|
|
735
|
+
method: e.method,
|
|
736
|
+
request: this.__bkOtHttpBodyRequest__,
|
|
737
|
+
response: t,
|
|
738
|
+
status: this.status,
|
|
739
|
+
url: e.url
|
|
740
|
+
});
|
|
741
|
+
}), o.call(this, e);
|
|
742
|
+
}, t.push(() => {
|
|
743
|
+
XMLHttpRequest.prototype.open = a, XMLHttpRequest.prototype.send = o, XMLHttpRequest.prototype.setRequestHeader = s;
|
|
744
|
+
});
|
|
745
|
+
},
|
|
746
|
+
shutdown() {
|
|
747
|
+
for (; t.length;) {
|
|
748
|
+
var e;
|
|
749
|
+
(e = t.pop()) == null || e();
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
}, nt = 50, rt = (e) => {
|
|
754
|
+
let t;
|
|
755
|
+
return {
|
|
756
|
+
name: "long-task",
|
|
757
|
+
enabled: !!e,
|
|
758
|
+
init(n) {
|
|
759
|
+
var r;
|
|
760
|
+
if (typeof PerformanceObserver > "u") return;
|
|
761
|
+
let i = PerformanceObserver.supportedEntryTypes;
|
|
762
|
+
if (!(i != null && i.includes("longtask"))) return;
|
|
763
|
+
let a = typeof e == "object" ? (r = e.threshold) == null ? nt : r : nt, o = n.meter.createCounter("browser.long_task.count", { description: "Number of long tasks observed (duration >= threshold)" }), s = n.meter.createHistogram("browser.long_task.duration", {
|
|
764
|
+
unit: "ms",
|
|
765
|
+
description: "Duration of long tasks"
|
|
766
|
+
});
|
|
767
|
+
try {
|
|
768
|
+
t = new PerformanceObserver((e) => {
|
|
769
|
+
for (let i of e.getEntries()) {
|
|
770
|
+
var t, r;
|
|
771
|
+
if (i.duration < a) continue;
|
|
772
|
+
let e = (t = i.attribution) == null ? void 0 : t[0], c = n.applyRedact(E(E(E({}, n.config.getPageAttributes()), n.config.getMetricAttributes()), {}, {
|
|
773
|
+
"long_task.name": i.name,
|
|
774
|
+
"long_task.attribution": (r = e == null ? void 0 : e.name) == null ? "unknown" : r
|
|
775
|
+
}));
|
|
776
|
+
o.add(1, c), s.record(i.duration, c);
|
|
777
|
+
}
|
|
778
|
+
}), t.observe({
|
|
779
|
+
type: "longtask",
|
|
780
|
+
buffered: !0
|
|
781
|
+
});
|
|
782
|
+
} catch (e) {
|
|
783
|
+
t = void 0;
|
|
784
|
+
}
|
|
785
|
+
},
|
|
786
|
+
shutdown() {
|
|
787
|
+
t == null || t.disconnect(), t = void 0;
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
}, K = /* @__PURE__ */ new Set(), q = "", J, Y, X = !1, Z = () => typeof location > "u" ? "" : location.href, Q = (e, t) => {
|
|
791
|
+
let n = Z();
|
|
792
|
+
q = n;
|
|
793
|
+
let r = {
|
|
794
|
+
fromUrl: t,
|
|
795
|
+
source: e,
|
|
796
|
+
toUrl: n
|
|
797
|
+
};
|
|
798
|
+
for (let e of Array.from(K)) e(r);
|
|
799
|
+
}, it = () => {
|
|
800
|
+
Q("popstate", q || Z());
|
|
801
|
+
}, at = () => {
|
|
802
|
+
Q("hashchange", q || Z());
|
|
803
|
+
}, ot = () => {
|
|
804
|
+
X || typeof window > "u" || typeof history > "u" || (X = !0, q = Z(), J = history.pushState, Y = history.replaceState, history.pushState = function(e, t, n) {
|
|
805
|
+
let r = q || Z(), i = J == null ? void 0 : J.apply(this, [
|
|
806
|
+
e,
|
|
807
|
+
t,
|
|
808
|
+
n
|
|
809
|
+
]);
|
|
810
|
+
return Q("pushState", r), i;
|
|
811
|
+
}, history.replaceState = function(e, t, n) {
|
|
812
|
+
let r = q || Z(), i = Y == null ? void 0 : Y.apply(this, [
|
|
813
|
+
e,
|
|
814
|
+
t,
|
|
815
|
+
n
|
|
816
|
+
]);
|
|
817
|
+
return Q("replaceState", r), i;
|
|
818
|
+
}, window.addEventListener("popstate", it), window.addEventListener("hashchange", at));
|
|
819
|
+
}, st = () => {
|
|
820
|
+
!X || typeof window > "u" || typeof history > "u" || (J && (history.pushState = J), Y && (history.replaceState = Y), window.removeEventListener("popstate", it), window.removeEventListener("hashchange", at), J = void 0, Y = void 0, X = !1, q = "");
|
|
821
|
+
}, ct = (e) => typeof window > "u" || typeof history > "u" ? () => {} : (ot(), K.add(e), () => {
|
|
822
|
+
K.delete(e), K.size === 0 && st();
|
|
823
|
+
}), lt = () => typeof location > "u" ? "" : location.href, ut = (e) => {
|
|
824
|
+
let t = [];
|
|
825
|
+
return {
|
|
826
|
+
name: "page-view",
|
|
827
|
+
enabled: !!e,
|
|
828
|
+
init(e) {
|
|
829
|
+
if (typeof window > "u") return;
|
|
830
|
+
let n = "", r = (t, r = n) => {
|
|
831
|
+
let i = lt();
|
|
832
|
+
i !== n && (n = i, e.startSpan("browser.page_view", E(E({}, e.config.getPageAttributes()), {}, {
|
|
833
|
+
"url.full": e.config.redactUrl(i),
|
|
834
|
+
"url.previous": e.config.redactUrl(r),
|
|
835
|
+
"document.referrer": e.config.redactUrl(document.referrer || ""),
|
|
836
|
+
"bk.rum.event.source": t
|
|
837
|
+
})).end());
|
|
838
|
+
}, i = ct((e) => {
|
|
839
|
+
r(e.source, e.fromUrl);
|
|
840
|
+
});
|
|
841
|
+
r("load"), t.push(i);
|
|
842
|
+
},
|
|
843
|
+
shutdown() {
|
|
844
|
+
for (; t.length;) {
|
|
845
|
+
var e;
|
|
846
|
+
(e = t.pop()) == null || e();
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
};
|
|
850
|
+
}, dt = (e) => {
|
|
851
|
+
let t = [];
|
|
852
|
+
return {
|
|
853
|
+
name: "route-timing",
|
|
854
|
+
enabled: !!e,
|
|
855
|
+
init(e) {
|
|
856
|
+
if (typeof window > "u" || typeof history > "u") return;
|
|
857
|
+
let n = e.meter.createHistogram("browser.route_change.duration", {
|
|
858
|
+
unit: "ms",
|
|
859
|
+
description: "Estimated SPA route change duration (route start to next idle)"
|
|
860
|
+
}), r = (t, r, i) => {
|
|
861
|
+
let a = performance.now(), o = () => {
|
|
862
|
+
let o = performance.now() - a, s = e.applyRedact(E(E(E({}, e.config.getPageAttributes()), e.config.getMetricAttributes()), {}, { "route.change.source": t }));
|
|
863
|
+
n.record(o, s), e.startSpan("browser.route_change", E(E({}, s), {}, {
|
|
864
|
+
"url.full": e.config.redactUrl(i),
|
|
865
|
+
"url.previous": e.config.redactUrl(r),
|
|
866
|
+
"route.change.duration_ms": o
|
|
867
|
+
})).end();
|
|
868
|
+
};
|
|
869
|
+
requestAnimationFrame(() => requestAnimationFrame(() => setTimeout(o, 0)));
|
|
870
|
+
}, i = ct((e) => {
|
|
871
|
+
e.fromUrl !== e.toUrl && r(e.source, e.fromUrl, e.toUrl);
|
|
872
|
+
});
|
|
873
|
+
t.push(i);
|
|
874
|
+
},
|
|
875
|
+
shutdown() {
|
|
876
|
+
for (; t.length;) {
|
|
877
|
+
var e;
|
|
878
|
+
(e = t.pop()) == null || e();
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
}, ft = "bk_ot_session", pt = 1800 * 1e3, mt = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `session-${Date.now()}-${Math.random().toString(16).slice(2)}`, ht = (e) => {
|
|
883
|
+
try {
|
|
884
|
+
var t;
|
|
885
|
+
let n = (t = window.sessionStorage.getItem(e)) == null ? window.localStorage.getItem(e) : t;
|
|
886
|
+
if (!n) return null;
|
|
887
|
+
let r = JSON.parse(n);
|
|
888
|
+
return typeof (r == null ? void 0 : r.id) == "string" && typeof (r == null ? void 0 : r.ts) == "number" ? r : null;
|
|
889
|
+
} catch (e) {
|
|
890
|
+
return null;
|
|
891
|
+
}
|
|
892
|
+
}, gt = (e, t) => {
|
|
893
|
+
try {
|
|
894
|
+
let n = JSON.stringify(t);
|
|
895
|
+
window.sessionStorage.setItem(e, n), window.localStorage.setItem(e, n);
|
|
896
|
+
} catch (e) {}
|
|
897
|
+
}, _t = (e, t) => {
|
|
898
|
+
let n = Date.now(), r = ht(e);
|
|
899
|
+
if (r && n - r.ts < t) {
|
|
900
|
+
let t = {
|
|
901
|
+
id: r.id,
|
|
902
|
+
ts: n
|
|
903
|
+
};
|
|
904
|
+
return gt(e, t), t.id;
|
|
905
|
+
}
|
|
906
|
+
let i = {
|
|
907
|
+
id: mt(),
|
|
908
|
+
ts: n
|
|
909
|
+
};
|
|
910
|
+
return gt(e, i), i.id;
|
|
911
|
+
}, vt = (e) => {
|
|
912
|
+
let t;
|
|
913
|
+
return {
|
|
914
|
+
name: "session",
|
|
915
|
+
enabled: !!e,
|
|
916
|
+
init(n) {
|
|
917
|
+
var r, i;
|
|
918
|
+
let a = typeof e == "object" ? (r = e.storageKey) == null ? ft : r : ft, o = typeof e == "object" ? (i = e.inactivityMs) == null ? pt : i : pt, s = () => {
|
|
919
|
+
let e = typeof window > "u" ? mt() : _t(a, o);
|
|
920
|
+
n.setRuntimeAttributes({ "session.id": e });
|
|
921
|
+
};
|
|
922
|
+
if (s(), typeof window > "u" || typeof document > "u") return;
|
|
923
|
+
let c = () => {
|
|
924
|
+
document.visibilityState === "visible" && s();
|
|
925
|
+
};
|
|
926
|
+
document.addEventListener("visibilitychange", c), t = () => document.removeEventListener("visibilitychange", c);
|
|
927
|
+
},
|
|
928
|
+
shutdown() {
|
|
929
|
+
t == null || t(), t = void 0;
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
}, yt = () => {
|
|
933
|
+
let e = performance.getEntriesByType("navigation")[0];
|
|
934
|
+
return (e == null ? void 0 : e.type) || "unknown";
|
|
935
|
+
}, bt = (e) => ({
|
|
936
|
+
"rum.navigation.type": yt(),
|
|
937
|
+
"web_vital.name": e.name,
|
|
938
|
+
"web_vital.rating": e.rating
|
|
939
|
+
}), xt = (e, t) => {
|
|
940
|
+
var n;
|
|
941
|
+
let r = (n = e.attribution) == null ? {} : n, i = {}, a = (e, t, n) => {
|
|
942
|
+
t != null && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") && (i[e] = typeof t == "string" && n ? n(t) : t);
|
|
943
|
+
};
|
|
944
|
+
switch (e.name) {
|
|
945
|
+
case "LCP":
|
|
946
|
+
a("web_vital.lcp.url", r.url, t), a("web_vital.lcp.target", r.target), a("web_vital.lcp.element_render_delay", r.elementRenderDelay), a("web_vital.lcp.resource_load_duration", r.resourceLoadDuration), a("web_vital.lcp.time_to_first_byte", r.timeToFirstByte);
|
|
947
|
+
break;
|
|
948
|
+
case "CLS":
|
|
949
|
+
a("web_vital.cls.largest_shift_target", r.largestShiftTarget), a("web_vital.cls.largest_shift_value", r.largestShiftValue), a("web_vital.cls.load_state", r.loadState);
|
|
950
|
+
break;
|
|
951
|
+
case "INP":
|
|
952
|
+
a("web_vital.inp.interaction_target", r.interactionTarget), a("web_vital.inp.interaction_type", r.interactionType), a("web_vital.inp.input_delay", r.inputDelay), a("web_vital.inp.processing_duration", r.processingDuration), a("web_vital.inp.presentation_delay", r.presentationDelay);
|
|
953
|
+
break;
|
|
954
|
+
case "FCP":
|
|
955
|
+
a("web_vital.fcp.time_to_first_byte", r.timeToFirstByte), a("web_vital.fcp.load_state", r.loadState);
|
|
956
|
+
break;
|
|
957
|
+
case "TTFB":
|
|
958
|
+
a("web_vital.ttfb.waiting_duration", r.waitingDuration), a("web_vital.ttfb.dns_duration", r.dnsDuration), a("web_vital.ttfb.connection_duration", r.connectionDuration), a("web_vital.ttfb.request_duration", r.requestDuration);
|
|
959
|
+
break;
|
|
960
|
+
default: break;
|
|
961
|
+
}
|
|
962
|
+
return i;
|
|
963
|
+
}, St = (e) => ({
|
|
964
|
+
name: "web-vitals",
|
|
965
|
+
enabled: !!e,
|
|
966
|
+
init(e) {
|
|
967
|
+
return B(function* () {
|
|
968
|
+
if (typeof window > "u") return;
|
|
969
|
+
let { onCLS: t, onFCP: n, onINP: r, onLCP: i, onTTFB: a } = yield import("web-vitals/attribution"), o = e.meter.createHistogram("browser.web_vital.cls", {
|
|
970
|
+
unit: "1",
|
|
971
|
+
description: "Cumulative Layout Shift"
|
|
972
|
+
}), s = e.meter.createHistogram("browser.web_vital.duration", {
|
|
973
|
+
unit: "ms",
|
|
974
|
+
description: "Web Vitals duration metrics, including FCP, INP, LCP and TTFB"
|
|
975
|
+
}), c = (t) => {
|
|
976
|
+
e.startSpan("browser.web_vital", E(E(E(E({}, e.config.getPageAttributes()), e.config.getMetricAttributes()), bt(t)), {}, {
|
|
977
|
+
"web_vital.id": t.id,
|
|
978
|
+
"web_vital.value": t.value
|
|
979
|
+
}, xt(t, e.config.redactUrl))).end();
|
|
980
|
+
}, l = (t) => {
|
|
981
|
+
s.record(t.value, e.applyRedact(E(E(E({}, e.config.getPageAttributes()), e.config.getMetricAttributes()), bt(t)))), c(t);
|
|
982
|
+
};
|
|
983
|
+
t((t) => {
|
|
984
|
+
o.record(t.value, e.applyRedact(E(E(E({}, e.config.getPageAttributes()), e.config.getMetricAttributes()), bt(t)))), c(t);
|
|
985
|
+
}), n(l), r(l), i(l), a(l);
|
|
986
|
+
})();
|
|
987
|
+
}
|
|
988
|
+
}), Ct = (e) => e == null ? 0 : typeof e == "string" ? 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, wt = (e, t) => {
|
|
989
|
+
let n = {
|
|
990
|
+
"url.full": t(e),
|
|
991
|
+
"network.protocol.name": "websocket"
|
|
992
|
+
};
|
|
993
|
+
try {
|
|
994
|
+
n["server.address"] = new URL(e, typeof location > "u" ? "http://localhost" : location.href).host;
|
|
995
|
+
} catch (e) {}
|
|
996
|
+
return {
|
|
997
|
+
spanAttributes: n,
|
|
998
|
+
metricAttributes: { "network.protocol.name": "websocket" }
|
|
999
|
+
};
|
|
1000
|
+
}, Tt = (e) => {
|
|
1001
|
+
let n;
|
|
1002
|
+
return {
|
|
1003
|
+
name: "websocket",
|
|
1004
|
+
enabled: !!e,
|
|
1005
|
+
init(e) {
|
|
1006
|
+
if (typeof window > "u" || window.WebSocket === void 0) return;
|
|
1007
|
+
let r = window.WebSocket;
|
|
1008
|
+
n = r;
|
|
1009
|
+
let i = e.meter.createCounter("browser.websocket.message.count", { description: "Total number of WebSocket messages observed" }), a = e.meter.createCounter("browser.websocket.message.bytes", {
|
|
1010
|
+
unit: "By",
|
|
1011
|
+
description: "Total bytes transferred over WebSocket (best-effort)"
|
|
1012
|
+
}), s = e.meter.createCounter("browser.websocket.error.count", { description: "Total number of WebSocket error events" }), c = function(n, c) {
|
|
1013
|
+
let l = n.toString();
|
|
1014
|
+
if (W(e.config, l)) return c === void 0 ? new r(n) : new r(n, c);
|
|
1015
|
+
let { metricAttributes: u, spanAttributes: d } = wt(l, e.config.redactUrl), f = e.startSpan("websocket.connect", d), p = performance.now(), m = c === void 0 ? new r(n) : new r(n, c), h = !1, g = (e) => {
|
|
1016
|
+
h || (h = !0, e === "error" && f.setStatus({
|
|
1017
|
+
code: t.ERROR,
|
|
1018
|
+
message: "websocket connect failed"
|
|
1019
|
+
}), f.setAttribute("websocket.connect.duration_ms", performance.now() - p), f.end());
|
|
1020
|
+
};
|
|
1021
|
+
m.addEventListener("open", () => g("opened")), m.addEventListener("message", (e) => {
|
|
1022
|
+
i.add(1, E(E({}, u), {}, { "websocket.direction": "in" })), a.add(Ct(e.data), E(E({}, u), {}, { "websocket.direction": "in" }));
|
|
1023
|
+
}), m.addEventListener("error", () => {
|
|
1024
|
+
s.add(1, u), g("error"), e.emitLog({
|
|
1025
|
+
severityNumber: o.ERROR,
|
|
1026
|
+
severityText: "ERROR",
|
|
1027
|
+
body: "websocket.error",
|
|
1028
|
+
attributes: d
|
|
1029
|
+
});
|
|
1030
|
+
}), m.addEventListener("close", (t) => {
|
|
1031
|
+
g("opened"), e.emitLog({
|
|
1032
|
+
severityNumber: o.INFO,
|
|
1033
|
+
severityText: "INFO",
|
|
1034
|
+
body: "websocket.close",
|
|
1035
|
+
attributes: E(E({}, d), {}, {
|
|
1036
|
+
"websocket.close.code": t.code,
|
|
1037
|
+
"websocket.close.reason": t.reason,
|
|
1038
|
+
"websocket.close.was_clean": t.wasClean
|
|
1039
|
+
})
|
|
1040
|
+
});
|
|
1041
|
+
});
|
|
1042
|
+
let _ = m.send.bind(m);
|
|
1043
|
+
return m.send = (e) => (i.add(1, E(E({}, u), {}, { "websocket.direction": "out" })), a.add(Ct(e), E(E({}, u), {}, { "websocket.direction": "out" })), _(e)), m;
|
|
1044
|
+
};
|
|
1045
|
+
c.prototype = r.prototype, Object.assign(c, r), window.WebSocket = c;
|
|
1046
|
+
},
|
|
1047
|
+
shutdown() {
|
|
1048
|
+
n && typeof window < "u" && (window.WebSocket = n);
|
|
1049
|
+
}
|
|
1050
|
+
};
|
|
1051
|
+
}, $ = "__bk_ot_sampled__", Et = /* @__PURE__ */ new Map(), Dt = (e) => Et.get(e), Ot = (e, t) => (Et.set(e, t), t), kt = ({ sampleRate: e }) => {
|
|
1052
|
+
if (e <= 0) return !1;
|
|
1053
|
+
if (e >= 1) return !0;
|
|
1054
|
+
try {
|
|
1055
|
+
let t = sessionStorage.getItem($);
|
|
1056
|
+
if (t) return t === "1";
|
|
1057
|
+
let n = Math.random() < e;
|
|
1058
|
+
return sessionStorage.setItem($, n ? "1" : "0"), Ot($, n), n;
|
|
1059
|
+
} catch (t) {
|
|
1060
|
+
let n = Dt($);
|
|
1061
|
+
return typeof n == "boolean" ? n : Ot($, Math.random() < e);
|
|
1062
|
+
}
|
|
1063
|
+
}, At = (e) => ({
|
|
1064
|
+
url: e.endpoint,
|
|
1065
|
+
headers: e.headers,
|
|
1066
|
+
concurrencyLimit: e.concurrencyLimit,
|
|
1067
|
+
timeoutMillis: e.timeoutMillis
|
|
1068
|
+
}), jt = "bk-rum", Mt = (e, t, n) => n ? new Proxy(e, { get(e, n, r) {
|
|
1069
|
+
if (n === "export") return (n, r) => {
|
|
1070
|
+
var i;
|
|
1071
|
+
return (i = globalThis.console) == null || i.log(`[bk-ot][${t}]`, n), e.export(n, r);
|
|
1072
|
+
};
|
|
1073
|
+
let i = Reflect.get(e, n, r);
|
|
1074
|
+
return typeof i == "function" ? i.bind(e) : i;
|
|
1075
|
+
} }) : e, Nt = (e) => [De(e.instrumentations)], Pt = (e) => [
|
|
1076
|
+
Ne(e.rum.device),
|
|
1077
|
+
tt(e.rum.httpBody),
|
|
1078
|
+
vt(e.rum.session),
|
|
1079
|
+
ut(e.rum.pageView),
|
|
1080
|
+
Ve(e.rum.error),
|
|
1081
|
+
St(e.rum.webVitals),
|
|
1082
|
+
Ce(e.rum.blankScreen),
|
|
1083
|
+
Tt(e.rum.websocket),
|
|
1084
|
+
rt(e.rum.longTask),
|
|
1085
|
+
Oe(e.rum.cspViolation),
|
|
1086
|
+
dt(e.rum.routeTiming)
|
|
1087
|
+
], Ft = (o) => {
|
|
1088
|
+
let b = ie(o), x = b.enabled && kt(b), S = p(b.resourceAttributes), C = Mt(new f(At(b.traces)), "traces", b.debug), w = Mt(new d(At(b.metrics)), "metrics", b.debug), T = Mt(new u(At(b.logs)), "logs", b.debug), D = new me(new v(C, b.spanBatch), b), ne = new _({
|
|
1089
|
+
exporter: w,
|
|
1090
|
+
exportIntervalMillis: b.metricIntervalMillis
|
|
1091
|
+
}), re = new m(T), O = new y({
|
|
1092
|
+
resource: S,
|
|
1093
|
+
sampler: new ee({ root: new te(+!!x) }),
|
|
1094
|
+
spanProcessors: [D]
|
|
1095
|
+
}), k = new g({
|
|
1096
|
+
resource: S,
|
|
1097
|
+
readers: [ne]
|
|
1098
|
+
}), A = new h({
|
|
1099
|
+
resource: S,
|
|
1100
|
+
processors: [re]
|
|
1101
|
+
}), j = O.getTracer(jt), M = k.getMeter(jt), N = A.getLogger(jt), P = { "bk.rum.sampled": x }, F = new ae([...b.enabled ? Nt(b) : [], ...x ? [...Pt(b), ...b.plugins] : []]), I = [], L = "idle", R = () => E({}, P), z = (e) => {
|
|
1102
|
+
Object.assign(P, e);
|
|
1103
|
+
}, V = (e) => b.redactAttributes(e), H = (t, n = {}) => j.startSpan(t, {
|
|
1104
|
+
kind: e.INTERNAL,
|
|
1105
|
+
attributes: V(E(E({}, R()), n))
|
|
1106
|
+
}), U = {
|
|
1107
|
+
config: b,
|
|
1108
|
+
tracer: j,
|
|
1109
|
+
meter: M,
|
|
1110
|
+
logger: N,
|
|
1111
|
+
applyRedact: V,
|
|
1112
|
+
emitLog: (e) => {
|
|
1113
|
+
var t;
|
|
1114
|
+
let n = E(E({}, e), {}, { attributes: V(E(E({}, R()), (t = e.attributes) == null ? {} : t)) });
|
|
1115
|
+
N.emit(n);
|
|
1116
|
+
},
|
|
1117
|
+
getRuntimeAttributes: R,
|
|
1118
|
+
setRuntimeAttributes: z,
|
|
1119
|
+
startSpan: H,
|
|
1120
|
+
reportCustomEvent({ attributes: e = {}, error: n, name: r }) {
|
|
1121
|
+
if (!x) {
|
|
1122
|
+
if (b.debug) {
|
|
1123
|
+
var i;
|
|
1124
|
+
(i = globalThis.console) == null || i.warn("[bk-ot] custom event dropped (not sampled):", r);
|
|
1125
|
+
}
|
|
1126
|
+
return;
|
|
1127
|
+
}
|
|
1128
|
+
let a = H(`custom.${r}`, E(E(E(E({}, b.getPageAttributes()), b.getCustomAttributes()), e), {}, { "rum.custom.name": r }));
|
|
1129
|
+
n && (a.recordException(n), a.setStatus({
|
|
1130
|
+
code: t.ERROR,
|
|
1131
|
+
message: n.message
|
|
1132
|
+
})), a.end();
|
|
1133
|
+
},
|
|
1134
|
+
start() {
|
|
1135
|
+
return B(function* () {
|
|
1136
|
+
if (L !== "started") {
|
|
1137
|
+
if (L === "stopped") throw Error("[bk-ot] instance has been shut down and cannot be restarted; create a new instance instead.");
|
|
1138
|
+
if (!b.enabled) {
|
|
1139
|
+
L = "started";
|
|
1140
|
+
return;
|
|
1141
|
+
}
|
|
1142
|
+
i.setGlobalPropagator(new l()), O.register({ contextManager: new c() }), r.setGlobalMeterProvider(k), s.setGlobalLoggerProvider(A);
|
|
1143
|
+
try {
|
|
1144
|
+
if (yield F.start(U), typeof window < "u" && typeof document < "u") {
|
|
1145
|
+
let e = () => {
|
|
1146
|
+
U.flush();
|
|
1147
|
+
}, t = () => {
|
|
1148
|
+
document.visibilityState === "hidden" && U.flush();
|
|
1149
|
+
};
|
|
1150
|
+
window.addEventListener("pagehide", e), document.addEventListener("visibilitychange", t), I.push(() => window.removeEventListener("pagehide", e), () => document.removeEventListener("visibilitychange", t));
|
|
1151
|
+
}
|
|
1152
|
+
} catch (t) {
|
|
1153
|
+
for (; I.length;) {
|
|
1154
|
+
var e;
|
|
1155
|
+
(e = I.pop()) == null || e();
|
|
1156
|
+
}
|
|
1157
|
+
throw yield F.shutdown(), a.disable(), r.disable(), n.disable(), t;
|
|
1158
|
+
}
|
|
1159
|
+
L = "started";
|
|
1160
|
+
}
|
|
1161
|
+
})();
|
|
1162
|
+
},
|
|
1163
|
+
flush() {
|
|
1164
|
+
return B(function* () {
|
|
1165
|
+
yield F.flush(), yield O.forceFlush(), yield k.forceFlush(), yield A.forceFlush();
|
|
1166
|
+
})();
|
|
1167
|
+
},
|
|
1168
|
+
shutdown() {
|
|
1169
|
+
return B(function* () {
|
|
1170
|
+
if (L !== "stopped") {
|
|
1171
|
+
for (yield U.flush(); I.length;) {
|
|
1172
|
+
var e;
|
|
1173
|
+
(e = I.pop()) == null || e();
|
|
1174
|
+
}
|
|
1175
|
+
yield F.shutdown(), yield O.shutdown(), yield k.shutdown(), yield A.shutdown(), a.disable(), r.disable(), n.disable(), L = "stopped";
|
|
1176
|
+
}
|
|
1177
|
+
})();
|
|
1178
|
+
}
|
|
1179
|
+
};
|
|
1180
|
+
return b.autoStart && U.start().catch((e) => {
|
|
1181
|
+
var t;
|
|
1182
|
+
(t = globalThis.console) == null || t.warn("[bk-ot] auto start failed:", e);
|
|
1183
|
+
}), U;
|
|
1184
|
+
}, It = Ft;
|
|
1185
|
+
//#endregion
|
|
1186
|
+
export { me as FilteringSpanProcessor, Ft as createBkOT, Ce as createBlankScreenPlugin, De as createCommonInstrumentationsPlugin, Oe as createCspViolationPlugin, Ne as createDevicePlugin, Ve as createErrorPlugin, tt as createHttpBodyPlugin, rt as createLongTaskPlugin, ut as createPageViewPlugin, H as createPlugin, dt as createRouteTimingPlugin, vt as createSessionPlugin, Tt as createWebSocketPlugin, St as createWebVitalsPlugin, It as initBkOT, ie as normalizeConfig };
|