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