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