@blueking/open-telemetry 0.0.4 → 0.0.6
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 +388 -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 +138 -0
- package/dist/core/id.d.ts +8 -0
- package/dist/core/plugin.d.ts +46 -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/throttle.d.ts +20 -0
- package/dist/core/url.d.ts +4 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +865 -601
- 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 +19 -0
- package/dist/plugins/device.d.ts +23 -0
- package/dist/plugins/error.d.ts +3 -0
- package/dist/plugins/http-body.d.ts +3 -0
- package/dist/plugins/long-task.d.ts +15 -0
- package/dist/plugins/page-view.d.ts +3 -0
- package/dist/plugins/route-timing.d.ts +3 -0
- package/dist/plugins/session.d.ts +3 -0
- package/dist/plugins/web-vitals.d.ts +3 -0
- package/dist/plugins/websocket.d.ts +3 -0
- package/package.json +5 -3
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, SimpleSpanProcessor as x, TraceIdRatioBasedSampler as S } from "@opentelemetry/sdk-trace-base";
|
|
13
|
+
import { WebTracerProvider as C } from "@opentelemetry/sdk-trace-web";
|
|
14
14
|
//#region \0@oxc-project+runtime@0.128.0/helpers/typeof.js
|
|
15
|
-
function
|
|
15
|
+
function w(e) {
|
|
16
16
|
"@babel/helpers - typeof";
|
|
17
|
-
return
|
|
17
|
+
return w = 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
|
+
}, w(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 T(e, t) {
|
|
26
|
+
if (w(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 (w(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 E(e) {
|
|
38
|
+
var t = T(e, "string");
|
|
39
|
+
return w(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 D(e, t, n) {
|
|
44
|
+
return (t = E(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 O(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 k(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 ? O(Object(n), !0).forEach(function(t) {
|
|
67
|
+
D(e, t, n[t]);
|
|
68
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : O(Object(n)).forEach(function(t) {
|
|
69
69
|
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
|
|
70
70
|
});
|
|
71
71
|
}
|
|
@@ -73,87 +73,94 @@ function E(e) {
|
|
|
73
73
|
}
|
|
74
74
|
//#endregion
|
|
75
75
|
//#region src/core/config.ts
|
|
76
|
-
var
|
|
77
|
-
let n =
|
|
76
|
+
var A = "http://localhost:4318", ee = 60 * 1e3, j = (e) => e.replace(/\/+$/, ""), M = (e, t) => {
|
|
77
|
+
let n = j(e || A);
|
|
78
78
|
return n.endsWith(`/v1/${t}`) ? n : n.endsWith("/v1") ? `${n}/${t}` : `${n}/v1/${t}`;
|
|
79
|
-
},
|
|
80
|
-
var n;
|
|
81
|
-
let
|
|
79
|
+
}, N = (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 ? k(k(k({}, 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 ? j(s) : M((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)), P = (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: P(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" ? k(k({}, e.session), {}, {
|
|
103
|
+
inactivityMs: P(e.session.inactivityMs, 1800 * 1e3),
|
|
104
|
+
maxLifetimeMs: P(e.session.maxLifetimeMs, 1440 * 60 * 1e3)
|
|
105
|
+
}) : (n = e == null ? void 0 : e.session) == null ? !0 : n,
|
|
101
106
|
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:
|
|
107
|
+
error: typeof (e == null ? void 0 : e.error) == "object" ? k(k({}, e.error), {}, {
|
|
108
|
+
maxPerWindow: P(e.error.maxPerWindow, 5),
|
|
109
|
+
windowMs: P(e.error.windowMs, 6e4)
|
|
105
110
|
}) : (i = e == null ? void 0 : e.error) == null ? !0 : i,
|
|
106
111
|
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:
|
|
112
|
+
blankScreen: typeof (e == null ? void 0 : e.blankScreen) == "object" ? k(k({}, e.blankScreen), {}, {
|
|
113
|
+
checkDelay: ne(e.blankScreen.checkDelay, 3e3),
|
|
114
|
+
threshold: re(e.blankScreen.threshold, .8)
|
|
110
115
|
}) : (o = e == null ? void 0 : e.blankScreen) == null ? !0 : o,
|
|
111
116
|
websocket: (s = e == null ? void 0 : e.websocket) == null ? !0 : s,
|
|
112
|
-
longTask: typeof (e == null ? void 0 : e.longTask) == "object" ?
|
|
117
|
+
longTask: typeof (e == null ? void 0 : e.longTask) == "object" ? k(k({}, e.longTask), {}, { threshold: ne(e.longTask.threshold, 50) }) : (c = e == null ? void 0 : e.longTask) == null ? !1 : c,
|
|
113
118
|
cspViolation: (l = e == null ? void 0 : e.cspViolation) == null ? !1 : l,
|
|
114
119
|
routeTiming: (u = e == null ? void 0 : e.routeTiming) == null ? !1 : u
|
|
115
120
|
};
|
|
116
|
-
},
|
|
117
|
-
var t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _, v,
|
|
118
|
-
let
|
|
121
|
+
}, se = (e) => e, ce = (e) => e, le = (e) => {
|
|
122
|
+
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, O;
|
|
123
|
+
let M = {
|
|
119
124
|
"deployment.environment.name": (t = e.environment) == null ? "production" : t,
|
|
120
125
|
"rum.provider": "blueking",
|
|
121
126
|
"telemetry.sdk.language": "webjs"
|
|
122
127
|
};
|
|
123
|
-
return
|
|
128
|
+
return k(k({}, e), {}, {
|
|
124
129
|
debug: (n = e.debug) == null ? !1 : n,
|
|
125
130
|
enabled: (r = e.enabled) == null ? !0 : r,
|
|
126
131
|
environment: (i = e.environment) == null ? "production" : i,
|
|
127
|
-
endpoint:
|
|
128
|
-
traces:
|
|
129
|
-
metrics:
|
|
130
|
-
logs:
|
|
131
|
-
sampleRate:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
132
|
+
endpoint: j(e.endpoint || A),
|
|
133
|
+
traces: N(e, "traces"),
|
|
134
|
+
metrics: N(e, "metrics"),
|
|
135
|
+
logs: N(e, "logs"),
|
|
136
|
+
sampleRate: te(e.sampleRate),
|
|
137
|
+
spanProcessor: (a = e.spanProcessor) == null ? "batch" : a,
|
|
138
|
+
resourceAttributes: M,
|
|
139
|
+
metricIntervalMillis: ee,
|
|
140
|
+
instrumentations: (o = e.instrumentations) == null ? [] : o,
|
|
141
|
+
commonInstrumentations: {
|
|
142
|
+
documentLoad: (s = (c = e.rum) == null ? void 0 : c.documentLoad) == null ? !0 : s,
|
|
143
|
+
fetch: (l = (u = e.rum) == null ? void 0 : u.fetch) == null ? !0 : l,
|
|
144
|
+
xhr: (d = (f = e.rum) == null ? void 0 : f.xhr) == null ? !0 : d,
|
|
145
|
+
userInteraction: (p = (m = e.rum) == null ? void 0 : m.userInteraction) == null ? !0 : p
|
|
139
146
|
},
|
|
140
|
-
rum:
|
|
141
|
-
plugins: (
|
|
142
|
-
autoStart: (
|
|
143
|
-
getPageAttributes: (
|
|
147
|
+
rum: oe(e.rum),
|
|
148
|
+
plugins: (h = e.plugins) == null ? [] : h,
|
|
149
|
+
autoStart: (g = e.autoStart) == null ? !0 : g,
|
|
150
|
+
getPageAttributes: (_ = (v = e.attributes) == null ? void 0 : v.page) == null ? (() => ({
|
|
144
151
|
"rum.page.host": typeof window > "u" ? "" : window.location.host,
|
|
145
152
|
"rum.page.path": typeof window > "u" ? "" : window.location.pathname
|
|
146
|
-
})) :
|
|
147
|
-
getMetricAttributes: (
|
|
148
|
-
getErrorAttributes: (
|
|
149
|
-
getCustomAttributes: (
|
|
150
|
-
redactAttributes: (
|
|
151
|
-
redactUrl: (
|
|
153
|
+
})) : _,
|
|
154
|
+
getMetricAttributes: (y = (b = e.attributes) == null ? void 0 : b.metric) == null ? (() => ({})) : y,
|
|
155
|
+
getErrorAttributes: (x = (S = e.attributes) == null ? void 0 : S.error) == null ? (() => ({})) : x,
|
|
156
|
+
getCustomAttributes: (C = (w = e.attributes) == null ? void 0 : w.custom) == null ? (() => ({})) : C,
|
|
157
|
+
redactAttributes: (T = (E = e.redact) == null ? void 0 : E.attributes) == null ? se : T,
|
|
158
|
+
redactUrl: (D = (O = e.redact) == null ? void 0 : O.url) == null ? ce : D
|
|
152
159
|
});
|
|
153
160
|
};
|
|
154
161
|
//#endregion
|
|
155
162
|
//#region \0@oxc-project+runtime@0.128.0/helpers/asyncToGenerator.js
|
|
156
|
-
function
|
|
163
|
+
function ue(e, t, n, r, i, a, o) {
|
|
157
164
|
try {
|
|
158
165
|
var s = e[a](o), c = s.value;
|
|
159
166
|
} catch (e) {
|
|
@@ -162,16 +169,16 @@ function z(e, t, n, r, i, a, o) {
|
|
|
162
169
|
}
|
|
163
170
|
s.done ? t(c) : Promise.resolve(c).then(r, i);
|
|
164
171
|
}
|
|
165
|
-
function
|
|
172
|
+
function F(e) {
|
|
166
173
|
return function() {
|
|
167
174
|
var t = this, n = arguments;
|
|
168
175
|
return new Promise(function(r, i) {
|
|
169
176
|
var a = e.apply(t, n);
|
|
170
177
|
function o(e) {
|
|
171
|
-
|
|
178
|
+
ue(a, r, i, o, s, "next", e);
|
|
172
179
|
}
|
|
173
180
|
function s(e) {
|
|
174
|
-
|
|
181
|
+
ue(a, r, i, o, s, "throw", e);
|
|
175
182
|
}
|
|
176
183
|
o(void 0);
|
|
177
184
|
});
|
|
@@ -179,13 +186,13 @@ function B(e) {
|
|
|
179
186
|
}
|
|
180
187
|
//#endregion
|
|
181
188
|
//#region src/core/plugin.ts
|
|
182
|
-
var
|
|
189
|
+
var de = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !== !1, fe = (e) => e, pe = class {
|
|
183
190
|
constructor(e) {
|
|
184
|
-
|
|
191
|
+
D(this, "plugins", void 0), D(this, "startedPlugins", []), this.plugins = e;
|
|
185
192
|
}
|
|
186
193
|
flush() {
|
|
187
194
|
var e = this;
|
|
188
|
-
return
|
|
195
|
+
return F(function* () {
|
|
189
196
|
yield Promise.all(e.startedPlugins.map((e) => Promise.resolve().then(() => {
|
|
190
197
|
var t;
|
|
191
198
|
return (t = e.flush) == null ? void 0 : t.call(e);
|
|
@@ -194,7 +201,7 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
194
201
|
}
|
|
195
202
|
shutdown() {
|
|
196
203
|
var e = this;
|
|
197
|
-
return
|
|
204
|
+
return F(function* () {
|
|
198
205
|
let t = [...e.startedPlugins].reverse();
|
|
199
206
|
for (let e of t) {
|
|
200
207
|
var n;
|
|
@@ -205,43 +212,46 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
205
212
|
}
|
|
206
213
|
start(e) {
|
|
207
214
|
var t = this;
|
|
208
|
-
return
|
|
209
|
-
try {
|
|
210
|
-
|
|
211
|
-
} catch (
|
|
212
|
-
|
|
215
|
+
return F(function* () {
|
|
216
|
+
for (let r of t.plugins) if (de(r, e.config)) try {
|
|
217
|
+
yield r.init(e), t.startedPlugins.push(r);
|
|
218
|
+
} catch (t) {
|
|
219
|
+
if (e.config.debug) {
|
|
220
|
+
var n;
|
|
221
|
+
(n = globalThis.console) == null || n.warn(`[bk-ot] plugin "${r.name}" init failed:`, t);
|
|
222
|
+
}
|
|
213
223
|
}
|
|
214
224
|
})();
|
|
215
225
|
}
|
|
216
|
-
},
|
|
226
|
+
}, me = () => typeof window > "u" ? "http://localhost" : window.location.origin, he = (e) => {
|
|
217
227
|
try {
|
|
218
|
-
return new URL(e,
|
|
228
|
+
return new URL(e, me()).href;
|
|
219
229
|
} catch (t) {
|
|
220
230
|
return e;
|
|
221
231
|
}
|
|
222
|
-
},
|
|
223
|
-
let n = (e) =>
|
|
232
|
+
}, ge = (e) => e.length > 1 ? e.replace(/\/+$/, "") : e, _e = (e, t) => {
|
|
233
|
+
let n = (e) => ge(e.replace(/[?#].*$/, ""));
|
|
224
234
|
return n(e) === n(t);
|
|
225
|
-
},
|
|
235
|
+
}, ve = (e) => {
|
|
226
236
|
try {
|
|
227
|
-
return new URL(e,
|
|
237
|
+
return new URL(e, me()).origin === me();
|
|
228
238
|
} catch (e) {
|
|
229
239
|
return !1;
|
|
230
240
|
}
|
|
231
|
-
},
|
|
232
|
-
let n =
|
|
241
|
+
}, ye = (e, t) => {
|
|
242
|
+
let n = he(t);
|
|
233
243
|
return [
|
|
234
244
|
e.traces.endpoint,
|
|
235
245
|
e.metrics.endpoint,
|
|
236
246
|
e.logs.endpoint
|
|
237
|
-
].some((e) =>
|
|
238
|
-
},
|
|
239
|
-
for (let n of
|
|
247
|
+
].some((e) => _e(n, he(e)));
|
|
248
|
+
}, I = (e, t) => ye(e, t), be = (e, t) => ve(t), xe = ["http.url", "url.full"], Se = (e) => {
|
|
249
|
+
for (let n of xe) {
|
|
240
250
|
var t;
|
|
241
251
|
let r = (t = e.attributes) == null ? void 0 : t[n];
|
|
242
252
|
if (typeof r == "string") return r;
|
|
243
253
|
}
|
|
244
|
-
},
|
|
254
|
+
}, Ce = class {
|
|
245
255
|
constructor(e, t) {
|
|
246
256
|
this.inner = e, this.config = t;
|
|
247
257
|
}
|
|
@@ -249,8 +259,8 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
249
259
|
return this.inner.forceFlush();
|
|
250
260
|
}
|
|
251
261
|
onEnd(e) {
|
|
252
|
-
let t =
|
|
253
|
-
t &&
|
|
262
|
+
let t = Se(e);
|
|
263
|
+
t && ye(this.config, t) || this.inner.onEnd(e);
|
|
254
264
|
}
|
|
255
265
|
onStart(e, t) {
|
|
256
266
|
this.inner.onStart(e, t);
|
|
@@ -258,7 +268,7 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
258
268
|
shutdown() {
|
|
259
269
|
return this.inner.shutdown();
|
|
260
270
|
}
|
|
261
|
-
},
|
|
271
|
+
}, we = "body", Te = 3e3, Ee = .8, De = [
|
|
262
272
|
"[data-loading=\"true\"]",
|
|
263
273
|
"[aria-busy=\"true\"]",
|
|
264
274
|
".loading",
|
|
@@ -266,79 +276,86 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
266
276
|
".spinner",
|
|
267
277
|
".skeleton",
|
|
268
278
|
".bk-loading"
|
|
269
|
-
],
|
|
279
|
+
], L = [
|
|
270
280
|
[.5, .5],
|
|
271
281
|
[.25, .25],
|
|
272
282
|
[.75, .25],
|
|
273
283
|
[.25, .75],
|
|
274
284
|
[.75, .75]
|
|
275
|
-
],
|
|
285
|
+
], Oe = (e) => {
|
|
276
286
|
if (!e) return "";
|
|
277
287
|
let t = e.tagName.toLowerCase();
|
|
278
288
|
return e.id ? `${t}#${e.id}` : t;
|
|
279
|
-
},
|
|
289
|
+
}, ke = (e, t) => e ? t.some((t) => {
|
|
280
290
|
try {
|
|
281
291
|
return e.matches(t) || !!e.closest(t);
|
|
282
292
|
} catch (e) {
|
|
283
293
|
return !1;
|
|
284
294
|
}
|
|
285
|
-
}) : !1,
|
|
286
|
-
if (typeof document > "u") return;
|
|
287
|
-
if (document.readyState === "complete" || document.readyState === "interactive") {
|
|
288
|
-
e();
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
295
|
+
}) : !1, Ae = (e) => {
|
|
296
|
+
if (typeof document > "u") return () => {};
|
|
297
|
+
if (document.readyState === "complete" || document.readyState === "interactive") return e(), () => {};
|
|
291
298
|
let t = () => {
|
|
292
299
|
document.removeEventListener("DOMContentLoaded", t), e();
|
|
293
300
|
};
|
|
294
|
-
document.addEventListener("DOMContentLoaded", t);
|
|
295
|
-
},
|
|
296
|
-
let t;
|
|
301
|
+
return document.addEventListener("DOMContentLoaded", t), () => document.removeEventListener("DOMContentLoaded", t);
|
|
302
|
+
}, je = (e) => {
|
|
303
|
+
let t, n, r = !1;
|
|
297
304
|
return {
|
|
298
305
|
name: "blank-screen",
|
|
299
306
|
enabled: !!e,
|
|
300
|
-
init(
|
|
301
|
-
var
|
|
307
|
+
init(i) {
|
|
308
|
+
var a, s, c, l;
|
|
302
309
|
if (typeof window > "u" || typeof document > "u") return;
|
|
303
|
-
let
|
|
304
|
-
|
|
305
|
-
t = window.setTimeout(() => {
|
|
310
|
+
let u = typeof e == "object" ? e : {}, d = (a = u.rootSelector) == null ? we : a, f = (s = u.checkDelay) == null ? Te : s, p = (c = u.threshold) == null ? Ee : c, m = [...De, ...(l = u.ignoreSelectors) == null ? [] : l], h = i.meter.createCounter("browser.blank_screen.count", { description: "Number of suspected blank screen detections" }), g = () => {
|
|
311
|
+
try {
|
|
306
312
|
var e, t;
|
|
307
|
-
let
|
|
308
|
-
for (let [e, t] of
|
|
309
|
-
let
|
|
310
|
-
if (
|
|
313
|
+
let n = document.querySelector(d), r = 0, a = 0;
|
|
314
|
+
for (let [e, t] of L) {
|
|
315
|
+
let i = document.elementFromPoint(window.innerWidth * e, window.innerHeight * t);
|
|
316
|
+
if (ke(i, m)) {
|
|
311
317
|
a += 1;
|
|
312
318
|
continue;
|
|
313
319
|
}
|
|
314
|
-
(
|
|
320
|
+
(i === n || i === document.body || i === document.documentElement) && (r += 1);
|
|
315
321
|
}
|
|
316
|
-
let s =
|
|
317
|
-
if (
|
|
318
|
-
let c = s >=
|
|
319
|
-
"bk.rum.blank_screen.score":
|
|
320
|
-
"bk.rum.blank_screen.threshold":
|
|
321
|
-
"bk.rum.blank_screen.root":
|
|
322
|
-
"bk.rum.blank_screen.detected":
|
|
323
|
-
"bk.rum.blank_screen.
|
|
322
|
+
let s = L.length - a;
|
|
323
|
+
if (s === 0) return;
|
|
324
|
+
let c = r / s, l = c >= p, u = {
|
|
325
|
+
"bk.rum.blank_screen.score": c,
|
|
326
|
+
"bk.rum.blank_screen.threshold": p,
|
|
327
|
+
"bk.rum.blank_screen.root": d,
|
|
328
|
+
"bk.rum.blank_screen.detected": l,
|
|
329
|
+
"bk.rum.blank_screen.sample_total": L.length,
|
|
330
|
+
"bk.rum.blank_screen.sample_valid": s,
|
|
331
|
+
"bk.rum.blank_screen.sample_loading": a,
|
|
332
|
+
"bk.rum.blank_screen.center_element": Oe(document.elementFromPoint(window.innerWidth / 2, window.innerHeight / 2)),
|
|
324
333
|
"bk.rum.blank_screen.dom_node_count": (e = (t = document.body) == null ? void 0 : t.getElementsByTagName("*").length) == null ? 0 : e
|
|
325
334
|
};
|
|
326
|
-
|
|
335
|
+
l && (h.add(1, i.applyRedact({ "bk.rum.blank_screen.root": d })), i.emitLog({
|
|
327
336
|
severityNumber: o.ERROR,
|
|
328
337
|
severityText: "ERROR",
|
|
329
338
|
body: "browser.blank_screen",
|
|
330
339
|
attributes: u
|
|
331
340
|
}));
|
|
332
|
-
}
|
|
341
|
+
} catch (e) {
|
|
342
|
+
if (i.config.debug) {
|
|
343
|
+
var n;
|
|
344
|
+
(n = globalThis.console) == null || n.warn("[bk-ot][blank-screen] detection failed:", e);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
n = Ae(() => {
|
|
349
|
+
r || (t = window.setTimeout(g, f));
|
|
333
350
|
});
|
|
334
351
|
},
|
|
335
352
|
shutdown() {
|
|
336
|
-
t !== void 0 && typeof window < "u" && window.clearTimeout(t);
|
|
353
|
+
r = !0, n == null || n(), n = void 0, t !== void 0 && typeof window < "u" && (window.clearTimeout(t), t = void 0);
|
|
337
354
|
}
|
|
338
355
|
};
|
|
339
|
-
},
|
|
356
|
+
}, Me = ["http.url", "url.full"], Ne = (e) => ({ test: e }), Pe = (e, t) => {
|
|
340
357
|
t.setAttributes(e.applyRedact(e.config.getPageAttributes()));
|
|
341
|
-
for (let r of
|
|
358
|
+
for (let r of Me) {
|
|
342
359
|
var n;
|
|
343
360
|
let i = (n = t.attributes) == null ? void 0 : n[r];
|
|
344
361
|
if (typeof i == "string") {
|
|
@@ -346,43 +363,36 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
346
363
|
typeof n == "string" && t.setAttribute(r, n);
|
|
347
364
|
}
|
|
348
365
|
}
|
|
349
|
-
},
|
|
366
|
+
}, Fe = (e) => {
|
|
350
367
|
let t = [];
|
|
351
368
|
return {
|
|
352
369
|
name: "official-instrumentations",
|
|
353
370
|
enabled: !!(e.documentLoad || e.fetch || e.xhr || e.userInteraction),
|
|
354
371
|
init(n) {
|
|
355
|
-
return
|
|
356
|
-
let r = [
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
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));
|
|
372
|
+
return F(function* () {
|
|
373
|
+
let r = [Ne((e) => I(n.config, e))], i = [Ne((e) => be(n.config, e))], [a, o, s, c] = yield Promise.all([
|
|
374
|
+
e.documentLoad ? import("@opentelemetry/instrumentation-document-load") : Promise.resolve(null),
|
|
375
|
+
e.fetch ? import("@opentelemetry/instrumentation-fetch") : Promise.resolve(null),
|
|
376
|
+
e.xhr ? import("@opentelemetry/instrumentation-xml-http-request") : Promise.resolve(null),
|
|
377
|
+
e.userInteraction ? import("@opentelemetry/instrumentation-user-interaction") : Promise.resolve(null)
|
|
378
|
+
]);
|
|
379
|
+
if (a && t.push(new a.DocumentLoadInstrumentation({ semconvStabilityOptIn: "http" })), o && t.push(new o.FetchInstrumentation({
|
|
380
|
+
applyCustomAttributesOnSpan: (e) => Pe(n, e),
|
|
381
|
+
ignoreUrls: r,
|
|
382
|
+
propagateTraceHeaderCorsUrls: i,
|
|
383
|
+
semconvStabilityOptIn: "http",
|
|
384
|
+
ignoreNetworkEvents: !1
|
|
385
|
+
})), s && t.push(new s.XMLHttpRequestInstrumentation({
|
|
386
|
+
applyCustomAttributesOnSpan: (e) => Pe(n, e),
|
|
387
|
+
ignoreUrls: r,
|
|
388
|
+
propagateTraceHeaderCorsUrls: i,
|
|
389
|
+
semconvStabilityOptIn: "http",
|
|
390
|
+
ignoreNetworkEvents: !1
|
|
391
|
+
})), c) {
|
|
392
|
+
let n = e.userInteraction !== null && typeof e.userInteraction == "object" ? { eventNames: e.userInteraction.eventNames } : void 0;
|
|
393
|
+
t.push(new c.UserInteractionInstrumentation(n));
|
|
384
394
|
}
|
|
385
|
-
|
|
395
|
+
p({ instrumentations: t });
|
|
386
396
|
})();
|
|
387
397
|
},
|
|
388
398
|
shutdown() {
|
|
@@ -392,66 +402,145 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
392
402
|
}
|
|
393
403
|
}
|
|
394
404
|
};
|
|
395
|
-
},
|
|
405
|
+
}, R = (e) => {
|
|
406
|
+
let t = 5381;
|
|
407
|
+
for (let n = 0; n < e.length; n++) t = t * 33 ^ e.charCodeAt(n);
|
|
408
|
+
return (t >>> 0).toString(36);
|
|
409
|
+
}, z = (e, t) => {
|
|
410
|
+
let n = /* @__PURE__ */ new Map(), r = 0, i = (t) => {
|
|
411
|
+
if (!(t - r < e)) {
|
|
412
|
+
r = t;
|
|
413
|
+
for (let [r, i] of n) t - i.windowStart > e && n.delete(r);
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
return { allow(r) {
|
|
417
|
+
let a = Date.now();
|
|
418
|
+
i(a);
|
|
419
|
+
let o = n.get(r);
|
|
420
|
+
return !o || a - o.windowStart > e ? (n.set(r, {
|
|
421
|
+
count: 1,
|
|
422
|
+
windowStart: a
|
|
423
|
+
}), {
|
|
424
|
+
allowed: !0,
|
|
425
|
+
count: 1
|
|
426
|
+
}) : (o.count += 1, {
|
|
427
|
+
allowed: o.count <= t,
|
|
428
|
+
count: o.count
|
|
429
|
+
});
|
|
430
|
+
} };
|
|
431
|
+
}, Ie = 6e4, Le = 5, Re = /^https?:|^\/\//i, ze = (e, t) => {
|
|
432
|
+
if (t) return Re.test(t) ? e(t) : t;
|
|
433
|
+
}, Be = (e) => {
|
|
396
434
|
let t;
|
|
397
435
|
return {
|
|
398
436
|
name: "csp-violation",
|
|
399
437
|
enabled: !!e,
|
|
400
438
|
init(e) {
|
|
401
439
|
if (typeof window > "u" || typeof document > "u") return;
|
|
402
|
-
let n = (t) => {
|
|
440
|
+
let n = z(Ie, Le), r = (t) => {
|
|
441
|
+
let r = R(`${t.violatedDirective}|${t.blockedURI}|${t.sourceFile}|${t.lineNumber}`), i = n.allow(r);
|
|
442
|
+
if (!i.allowed) return;
|
|
443
|
+
let a = ze(e.config.redactUrl, t.blockedURI), s = t.sourceFile ? e.config.redactUrl(t.sourceFile) : void 0, c = i.count === 1;
|
|
403
444
|
e.emitLog({
|
|
404
445
|
severityNumber: o.WARN,
|
|
405
446
|
severityText: "WARN",
|
|
406
447
|
body: "csp.violation",
|
|
407
|
-
attributes:
|
|
408
|
-
"csp.blocked_uri":
|
|
448
|
+
attributes: k(k({}, e.config.getPageAttributes()), {}, {
|
|
449
|
+
"csp.blocked_uri": a,
|
|
409
450
|
"csp.violated_directive": t.violatedDirective,
|
|
410
451
|
"csp.effective_directive": t.effectiveDirective,
|
|
411
|
-
"csp.original_policy": t.originalPolicy,
|
|
412
452
|
"csp.disposition": t.disposition,
|
|
413
|
-
"csp.source_file":
|
|
453
|
+
"csp.source_file": s,
|
|
414
454
|
"csp.line_number": t.lineNumber,
|
|
415
455
|
"csp.column_number": t.columnNumber,
|
|
416
|
-
"csp.status_code": t.statusCode
|
|
417
|
-
|
|
456
|
+
"csp.status_code": t.statusCode,
|
|
457
|
+
"csp.fingerprint": r,
|
|
458
|
+
"csp.window_count": i.count
|
|
459
|
+
}, c ? { "csp.original_policy": t.originalPolicy } : {})
|
|
418
460
|
});
|
|
419
461
|
};
|
|
420
|
-
document.addEventListener("securitypolicyviolation",
|
|
462
|
+
document.addEventListener("securitypolicyviolation", r), t = () => document.removeEventListener("securitypolicyviolation", r);
|
|
421
463
|
},
|
|
422
464
|
shutdown() {
|
|
423
465
|
t == null || t(), t = void 0;
|
|
424
466
|
}
|
|
425
467
|
};
|
|
426
|
-
},
|
|
468
|
+
}, B = (e) => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`, Ve = "bk_ot_session_id", He = 250, Ue = () => navigator.connection, We = () => navigator.userAgentData, Ge = (e) => {
|
|
469
|
+
let t = null;
|
|
427
470
|
try {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
return {
|
|
471
|
+
t = window.localStorage.getItem(e);
|
|
472
|
+
} catch (e) {}
|
|
473
|
+
if (t) return t;
|
|
474
|
+
let n = B("device");
|
|
475
|
+
try {
|
|
476
|
+
window.localStorage.setItem(e, n);
|
|
477
|
+
} catch (e) {}
|
|
478
|
+
return n;
|
|
479
|
+
}, Ke = () => {
|
|
480
|
+
var e, t;
|
|
481
|
+
return typeof window > "u" ? {} : {
|
|
440
482
|
"browser.viewport.width": window.innerWidth,
|
|
441
483
|
"browser.viewport.height": window.innerHeight,
|
|
442
484
|
"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
|
|
485
|
+
"browser.screen.height": (t = window.screen) == null ? void 0 : t.height
|
|
445
486
|
};
|
|
446
|
-
},
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}
|
|
487
|
+
}, qe = () => {
|
|
488
|
+
let e = Ue();
|
|
489
|
+
return e ? {
|
|
490
|
+
"network.effective_type": e.effectiveType,
|
|
491
|
+
"network.connection_type": e.type,
|
|
492
|
+
"network.downlink": e.downlink,
|
|
493
|
+
"network.rtt": e.rtt,
|
|
494
|
+
"network.save_data": e.saveData
|
|
495
|
+
} : {};
|
|
496
|
+
}, Je = () => {
|
|
497
|
+
if (typeof navigator > "u") return {};
|
|
498
|
+
let e = We();
|
|
499
|
+
return {
|
|
500
|
+
"device.memory": navigator.deviceMemory,
|
|
501
|
+
"device.cpu_cores": navigator.hardwareConcurrency,
|
|
502
|
+
"device.platform": e == null ? void 0 : e.platform,
|
|
503
|
+
"device.mobile": e == null ? void 0 : e.mobile
|
|
504
|
+
};
|
|
505
|
+
}, Ye = (e, t) => {
|
|
506
|
+
let n;
|
|
507
|
+
return () => {
|
|
508
|
+
n !== void 0 && window.clearTimeout(n), n = window.setTimeout(() => {
|
|
509
|
+
n = void 0, e();
|
|
510
|
+
}, t);
|
|
511
|
+
};
|
|
512
|
+
}, Xe = (e) => {
|
|
513
|
+
let t = [];
|
|
514
|
+
return {
|
|
515
|
+
name: "device",
|
|
516
|
+
enabled: !!e,
|
|
517
|
+
init(n) {
|
|
518
|
+
var r;
|
|
519
|
+
let i = typeof e == "object" ? (r = e.storageKey) == null ? Ve : r : Ve, a = typeof window > "u" ? B("device") : Ge(i);
|
|
520
|
+
if (n.setRuntimeAttributes(k(k(k({ "device.id": a }, Je()), Ke()), qe())), typeof window > "u") return;
|
|
521
|
+
let o = Ye(() => {
|
|
522
|
+
n.setRuntimeAttributes(Ke());
|
|
523
|
+
}, He);
|
|
524
|
+
window.addEventListener("resize", o), window.addEventListener("orientationchange", o), t.push(() => window.removeEventListener("resize", o), () => window.removeEventListener("orientationchange", o));
|
|
525
|
+
let s = Ue();
|
|
526
|
+
if (s && typeof s.addEventListener == "function") {
|
|
527
|
+
let e = () => {
|
|
528
|
+
n.setRuntimeAttributes(qe());
|
|
529
|
+
};
|
|
530
|
+
s.addEventListener("change", e), t.push(() => {
|
|
531
|
+
var t;
|
|
532
|
+
(t = s.removeEventListener) == null || t.call(s, "change", e);
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
},
|
|
536
|
+
shutdown() {
|
|
537
|
+
for (; t.length;) {
|
|
538
|
+
var e;
|
|
539
|
+
(e = t.pop()) == null || e();
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
}, Ze = 6e4, Qe = 5, $e = (e) => {
|
|
455
544
|
if (e instanceof Error) return e.message;
|
|
456
545
|
if (typeof e == "string") return e;
|
|
457
546
|
try {
|
|
@@ -459,48 +548,41 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
459
548
|
} catch (t) {
|
|
460
549
|
return String(e);
|
|
461
550
|
}
|
|
462
|
-
},
|
|
551
|
+
}, et = (e) => {
|
|
463
552
|
var t;
|
|
464
553
|
return e instanceof Error ? (t = e.stack) == null ? "" : t : "";
|
|
465
|
-
},
|
|
466
|
-
let
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
},
|
|
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({
|
|
554
|
+
}, V = ({ context: e, error: r, exceptionType: i, extra: s = {}, source: c, spanName: l, throttle: u }) => {
|
|
555
|
+
let d = $e(r), f = et(r), p = R(`${c}|${d}|${f.slice(0, 256)}`), m = u.allow(p);
|
|
556
|
+
if (!m.allowed) return;
|
|
557
|
+
let h = a.getActiveSpan(), g = r instanceof Error ? r : {
|
|
558
|
+
message: d,
|
|
559
|
+
name: i == null ? c : i
|
|
560
|
+
}, _ = k(k(k({}, e.config.getPageAttributes()), e.config.getErrorAttributes()), {}, {
|
|
561
|
+
"exception.message": d,
|
|
562
|
+
"exception.stacktrace": f,
|
|
563
|
+
"exception.type": r instanceof Error ? r.name : i == null ? c : i,
|
|
564
|
+
"bk.rum.error.source": c,
|
|
565
|
+
"bk.rum.error.fingerprint": p,
|
|
566
|
+
"bk.rum.error.window_count": m.count
|
|
567
|
+
}, s), v = () => e.emitLog({
|
|
498
568
|
severityNumber: o.ERROR,
|
|
499
569
|
severityText: "ERROR",
|
|
500
|
-
body:
|
|
501
|
-
attributes:
|
|
570
|
+
body: d,
|
|
571
|
+
attributes: _
|
|
502
572
|
});
|
|
503
|
-
|
|
573
|
+
if (h) {
|
|
574
|
+
h.recordException(g), h.setStatus({
|
|
575
|
+
code: t.ERROR,
|
|
576
|
+
message: d
|
|
577
|
+
}), v();
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
let y = e.startSpan(l, _);
|
|
581
|
+
y.recordException(g), y.setStatus({
|
|
582
|
+
code: t.ERROR,
|
|
583
|
+
message: d
|
|
584
|
+
}), n.with(a.setSpan(n.active(), y), v), y.end();
|
|
585
|
+
}, tt = (e) => {
|
|
504
586
|
let t = [];
|
|
505
587
|
return {
|
|
506
588
|
name: "error",
|
|
@@ -508,22 +590,23 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
508
590
|
init(n) {
|
|
509
591
|
var r, i;
|
|
510
592
|
if (typeof window > "u") return;
|
|
511
|
-
let a =
|
|
593
|
+
let a = z(typeof e == "object" ? (r = e.windowMs) == null ? Ze : r : Ze, typeof e == "object" ? (i = e.maxPerWindow) == null ? Qe : i : Qe), o = (e) => {
|
|
512
594
|
var t;
|
|
513
|
-
|
|
595
|
+
let r = !e.error && !e.filename && e.message === "Script error.";
|
|
596
|
+
V({
|
|
514
597
|
context: n,
|
|
515
598
|
throttle: a,
|
|
516
599
|
spanName: "browser.error",
|
|
517
600
|
source: "window.error",
|
|
518
601
|
error: (t = e.error) == null ? e.message : t,
|
|
519
|
-
extra: {
|
|
602
|
+
extra: k({
|
|
520
603
|
"code.filepath": e.filename,
|
|
521
604
|
"code.lineno": e.lineno,
|
|
522
605
|
"code.column": e.colno
|
|
523
|
-
}
|
|
606
|
+
}, r ? { "bk.rum.error.cross_origin": !0 } : {})
|
|
524
607
|
});
|
|
525
608
|
}, s = (e) => {
|
|
526
|
-
|
|
609
|
+
V({
|
|
527
610
|
context: n,
|
|
528
611
|
throttle: a,
|
|
529
612
|
spanName: "browser.unhandledrejection",
|
|
@@ -532,20 +615,20 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
532
615
|
exceptionType: e.reason instanceof Error ? e.reason.name : "UnhandledRejection"
|
|
533
616
|
});
|
|
534
617
|
}, c = (e) => {
|
|
535
|
-
|
|
536
|
-
let
|
|
537
|
-
if (
|
|
538
|
-
let i = r.src || r.href || "";
|
|
539
|
-
|
|
618
|
+
if (e instanceof ErrorEvent) return;
|
|
619
|
+
let t = e.target;
|
|
620
|
+
if (!(t instanceof Element)) return;
|
|
621
|
+
let r = t, i = r.src || r.href || t.currentSrc || "";
|
|
622
|
+
V({
|
|
540
623
|
context: n,
|
|
541
624
|
throttle: a,
|
|
542
625
|
spanName: "browser.resource_error",
|
|
543
626
|
source: "resource",
|
|
544
|
-
error: /* @__PURE__ */ Error(`Resource load failed: ${
|
|
627
|
+
error: /* @__PURE__ */ Error(`Resource load failed: ${t.tagName.toLowerCase()} ${i}`),
|
|
545
628
|
exceptionType: "ResourceError",
|
|
546
629
|
extra: {
|
|
547
630
|
"url.full": n.config.redactUrl(i),
|
|
548
|
-
"html.tag":
|
|
631
|
+
"html.tag": t.tagName
|
|
549
632
|
}
|
|
550
633
|
});
|
|
551
634
|
};
|
|
@@ -558,13 +641,13 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
558
641
|
}
|
|
559
642
|
}
|
|
560
643
|
};
|
|
561
|
-
},
|
|
644
|
+
}, nt = 10 * 1024, rt = 10, H = /* @__PURE__ */ new WeakMap(), U = (e, t) => e.length <= t ? {
|
|
562
645
|
body: e,
|
|
563
646
|
truncated: !1
|
|
564
647
|
} : {
|
|
565
648
|
body: e.slice(0, t),
|
|
566
649
|
truncated: !0
|
|
567
|
-
},
|
|
650
|
+
}, it = (e, t) => {
|
|
568
651
|
if (!e) return;
|
|
569
652
|
if (e instanceof Headers) return e.get(t) || void 0;
|
|
570
653
|
let n = t.toLowerCase();
|
|
@@ -574,30 +657,30 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
574
657
|
}
|
|
575
658
|
let i = Object.keys(e).find((e) => e.toLowerCase() === n);
|
|
576
659
|
return i ? e[i] : void 0;
|
|
577
|
-
},
|
|
660
|
+
}, at = (e) => {
|
|
578
661
|
let t = {};
|
|
579
662
|
return e.forEach((e, n) => {
|
|
580
663
|
t[n] = e instanceof File ? `[File name=${e.name} type=${e.type || "unknown"} size=${e.size}]` : e;
|
|
581
664
|
}), JSON.stringify(t);
|
|
582
|
-
},
|
|
583
|
-
var e =
|
|
584
|
-
return e == null ? "" : typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : e instanceof FormData ?
|
|
665
|
+
}, ot = function() {
|
|
666
|
+
var e = F(function* (e) {
|
|
667
|
+
return e == null ? "" : typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : e instanceof FormData ? at(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
668
|
});
|
|
586
669
|
return function(t) {
|
|
587
670
|
return e.apply(this, arguments);
|
|
588
671
|
};
|
|
589
|
-
}(),
|
|
590
|
-
var e =
|
|
591
|
-
let r = yield
|
|
592
|
-
if (r) return
|
|
672
|
+
}(), st = function() {
|
|
673
|
+
var e = F(function* (e, t, n) {
|
|
674
|
+
let r = yield ot(e);
|
|
675
|
+
if (r) return k(k({}, U(r, t)), {}, { contentType: n });
|
|
593
676
|
});
|
|
594
677
|
return function(t, n, r) {
|
|
595
678
|
return e.apply(this, arguments);
|
|
596
679
|
};
|
|
597
|
-
}(),
|
|
598
|
-
var e =
|
|
680
|
+
}(), W = function() {
|
|
681
|
+
var e = F(function* (e, t, n) {
|
|
599
682
|
try {
|
|
600
|
-
return yield
|
|
683
|
+
return yield st(e, t, n);
|
|
601
684
|
} catch (e) {
|
|
602
685
|
return;
|
|
603
686
|
}
|
|
@@ -605,11 +688,11 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
605
688
|
return function(t, n, r) {
|
|
606
689
|
return e.apply(this, arguments);
|
|
607
690
|
};
|
|
608
|
-
}(),
|
|
609
|
-
var e =
|
|
610
|
-
if (t != null && t.body) return
|
|
691
|
+
}(), ct = (e) => e instanceof Request ? e.url : String(e), lt = (e, t) => t != null && t.method ? t.method : e instanceof Request ? e.method : "GET", ut = function() {
|
|
692
|
+
var e = F(function* (e, t, n) {
|
|
693
|
+
if (t != null && t.body) return W(t.body, n, it(t.headers, "content-type"));
|
|
611
694
|
if (e instanceof Request) try {
|
|
612
|
-
return
|
|
695
|
+
return W(yield e.clone().text(), n, e.headers.get("content-type") || void 0);
|
|
613
696
|
} catch (e) {
|
|
614
697
|
return;
|
|
615
698
|
}
|
|
@@ -617,11 +700,20 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
617
700
|
return function(t, n, r) {
|
|
618
701
|
return e.apply(this, arguments);
|
|
619
702
|
};
|
|
620
|
-
}(),
|
|
621
|
-
var e =
|
|
703
|
+
}(), dt = function() {
|
|
704
|
+
var e = F(function* (e, t) {
|
|
622
705
|
try {
|
|
623
|
-
let n = e.
|
|
624
|
-
|
|
706
|
+
let n = e.headers.get("content-type") || void 0, r = e.headers.get("content-length");
|
|
707
|
+
if (r) {
|
|
708
|
+
let e = Number(r);
|
|
709
|
+
if (Number.isFinite(e) && e > t * rt) return {
|
|
710
|
+
body: "",
|
|
711
|
+
contentType: n,
|
|
712
|
+
truncated: !0
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
let i = e.clone();
|
|
716
|
+
return W(i.body ? yield i.text() : "", t, n);
|
|
625
717
|
} catch (e) {
|
|
626
718
|
return;
|
|
627
719
|
}
|
|
@@ -629,30 +721,30 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
629
721
|
return function(t, n) {
|
|
630
722
|
return e.apply(this, arguments);
|
|
631
723
|
};
|
|
632
|
-
}(),
|
|
633
|
-
if (e.responseType === "" || e.responseType === "text") return
|
|
634
|
-
if (e.responseType === "json") return
|
|
635
|
-
},
|
|
636
|
-
if (n) return e.redact(
|
|
724
|
+
}(), ft = (e, t) => {
|
|
725
|
+
if (e.responseType === "" || e.responseType === "text") return k(k({}, U(e.responseText || "", t)), {}, { contentType: e.getResponseHeader("content-type") || void 0 });
|
|
726
|
+
if (e.responseType === "json") return k(k({}, U(JSON.stringify(e.response), t)), {}, { contentType: e.getResponseHeader("content-type") || void 0 });
|
|
727
|
+
}, pt = (e, t, n) => {
|
|
728
|
+
if (n) return e.redact(k(k({}, t), {}, {
|
|
637
729
|
body: n.body,
|
|
638
730
|
truncated: n.truncated
|
|
639
731
|
}));
|
|
640
|
-
},
|
|
732
|
+
}, G = ({ context: e, duration: t, error: n, method: r, request: i, response: a, status: s, url: c }) => {
|
|
641
733
|
let l = e.config.rum.httpBody;
|
|
642
734
|
if (!l) return;
|
|
643
|
-
let u = !!n || typeof s == "number" && s >= 400, d = r.toUpperCase(), f = u ?
|
|
735
|
+
let u = !!n || typeof s == "number" && s >= 400, d = r.toUpperCase(), f = u ? pt(l, {
|
|
644
736
|
contentType: i == null ? void 0 : i.contentType,
|
|
645
737
|
method: d,
|
|
646
738
|
status: s,
|
|
647
739
|
type: "request",
|
|
648
740
|
url: c
|
|
649
|
-
}, i) : void 0, p = u ?
|
|
741
|
+
}, i) : void 0, p = u ? pt(l, {
|
|
650
742
|
contentType: a == null ? void 0 : a.contentType,
|
|
651
743
|
method: d,
|
|
652
744
|
status: s,
|
|
653
745
|
type: "response",
|
|
654
746
|
url: c
|
|
655
|
-
}, a) : void 0, m =
|
|
747
|
+
}, a) : void 0, m = k(k({}, e.config.getPageAttributes()), {}, {
|
|
656
748
|
"http.duration": t,
|
|
657
749
|
"http.request.method": d,
|
|
658
750
|
"url.full": e.config.redactUrl(c)
|
|
@@ -671,76 +763,98 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
671
763
|
body: u ? "HTTP request completed with error" : "HTTP request completed",
|
|
672
764
|
attributes: m
|
|
673
765
|
});
|
|
674
|
-
},
|
|
766
|
+
}, mt = (e) => {
|
|
675
767
|
let t = [];
|
|
676
768
|
return {
|
|
677
769
|
name: "http-body",
|
|
678
770
|
enabled: !!e,
|
|
679
771
|
init(n) {
|
|
680
772
|
if (!e || typeof window > "u") return;
|
|
681
|
-
let r = e.maxBodySize ||
|
|
682
|
-
typeof i == "function"
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
773
|
+
let r = e.maxBodySize || nt, i = window.fetch;
|
|
774
|
+
if (typeof i == "function") {
|
|
775
|
+
let e = function() {
|
|
776
|
+
var e = F(function* (e, t) {
|
|
777
|
+
let a = ct(e);
|
|
778
|
+
if (I(n.config, a)) return i(e, t);
|
|
779
|
+
let o = lt(e, t), s = yield ut(e, t, r), c = performance.now();
|
|
780
|
+
try {
|
|
781
|
+
let l = yield i(e, t);
|
|
782
|
+
return G({
|
|
783
|
+
context: n,
|
|
784
|
+
duration: performance.now() - c,
|
|
785
|
+
method: o,
|
|
786
|
+
request: s,
|
|
787
|
+
response: l.status >= 400 ? yield dt(l, r) : void 0,
|
|
788
|
+
status: l.status,
|
|
789
|
+
url: a
|
|
790
|
+
}), l;
|
|
791
|
+
} catch (e) {
|
|
792
|
+
throw G({
|
|
793
|
+
context: n,
|
|
794
|
+
duration: performance.now() - c,
|
|
795
|
+
error: e,
|
|
796
|
+
method: o,
|
|
797
|
+
request: s,
|
|
798
|
+
url: a
|
|
799
|
+
}), e;
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
return function(t, n) {
|
|
803
|
+
return e.apply(this, arguments);
|
|
804
|
+
};
|
|
805
|
+
}();
|
|
806
|
+
window.fetch = e, t.push(() => {
|
|
807
|
+
window.fetch === e && (window.fetch = i);
|
|
708
808
|
});
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
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__ = {
|
|
809
|
+
}
|
|
810
|
+
let a = XMLHttpRequest.prototype.open, o = XMLHttpRequest.prototype.send, s = XMLHttpRequest.prototype.setRequestHeader, c = function(e, t, ...n) {
|
|
811
|
+
var r;
|
|
812
|
+
return H.set(this, {
|
|
718
813
|
method: e,
|
|
719
814
|
startTime: performance.now(),
|
|
720
815
|
url: String(t)
|
|
721
|
-
}, a.call(this, e, t,
|
|
722
|
-
},
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
816
|
+
}), a.call(this, e, t, (r = n[0]) == null ? !0 : r, n[1], n[2]);
|
|
817
|
+
}, l = function(e, t) {
|
|
818
|
+
let n = H.get(this);
|
|
819
|
+
if (n) {
|
|
820
|
+
var r;
|
|
821
|
+
let i = e.toLowerCase(), a = (r = n.requestHeaders) == null ? {} : r, o = a[i];
|
|
822
|
+
a[i] = o ? `${o}, ${t}` : t, n.requestHeaders = a;
|
|
823
|
+
}
|
|
824
|
+
return s.call(this, e, t);
|
|
825
|
+
}, u = function(e) {
|
|
826
|
+
var t = this;
|
|
827
|
+
let i = H.get(this);
|
|
828
|
+
if (i) {
|
|
829
|
+
var a;
|
|
830
|
+
i.requestPromise = W(e, r, (a = i.requestHeaders) == null ? void 0 : a["content-type"]);
|
|
831
|
+
}
|
|
832
|
+
return this.addEventListener("abort", () => {
|
|
833
|
+
let e = H.get(this);
|
|
834
|
+
e && (e.aborted = !0);
|
|
835
|
+
}, { once: !0 }), this.addEventListener("error", () => {
|
|
836
|
+
let e = H.get(this);
|
|
837
|
+
e && (e.networkError = !0);
|
|
838
|
+
}, { once: !0 }), this.addEventListener("loadend", () => {
|
|
839
|
+
F(function* () {
|
|
840
|
+
let e = H.get(t);
|
|
841
|
+
if (!e || I(n.config, e.url) || e.aborted) return;
|
|
842
|
+
let i = e.networkError || t.status >= 400 ? ft(t, r) : void 0, a = yield e.requestPromise;
|
|
843
|
+
G({
|
|
844
|
+
context: n,
|
|
845
|
+
duration: performance.now() - e.startTime,
|
|
846
|
+
error: e.networkError ? /* @__PURE__ */ Error("XHR network error") : void 0,
|
|
847
|
+
method: e.method,
|
|
848
|
+
request: a,
|
|
849
|
+
response: i,
|
|
850
|
+
status: t.status,
|
|
851
|
+
url: e.url
|
|
852
|
+
});
|
|
853
|
+
})();
|
|
854
|
+
}, { once: !0 }), o.call(this, e);
|
|
855
|
+
};
|
|
856
|
+
XMLHttpRequest.prototype.open = c, XMLHttpRequest.prototype.setRequestHeader = l, XMLHttpRequest.prototype.send = u, t.push(() => {
|
|
857
|
+
XMLHttpRequest.prototype.open === c && (XMLHttpRequest.prototype.open = a), XMLHttpRequest.prototype.setRequestHeader === l && (XMLHttpRequest.prototype.setRequestHeader = s), XMLHttpRequest.prototype.send === u && (XMLHttpRequest.prototype.send = o);
|
|
744
858
|
});
|
|
745
859
|
},
|
|
746
860
|
shutdown() {
|
|
@@ -750,30 +864,29 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
750
864
|
}
|
|
751
865
|
}
|
|
752
866
|
};
|
|
753
|
-
},
|
|
867
|
+
}, ht = 50, gt = (e) => {
|
|
754
868
|
let t;
|
|
755
869
|
return {
|
|
756
870
|
name: "long-task",
|
|
757
871
|
enabled: !!e,
|
|
758
872
|
init(n) {
|
|
759
|
-
var r;
|
|
760
|
-
if (typeof PerformanceObserver > "u") return;
|
|
761
|
-
let i =
|
|
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", {
|
|
873
|
+
var r, i;
|
|
874
|
+
if (typeof PerformanceObserver > "u" || !((r = PerformanceObserver.supportedEntryTypes) != null && r.includes("longtask"))) return;
|
|
875
|
+
let a = typeof e == "object" ? (i = e.threshold) == null ? ht : i : ht, 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
876
|
unit: "ms",
|
|
765
877
|
description: "Duration of long tasks"
|
|
766
878
|
});
|
|
767
879
|
try {
|
|
768
880
|
t = new PerformanceObserver((e) => {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
"long_task.
|
|
775
|
-
|
|
776
|
-
|
|
881
|
+
let t = n.applyRedact(k(k({}, n.config.getPageAttributes()), n.config.getMetricAttributes()));
|
|
882
|
+
for (let n of e.getEntries()) {
|
|
883
|
+
var r, i;
|
|
884
|
+
if (n.duration < a) continue;
|
|
885
|
+
let e = (r = n.attribution) == null ? void 0 : r[0], c = k(k({}, t), {}, {
|
|
886
|
+
"long_task.name": n.name,
|
|
887
|
+
"long_task.attribution": (i = e == null ? void 0 : e.name) == null ? "unknown" : i
|
|
888
|
+
});
|
|
889
|
+
o.add(1, c), s.record(n.duration, c);
|
|
777
890
|
}
|
|
778
891
|
}), t.observe({
|
|
779
892
|
type: "longtask",
|
|
@@ -796,11 +909,11 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
796
909
|
toUrl: n
|
|
797
910
|
};
|
|
798
911
|
for (let e of Array.from(K)) e(r);
|
|
799
|
-
},
|
|
912
|
+
}, _t = () => {
|
|
800
913
|
Q("popstate", q || Z());
|
|
801
|
-
},
|
|
914
|
+
}, vt = () => {
|
|
802
915
|
Q("hashchange", q || Z());
|
|
803
|
-
},
|
|
916
|
+
}, yt = () => {
|
|
804
917
|
X || typeof window > "u" || typeof history > "u" || (X = !0, q = Z(), J = history.pushState, Y = history.replaceState, history.pushState = function(e, t, n) {
|
|
805
918
|
let r = q || Z(), i = J == null ? void 0 : J.apply(this, [
|
|
806
919
|
e,
|
|
@@ -815,12 +928,12 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
815
928
|
n
|
|
816
929
|
]);
|
|
817
930
|
return Q("replaceState", r), i;
|
|
818
|
-
}, window.addEventListener("popstate",
|
|
819
|
-
},
|
|
820
|
-
!X || typeof window > "u" || typeof history > "u" || (J && (history.pushState = J), Y && (history.replaceState = Y), window.removeEventListener("popstate",
|
|
821
|
-
},
|
|
822
|
-
K.delete(e), K.size === 0 &&
|
|
823
|
-
}),
|
|
931
|
+
}, window.addEventListener("popstate", _t), window.addEventListener("hashchange", vt));
|
|
932
|
+
}, bt = () => {
|
|
933
|
+
!X || typeof window > "u" || typeof history > "u" || (J && (history.pushState = J), Y && (history.replaceState = Y), window.removeEventListener("popstate", _t), window.removeEventListener("hashchange", vt), J = void 0, Y = void 0, X = !1, q = "");
|
|
934
|
+
}, xt = (e) => typeof window > "u" || typeof history > "u" ? () => {} : (yt(), K.add(e), () => {
|
|
935
|
+
K.delete(e), K.size === 0 && bt();
|
|
936
|
+
}), St = () => typeof location > "u" ? "" : location.href, Ct = (e) => {
|
|
824
937
|
let t = [];
|
|
825
938
|
return {
|
|
826
939
|
name: "page-view",
|
|
@@ -828,14 +941,16 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
828
941
|
init(e) {
|
|
829
942
|
if (typeof window > "u") return;
|
|
830
943
|
let n = "", r = (t, r = n) => {
|
|
831
|
-
let i =
|
|
832
|
-
|
|
944
|
+
let i = St();
|
|
945
|
+
if (i === n) return;
|
|
946
|
+
n = i;
|
|
947
|
+
let a = t === "load";
|
|
948
|
+
e.startSpan("browser.page_view", k(k({}, e.config.getPageAttributes()), {}, {
|
|
833
949
|
"url.full": e.config.redactUrl(i),
|
|
834
950
|
"url.previous": e.config.redactUrl(r),
|
|
835
|
-
"document.referrer": e.config.redactUrl(document.referrer || ""),
|
|
836
951
|
"bk.rum.event.source": t
|
|
837
|
-
})).end()
|
|
838
|
-
}, i =
|
|
952
|
+
}, a ? { "document.referrer": e.config.redactUrl(document.referrer || "") } : {})).end();
|
|
953
|
+
}, i = xt((e) => {
|
|
839
954
|
r(e.source, e.fromUrl);
|
|
840
955
|
});
|
|
841
956
|
r("load"), t.push(i);
|
|
@@ -847,340 +962,489 @@ var V = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
847
962
|
}
|
|
848
963
|
}
|
|
849
964
|
};
|
|
850
|
-
},
|
|
851
|
-
let t = [];
|
|
965
|
+
}, wt = (e) => {
|
|
966
|
+
let t = [], n = !1;
|
|
852
967
|
return {
|
|
853
968
|
name: "route-timing",
|
|
854
969
|
enabled: !!e,
|
|
855
970
|
init(e) {
|
|
856
971
|
if (typeof window > "u" || typeof history > "u") return;
|
|
857
|
-
let
|
|
972
|
+
let r = e.meter.createHistogram("browser.route_change.duration", {
|
|
858
973
|
unit: "ms",
|
|
859
974
|
description: "Estimated SPA route change duration (route start to next idle)"
|
|
860
|
-
}),
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
n
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
"
|
|
867
|
-
|
|
975
|
+
}), i = (t, i, a) => {
|
|
976
|
+
if (n) return;
|
|
977
|
+
let o = performance.now(), s = performance.timeOrigin + o, c = () => {
|
|
978
|
+
if (n || typeof document < "u" && document.visibilityState === "hidden") return;
|
|
979
|
+
let c = performance.now() - o, l = e.applyRedact(k(k(k({}, e.config.getPageAttributes()), e.config.getMetricAttributes()), {}, { "route.change.source": t }));
|
|
980
|
+
r.record(c, l), e.startSpan("browser.route_change", k(k({}, l), {}, {
|
|
981
|
+
"url.full": e.config.redactUrl(a),
|
|
982
|
+
"url.previous": e.config.redactUrl(i),
|
|
983
|
+
"route.change.duration_ms": c
|
|
984
|
+
}), { startTime: s }).end();
|
|
868
985
|
};
|
|
869
|
-
requestAnimationFrame(() => requestAnimationFrame(() => setTimeout(
|
|
870
|
-
},
|
|
871
|
-
e.fromUrl !== e.toUrl &&
|
|
986
|
+
requestAnimationFrame(() => requestAnimationFrame(() => setTimeout(c, 0)));
|
|
987
|
+
}, a = xt((e) => {
|
|
988
|
+
e.fromUrl !== e.toUrl && i(e.source, e.fromUrl, e.toUrl);
|
|
872
989
|
});
|
|
873
|
-
t.push(
|
|
990
|
+
t.push(a);
|
|
874
991
|
},
|
|
875
992
|
shutdown() {
|
|
876
|
-
for (; t.length;) {
|
|
993
|
+
for (n = !0; t.length;) {
|
|
877
994
|
var e;
|
|
878
995
|
(e = t.pop()) == null || e();
|
|
879
996
|
}
|
|
880
997
|
}
|
|
881
998
|
};
|
|
882
|
-
},
|
|
999
|
+
}, Tt = 1800 * 1e3, Et = 1440 * 60 * 1e3, Dt = 6e4, Ot = 5e3, kt = [
|
|
1000
|
+
"click",
|
|
1001
|
+
"keydown",
|
|
1002
|
+
"scroll",
|
|
1003
|
+
"mousemove",
|
|
1004
|
+
"touchstart"
|
|
1005
|
+
], At = (e, t) => typeof e == "number" && Number.isFinite(e) && e > 0 && e <= t + Ot, jt = (e, t) => {
|
|
1006
|
+
if (!e) return null;
|
|
883
1007
|
try {
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
1008
|
+
let n = JSON.parse(e);
|
|
1009
|
+
if (typeof (n == null ? void 0 : n.id) == "string" && At(n.ts, t) && At(n.startedAt, t)) return n;
|
|
1010
|
+
} catch (e) {}
|
|
1011
|
+
return null;
|
|
1012
|
+
}, Mt = (e, t) => {
|
|
1013
|
+
if (typeof window > "u") return null;
|
|
1014
|
+
let n = null;
|
|
1015
|
+
try {
|
|
1016
|
+
n = window.localStorage.getItem(e);
|
|
1017
|
+
} catch (e) {}
|
|
1018
|
+
let r = jt(n, t);
|
|
1019
|
+
if (r) return r;
|
|
1020
|
+
try {
|
|
1021
|
+
n = window.sessionStorage.getItem(e);
|
|
1022
|
+
} catch (e) {}
|
|
1023
|
+
return r = jt(n, t), r;
|
|
1024
|
+
}, Nt = (e, t) => {
|
|
1025
|
+
if (typeof window > "u") return;
|
|
1026
|
+
let n = JSON.stringify(t);
|
|
893
1027
|
try {
|
|
894
|
-
|
|
895
|
-
window.sessionStorage.setItem(e, n), window.localStorage.setItem(e, n);
|
|
1028
|
+
window.sessionStorage.setItem(e, n);
|
|
896
1029
|
} catch (e) {}
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
1030
|
+
try {
|
|
1031
|
+
window.localStorage.setItem(e, n);
|
|
1032
|
+
} catch (e) {}
|
|
1033
|
+
}, Pt = (e, t, n) => {
|
|
1034
|
+
let r = Date.now(), i = Mt(e, r);
|
|
1035
|
+
if (i) {
|
|
1036
|
+
let a = r - i.ts >= t, o = r - i.startedAt >= n;
|
|
1037
|
+
if (!a && !o) {
|
|
1038
|
+
let t = k(k({}, i), {}, { ts: r });
|
|
1039
|
+
return Nt(e, t), {
|
|
1040
|
+
id: t.id,
|
|
1041
|
+
rotated: !1
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
1044
|
+
let s = a ? "inactivity" : "maxLifetime", c = {
|
|
1045
|
+
id: B("session"),
|
|
1046
|
+
startedAt: r,
|
|
1047
|
+
ts: r
|
|
1048
|
+
};
|
|
1049
|
+
return Nt(e, c), {
|
|
1050
|
+
id: c.id,
|
|
1051
|
+
prevId: i.id,
|
|
1052
|
+
reason: s,
|
|
1053
|
+
rotated: !0
|
|
903
1054
|
};
|
|
904
|
-
return gt(e, t), t.id;
|
|
905
1055
|
}
|
|
906
|
-
let
|
|
907
|
-
id:
|
|
908
|
-
|
|
1056
|
+
let a = {
|
|
1057
|
+
id: B("session"),
|
|
1058
|
+
startedAt: r,
|
|
1059
|
+
ts: r
|
|
909
1060
|
};
|
|
910
|
-
return
|
|
911
|
-
|
|
912
|
-
|
|
1061
|
+
return Nt(e, a), {
|
|
1062
|
+
id: a.id,
|
|
1063
|
+
reason: "init",
|
|
1064
|
+
rotated: !0
|
|
1065
|
+
};
|
|
1066
|
+
}, Ft = (e) => {
|
|
1067
|
+
let t = "";
|
|
1068
|
+
try {
|
|
1069
|
+
t = new URL(e).host;
|
|
1070
|
+
} catch (n) {
|
|
1071
|
+
t = e;
|
|
1072
|
+
}
|
|
1073
|
+
return `bk_ot_session__${R(t || "default")}`;
|
|
1074
|
+
}, It = (e, t) => {
|
|
1075
|
+
!t.rotated || !t.reason || e.emitLog({
|
|
1076
|
+
severityNumber: o.INFO,
|
|
1077
|
+
severityText: "INFO",
|
|
1078
|
+
body: t.reason === "init" ? "session.start" : "session.rotate",
|
|
1079
|
+
attributes: k(k({}, e.config.getPageAttributes()), {}, {
|
|
1080
|
+
"session.id": t.id,
|
|
1081
|
+
"session.rotate.reason": t.reason
|
|
1082
|
+
}, t.prevId ? { "session.previous_id": t.prevId } : {})
|
|
1083
|
+
});
|
|
1084
|
+
}, Lt = (e) => {
|
|
1085
|
+
let t = [];
|
|
913
1086
|
return {
|
|
914
1087
|
name: "session",
|
|
915
1088
|
enabled: !!e,
|
|
916
1089
|
init(n) {
|
|
917
|
-
var r, i;
|
|
918
|
-
let
|
|
919
|
-
|
|
920
|
-
|
|
1090
|
+
var r, i, a;
|
|
1091
|
+
let o = typeof e == "object" ? e : void 0, s = (r = o == null ? void 0 : o.storageKey) == null ? Ft(n.config.endpoint) : r, c = (i = o == null ? void 0 : o.inactivityMs) == null ? Tt : i, l = (a = o == null ? void 0 : o.maxLifetimeMs) == null ? Et : a, u = "", d = () => {
|
|
1092
|
+
if (typeof window > "u") {
|
|
1093
|
+
u || (u = B("session"), n.setRuntimeAttributes({ "session.id": u }));
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1096
|
+
let e = Pt(s, c, l);
|
|
1097
|
+
n.setRuntimeAttributes({ "session.id": e.id }), e.id !== u && (u = e.id, It(n, e));
|
|
1098
|
+
};
|
|
1099
|
+
if (d(), typeof window > "u" || typeof document > "u") return;
|
|
1100
|
+
let f = Date.now(), p = () => {
|
|
1101
|
+
let e = Date.now();
|
|
1102
|
+
e - f < Dt || (f = e, d());
|
|
1103
|
+
}, m = {
|
|
1104
|
+
capture: !0,
|
|
1105
|
+
passive: !0
|
|
1106
|
+
};
|
|
1107
|
+
kt.forEach((e) => {
|
|
1108
|
+
window.addEventListener(e, p, m);
|
|
1109
|
+
}), t.push(() => {
|
|
1110
|
+
kt.forEach((e) => {
|
|
1111
|
+
window.removeEventListener(e, p, m);
|
|
1112
|
+
});
|
|
1113
|
+
});
|
|
1114
|
+
let h = () => {
|
|
1115
|
+
document.visibilityState === "visible" && d();
|
|
921
1116
|
};
|
|
922
|
-
|
|
923
|
-
let
|
|
924
|
-
|
|
1117
|
+
document.addEventListener("visibilitychange", h), t.push(() => document.removeEventListener("visibilitychange", h));
|
|
1118
|
+
let g = (e) => {
|
|
1119
|
+
if (e.storageArea !== window.localStorage || e.key !== s || !e.newValue) return;
|
|
1120
|
+
let t = Date.now(), r = jt(e.newValue, t);
|
|
1121
|
+
if (!(!r || r.id === u)) {
|
|
1122
|
+
u = r.id;
|
|
1123
|
+
try {
|
|
1124
|
+
window.sessionStorage.setItem(s, e.newValue);
|
|
1125
|
+
} catch (e) {}
|
|
1126
|
+
n.setRuntimeAttributes({ "session.id": r.id });
|
|
1127
|
+
}
|
|
925
1128
|
};
|
|
926
|
-
|
|
1129
|
+
window.addEventListener("storage", g), t.push(() => window.removeEventListener("storage", g));
|
|
927
1130
|
},
|
|
928
1131
|
shutdown() {
|
|
929
|
-
|
|
1132
|
+
for (; t.length;) {
|
|
1133
|
+
var e;
|
|
1134
|
+
(e = t.pop()) == null || e();
|
|
1135
|
+
}
|
|
930
1136
|
}
|
|
931
1137
|
};
|
|
932
|
-
},
|
|
1138
|
+
}, Rt = "unknown", zt = (e) => e ? e.replace(/_/g, "-") : Rt, Bt = () => {
|
|
1139
|
+
if (typeof performance > "u") return Rt;
|
|
933
1140
|
let e = performance.getEntriesByType("navigation")[0];
|
|
934
|
-
return (e == null ? void 0 : e.type)
|
|
935
|
-
},
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
1141
|
+
return zt(e == null ? void 0 : e.type);
|
|
1142
|
+
}, Vt = (e, t) => {
|
|
1143
|
+
var n;
|
|
1144
|
+
return {
|
|
1145
|
+
"rum.navigation.type": (n = e.navigationType) == null ? t : n,
|
|
1146
|
+
"web_vital.name": e.name,
|
|
1147
|
+
"web_vital.rating": e.rating
|
|
1148
|
+
};
|
|
1149
|
+
}, Ht = (e, t) => {
|
|
940
1150
|
var n;
|
|
941
|
-
let r = (n = e.attribution) == null ? {} : n, i = {}, a = (e, t, n) => {
|
|
1151
|
+
let r = (n = e.attribution) == null ? {} : n, i = {}, a = (e) => r[e], o = (e, t, n) => {
|
|
942
1152
|
t != null && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") && (i[e] = typeof t == "string" && n ? n(t) : t);
|
|
943
1153
|
};
|
|
944
1154
|
switch (e.name) {
|
|
945
1155
|
case "LCP":
|
|
946
|
-
|
|
1156
|
+
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
1157
|
break;
|
|
948
1158
|
case "CLS":
|
|
949
|
-
|
|
1159
|
+
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
1160
|
break;
|
|
951
1161
|
case "INP":
|
|
952
|
-
|
|
1162
|
+
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
1163
|
break;
|
|
954
1164
|
case "FCP":
|
|
955
|
-
|
|
1165
|
+
o("web_vital.fcp.time_to_first_byte", a("timeToFirstByte")), o("web_vital.fcp.load_state", a("loadState"));
|
|
956
1166
|
break;
|
|
957
1167
|
case "TTFB":
|
|
958
|
-
|
|
1168
|
+
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
1169
|
break;
|
|
960
1170
|
default: break;
|
|
961
1171
|
}
|
|
962
1172
|
return i;
|
|
963
|
-
},
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
}),
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
1173
|
+
}, Ut = (e) => {
|
|
1174
|
+
let t = !1;
|
|
1175
|
+
return {
|
|
1176
|
+
name: "web-vitals",
|
|
1177
|
+
enabled: !!e,
|
|
1178
|
+
init(e) {
|
|
1179
|
+
return F(function* () {
|
|
1180
|
+
if (typeof window > "u") return;
|
|
1181
|
+
let n;
|
|
1182
|
+
try {
|
|
1183
|
+
n = yield import("web-vitals/attribution");
|
|
1184
|
+
} catch (t) {
|
|
1185
|
+
if (e.config.debug) {
|
|
1186
|
+
var r;
|
|
1187
|
+
(r = globalThis.console) == null || r.warn("[bk-ot] web-vitals load failed:", t);
|
|
1188
|
+
}
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
if (t) return;
|
|
1192
|
+
let { onCLS: i, onFCP: a, onINP: o, onLCP: s, onTTFB: c } = n, l = Bt(), u = e.meter.createHistogram("browser.web_vital.cls", {
|
|
1193
|
+
unit: "1",
|
|
1194
|
+
description: "Cumulative Layout Shift"
|
|
1195
|
+
}), d = e.meter.createHistogram("browser.web_vital.duration", {
|
|
1196
|
+
unit: "ms",
|
|
1197
|
+
description: "Web Vitals duration metrics, including FCP, INP, LCP and TTFB"
|
|
1198
|
+
}), f = (t) => {
|
|
1199
|
+
e.startSpan("browser.web_vital", k(k(k(k({}, e.config.getPageAttributes()), e.config.getMetricAttributes()), Vt(t, l)), {}, {
|
|
1200
|
+
"web_vital.id": t.id,
|
|
1201
|
+
"web_vital.value": t.value
|
|
1202
|
+
}, Ht(t, e.config.redactUrl))).end();
|
|
1203
|
+
}, p = (n) => {
|
|
1204
|
+
t || !Number.isFinite(n.value) || (d.record(n.value, e.applyRedact(k(k(k({}, e.config.getPageAttributes()), e.config.getMetricAttributes()), Vt(n, l)))), f(n));
|
|
1205
|
+
};
|
|
1206
|
+
i((n) => {
|
|
1207
|
+
t || !Number.isFinite(n.value) || (u.record(n.value, e.applyRedact(k(k(k({}, e.config.getPageAttributes()), e.config.getMetricAttributes()), Vt(n, l)))), f(n));
|
|
1208
|
+
}), a(p), o(p), s(p), c(p);
|
|
1209
|
+
})();
|
|
1210
|
+
},
|
|
1211
|
+
shutdown() {
|
|
1212
|
+
t = !0;
|
|
1213
|
+
}
|
|
992
1214
|
};
|
|
1215
|
+
}, Wt = 64 * 1024, Gt = 6e4, Kt = 5, qt = (e) => e == null ? 0 : typeof e == "string" ? e.length > Wt || 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, Jt = (e, t) => {
|
|
1216
|
+
let n = {
|
|
1217
|
+
"network.protocol.name": "websocket",
|
|
1218
|
+
"url.full": t(e)
|
|
1219
|
+
}, r = { "network.protocol.name": "websocket" };
|
|
993
1220
|
try {
|
|
994
|
-
|
|
1221
|
+
let t = new URL(e, typeof location > "u" ? "http://localhost" : location.href);
|
|
1222
|
+
n["server.address"] = t.host, n["url.scheme"] = t.protocol.replace(":", ""), r["server.address"] = t.host, r["url.scheme"] = n["url.scheme"];
|
|
995
1223
|
} catch (e) {}
|
|
996
1224
|
return {
|
|
997
|
-
|
|
998
|
-
|
|
1225
|
+
metricAttributes: r,
|
|
1226
|
+
spanAttributes: n
|
|
999
1227
|
};
|
|
1000
|
-
},
|
|
1001
|
-
let n
|
|
1228
|
+
}, Yt = (e, n) => {
|
|
1229
|
+
let { bytesCounter: r, connectDurationHistogram: i, context: a, errorCounter: s, errorThrottle: c, isDisposed: l, messageCounter: u, url: d } = n, { metricAttributes: f, spanAttributes: p } = Jt(d, a.config.redactUrl), m = a.startSpan("websocket.connect", p), h = performance.now(), g = !1, _ = (e) => {
|
|
1230
|
+
if (g) return;
|
|
1231
|
+
g = !0;
|
|
1232
|
+
let n = performance.now() - h;
|
|
1233
|
+
e === "error" && m.setStatus({
|
|
1234
|
+
code: t.ERROR,
|
|
1235
|
+
message: "websocket connect failed"
|
|
1236
|
+
}), m.setAttribute("websocket.connect.duration_ms", n), m.end(), e === "opened" && !l() && i.record(n, f);
|
|
1237
|
+
};
|
|
1238
|
+
e.addEventListener("open", () => {
|
|
1239
|
+
l() || _("opened");
|
|
1240
|
+
}), e.addEventListener("message", (e) => {
|
|
1241
|
+
if (l()) return;
|
|
1242
|
+
let t = k(k({}, f), {}, { "websocket.direction": "in" });
|
|
1243
|
+
u.add(1, t), r.add(qt(e.data), t);
|
|
1244
|
+
}), e.addEventListener("error", () => {
|
|
1245
|
+
if (l()) return;
|
|
1246
|
+
let e = g ? "runtime" : "connect";
|
|
1247
|
+
s.add(1, k(k({}, f), {}, { "websocket.error.phase": e })), _("error");
|
|
1248
|
+
let t = c.allow(`ws:error:${d}`);
|
|
1249
|
+
t.allowed && a.emitLog({
|
|
1250
|
+
severityNumber: o.ERROR,
|
|
1251
|
+
severityText: "ERROR",
|
|
1252
|
+
body: "websocket.error",
|
|
1253
|
+
attributes: k(k({}, p), {}, {
|
|
1254
|
+
"websocket.error.phase": e,
|
|
1255
|
+
"websocket.error.window_count": t.count
|
|
1256
|
+
})
|
|
1257
|
+
});
|
|
1258
|
+
}), e.addEventListener("close", (e) => {
|
|
1259
|
+
l() || (g || _("error"), a.emitLog({
|
|
1260
|
+
severityNumber: o.INFO,
|
|
1261
|
+
severityText: "INFO",
|
|
1262
|
+
body: "websocket.close",
|
|
1263
|
+
attributes: k(k({}, p), {}, {
|
|
1264
|
+
"websocket.close.code": e.code,
|
|
1265
|
+
"websocket.close.reason": e.reason,
|
|
1266
|
+
"websocket.close.was_clean": e.wasClean
|
|
1267
|
+
})
|
|
1268
|
+
}));
|
|
1269
|
+
});
|
|
1270
|
+
let v = e.send.bind(e);
|
|
1271
|
+
e.send = (e) => {
|
|
1272
|
+
if (!l()) {
|
|
1273
|
+
let t = k(k({}, f), {}, { "websocket.direction": "out" });
|
|
1274
|
+
u.add(1, t), r.add(qt(e), t);
|
|
1275
|
+
}
|
|
1276
|
+
return v(e);
|
|
1277
|
+
};
|
|
1278
|
+
}, Xt = (e) => {
|
|
1279
|
+
let t, n, r = !1;
|
|
1002
1280
|
return {
|
|
1003
1281
|
name: "websocket",
|
|
1004
1282
|
enabled: !!e,
|
|
1005
1283
|
init(e) {
|
|
1006
1284
|
if (typeof window > "u" || window.WebSocket === void 0) return;
|
|
1007
|
-
let
|
|
1008
|
-
|
|
1009
|
-
let
|
|
1285
|
+
let i = window.WebSocket;
|
|
1286
|
+
t = i;
|
|
1287
|
+
let a = e.meter.createCounter("browser.websocket.message.count", { description: "Total number of WebSocket messages observed" }), o = e.meter.createCounter("browser.websocket.message.bytes", {
|
|
1010
1288
|
unit: "By",
|
|
1011
1289
|
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 =
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
s
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
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;
|
|
1290
|
+
}), s = e.meter.createCounter("browser.websocket.error.count", { description: "Total number of WebSocket error events" }), c = e.meter.createHistogram("browser.websocket.connect.duration", {
|
|
1291
|
+
unit: "ms",
|
|
1292
|
+
description: "WebSocket connection establishment duration (only successful connects)"
|
|
1293
|
+
}), l = z(Gt, Kt), u = () => r;
|
|
1294
|
+
n = new Proxy(i, { construct(t, n, i) {
|
|
1295
|
+
let d = Reflect.construct(t, n, i);
|
|
1296
|
+
if (r) return d;
|
|
1297
|
+
let f = n[0] == null ? "" : String(n[0]);
|
|
1298
|
+
return !f || I(e.config, f) || Yt(d, {
|
|
1299
|
+
bytesCounter: o,
|
|
1300
|
+
connectDurationHistogram: c,
|
|
1301
|
+
context: e,
|
|
1302
|
+
errorCounter: s,
|
|
1303
|
+
errorThrottle: l,
|
|
1304
|
+
isDisposed: u,
|
|
1305
|
+
messageCounter: a,
|
|
1306
|
+
url: f
|
|
1307
|
+
}), d;
|
|
1308
|
+
} }), window.WebSocket = n;
|
|
1046
1309
|
},
|
|
1047
1310
|
shutdown() {
|
|
1048
|
-
|
|
1311
|
+
r = !0, typeof window < "u" && t && window.WebSocket === n && (window.WebSocket = t), n = void 0, t = void 0;
|
|
1049
1312
|
}
|
|
1050
1313
|
};
|
|
1051
|
-
}, $ = "__bk_ot_sampled__",
|
|
1314
|
+
}, $ = "__bk_ot_sampled__", Zt = /* @__PURE__ */ new Map(), Qt = (e) => Zt.get(e), $t = (e, t) => (Zt.set(e, t), t), en = ({ sampleRate: e }) => {
|
|
1052
1315
|
if (e <= 0) return !1;
|
|
1053
1316
|
if (e >= 1) return !0;
|
|
1054
1317
|
try {
|
|
1055
1318
|
let t = sessionStorage.getItem($);
|
|
1056
1319
|
if (t) return t === "1";
|
|
1057
1320
|
let n = Math.random() < e;
|
|
1058
|
-
return sessionStorage.setItem($, n ? "1" : "0"),
|
|
1321
|
+
return sessionStorage.setItem($, n ? "1" : "0"), $t($, n), n;
|
|
1059
1322
|
} catch (t) {
|
|
1060
|
-
let n =
|
|
1061
|
-
return typeof n == "boolean" ? n :
|
|
1323
|
+
let n = Qt($);
|
|
1324
|
+
return typeof n == "boolean" ? n : $t($, Math.random() < e);
|
|
1062
1325
|
}
|
|
1063
|
-
},
|
|
1326
|
+
}, tn = (e) => ({
|
|
1064
1327
|
url: e.endpoint,
|
|
1065
1328
|
headers: e.headers,
|
|
1066
1329
|
concurrencyLimit: e.concurrencyLimit,
|
|
1067
1330
|
timeoutMillis: e.timeoutMillis
|
|
1068
|
-
}),
|
|
1331
|
+
}), nn = "bk-rum", rn = (e, t, n) => n ? new Proxy(e, { get(e, n, r) {
|
|
1069
1332
|
if (n === "export") return (n, r) => {
|
|
1070
1333
|
var i;
|
|
1071
1334
|
return (i = globalThis.console) == null || i.log(`[bk-ot][${t}]`, n), e.export(n, r);
|
|
1072
1335
|
};
|
|
1073
1336
|
let i = Reflect.get(e, n, r);
|
|
1074
1337
|
return typeof i == "function" ? i.bind(e) : i;
|
|
1075
|
-
} }) : e,
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
],
|
|
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) => {
|
|
1338
|
+
} }) : e, an = (e) => [Fe(e.commonInstrumentations)], on = (e) => [
|
|
1339
|
+
Xe(e.rum.device),
|
|
1340
|
+
mt(e.rum.httpBody),
|
|
1341
|
+
Lt(e.rum.session),
|
|
1342
|
+
Ct(e.rum.pageView),
|
|
1343
|
+
tt(e.rum.error),
|
|
1344
|
+
Ut(e.rum.webVitals),
|
|
1345
|
+
je(e.rum.blankScreen),
|
|
1346
|
+
Xt(e.rum.websocket),
|
|
1347
|
+
gt(e.rum.longTask),
|
|
1348
|
+
Be(e.rum.cspViolation),
|
|
1349
|
+
wt(e.rum.routeTiming)
|
|
1350
|
+
], sn = class {
|
|
1351
|
+
assertBeforeStart(e) {
|
|
1352
|
+
if (this.phase !== "idle") throw Error(`[bk-ot] ${e}() must be called before start(); set autoStart: false before registration.`);
|
|
1353
|
+
}
|
|
1354
|
+
constructor(o) {
|
|
1355
|
+
var w = this;
|
|
1356
|
+
D(this, "loggerProvider", void 0), D(this, "meterProvider", void 0), D(this, "phase", "idle"), D(this, "pluginManager", void 0), D(this, "plugins", void 0), D(this, "registeredInstrumentations", void 0), D(this, "runtimeAttributes", void 0), D(this, "sampled", void 0), D(this, "teardownCallbacks", []), D(this, "tracerProvider", void 0), D(this, "applyRedact", (e) => this.config.redactAttributes(e)), D(this, "config", void 0), D(this, "emitLog", (e) => {
|
|
1113
1357
|
var t;
|
|
1114
|
-
let n =
|
|
1115
|
-
|
|
1116
|
-
},
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
if (!x) {
|
|
1122
|
-
if (b.debug) {
|
|
1358
|
+
let n = k(k({}, e), {}, { attributes: this.applyRedact(k(k({}, this.getRuntimeAttributes()), (t = e.attributes) == null ? {} : t)) });
|
|
1359
|
+
this.logger.emit(n);
|
|
1360
|
+
}), D(this, "flush", F(function* () {
|
|
1361
|
+
yield w.pluginManager.flush(), yield w.tracerProvider.forceFlush(), yield w.meterProvider.forceFlush(), yield w.loggerProvider.forceFlush();
|
|
1362
|
+
})), D(this, "getRuntimeAttributes", () => k({}, this.runtimeAttributes)), D(this, "logger", void 0), D(this, "meter", void 0), D(this, "reportCustomEvent", ({ attributes: e = {}, error: n, name: r }) => {
|
|
1363
|
+
if (!this.sampled) {
|
|
1364
|
+
if (this.config.debug) {
|
|
1123
1365
|
var i;
|
|
1124
1366
|
(i = globalThis.console) == null || i.warn("[bk-ot] custom event dropped (not sampled):", r);
|
|
1125
1367
|
}
|
|
1126
1368
|
return;
|
|
1127
1369
|
}
|
|
1128
|
-
let a =
|
|
1370
|
+
let a = this.startSpan(`custom.${r}`, k(k(k(k({}, this.config.getPageAttributes()), this.config.getCustomAttributes()), e), {}, { "rum.custom.name": r }));
|
|
1129
1371
|
n && (a.recordException(n), a.setStatus({
|
|
1130
1372
|
code: t.ERROR,
|
|
1131
1373
|
message: n.message
|
|
1132
1374
|
})), 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";
|
|
1375
|
+
}), D(this, "setRuntimeAttributes", (e) => {
|
|
1376
|
+
Object.assign(this.runtimeAttributes, e);
|
|
1377
|
+
}), D(this, "shutdown", F(function* () {
|
|
1378
|
+
if (w.phase !== "stopped") {
|
|
1379
|
+
for (yield w.flush(); w.teardownCallbacks.length;) {
|
|
1380
|
+
var e;
|
|
1381
|
+
(e = w.teardownCallbacks.pop()) == null || e();
|
|
1160
1382
|
}
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
yield
|
|
1166
|
-
}
|
|
1167
|
-
},
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
if (
|
|
1171
|
-
|
|
1383
|
+
for (yield w.pluginManager.shutdown(); w.registeredInstrumentations.length;) {
|
|
1384
|
+
var t, i;
|
|
1385
|
+
(t = w.registeredInstrumentations.pop()) == null || (i = t.disable) == null || i.call(t);
|
|
1386
|
+
}
|
|
1387
|
+
yield w.tracerProvider.shutdown(), yield w.meterProvider.shutdown(), yield w.loggerProvider.shutdown(), a.disable(), r.disable(), n.disable(), w.phase = "stopped";
|
|
1388
|
+
}
|
|
1389
|
+
})), D(this, "start", F(function* () {
|
|
1390
|
+
if (!(w.phase === "started" || w.phase === "starting")) {
|
|
1391
|
+
if (w.phase === "stopped") throw Error("[bk-ot] instance has been shut down and cannot be restarted; create a new instance instead.");
|
|
1392
|
+
if (!w.config.enabled) {
|
|
1393
|
+
w.phase = "started";
|
|
1394
|
+
return;
|
|
1395
|
+
}
|
|
1396
|
+
w.phase = "starting", i.setGlobalPropagator(new l()), w.tracerProvider.register({ contextManager: new c() }), r.setGlobalMeterProvider(w.meterProvider), s.setGlobalLoggerProvider(w.loggerProvider);
|
|
1397
|
+
try {
|
|
1398
|
+
if (w.registeredInstrumentations.length && p({
|
|
1399
|
+
instrumentations: w.registeredInstrumentations,
|
|
1400
|
+
meterProvider: w.meterProvider,
|
|
1401
|
+
tracerProvider: w.tracerProvider
|
|
1402
|
+
}), yield w.pluginManager.start(w), typeof window < "u" && typeof document < "u") {
|
|
1403
|
+
let e = () => {
|
|
1404
|
+
w.flush();
|
|
1405
|
+
}, t = () => {
|
|
1406
|
+
document.visibilityState === "hidden" && w.flush();
|
|
1407
|
+
};
|
|
1408
|
+
window.addEventListener("pagehide", e), document.addEventListener("visibilitychange", t), w.teardownCallbacks.push(() => window.removeEventListener("pagehide", e), () => document.removeEventListener("visibilitychange", t));
|
|
1409
|
+
}
|
|
1410
|
+
} catch (i) {
|
|
1411
|
+
for (; w.teardownCallbacks.length;) {
|
|
1172
1412
|
var e;
|
|
1173
|
-
(e =
|
|
1413
|
+
(e = w.teardownCallbacks.pop()) == null || e();
|
|
1414
|
+
}
|
|
1415
|
+
yield w.pluginManager.shutdown();
|
|
1416
|
+
for (let e of w.registeredInstrumentations) {
|
|
1417
|
+
var t;
|
|
1418
|
+
(t = e.disable) == null || t.call(e);
|
|
1174
1419
|
}
|
|
1175
|
-
|
|
1420
|
+
throw a.disable(), r.disable(), n.disable(), w.phase = "idle", i;
|
|
1176
1421
|
}
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1422
|
+
w.phase = "started";
|
|
1423
|
+
}
|
|
1424
|
+
})), D(this, "startSpan", (t, n = {}, r) => this.tracer.startSpan(t, {
|
|
1425
|
+
kind: e.INTERNAL,
|
|
1426
|
+
startTime: r == null ? void 0 : r.startTime,
|
|
1427
|
+
attributes: this.applyRedact(k(k({}, this.getRuntimeAttributes()), n))
|
|
1428
|
+
})), D(this, "tracer", void 0), D(this, "use", (e) => (this.assertBeforeStart("use"), this.sampled && this.plugins.push(e), this)), D(this, "useInstrumentation", (e) => (this.assertBeforeStart("useInstrumentation"), this.config.enabled && this.registeredInstrumentations.push(e), this)), this.config = le(o), this.sampled = this.config.enabled && en(this.config);
|
|
1429
|
+
let T = m(this.config.resourceAttributes), E = rn(new f(tn(this.config.traces)), "traces", this.config.debug), O = rn(new d(tn(this.config.metrics)), "metrics", this.config.debug), A = rn(new u(tn(this.config.logs)), "logs", this.config.debug), ee = new Ce(this.config.spanProcessor === "simple" ? new x(E) : new y(E, this.config.spanBatch), this.config), j = new v({
|
|
1430
|
+
exporter: O,
|
|
1431
|
+
exportIntervalMillis: this.config.metricIntervalMillis
|
|
1432
|
+
}), M = new h(A);
|
|
1433
|
+
this.tracerProvider = new C({
|
|
1434
|
+
resource: T,
|
|
1435
|
+
sampler: new b({ root: new S(+!!this.sampled) }),
|
|
1436
|
+
spanProcessors: [ee]
|
|
1437
|
+
}), this.meterProvider = new _({
|
|
1438
|
+
resource: T,
|
|
1439
|
+
readers: [j]
|
|
1440
|
+
}), this.loggerProvider = new g({
|
|
1441
|
+
resource: T,
|
|
1442
|
+
processors: [M]
|
|
1443
|
+
}), this.tracer = this.tracerProvider.getTracer(nn), this.meter = this.meterProvider.getMeter(nn), this.logger = this.loggerProvider.getLogger(nn), this.runtimeAttributes = { "bk.rum.sampled": this.sampled }, this.registeredInstrumentations = this.config.enabled ? [...this.config.instrumentations] : [], this.plugins = [...this.config.enabled ? an(this.config) : [], ...this.sampled ? [...on(this.config), ...this.config.plugins] : []], this.pluginManager = new pe(this.plugins), this.config.autoStart && this.start().catch((e) => {
|
|
1444
|
+
var t;
|
|
1445
|
+
(t = globalThis.console) == null || t.warn("[bk-ot] auto start failed:", e);
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
};
|
|
1185
1449
|
//#endregion
|
|
1186
|
-
export {
|
|
1450
|
+
export { sn as BkOpenTelemetry, Ce as FilteringSpanProcessor, je as createBlankScreenPlugin, Fe as createCommonInstrumentationsPlugin, Be as createCspViolationPlugin, Xe as createDevicePlugin, tt as createErrorPlugin, mt as createHttpBodyPlugin, gt as createLongTaskPlugin, Ct as createPageViewPlugin, fe as createPlugin, wt as createRouteTimingPlugin, Lt as createSessionPlugin, Xt as createWebSocketPlugin, Ut as createWebVitalsPlugin, le as normalizeConfig };
|