@blueking/open-telemetry 0.0.14 → 0.0.16
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 +96 -641
- package/dist/bk-rum.global.js +9 -9
- package/dist/bk-rum.global.js.map +1 -1
- package/dist/core/action-activity.d.ts +28 -0
- package/dist/core/config.d.ts +113 -93
- package/dist/core/page-activity.d.ts +14 -0
- package/dist/core/plugin.d.ts +23 -6
- package/dist/core/processor.d.ts +25 -4
- package/dist/core/request-timing.d.ts +5 -0
- package/dist/core/runtime-context.d.ts +51 -3
- package/dist/core/sampling.d.ts +5 -1
- package/dist/core/sdk.d.ts +29 -10
- package/dist/core/url.d.ts +4 -1
- package/dist/index.d.ts +12 -14
- package/dist/index.js +2184 -1175
- package/dist/index.js.map +1 -1
- package/dist/plugins/action.d.ts +6 -2
- package/dist/plugins/activity.d.ts +6 -0
- package/dist/plugins/blank-screen.d.ts +17 -0
- package/dist/plugins/common.d.ts +11 -3
- package/dist/plugins/device.d.ts +2 -0
- package/dist/plugins/long-task.d.ts +3 -12
- package/dist/plugins/page-view.d.ts +1 -0
- package/dist/plugins/request-body.d.ts +14 -0
- package/dist/plugins/resource.d.ts +17 -1
- package/dist/plugins/session-state.d.ts +18 -0
- package/dist/plugins/session.d.ts +4 -4
- package/dist/plugins/web-vitals.d.ts +74 -0
- package/dist/schema/attributes.d.ts +31 -10
- package/dist/schema/span.d.ts +4 -12
- package/package.json +3 -7
- package/skills/bk-rum-otele/SKILL.md +39 -33
- package/skills/bk-rum-otele/evals/evals.json +3 -3
- package/skills/bk-rum-otele/references/api.md +247 -114
- package/skills/bk-rum-otele/references/architecture.md +141 -0
- package/skills/bk-rum-otele/references/capabilities.md +100 -0
- package/skills/bk-rum-otele/references/concepts.md +40 -111
- package/skills/bk-rum-otele/references/configuration.md +202 -254
- package/skills/bk-rum-otele/references/custom-plugin.md +22 -7
- package/skills/bk-rum-otele/references/data-model.md +17 -10
- package/skills/bk-rum-otele/references/framework-integration.md +25 -17
- package/skills/bk-rum-otele/references/getting-started.md +42 -86
- package/skills/bk-rum-otele/references/plugins.md +232 -138
- package/skills/bk-rum-otele/references/privacy.md +47 -34
- package/skills/bk-rum-otele/references/telemetry-reference.md +74 -45
- package/skills/bk-rum-otele/references/transport-sampling.md +79 -0
- package/skills/bk-rum-otele/references/troubleshooting.md +71 -37
- package/dist/plugins/http-body.d.ts +0 -3
- package/dist/plugins/route-timing.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -1,38 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { OTLPLogExporter as
|
|
6
|
-
import { OTLPMetricExporter as
|
|
7
|
-
import { OTLPTraceExporter as
|
|
8
|
-
import { registerInstrumentations as
|
|
9
|
-
import { resourceFromAttributes as
|
|
10
|
-
import { BatchLogRecordProcessor as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
1
|
+
import { ExportResultCode as e, W3CTraceContextPropagator as t, hrTimeToMilliseconds as n, timeInputToHrTime as r } from "@opentelemetry/core";
|
|
2
|
+
import { AggregationTemporality as i, MeterProvider as a, PeriodicExportingMetricReader as o } from "@opentelemetry/sdk-metrics";
|
|
3
|
+
import { SpanKind as s, SpanStatusCode as c, context as l, propagation as u, trace as d } from "@opentelemetry/api";
|
|
4
|
+
import { ZoneContextManager as f } from "@opentelemetry/context-zone";
|
|
5
|
+
import { OTLPLogExporter as p } from "@opentelemetry/exporter-logs-otlp-http";
|
|
6
|
+
import { AggregationTemporalityPreference as m, OTLPMetricExporter as h } from "@opentelemetry/exporter-metrics-otlp-http";
|
|
7
|
+
import { OTLPTraceExporter as g } from "@opentelemetry/exporter-trace-otlp-http";
|
|
8
|
+
import { registerInstrumentations as _ } from "@opentelemetry/instrumentation";
|
|
9
|
+
import { resourceFromAttributes as v } from "@opentelemetry/resources";
|
|
10
|
+
import { BatchLogRecordProcessor as y, LoggerProvider as b } from "@opentelemetry/sdk-logs";
|
|
11
|
+
import { BatchSpanProcessor as x, SamplingDecision as S, SimpleSpanProcessor as C } from "@opentelemetry/sdk-trace-base";
|
|
12
|
+
import { WebTracerProvider as ee } from "@opentelemetry/sdk-trace-web";
|
|
13
|
+
import { SeverityNumber as w } from "@opentelemetry/api-logs";
|
|
14
14
|
//#region src/schema/attributes.ts
|
|
15
|
-
var
|
|
15
|
+
var T = {
|
|
16
|
+
actionErrorCount: "action.error.count",
|
|
17
|
+
actionFrustrationCount: "action.frustration.count",
|
|
18
|
+
actionFrustrationType: "action.frustration.type",
|
|
19
|
+
actionId: "action.id",
|
|
20
|
+
actionLoadingTime: "action.loading_time",
|
|
21
|
+
actionLongTaskCount: "action.long_task.count",
|
|
22
|
+
actionName: "action.name",
|
|
23
|
+
actionResourceCount: "action.resource.count",
|
|
24
|
+
actionTargetName: "action.target.name",
|
|
25
|
+
actionTargetTag: "action.target.tag",
|
|
16
26
|
actionType: "action.type",
|
|
17
27
|
deploymentEnvironmentName: "deployment.environment.name",
|
|
18
|
-
browserName: "
|
|
19
|
-
browserVersion: "
|
|
20
|
-
cacheHit: "
|
|
21
|
-
deviceType: "
|
|
28
|
+
browserName: "browser.name",
|
|
29
|
+
browserVersion: "browser.version",
|
|
30
|
+
cacheHit: "resource.cache.hit",
|
|
31
|
+
deviceType: "device.type",
|
|
22
32
|
durationBucket: "duration_bucket",
|
|
23
33
|
errorType: "error_type",
|
|
24
34
|
eventLabel: "event_label",
|
|
25
35
|
exceptionFingerprint: "exception.fingerprint",
|
|
26
36
|
exceptionMessageShort: "exception.message_short",
|
|
27
37
|
exceptionStackTopFrame: "exception.stack_top_frame",
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
longTaskBlockingDuration: "long_task.blocking_duration",
|
|
39
|
+
longTaskCulprit: "long_task.culprit",
|
|
40
|
+
longTaskDuration: "long_task.duration",
|
|
41
|
+
longTaskEntryType: "long_task.entry_type",
|
|
42
|
+
longTaskId: "long_task.id",
|
|
43
|
+
longTaskIsFrozenFrame: "long_task.is_frozen_frame",
|
|
44
|
+
longTaskScriptCount: "long_task.script.count",
|
|
45
|
+
longTaskStartTime: "long_task.start_time",
|
|
30
46
|
networkEffectiveType: "network.effective_type",
|
|
31
|
-
nextHopProtocol: "
|
|
47
|
+
nextHopProtocol: "resource.protocol",
|
|
32
48
|
result: "result",
|
|
33
49
|
serviceName: "service.name",
|
|
34
50
|
serviceVersion: "service.version",
|
|
35
|
-
osName: "
|
|
51
|
+
osName: "os.name",
|
|
36
52
|
sessionHasReplay: "session.has_replay",
|
|
37
53
|
sessionId: "session.id",
|
|
38
54
|
sessionStartTime: "session.start_time",
|
|
@@ -42,8 +58,6 @@ var x = {
|
|
|
42
58
|
targetDomain: "target_domain",
|
|
43
59
|
targetLabel: "target_label",
|
|
44
60
|
targetPathTemplate: "target_path_template",
|
|
45
|
-
targetTag: "target.tag",
|
|
46
|
-
targetTextShort: "target.text_short",
|
|
47
61
|
targetValue: "target_value",
|
|
48
62
|
traceScene: "trace_scene",
|
|
49
63
|
transferSize: "transfer_size",
|
|
@@ -51,43 +65,50 @@ var x = {
|
|
|
51
65
|
vitalMetric: "vital.metric",
|
|
52
66
|
vitalRating: "vital.rating",
|
|
53
67
|
vitalValue: "vital.value",
|
|
68
|
+
viewDomComplete: "view.dom_complete",
|
|
69
|
+
viewDomContentLoaded: "view.dom_content_loaded",
|
|
70
|
+
viewDomInteractive: "view.dom_interactive",
|
|
71
|
+
viewFirstByte: "view.first_byte",
|
|
54
72
|
viewId: "view.id",
|
|
73
|
+
viewLoadEvent: "view.load_event",
|
|
74
|
+
viewLoadingTime: "view.loading_time",
|
|
55
75
|
viewLoadingType: "view.loading_type",
|
|
76
|
+
viewName: "view.name",
|
|
56
77
|
viewUrl: "view.url",
|
|
57
78
|
viewUrlPathGroup: "view.url_path_group"
|
|
58
79
|
};
|
|
59
80
|
//#endregion
|
|
60
81
|
//#region \0@oxc-project+runtime@0.128.0/helpers/typeof.js
|
|
61
|
-
function
|
|
82
|
+
function E(e) {
|
|
62
83
|
"@babel/helpers - typeof";
|
|
63
|
-
return
|
|
84
|
+
return E = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
64
85
|
return typeof e;
|
|
65
86
|
} : function(e) {
|
|
66
87
|
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
67
|
-
},
|
|
88
|
+
}, E(e);
|
|
68
89
|
}
|
|
69
90
|
//#endregion
|
|
70
91
|
//#region \0@oxc-project+runtime@0.128.0/helpers/toPrimitive.js
|
|
71
|
-
function
|
|
72
|
-
if (
|
|
92
|
+
function te(e, t) {
|
|
93
|
+
if (E(e) != "object" || !e) return e;
|
|
73
94
|
var n = e[Symbol.toPrimitive];
|
|
74
95
|
if (n !== void 0) {
|
|
75
96
|
var r = n.call(e, t || "default");
|
|
76
|
-
if (
|
|
97
|
+
if (E(r) != "object") return r;
|
|
77
98
|
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
78
99
|
}
|
|
79
100
|
return (t === "string" ? String : Number)(e);
|
|
80
101
|
}
|
|
81
102
|
//#endregion
|
|
82
103
|
//#region \0@oxc-project+runtime@0.128.0/helpers/toPropertyKey.js
|
|
83
|
-
function
|
|
84
|
-
var t =
|
|
85
|
-
return
|
|
104
|
+
function ne(e) {
|
|
105
|
+
var t = te(e, "string");
|
|
106
|
+
return E(t) == "symbol" ? t : t + "";
|
|
86
107
|
}
|
|
87
108
|
//#endregion
|
|
88
109
|
//#region \0@oxc-project+runtime@0.128.0/helpers/defineProperty.js
|
|
89
|
-
function
|
|
90
|
-
return (t =
|
|
110
|
+
function D(e, t, n) {
|
|
111
|
+
return (t = ne(t)) in e ? Object.defineProperty(e, t, {
|
|
91
112
|
value: n,
|
|
92
113
|
enumerable: !0,
|
|
93
114
|
configurable: !0,
|
|
@@ -96,7 +117,7 @@ function w(e, t, n) {
|
|
|
96
117
|
}
|
|
97
118
|
//#endregion
|
|
98
119
|
//#region \0@oxc-project+runtime@0.128.0/helpers/objectSpread2.js
|
|
99
|
-
function
|
|
120
|
+
function re(e, t) {
|
|
100
121
|
var n = Object.keys(e);
|
|
101
122
|
if (Object.getOwnPropertySymbols) {
|
|
102
123
|
var r = Object.getOwnPropertySymbols(e);
|
|
@@ -106,12 +127,12 @@ function T(e, t) {
|
|
|
106
127
|
}
|
|
107
128
|
return n;
|
|
108
129
|
}
|
|
109
|
-
function
|
|
130
|
+
function O(e) {
|
|
110
131
|
for (var t = 1; t < arguments.length; t++) {
|
|
111
132
|
var n = arguments[t] == null ? {} : arguments[t];
|
|
112
|
-
t % 2 ?
|
|
113
|
-
|
|
114
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) :
|
|
133
|
+
t % 2 ? re(Object(n), !0).forEach(function(t) {
|
|
134
|
+
D(e, t, n[t]);
|
|
135
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : re(Object(n)).forEach(function(t) {
|
|
115
136
|
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
|
|
116
137
|
});
|
|
117
138
|
}
|
|
@@ -119,81 +140,130 @@ function E(e) {
|
|
|
119
140
|
}
|
|
120
141
|
//#endregion
|
|
121
142
|
//#region src/core/config.ts
|
|
122
|
-
var
|
|
143
|
+
var ie = 60 * 1e3, ae = (e) => e.trim().replace(/\/+$/, ""), oe = {
|
|
123
144
|
traces: "rum",
|
|
124
145
|
metrics: "metrics",
|
|
125
146
|
logs: "logs"
|
|
126
|
-
}, se = (e, t) => `${
|
|
127
|
-
var n, r, i
|
|
128
|
-
let
|
|
147
|
+
}, se = (e, t) => `${ae(e == null ? "" : e)}/v1/${oe[t]}`, ce = (e, t) => {
|
|
148
|
+
var n, r, i;
|
|
149
|
+
let a = (n = e.signals) == null ? void 0 : n[t];
|
|
150
|
+
if (a === !1) return !1;
|
|
151
|
+
let o = a == null ? void 0 : a.endpoint, s = e.token || e.headers || a != null && a.headers ? O(O(O({}, e.token ? { Authorization: `Bearer ${e.token}` } : {}), (r = e.headers) == null ? {} : r), (i = a == null ? void 0 : a.headers) == null ? {} : i) : void 0;
|
|
129
152
|
return {
|
|
130
|
-
concurrencyLimit:
|
|
131
|
-
endpoint:
|
|
132
|
-
headers:
|
|
133
|
-
timeoutMillis:
|
|
153
|
+
concurrencyLimit: a == null ? void 0 : a.concurrencyLimit,
|
|
154
|
+
endpoint: o ? ae(o) : se(e.endpoint, t),
|
|
155
|
+
headers: s,
|
|
156
|
+
timeoutMillis: a == null ? void 0 : a.timeoutMillis
|
|
134
157
|
};
|
|
135
|
-
},
|
|
158
|
+
}, le = (e) => typeof e != "number" || !Number.isFinite(e) ? 1 : Math.max(0, Math.min(1, e)), ue = (e) => e, de = (e) => {
|
|
159
|
+
try {
|
|
160
|
+
let t = new URL(e, typeof location > "u" ? "http://localhost" : location.href);
|
|
161
|
+
return t.username = "", t.password = "", t.search = "", t.hash = "", t.href;
|
|
162
|
+
} catch (t) {
|
|
163
|
+
return e.replace(/[?#].*$/, "");
|
|
164
|
+
}
|
|
165
|
+
}, fe = (e) => {
|
|
136
166
|
try {
|
|
137
167
|
return new URL(e, typeof location > "u" ? "http://localhost" : location.href).pathname || "/";
|
|
138
168
|
} catch (t) {
|
|
139
169
|
return e || "/";
|
|
140
170
|
}
|
|
141
|
-
},
|
|
142
|
-
var t
|
|
171
|
+
}, pe = (e) => {
|
|
172
|
+
var t;
|
|
143
173
|
return {
|
|
144
|
-
environment: (t = e
|
|
145
|
-
name:
|
|
146
|
-
version: e
|
|
174
|
+
environment: (t = e.environment) == null ? "production" : t,
|
|
175
|
+
name: e.name,
|
|
176
|
+
version: e.version
|
|
147
177
|
};
|
|
148
|
-
},
|
|
149
|
-
[
|
|
178
|
+
}, me = (e) => O(O({
|
|
179
|
+
[T.deploymentEnvironmentName]: e.environment,
|
|
150
180
|
"rum.provider": "blueking",
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
181
|
+
"rum.schema.version": "1",
|
|
182
|
+
[T.serviceName]: e.name
|
|
183
|
+
}, e.version ? { [T.serviceVersion]: e.version } : {}), {}, {
|
|
184
|
+
"telemetry.sdk.language": "webjs",
|
|
185
|
+
"telemetry.sdk.name": "@blueking/open-telemetry"
|
|
186
|
+
}), he = (e) => {
|
|
187
|
+
var t, n;
|
|
188
|
+
let r = ce(e, "traces"), i = ce(e, "metrics"), a = ce(e, "logs");
|
|
189
|
+
return {
|
|
190
|
+
endpoint: ae((t = e.endpoint) == null ? "" : t) || ((n = [
|
|
191
|
+
r,
|
|
192
|
+
i,
|
|
193
|
+
a
|
|
194
|
+
].find((e) => e !== !1)) == null ? void 0 : n.endpoint) || "",
|
|
195
|
+
traces: r,
|
|
196
|
+
metrics: i,
|
|
197
|
+
logs: a
|
|
198
|
+
};
|
|
199
|
+
}, ge = (e) => {
|
|
200
|
+
if (!e) throw Error("[bk-ot] transport is required.");
|
|
201
|
+
let t = [
|
|
202
|
+
"traces",
|
|
203
|
+
"metrics",
|
|
204
|
+
"logs"
|
|
205
|
+
].filter((t) => {
|
|
206
|
+
var n;
|
|
207
|
+
return ((n = e.signals) == null ? void 0 : n[t]) !== !1;
|
|
208
|
+
});
|
|
209
|
+
if (!t.length) throw Error("[bk-ot] at least one transport signal must be enabled.");
|
|
210
|
+
for (let i of t) {
|
|
211
|
+
var n, r;
|
|
212
|
+
let t = (n = e.signals) == null ? void 0 : n[i], a = t ? t.endpoint : void 0;
|
|
213
|
+
if (!(a != null && a.trim()) && !((r = e.endpoint) != null && r.trim())) throw Error(`[bk-ot] transport.signals.${i}.endpoint or transport.endpoint is required.`);
|
|
214
|
+
}
|
|
215
|
+
}, _e = (e) => {
|
|
216
|
+
var t, n, r, i, a, o, s, c, l, u, d, f, p;
|
|
159
217
|
return {
|
|
160
|
-
|
|
218
|
+
beforeSend: (t = e.tracking) == null ? void 0 : t.beforeSend,
|
|
219
|
+
getPageAttributes: (n = (r = e.context) == null || (r = r.attributes) == null ? void 0 : r.page) == null ? (() => ({
|
|
161
220
|
"rum.page.host": typeof window > "u" ? "" : window.location.host,
|
|
162
221
|
"rum.page.path": typeof window > "u" ? "" : window.location.pathname
|
|
163
|
-
})) :
|
|
164
|
-
getMetricAttributes: (
|
|
165
|
-
getErrorAttributes: (
|
|
166
|
-
getCustomAttributes: (
|
|
222
|
+
})) : n,
|
|
223
|
+
getMetricAttributes: (i = (a = e.context) == null || (a = a.attributes) == null ? void 0 : a.metric) == null ? (() => ({})) : i,
|
|
224
|
+
getErrorAttributes: (o = (s = e.context) == null || (s = s.attributes) == null ? void 0 : s.error) == null ? (() => ({})) : o,
|
|
225
|
+
getCustomAttributes: (c = (l = e.context) == null || (l = l.attributes) == null ? void 0 : l.custom) == null ? (() => ({})) : c,
|
|
167
226
|
getViewPathGroup: (t) => {
|
|
168
|
-
var n, r, i;
|
|
169
|
-
return (n = (r = e.
|
|
227
|
+
var n, r, i, a;
|
|
228
|
+
return (n = typeof ((r = e.tracking) == null ? void 0 : r.view) == "object" ? (i = (a = e.tracking.view).getPathGroup) == null ? void 0 : i.call(a, t) : void 0) == null ? fe(t) : n;
|
|
170
229
|
},
|
|
171
|
-
redactAttributes: (
|
|
172
|
-
redactUrl: (
|
|
230
|
+
redactAttributes: (u = (d = e.privacy) == null ? void 0 : d.redactAttributes) == null ? ue : u,
|
|
231
|
+
redactUrl: (f = (p = e.privacy) == null ? void 0 : p.redactUrl) == null ? de : f
|
|
173
232
|
};
|
|
174
|
-
},
|
|
175
|
-
var t, n, r, i, a, o;
|
|
176
|
-
|
|
233
|
+
}, ve = (e) => {
|
|
234
|
+
var t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _, v;
|
|
235
|
+
if (!(!((t = e.application) == null || (t = t.name) == null) && t.trim())) throw Error("[bk-ot] application.name is required.");
|
|
236
|
+
ge(e.transport);
|
|
237
|
+
let y = pe(e.application), b = typeof ((n = e.tracking) == null ? void 0 : n.view) == "object" ? e.tracking.view : void 0, x = (r = e.transport.signals) == null ? void 0 : r.traces, S = (i = e.transport.signals) == null ? void 0 : i.metrics;
|
|
177
238
|
return {
|
|
178
|
-
|
|
179
|
-
autoStart: (
|
|
180
|
-
debug: (
|
|
181
|
-
enabled: (
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
239
|
+
application: y,
|
|
240
|
+
autoStart: (a = e.autoStart) == null ? !0 : a,
|
|
241
|
+
debug: (o = e.debug) == null ? !1 : o,
|
|
242
|
+
enabled: (s = e.enabled) == null ? !0 : s,
|
|
243
|
+
extensions: {
|
|
244
|
+
instrumentations: [...(c = (l = e.extensions) == null ? void 0 : l.instrumentations) == null ? [] : c],
|
|
245
|
+
plugins: [...(u = (d = e.extensions) == null ? void 0 : d.plugins) == null ? [] : u]
|
|
246
|
+
},
|
|
247
|
+
hooks: _e(e),
|
|
248
|
+
metricIntervalMillis: S ? (f = S.intervalMillis) == null ? ie : f : ie,
|
|
249
|
+
resourceAttributes: me(y),
|
|
250
|
+
session: O(O({}, e.session), {}, { sampleRate: le((p = e.session) == null ? void 0 : p.sampleRate) }),
|
|
251
|
+
spanBatch: x ? x.batch : void 0,
|
|
252
|
+
spanProcessor: x ? (m = x.processor) == null ? "batch" : m : "batch",
|
|
253
|
+
tracking: (h = e.tracking) == null ? {} : h,
|
|
254
|
+
trackingConsent: (g = (_ = e.privacy) == null ? void 0 : _.trackingConsent) == null ? "granted" : g,
|
|
255
|
+
transport: he(e.transport),
|
|
256
|
+
user: (v = e.context) == null ? void 0 : v.user,
|
|
257
|
+
view: {
|
|
258
|
+
excludedActivityUrls: b == null ? void 0 : b.excludedActivityUrls,
|
|
259
|
+
loadingTime: (b == null ? void 0 : b.loadingTime) !== !1,
|
|
260
|
+
tracking: (b == null ? void 0 : b.tracking) === "manual" ? "manual" : "auto"
|
|
261
|
+
}
|
|
192
262
|
};
|
|
193
263
|
};
|
|
194
264
|
//#endregion
|
|
195
265
|
//#region \0@oxc-project+runtime@0.128.0/helpers/asyncToGenerator.js
|
|
196
|
-
function
|
|
266
|
+
function ye(e, t, n, r, i, a, o) {
|
|
197
267
|
try {
|
|
198
268
|
var s = e[a](o), c = s.value;
|
|
199
269
|
} catch (e) {
|
|
@@ -202,16 +272,16 @@ function ve(e, t, n, r, i, a, o) {
|
|
|
202
272
|
}
|
|
203
273
|
s.done ? t(c) : Promise.resolve(c).then(r, i);
|
|
204
274
|
}
|
|
205
|
-
function
|
|
275
|
+
function k(e) {
|
|
206
276
|
return function() {
|
|
207
277
|
var t = this, n = arguments;
|
|
208
278
|
return new Promise(function(r, i) {
|
|
209
279
|
var a = e.apply(t, n);
|
|
210
280
|
function o(e) {
|
|
211
|
-
|
|
281
|
+
ye(a, r, i, o, s, "next", e);
|
|
212
282
|
}
|
|
213
283
|
function s(e) {
|
|
214
|
-
|
|
284
|
+
ye(a, r, i, o, s, "throw", e);
|
|
215
285
|
}
|
|
216
286
|
o(void 0);
|
|
217
287
|
});
|
|
@@ -219,13 +289,13 @@ function A(e) {
|
|
|
219
289
|
}
|
|
220
290
|
//#endregion
|
|
221
291
|
//#region src/core/plugin.ts
|
|
222
|
-
var
|
|
292
|
+
var be = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !== !1, xe = (e) => e, Se = class {
|
|
223
293
|
constructor(e) {
|
|
224
|
-
|
|
294
|
+
D(this, "plugins", void 0), D(this, "startedPlugins", []), this.plugins = e;
|
|
225
295
|
}
|
|
226
296
|
flush() {
|
|
227
297
|
var e = this;
|
|
228
|
-
return
|
|
298
|
+
return k(function* () {
|
|
229
299
|
yield Promise.all(e.startedPlugins.map((e) => Promise.resolve().then(() => {
|
|
230
300
|
var t;
|
|
231
301
|
return (t = e.flush) == null ? void 0 : t.call(e);
|
|
@@ -234,7 +304,7 @@ var ye = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
234
304
|
}
|
|
235
305
|
shutdown() {
|
|
236
306
|
var e = this;
|
|
237
|
-
return
|
|
307
|
+
return k(function* () {
|
|
238
308
|
let t = [...e.startedPlugins].reverse();
|
|
239
309
|
for (let e of t) {
|
|
240
310
|
var n;
|
|
@@ -245,8 +315,8 @@ var ye = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
245
315
|
}
|
|
246
316
|
start(e) {
|
|
247
317
|
var t = this;
|
|
248
|
-
return
|
|
249
|
-
for (let r of t.plugins) if (
|
|
318
|
+
return k(function* () {
|
|
319
|
+
for (let r of t.plugins) if (be(r, e.config)) try {
|
|
250
320
|
yield r.init(e), t.startedPlugins.push(r);
|
|
251
321
|
} catch (t) {
|
|
252
322
|
if (e.config.debug) {
|
|
@@ -256,64 +326,207 @@ var ye = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
256
326
|
}
|
|
257
327
|
})();
|
|
258
328
|
}
|
|
259
|
-
},
|
|
329
|
+
}, A = "bk.rum.sampled", Ce = (e) => {
|
|
330
|
+
let t = 2166136261;
|
|
331
|
+
for (let n = 0; n < e.length; n += 1) t = Math.imul(t ^ e.charCodeAt(n), 16777619);
|
|
332
|
+
return t += t << 13, t ^= t >>> 7, t += t << 3, t ^= t >>> 17, t += t << 5, (t >>> 0) / 4294967296;
|
|
333
|
+
}, we = ({ application: e, session: t }, n) => t.sampleRate <= 0 ? !1 : t.sampleRate >= 1 ? !0 : Ce(`${e.name}\0${n}`) < t.sampleRate, Te = () => typeof window > "u" ? "http://localhost" : window.location.origin, j = (e) => {
|
|
260
334
|
try {
|
|
261
|
-
return new URL(e,
|
|
335
|
+
return new URL(e, Te()).href;
|
|
262
336
|
} catch (t) {
|
|
263
337
|
return e;
|
|
264
338
|
}
|
|
265
|
-
},
|
|
266
|
-
let n = (e) =>
|
|
339
|
+
}, Ee = (e) => e.length > 1 ? e.replace(/\/+$/, "") : e, De = (e, t) => {
|
|
340
|
+
let n = (e) => Ee(e.replace(/[?#].*$/, ""));
|
|
267
341
|
return n(e) === n(t);
|
|
268
|
-
},
|
|
269
|
-
try {
|
|
270
|
-
return new URL(e, Se()).origin === Se();
|
|
271
|
-
} catch (e) {
|
|
272
|
-
return !1;
|
|
273
|
-
}
|
|
274
|
-
}, Ee = (e, t) => {
|
|
342
|
+
}, Oe = (e, t) => {
|
|
275
343
|
let n = j(t);
|
|
276
344
|
return [
|
|
277
|
-
e.transport.traces
|
|
278
|
-
e.transport.metrics
|
|
279
|
-
e.transport.logs
|
|
280
|
-
].some((e) =>
|
|
281
|
-
},
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
345
|
+
e.transport.traces,
|
|
346
|
+
e.transport.metrics,
|
|
347
|
+
e.transport.logs
|
|
348
|
+
].filter((e) => e !== !1).some((e) => De(n, j(e.endpoint)));
|
|
349
|
+
}, ke = (e, t) => Oe(e, t), Ae = (e, t) => typeof e == "function" ? e(t) : typeof e == "string" ? t.includes(e) : (e.lastIndex = 0, e.test(t)), M = (e, t) => (Array.isArray(e) ? e : e ? [e] : []).some((e) => Ae(e, t)), je = (e) => typeof e.tracking.request == "object" ? e.tracking.request : void 0, Me = (e, t) => {
|
|
350
|
+
var n;
|
|
351
|
+
return ke(e, t) || M((n = je(e)) == null ? void 0 : n.excludedUrls, j(t));
|
|
352
|
+
}, Ne = (e, t) => {
|
|
353
|
+
var n;
|
|
354
|
+
return e.transport.traces !== !1 && M((n = je(e)) == null ? void 0 : n.allowedTracingUrls, j(t));
|
|
355
|
+
};
|
|
356
|
+
//#endregion
|
|
357
|
+
//#region \0@oxc-project+runtime@0.128.0/helpers/objectWithoutPropertiesLoose.js
|
|
358
|
+
function Pe(e, t) {
|
|
359
|
+
if (e == null) return {};
|
|
360
|
+
var n = {};
|
|
361
|
+
for (var r in e) if ({}.hasOwnProperty.call(e, r)) {
|
|
362
|
+
if (t.includes(r)) continue;
|
|
363
|
+
n[r] = e[r];
|
|
364
|
+
}
|
|
365
|
+
return n;
|
|
366
|
+
}
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region \0@oxc-project+runtime@0.128.0/helpers/objectWithoutProperties.js
|
|
369
|
+
function Fe(e, t) {
|
|
370
|
+
if (e == null) return {};
|
|
371
|
+
var n, r, i = Pe(e, t);
|
|
372
|
+
if (Object.getOwnPropertySymbols) {
|
|
373
|
+
var a = Object.getOwnPropertySymbols(e);
|
|
374
|
+
for (r = 0; r < a.length; r++) n = a[r], t.includes(n) || {}.propertyIsEnumerable.call(e, n) && (i[n] = e[n]);
|
|
375
|
+
}
|
|
376
|
+
return i;
|
|
377
|
+
}
|
|
378
|
+
//#endregion
|
|
379
|
+
//#region src/core/processor.ts
|
|
380
|
+
var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
381
|
+
for (let n of Ie) {
|
|
287
382
|
var t;
|
|
288
383
|
let r = (t = e.attributes) == null ? void 0 : t[n];
|
|
289
384
|
if (typeof r == "string") return r;
|
|
290
385
|
}
|
|
291
|
-
},
|
|
386
|
+
}, ze = (e) => {
|
|
387
|
+
let t = e == null ? void 0 : e[T.sessionId];
|
|
388
|
+
return typeof t == "string" && t.length > 0;
|
|
389
|
+
}, Be = (e) => {
|
|
390
|
+
let t = e == null ? void 0 : e[T.viewId];
|
|
391
|
+
return typeof t == "string" && t.length > 0;
|
|
392
|
+
}, Ve = (e) => (e == null ? void 0 : e["bk.rum.sampled"]) === !0 && ze(e) && Be(e), He = class {
|
|
292
393
|
constructor(e, t) {
|
|
293
394
|
this.inner = e, this.config = t;
|
|
294
395
|
}
|
|
396
|
+
enabled(e) {
|
|
397
|
+
var t, n, r;
|
|
398
|
+
return (t = (n = (r = this.inner).enabled) == null ? void 0 : n.call(r, e)) == null ? !0 : t;
|
|
399
|
+
}
|
|
400
|
+
forceFlush() {
|
|
401
|
+
return this.inner.forceFlush();
|
|
402
|
+
}
|
|
403
|
+
onEmit(e, t) {
|
|
404
|
+
var n;
|
|
405
|
+
let r = e.body === "session.start" || e.body === "session.rotate";
|
|
406
|
+
if (Ve(e.attributes) || r && ((n = e.attributes) == null ? void 0 : n["bk.rum.sampled"]) === !0 && ze(e.attributes)) {
|
|
407
|
+
delete e.attributes[A];
|
|
408
|
+
try {
|
|
409
|
+
var i, a, o, s, c;
|
|
410
|
+
if (((i = this.config) == null || (o = (a = i.hooks).beforeSend) == null ? void 0 : o.call(a, {
|
|
411
|
+
attributes: e.attributes,
|
|
412
|
+
name: (s = e.eventName) == null ? String((c = e.body) == null ? "" : c) : s,
|
|
413
|
+
signal: "log"
|
|
414
|
+
})) === !1) return;
|
|
415
|
+
} catch (e) {
|
|
416
|
+
var l, u;
|
|
417
|
+
(l = this.config) != null && l.debug && ((u = globalThis.console) == null || u.warn("[bk-ot] tracking.beforeSend failed:", e));
|
|
418
|
+
}
|
|
419
|
+
this.inner.onEmit(e, t);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
shutdown() {
|
|
423
|
+
return this.inner.shutdown();
|
|
424
|
+
}
|
|
425
|
+
}, Ue = class {
|
|
426
|
+
constructor(e, t, n) {
|
|
427
|
+
this.inner = e, this.config = t, this.getRuntimeAttributes = n;
|
|
428
|
+
}
|
|
295
429
|
forceFlush() {
|
|
296
430
|
return this.inner.forceFlush();
|
|
297
431
|
}
|
|
298
432
|
onEnd(e) {
|
|
299
|
-
let t =
|
|
300
|
-
t &&
|
|
433
|
+
let t = Re(e);
|
|
434
|
+
if (!(e.attributes["bk.rum.request.discard"] === !0 || t && Oe(this.config, t) || !Ve(e.attributes))) {
|
|
435
|
+
delete e.attributes[A];
|
|
436
|
+
try {
|
|
437
|
+
var n, r;
|
|
438
|
+
if (((n = this.config.hooks) == null || (r = n.beforeSend) == null ? void 0 : r.call(n, {
|
|
439
|
+
attributes: e.attributes,
|
|
440
|
+
name: e.name,
|
|
441
|
+
signal: "span"
|
|
442
|
+
})) === !1) return;
|
|
443
|
+
} catch (e) {
|
|
444
|
+
var i;
|
|
445
|
+
this.config.debug && ((i = globalThis.console) == null || i.warn("[bk-ot] tracking.beforeSend failed:", e));
|
|
446
|
+
}
|
|
447
|
+
this.inner.onEnd(e);
|
|
448
|
+
}
|
|
301
449
|
}
|
|
302
450
|
onStart(e, t) {
|
|
303
|
-
|
|
451
|
+
var n;
|
|
452
|
+
let r = (n = e.attributes) == null ? {} : n, i = {};
|
|
453
|
+
for (let [e, t] of Object.entries(this.getRuntimeAttributes())) r[e] === void 0 && t !== void 0 && (i[e] = t);
|
|
454
|
+
e.setAttributes(i), this.inner.onStart(e, t);
|
|
304
455
|
}
|
|
305
456
|
shutdown() {
|
|
306
457
|
return this.inner.shutdown();
|
|
307
458
|
}
|
|
308
|
-
},
|
|
459
|
+
}, We = (e) => O(O({}, e), {}, { dataPoints: e.dataPoints.filter((e) => e.attributes[A] === !0).map((e) => {
|
|
460
|
+
let t = e.attributes, { [A]: n } = t, r = Fe(t, [A].map(ne));
|
|
461
|
+
return O(O({}, e), {}, { attributes: r });
|
|
462
|
+
}) }), Ge = class {
|
|
463
|
+
constructor(e) {
|
|
464
|
+
this.inner = e;
|
|
465
|
+
}
|
|
466
|
+
export(t, n) {
|
|
467
|
+
let r = O(O({}, t), {}, { scopeMetrics: t.scopeMetrics.map((e) => O(O({}, e), {}, { metrics: e.metrics.map(We).filter((e) => e.dataPoints.length > 0) })).filter((e) => e.metrics.length > 0) });
|
|
468
|
+
if (r.scopeMetrics.length === 0) {
|
|
469
|
+
n({ code: e.SUCCESS });
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
this.inner.export(r, n);
|
|
473
|
+
}
|
|
474
|
+
forceFlush() {
|
|
475
|
+
return this.inner.forceFlush();
|
|
476
|
+
}
|
|
477
|
+
selectAggregationTemporality(e) {
|
|
478
|
+
var t, n, r;
|
|
479
|
+
return (t = (n = (r = this.inner).selectAggregationTemporality) == null ? void 0 : n.call(r, e)) == null ? i.CUMULATIVE : t;
|
|
480
|
+
}
|
|
481
|
+
shutdown() {
|
|
482
|
+
return this.inner.shutdown();
|
|
483
|
+
}
|
|
484
|
+
}, Ke = new Set([...Object.values(T), A]), qe = class {
|
|
309
485
|
constructor(e = {}, t) {
|
|
310
|
-
|
|
486
|
+
D(this, "actionHistory", []), D(this, "attributes", {}), D(this, "queuedViewCommands", []), D(this, "recordAssociation", (e, t, n, r) => {
|
|
487
|
+
let i = e.at(-1);
|
|
488
|
+
if (i && i.endedAt === void 0 && (i.endedAt = Math.max(i.startedAt, n)), r) {
|
|
489
|
+
let r = {};
|
|
490
|
+
for (let e of t) {
|
|
491
|
+
let t = this.attributes[e];
|
|
492
|
+
t !== void 0 && (r[e] = t);
|
|
493
|
+
}
|
|
494
|
+
e.push({
|
|
495
|
+
attributes: r,
|
|
496
|
+
startedAt: n
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
e.length > 100 && e.splice(0, e.length - 100);
|
|
500
|
+
}), D(this, "sessionHistory", []), D(this, "sessionLifecycleListeners", /* @__PURE__ */ new Set()), D(this, "setOptionalAttribute", (e, t) => {
|
|
311
501
|
if (t === void 0) {
|
|
312
502
|
delete this.attributes[e];
|
|
313
503
|
return;
|
|
314
504
|
}
|
|
315
505
|
this.attributes[e] = t;
|
|
316
|
-
}),
|
|
506
|
+
}), D(this, "user", {}), D(this, "view", {}), D(this, "viewAttributeKeys", /* @__PURE__ */ new Set()), D(this, "viewChangeListeners", /* @__PURE__ */ new Set()), D(this, "viewCommandListeners", /* @__PURE__ */ new Set()), D(this, "viewHistory", []), D(this, "viewScopedAttributeKeys", /* @__PURE__ */ new Set()), D(this, "dispatchViewCommand", (e) => {
|
|
507
|
+
if (this.viewCommandListeners.size === 0) {
|
|
508
|
+
this.queuedViewCommands.push(e);
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
this.viewCommandListeners.forEach((t) => t(e));
|
|
512
|
+
}), D(this, "getAttributes", () => O({}, this.attributes)), D(this, "getAttributesAt", (e) => {
|
|
513
|
+
if (!Number.isFinite(e)) return this.getAttributes();
|
|
514
|
+
let t = this.getAttributes(), n = (n, r) => {
|
|
515
|
+
for (let e of r) delete t[e];
|
|
516
|
+
let i = [...n].reverse().find((t) => t.startedAt <= e && (t.endedAt === void 0 || e < t.endedAt));
|
|
517
|
+
i && Object.assign(t, i.attributes);
|
|
518
|
+
};
|
|
519
|
+
return n(this.sessionHistory, [
|
|
520
|
+
T.sessionId,
|
|
521
|
+
T.sessionHasReplay,
|
|
522
|
+
A
|
|
523
|
+
]), n(this.viewHistory, this.viewScopedAttributeKeys), n(this.actionHistory, [T.actionId]), t;
|
|
524
|
+
}), D(this, "getUser", () => O({}, this.user)), D(this, "getView", () => O({}, this.view)), D(this, "isSessionActive", () => typeof this.attributes[T.sessionId] == "string"), D(this, "isViewActive", () => typeof this.attributes[T.viewId] == "string"), D(this, "notifySessionLifecycle", (e) => {
|
|
525
|
+
this.sessionLifecycleListeners.forEach((t) => t(e));
|
|
526
|
+
}), D(this, "onSessionLifecycle", (e) => (this.sessionLifecycleListeners.add(e), () => this.sessionLifecycleListeners.delete(e))), D(this, "onViewChange", (e) => (this.viewChangeListeners.add(e), this.view.id && e(this.getView()), () => this.viewChangeListeners.delete(e))), D(this, "onViewCommand", (e) => {
|
|
527
|
+
for (this.viewCommandListeners.add(e); this.queuedViewCommands.length;) e(this.queuedViewCommands.shift());
|
|
528
|
+
return () => this.viewCommandListeners.delete(e);
|
|
529
|
+
}), D(this, "setAttributes", (e, t = Date.now()) => {
|
|
317
530
|
for (let [t, n] of Object.entries(e)) {
|
|
318
531
|
if (n === void 0) {
|
|
319
532
|
delete this.attributes[t];
|
|
@@ -321,35 +534,52 @@ var ye = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
321
534
|
}
|
|
322
535
|
this.attributes[t] = n;
|
|
323
536
|
}
|
|
324
|
-
|
|
325
|
-
|
|
537
|
+
if (T.sessionId in e && this.recordAssociation(this.sessionHistory, [
|
|
538
|
+
T.sessionId,
|
|
539
|
+
T.sessionHasReplay,
|
|
540
|
+
A
|
|
541
|
+
], t, typeof this.attributes[T.sessionId] == "string"), T.actionId in e) {
|
|
542
|
+
let e = this.attributes[T.actionId];
|
|
543
|
+
this.recordAssociation(this.actionHistory, [T.actionId], t, Array.isArray(e) ? e.length > 0 : typeof e == "string");
|
|
544
|
+
}
|
|
545
|
+
}), D(this, "setUser", (e) => {
|
|
546
|
+
if (this.user = O(O({}, this.user), e), "id" in e) {
|
|
326
547
|
if (e.id === void 0) {
|
|
327
|
-
delete this.attributes[
|
|
548
|
+
delete this.attributes[T.userId];
|
|
328
549
|
return;
|
|
329
550
|
}
|
|
330
|
-
this.attributes[
|
|
551
|
+
this.attributes[T.userId] = e.id;
|
|
331
552
|
}
|
|
332
|
-
}),
|
|
333
|
-
|
|
553
|
+
}), D(this, "setView", (e, t = ((t) => (t = e.startedAt) == null ? Date.now() : t)()) => {
|
|
554
|
+
var n;
|
|
555
|
+
this.viewAttributeKeys.forEach((e) => delete this.attributes[e]), this.viewAttributeKeys.clear();
|
|
556
|
+
let r = {};
|
|
557
|
+
for (let [t, i] of Object.entries((n = e.attributes) == null ? {} : n)) i === void 0 || Ke.has(t) || (r[t] = i, this.attributes[t] = i, this.viewAttributeKeys.add(t), this.viewScopedAttributeKeys.add(t));
|
|
558
|
+
this.view = O(O({}, e), {}, { attributes: r }), this.setOptionalAttribute(T.viewId, e.id), this.setOptionalAttribute(T.viewUrl, e.url), this.setOptionalAttribute(T.viewUrlPathGroup, e.urlPathGroup), this.setOptionalAttribute(T.viewLoadingType, e.loadingType), this.setOptionalAttribute(T.viewName, e.name), [
|
|
559
|
+
T.viewId,
|
|
560
|
+
T.viewUrl,
|
|
561
|
+
T.viewUrlPathGroup,
|
|
562
|
+
T.viewLoadingType,
|
|
563
|
+
T.viewName
|
|
564
|
+
].forEach((e) => this.viewScopedAttributeKeys.add(e)), this.recordAssociation(this.viewHistory, this.viewScopedAttributeKeys, t, typeof e.id == "string" && e.id.length > 0), this.viewChangeListeners.forEach((e) => e(this.getView()));
|
|
334
565
|
}), this.setAttributes(e), t && this.setUser(t);
|
|
335
566
|
}
|
|
336
|
-
}, N = {
|
|
567
|
+
}, N = (e) => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`, P = {
|
|
337
568
|
abort: "abort",
|
|
338
569
|
error: "error",
|
|
339
570
|
success: "success",
|
|
340
571
|
timeout: "timeout",
|
|
341
572
|
warning: "warning"
|
|
342
|
-
},
|
|
573
|
+
}, F = {
|
|
343
574
|
action: "action",
|
|
344
575
|
custom: "custom",
|
|
345
576
|
document: "document",
|
|
346
577
|
error: "error",
|
|
347
|
-
http: "http",
|
|
348
578
|
longtask: "longtask",
|
|
349
579
|
resource: "resource",
|
|
350
580
|
route: "route",
|
|
351
581
|
vital: "vital"
|
|
352
|
-
},
|
|
582
|
+
}, Je = (e) => e < 100 ? "<100ms" : e < 500 ? "100~500ms" : e < 2e3 ? "500ms~2s" : ">2s", Ye = (e) => `${Math.trunc(e / 100)}xx`, Xe = (e) => e === 408 || e === 504 ? P.timeout : typeof e == "number" && e >= 400 ? P.error : P.success, Ze = (e) => e === 408 || e === 504 ? "network_timeout" : typeof e != "number" || e < 400 ? "none" : e >= 500 ? "http_5xx" : "http_4xx", Qe = (e) => e === "good" ? P.success : P.warning, $e = (e, t) => {
|
|
353
583
|
if (!e) return {};
|
|
354
584
|
try {
|
|
355
585
|
let n = new URL(e, typeof location > "u" ? "http://localhost" : location.href), r = t == null ? n.pathname : t;
|
|
@@ -364,114 +594,371 @@ var ye = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
364
594
|
pathTemplate: t == null ? e : t
|
|
365
595
|
};
|
|
366
596
|
}
|
|
367
|
-
},
|
|
368
|
-
[
|
|
369
|
-
[
|
|
370
|
-
[
|
|
371
|
-
[
|
|
372
|
-
}, e === void 0 ? {} : { [
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
errorType: Ie(n),
|
|
377
|
-
eventLabel: "API 调用",
|
|
378
|
-
result: Fe(n),
|
|
379
|
-
spanSubtype: r,
|
|
380
|
-
spanType: P.http,
|
|
381
|
-
targetLabel: o.label,
|
|
382
|
-
targetValue: n
|
|
383
|
-
})), t ? { "http.request.method": t.toUpperCase() } : {}), o.domain ? { [x.targetDomain]: o.domain } : {}), o.pathTemplate ? { [x.targetPathTemplate]: o.pathTemplate } : {}), typeof n == "number" ? {
|
|
384
|
-
"http.response.status_code": n,
|
|
385
|
-
[x.statusClass]: Pe(n)
|
|
386
|
-
} : {});
|
|
387
|
-
}, Be = ({ duration: e, initiatorType: t = "other", responseStatus: n, transferSize: r, url: i, urlPathTemplate: a }) => {
|
|
388
|
-
var o;
|
|
389
|
-
let s = Re(i, a), c = typeof n == "number" ? Fe(n) : N.success;
|
|
390
|
-
return E(E(E(E({}, F({
|
|
597
|
+
}, I = ({ duration: e, errorType: t = "none", eventLabel: n, result: r = P.success, spanSubtype: i, spanType: a, targetLabel: o, targetValue: s, traceScene: c }) => O(O(O(O(O({
|
|
598
|
+
[T.spanType]: a,
|
|
599
|
+
[T.spanSubtype]: i,
|
|
600
|
+
[T.result]: r,
|
|
601
|
+
[T.errorType]: t
|
|
602
|
+
}, e === void 0 ? {} : { [T.durationBucket]: Je(e) }), n === void 0 ? {} : { [T.eventLabel]: n }), o === void 0 ? {} : { [T.targetLabel]: o }), s === void 0 ? {} : { [T.targetValue]: s }), c === void 0 ? {} : { [T.traceScene]: c }), et = ({ duration: e, initiatorType: t = "other", method: n, networkError: r = !1, responseStatus: i, transferSize: a, url: o, urlPathTemplate: s }) => {
|
|
603
|
+
var c;
|
|
604
|
+
let l = $e(o, s), u = t === "fetch" || t === "xhr", d = r ? P.error : typeof i == "number" ? Xe(i) : P.success, f = n == null ? void 0 : n.toUpperCase();
|
|
605
|
+
return O(O(O(O(O(O(O({}, I({
|
|
391
606
|
duration: e,
|
|
392
|
-
errorType: typeof
|
|
393
|
-
eventLabel: "静态资源",
|
|
394
|
-
result:
|
|
607
|
+
errorType: r ? "network" : typeof i == "number" ? Ze(i) : "none",
|
|
608
|
+
eventLabel: u ? "请求资源" : "静态资源",
|
|
609
|
+
result: d,
|
|
395
610
|
spanSubtype: t,
|
|
396
|
-
spanType:
|
|
397
|
-
targetLabel: (
|
|
398
|
-
targetValue:
|
|
399
|
-
})),
|
|
400
|
-
"
|
|
401
|
-
|
|
402
|
-
} : {})
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
"
|
|
406
|
-
|
|
407
|
-
|
|
611
|
+
spanType: F.resource,
|
|
612
|
+
targetLabel: (c = l.label) == null ? o : c,
|
|
613
|
+
targetValue: u ? i : a
|
|
614
|
+
})), l.domain ? { [T.targetDomain]: l.domain } : {}), l.pathTemplate ? { [T.targetPathTemplate]: l.pathTemplate } : {}), {}, {
|
|
615
|
+
"resource.type": t,
|
|
616
|
+
"resource.url": o
|
|
617
|
+
}, e === void 0 ? {} : { "resource.duration": e }), f ? {
|
|
618
|
+
"http.request.method": f,
|
|
619
|
+
"resource.method": f
|
|
620
|
+
} : {}), typeof a == "number" ? { "resource.size": a } : {}), typeof i == "number" ? O({
|
|
621
|
+
"http.response.status_code": i,
|
|
622
|
+
"resource.status_code": i
|
|
623
|
+
}, i > 0 ? { [T.statusClass]: Ye(i) } : {}) : {});
|
|
624
|
+
}, tt = 100, nt = 100, rt = 1e3, it = 100, at = 1e4, ot = "data-bk-action-name", st = 100, ct = 10, L = (e) => e.replace(/\s+/g, " ").trim().slice(0, st), R = (e) => {
|
|
408
625
|
var t;
|
|
409
|
-
if (
|
|
410
|
-
let n = (
|
|
411
|
-
return n ? n.
|
|
412
|
-
},
|
|
626
|
+
if (e.parentElement) return e.parentElement;
|
|
627
|
+
let n = (t = e.getRootNode) == null ? void 0 : t.call(e);
|
|
628
|
+
return typeof ShadowRoot < "u" && n instanceof ShadowRoot ? n.host : null;
|
|
629
|
+
}, lt = (e, t) => {
|
|
630
|
+
let n = e;
|
|
631
|
+
for (; n;) {
|
|
632
|
+
let e = n.getAttribute(t);
|
|
633
|
+
if (e) return L(e);
|
|
634
|
+
n = R(n);
|
|
635
|
+
}
|
|
636
|
+
}, ut = (e) => {
|
|
637
|
+
var t;
|
|
638
|
+
return e.isContentEditable ? "" : L((t = e.textContent) == null ? "" : t);
|
|
639
|
+
}, dt = (e) => {
|
|
640
|
+
var t, n;
|
|
641
|
+
let r = e, i = (t = r.labels) == null ? void 0 : t[0];
|
|
642
|
+
if (i) {
|
|
643
|
+
let e = ut(i);
|
|
644
|
+
if (e) return e;
|
|
645
|
+
}
|
|
646
|
+
let a = e.tagName.toLowerCase(), o = (n = e.getAttribute("type")) == null ? void 0 : n.toLowerCase();
|
|
647
|
+
if (a === "input" && [
|
|
648
|
+
"button",
|
|
649
|
+
"reset",
|
|
650
|
+
"submit"
|
|
651
|
+
].includes(o == null ? "" : o)) {
|
|
652
|
+
var s;
|
|
653
|
+
let e = L((s = r.value) == null ? "" : s);
|
|
654
|
+
if (e) return e;
|
|
655
|
+
}
|
|
656
|
+
if (a === "button" || a === "label" || e.getAttribute("role") === "button") {
|
|
657
|
+
let t = ut(e);
|
|
658
|
+
if (t) return t;
|
|
659
|
+
}
|
|
660
|
+
for (let t of [
|
|
661
|
+
"aria-label",
|
|
662
|
+
"alt",
|
|
663
|
+
"name",
|
|
664
|
+
"title",
|
|
665
|
+
"placeholder"
|
|
666
|
+
]) {
|
|
667
|
+
var c;
|
|
668
|
+
let n = L((c = e.getAttribute(t)) == null ? "" : c);
|
|
669
|
+
if (n) return n;
|
|
670
|
+
}
|
|
671
|
+
}, ft = (e, t = ot, n = !1) => {
|
|
672
|
+
let r = lt(e, t);
|
|
673
|
+
if (r) return r;
|
|
674
|
+
if (!n) return e.tagName.toLowerCase();
|
|
675
|
+
let i = e, a = 0;
|
|
676
|
+
for (; i && a <= ct;) {
|
|
677
|
+
let e = i.tagName.toLowerCase();
|
|
678
|
+
if (e === "body" || e === "html" || e === "head") break;
|
|
679
|
+
let t = dt(i);
|
|
680
|
+
if (t) return t;
|
|
681
|
+
if (e === "form") break;
|
|
682
|
+
i = R(i), a += 1;
|
|
683
|
+
}
|
|
684
|
+
for (i = e, a = 0; i && a <= ct;) {
|
|
685
|
+
let e = i.tagName.toLowerCase();
|
|
686
|
+
if (e === "body" || e === "html" || e === "head") break;
|
|
687
|
+
let t = ut(i);
|
|
688
|
+
if (t) return t;
|
|
689
|
+
if (e === "form") break;
|
|
690
|
+
i = R(i), a += 1;
|
|
691
|
+
}
|
|
692
|
+
return e.tagName.toLowerCase();
|
|
693
|
+
}, pt = (e) => {
|
|
413
694
|
var t;
|
|
414
|
-
let n =
|
|
695
|
+
let n = (t = e.composedPath) == null ? void 0 : t.call(e)[0];
|
|
696
|
+
return n instanceof Element ? n : e.target instanceof Element ? e.target : void 0;
|
|
697
|
+
}, mt = (e) => {
|
|
698
|
+
let t = e.timeStamp;
|
|
699
|
+
return !Number.isFinite(t) || t <= 0 ? Date.now() : t > 0xe8d4a51000 ? t : typeof performance > "u" ? Date.now() : performance.timeOrigin + t;
|
|
700
|
+
}, ht = (e, t) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : t, gt = (e) => {
|
|
701
|
+
let t = e;
|
|
702
|
+
if (t.tagName.toLowerCase() === "label" && t.hasAttribute("for")) {
|
|
703
|
+
var n;
|
|
704
|
+
t = document.getElementById((n = t.getAttribute("for")) == null ? "" : n);
|
|
705
|
+
}
|
|
706
|
+
for (; t;) {
|
|
707
|
+
let e = t.tagName.toLowerCase();
|
|
708
|
+
if (t.hasAttribute("contenteditable") || e === "canvas" || e === "select" || e === "textarea" || e === "a" && t.hasAttribute("href")) return !0;
|
|
709
|
+
if (e === "input") {
|
|
710
|
+
var r, i;
|
|
711
|
+
return ![
|
|
712
|
+
"button",
|
|
713
|
+
"checkbox",
|
|
714
|
+
"radio",
|
|
715
|
+
"range",
|
|
716
|
+
"reset",
|
|
717
|
+
"submit"
|
|
718
|
+
].includes((r = (i = t.getAttribute("type")) == null ? void 0 : i.toLowerCase()) == null ? "text" : r);
|
|
719
|
+
}
|
|
720
|
+
t = R(t);
|
|
721
|
+
}
|
|
722
|
+
return !1;
|
|
723
|
+
}, _t = (e = {}) => {
|
|
724
|
+
let t = [], n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = e.actionNameAttribute || ot, a = ht(e.maxDuration, at), o = [], s, c = () => {
|
|
725
|
+
s == null || s.setRuntimeAttributes({ [T.actionId]: n.size ? [...n.keys()] : void 0 });
|
|
726
|
+
}, l = (e) => !e.hadActivity && !e.userActivity.input && !e.userActivity.scroll && !e.userActivity.selection && !gt(e.target), u = (e) => {
|
|
727
|
+
var t;
|
|
728
|
+
if (!r.delete(e) || !s || !e.completed || e.discardedByRage) return;
|
|
729
|
+
clearTimeout(e.reportTimer), e.counts.error && e.frustrations.add("error_click"), ((t = e.rageSources) == null ? [e] : t).some(l) && e.frustrations.add("dead_click");
|
|
730
|
+
let n = [
|
|
731
|
+
"rage_click",
|
|
732
|
+
"dead_click",
|
|
733
|
+
"error_click"
|
|
734
|
+
].filter((t) => e.frustrations.has(t)), { endTime: i, hasLoadingTime: a } = e.completed, o = Math.max(0, i - e.startTime), c = e.counts.error > 0 || n.length > 0, u = s.startSpan("action.click", O(O(O(O(O({}, s.config.hooks.getPageAttributes()), I({
|
|
735
|
+
duration: a ? o : void 0,
|
|
736
|
+
errorType: e.counts.error ? "js" : n.length ? "frustration" : "none",
|
|
737
|
+
eventLabel: "用户操作",
|
|
738
|
+
result: c ? P.warning : P.success,
|
|
739
|
+
spanSubtype: "click",
|
|
740
|
+
spanType: F.action,
|
|
741
|
+
targetLabel: e.targetName,
|
|
742
|
+
targetValue: a ? o : void 0,
|
|
743
|
+
traceScene: "user_action"
|
|
744
|
+
})), e.runtimeAttributes), {}, {
|
|
745
|
+
[T.actionId]: e.id,
|
|
746
|
+
[T.actionType]: "click",
|
|
747
|
+
[T.actionName]: `Click on ${e.targetName}`,
|
|
748
|
+
[T.actionTargetName]: e.targetName,
|
|
749
|
+
[T.actionTargetTag]: e.targetTag,
|
|
750
|
+
[T.actionResourceCount]: e.counts.resource,
|
|
751
|
+
[T.actionErrorCount]: e.counts.error,
|
|
752
|
+
[T.actionLongTaskCount]: e.counts.longTask,
|
|
753
|
+
[T.actionFrustrationCount]: n.length
|
|
754
|
+
}, n.length ? { [T.actionFrustrationType]: n } : {}), a ? { [T.actionLoadingTime]: o } : {}), { startTime: e.startTime });
|
|
755
|
+
u.setAttributes(O(O({}, e.runtimeAttributes), {}, { [T.actionId]: e.id })), u.end(a ? i : e.startTime);
|
|
756
|
+
}, d = (e, t, i) => {
|
|
757
|
+
if (!n.delete(e.id) || !s) return;
|
|
758
|
+
clearTimeout(e.validationTimer), clearTimeout(e.quietTimer), clearTimeout(e.maxDurationTimer), c(), e.completed = {
|
|
759
|
+
endTime: t,
|
|
760
|
+
hasLoadingTime: i
|
|
761
|
+
}, r.add(e);
|
|
762
|
+
let a = Math.max(0, e.startTime + rt - Date.now());
|
|
763
|
+
e.reportTimer = setTimeout(() => u(e), a);
|
|
764
|
+
}, f = () => {
|
|
765
|
+
[...r].forEach(u);
|
|
766
|
+
}, p = (e) => {
|
|
767
|
+
if (clearTimeout(e.quietTimer), !e.hadActivity || e.pendingRequests.size) return;
|
|
768
|
+
let t = Math.max(0, e.lastActivityTime + nt - Date.now());
|
|
769
|
+
e.quietTimer = setTimeout(() => d(e, e.lastActivityTime, !0), t);
|
|
770
|
+
}, m = (e, t) => {
|
|
771
|
+
e.hadActivity = !0, e.lastActivityTime = Math.max(e.lastActivityTime, t), p(e);
|
|
772
|
+
}, h = (e, t) => t >= e.startTime && t <= e.startTime + a, g = (e) => {
|
|
773
|
+
for (let i of n.values()) {
|
|
774
|
+
if (e.type === "request_start") {
|
|
775
|
+
var t;
|
|
776
|
+
if (e.url && M(s == null || (t = s.config.view) == null ? void 0 : t.excludedActivityUrls, e.url) || !h(i, e.time)) continue;
|
|
777
|
+
i.pendingRequests.add(e.id), m(i, e.time);
|
|
778
|
+
continue;
|
|
779
|
+
}
|
|
780
|
+
if (e.type === "request_end") {
|
|
781
|
+
if (!i.pendingRequests.delete(e.id)) continue;
|
|
782
|
+
i.counts.resource += 1, m(i, e.time);
|
|
783
|
+
continue;
|
|
784
|
+
}
|
|
785
|
+
if (e.type === "long_task" || e.type === "resource") {
|
|
786
|
+
var r;
|
|
787
|
+
if (e.type === "resource" && e.url && M(s == null || (r = s.config.view) == null ? void 0 : r.excludedActivityUrls, e.url) || e.startTime > i.startTime + a || (e.type === "resource" ? e.startTime < i.startTime : e.endTime < i.startTime)) continue;
|
|
788
|
+
i.counts[e.type === "long_task" ? "longTask" : "resource"] += 1, m(i, e.endTime);
|
|
789
|
+
continue;
|
|
790
|
+
}
|
|
791
|
+
if (e.type === "dom_mutation" || e.type === "window_open") {
|
|
792
|
+
h(i, e.time) && m(i, e.time);
|
|
793
|
+
continue;
|
|
794
|
+
}
|
|
795
|
+
e.type === "error" && h(i, e.time) && (i.counts.error += 1, m(i, e.time));
|
|
796
|
+
}
|
|
797
|
+
}, _ = (e = Date.now()) => {
|
|
798
|
+
[...n.values()].forEach((t) => d(t, e, t.hadActivity));
|
|
799
|
+
}, v = (e, t) => {
|
|
800
|
+
let n = "clientX" in t && typeof t.clientX == "number" ? t.clientX : 0, r = "clientY" in t && typeof t.clientY == "number" ? t.clientY : 0;
|
|
801
|
+
o = o.filter((t) => e.startTime - t.action.startTime <= rt);
|
|
802
|
+
let i = o.at(-1), a = o.some((e) => e.action.userActivity.scroll || e.action.userActivity.selection), s = (i == null ? void 0 : i.target) === e.target && Math.hypot(i.x - n, i.y - r) <= it;
|
|
803
|
+
if ((a || i && !s) && (o = []), o.push({
|
|
804
|
+
action: e,
|
|
805
|
+
target: e.target,
|
|
806
|
+
x: n,
|
|
807
|
+
y: r
|
|
808
|
+
}), o.length >= 3 && e.startTime - o[o.length - 3].action.startTime <= rt) {
|
|
809
|
+
let t = o.slice(-3).map((e) => e.action);
|
|
810
|
+
t.slice(0, -1).forEach((e) => {
|
|
811
|
+
e.discardedByRage = !0;
|
|
812
|
+
}), e.frustrations.add("rage_click"), e.rageSources = t, o = [];
|
|
813
|
+
}
|
|
814
|
+
};
|
|
415
815
|
return {
|
|
416
816
|
name: "action",
|
|
417
|
-
init(
|
|
418
|
-
if (typeof window > "u") return;
|
|
419
|
-
|
|
817
|
+
init(l) {
|
|
818
|
+
if (typeof window > "u" || typeof document > "u") return;
|
|
819
|
+
s = l;
|
|
820
|
+
let u = {
|
|
420
821
|
capture: !0,
|
|
421
822
|
passive: !0
|
|
422
|
-
},
|
|
423
|
-
|
|
424
|
-
let r =
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
823
|
+
}, p = (t) => {
|
|
824
|
+
if ("button" in t && typeof t.button == "number" && t.button !== 0) return;
|
|
825
|
+
let r = pt(t);
|
|
826
|
+
if (!r) return;
|
|
827
|
+
let o = mt(t), s = N("action"), u = {
|
|
828
|
+
counts: {
|
|
829
|
+
error: 0,
|
|
830
|
+
longTask: 0,
|
|
831
|
+
resource: 0
|
|
832
|
+
},
|
|
833
|
+
frustrations: /* @__PURE__ */ new Set(),
|
|
834
|
+
hadActivity: !1,
|
|
835
|
+
id: s,
|
|
836
|
+
lastActivityTime: o,
|
|
837
|
+
maxDurationTimer: setTimeout(() => d(u, o + a, !0), a),
|
|
838
|
+
pendingRequests: /* @__PURE__ */ new Set(),
|
|
839
|
+
runtimeAttributes: l.getRuntimeAttributes(),
|
|
840
|
+
startTime: o,
|
|
841
|
+
target: r,
|
|
842
|
+
targetName: ft(r, i, e.nameCollection === "text"),
|
|
843
|
+
targetTag: r.tagName.toLowerCase(),
|
|
844
|
+
userActivity: {
|
|
845
|
+
input: !1,
|
|
846
|
+
scroll: !1,
|
|
847
|
+
selection: !1
|
|
848
|
+
},
|
|
849
|
+
validationTimer: setTimeout(() => {
|
|
850
|
+
u.hadActivity || d(u, u.startTime, !1);
|
|
851
|
+
}, tt)
|
|
852
|
+
};
|
|
853
|
+
n.set(s, u), v(u, t), c();
|
|
432
854
|
};
|
|
433
|
-
|
|
855
|
+
window.addEventListener("click", p, u), t.push(() => window.removeEventListener("click", p, u));
|
|
856
|
+
let m = l.onActivity(g), h = l.onSessionLifecycle((e) => {
|
|
857
|
+
e.type === "expired" && (_(e.expiredAt), f());
|
|
858
|
+
});
|
|
859
|
+
t.push(m, h);
|
|
860
|
+
let y = () => {
|
|
861
|
+
document.visibilityState === "hidden" && (_(), f());
|
|
862
|
+
}, b = () => {
|
|
863
|
+
_(), f();
|
|
864
|
+
};
|
|
865
|
+
window.addEventListener("pagehide", b), document.addEventListener("visibilitychange", y), t.push(() => window.removeEventListener("pagehide", b), () => document.removeEventListener("visibilitychange", y));
|
|
866
|
+
let x = (e) => {
|
|
867
|
+
new Set([
|
|
868
|
+
...n.values(),
|
|
869
|
+
...r,
|
|
870
|
+
...o.map((e) => e.action)
|
|
871
|
+
]).forEach((t) => {
|
|
872
|
+
if (t.userActivity[e] = !0, e !== "input" && t.frustrations.delete("rage_click")) {
|
|
873
|
+
var n;
|
|
874
|
+
(n = t.rageSources) == null || n.slice(0, -1).forEach((e) => {
|
|
875
|
+
e.discardedByRage = !1;
|
|
876
|
+
}), t.rageSources = void 0;
|
|
877
|
+
}
|
|
878
|
+
});
|
|
879
|
+
}, S = () => x("input"), C = () => x("scroll"), ee = () => x("selection");
|
|
880
|
+
window.addEventListener("input", S, u), window.addEventListener("scroll", C, u), document.addEventListener("selectionchange", ee, u), t.push(() => window.removeEventListener("input", S, u), () => window.removeEventListener("scroll", C, u), () => document.removeEventListener("selectionchange", ee, u));
|
|
434
881
|
},
|
|
435
882
|
shutdown() {
|
|
436
|
-
for (;
|
|
883
|
+
for (_(), f(); t.length;) {
|
|
437
884
|
var e;
|
|
438
|
-
(e =
|
|
885
|
+
(e = t.pop()) == null || e();
|
|
439
886
|
}
|
|
887
|
+
o = [], s = void 0;
|
|
440
888
|
}
|
|
441
889
|
};
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}
|
|
890
|
+
}, vt = "data-bk-excluded-activity-mutations", yt = (e) => {
|
|
891
|
+
let t = e.type === "characterData" ? e.target.parentElement : e.target;
|
|
892
|
+
return t instanceof Element && !!t.closest("[data-bk-excluded-activity-mutations]");
|
|
893
|
+
}, bt = () => {
|
|
894
|
+
let e, t = [];
|
|
895
|
+
return {
|
|
896
|
+
name: "activity",
|
|
897
|
+
init(n) {
|
|
898
|
+
if (typeof document < "u" && typeof MutationObserver < "u" && (e = new MutationObserver((e) => {
|
|
899
|
+
e.length && !e.every(yt) && n.notifyActivity({
|
|
900
|
+
time: Date.now(),
|
|
901
|
+
type: "dom_mutation"
|
|
902
|
+
});
|
|
903
|
+
}), e.observe(document, {
|
|
904
|
+
attributes: !0,
|
|
905
|
+
characterData: !0,
|
|
906
|
+
childList: !0,
|
|
907
|
+
subtree: !0
|
|
908
|
+
})), !(typeof window > "u") && typeof window.open == "function") {
|
|
909
|
+
let e = window.open, r = ((...t) => (n.notifyActivity({
|
|
910
|
+
time: Date.now(),
|
|
911
|
+
type: "window_open"
|
|
912
|
+
}), Reflect.apply(e, window, t)));
|
|
913
|
+
window.open = r, t.push(() => {
|
|
914
|
+
window.open === r && (window.open = e);
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
},
|
|
918
|
+
shutdown() {
|
|
919
|
+
var n;
|
|
920
|
+
for (e == null || e.disconnect(), e = void 0; t.length;) (n = t.pop()) == null || n();
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
}, xt = (e, t) => !!(t && M(e.config.view.excludedActivityUrls, t)), St = (e, t, n) => {
|
|
924
|
+
let r = /* @__PURE__ */ new Set(), i = !1, a = !1, o = t, s, c = (e) => {
|
|
925
|
+
i || (i = !0, clearTimeout(f), clearTimeout(s), d(), n(e));
|
|
926
|
+
}, l = () => {
|
|
927
|
+
clearTimeout(s), !(!a || r.size) && (s = setTimeout(() => c({
|
|
928
|
+
endTime: o,
|
|
929
|
+
hadActivity: !0
|
|
930
|
+
}), Math.max(0, o + 100 - Date.now())));
|
|
931
|
+
}, u = (e) => {
|
|
932
|
+
a = !0, o = Math.max(o, e), l();
|
|
933
|
+
}, d = e.onActivity((n) => {
|
|
934
|
+
if (!(n.type === "error" || n.type === "long_task")) {
|
|
935
|
+
if (n.type === "request_start") {
|
|
936
|
+
if (n.time < t || xt(e, n.url)) return;
|
|
937
|
+
r.add(n.id), u(n.time);
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
if (n.type === "request_end") {
|
|
941
|
+
if (!r.delete(n.id)) return;
|
|
942
|
+
u(n.time);
|
|
943
|
+
return;
|
|
944
|
+
}
|
|
945
|
+
if (n.type === "resource") {
|
|
946
|
+
if (n.endTime < t || xt(e, n.url)) return;
|
|
947
|
+
u(n.endTime);
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
n.time >= t && u(n.time);
|
|
951
|
+
}
|
|
952
|
+
}), f = setTimeout(() => {
|
|
953
|
+
a || c({ hadActivity: !1 });
|
|
954
|
+
}, 100);
|
|
955
|
+
return () => {
|
|
956
|
+
i || (i = !0, clearTimeout(f), clearTimeout(s), d());
|
|
957
|
+
};
|
|
958
|
+
}, Ct = (e) => typeof e == "string" && e.length > 0 ? e : void 0, wt = (e) => {
|
|
959
|
+
let t = Ct(e);
|
|
960
|
+
return t ? { [T.viewUrlPathGroup]: t } : {};
|
|
961
|
+
}, z = (e) => O(O({}, wt(e[T.viewUrlPathGroup])), {}, { [A]: e[A] === !0 }), Tt = 1e3, Et = 200, Dt = "body", Ot = .8, kt = [
|
|
475
962
|
"[data-loading=\"true\"]",
|
|
476
963
|
"[aria-busy=\"true\"]",
|
|
477
964
|
".loading",
|
|
@@ -479,196 +966,570 @@ var qe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Je = (e) => {
|
|
|
479
966
|
".spinner",
|
|
480
967
|
".skeleton",
|
|
481
968
|
".bk-loading"
|
|
482
|
-
],
|
|
969
|
+
], B = [
|
|
970
|
+
[.2, .2],
|
|
971
|
+
[.5, .2],
|
|
972
|
+
[.8, .2],
|
|
973
|
+
[.2, .5],
|
|
483
974
|
[.5, .5],
|
|
484
|
-
[.
|
|
485
|
-
[.
|
|
486
|
-
[.
|
|
487
|
-
[.
|
|
488
|
-
],
|
|
975
|
+
[.8, .5],
|
|
976
|
+
[.2, .8],
|
|
977
|
+
[.5, .8],
|
|
978
|
+
[.8, .8]
|
|
979
|
+
], At = (e, t) => typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : t, jt = (e, t) => typeof e == "number" && Number.isFinite(e) ? Math.max(0, Math.min(1, e)) : t, Mt = (e) => {
|
|
489
980
|
if (!e) return "";
|
|
490
981
|
let t = e.tagName.toLowerCase();
|
|
491
982
|
return e.id ? `${t}#${e.id}` : t;
|
|
492
|
-
},
|
|
983
|
+
}, Nt = (e, t) => t.some((t) => {
|
|
493
984
|
try {
|
|
494
985
|
return e.matches(t) || !!e.closest(t);
|
|
495
986
|
} catch (e) {
|
|
496
987
|
return !1;
|
|
497
988
|
}
|
|
498
|
-
})
|
|
499
|
-
if (typeof
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
989
|
+
}), Pt = (e) => {
|
|
990
|
+
if (typeof getComputedStyle != "function") return !0;
|
|
991
|
+
let t = getComputedStyle(e);
|
|
992
|
+
return t.display !== "none" && t.visibility !== "hidden" && Number(t.opacity || 1) > 0;
|
|
993
|
+
}, Ft = (e, t) => {
|
|
994
|
+
if (typeof document.elementsFromPoint == "function") return document.elementsFromPoint(e, t);
|
|
995
|
+
let n = document.elementFromPoint(e, t);
|
|
996
|
+
return n ? [n] : [];
|
|
997
|
+
}, It = (e, t) => {
|
|
998
|
+
let n = document.querySelector(e);
|
|
999
|
+
if (!n) return {
|
|
1000
|
+
centerElement: Mt(Ft(window.innerWidth / 2, window.innerHeight / 2)[0]),
|
|
1001
|
+
emptyCount: B.length,
|
|
1002
|
+
ignoredCount: 0,
|
|
1003
|
+
reason: "missing_root",
|
|
1004
|
+
rootFound: !1,
|
|
1005
|
+
score: 1,
|
|
1006
|
+
validCount: B.length
|
|
503
1007
|
};
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
1008
|
+
let r = 0, i = 0, a = "";
|
|
1009
|
+
for (let [e, o] of B) {
|
|
1010
|
+
let s = Ft(window.innerWidth * e, window.innerHeight * o);
|
|
1011
|
+
if (e === .5 && o === .5 && (a = Mt(s[0])), s.some((e) => Nt(e, t))) {
|
|
1012
|
+
i += 1;
|
|
1013
|
+
continue;
|
|
1014
|
+
}
|
|
1015
|
+
s.some((e) => e !== n && e !== document.body && e !== document.documentElement && n.contains(e) && Pt(e)) || (r += 1);
|
|
1016
|
+
}
|
|
1017
|
+
let o = B.length - i;
|
|
1018
|
+
return {
|
|
1019
|
+
centerElement: a,
|
|
1020
|
+
emptyCount: r,
|
|
1021
|
+
ignoredCount: i,
|
|
1022
|
+
reason: "empty_viewport",
|
|
1023
|
+
rootFound: !0,
|
|
1024
|
+
score: o ? r / o : 0,
|
|
1025
|
+
validCount: o
|
|
512
1026
|
};
|
|
1027
|
+
}, Lt = (e = {}) => {
|
|
1028
|
+
var t;
|
|
1029
|
+
let n = At(e.checkDelay, Tt), r = At(e.confirmationDelay, Et), i = e.rootSelector || Dt, a = jt(e.threshold, Ot), o = [...kt, ...(t = e.ignoreSelectors) == null ? [] : t], s, c, l, u, d = () => {}, f;
|
|
513
1030
|
return {
|
|
514
1031
|
name: "blank-screen",
|
|
515
1032
|
init(e) {
|
|
516
1033
|
if (typeof window > "u" || typeof document > "u") return;
|
|
517
|
-
let
|
|
1034
|
+
let t = e.meter.createCounter("browser.blank_screen.count", { description: "Number of confirmed blank screens" }), p = () => {
|
|
1035
|
+
clearTimeout(u), u = void 0;
|
|
1036
|
+
}, m = (n, r) => {
|
|
1037
|
+
s !== n || c === n || (c = n, t.add(1, e.applyRedact(O(O(O({}, e.config.hooks.getMetricAttributes()), z(e.getRuntimeAttributes())), {}, {
|
|
1038
|
+
"blank_screen.reason": r.reason,
|
|
1039
|
+
"blank_screen.root_selector": i
|
|
1040
|
+
}))), e.startSpan("browser.blank_screen", O(O({}, I({
|
|
1041
|
+
errorType: "blank_screen",
|
|
1042
|
+
eventLabel: "白屏",
|
|
1043
|
+
result: P.error,
|
|
1044
|
+
spanSubtype: r.reason,
|
|
1045
|
+
spanType: F.error,
|
|
1046
|
+
targetLabel: i,
|
|
1047
|
+
targetValue: r.score
|
|
1048
|
+
})), {}, {
|
|
1049
|
+
"blank_screen.center_element": r.centerElement,
|
|
1050
|
+
"blank_screen.empty_ratio": r.score,
|
|
1051
|
+
"blank_screen.empty_sample_count": r.emptyCount,
|
|
1052
|
+
"blank_screen.ignored_sample_count": r.ignoredCount,
|
|
1053
|
+
"blank_screen.reason": r.reason,
|
|
1054
|
+
"blank_screen.root_found": r.rootFound,
|
|
1055
|
+
"blank_screen.root_selector": i,
|
|
1056
|
+
"blank_screen.sample_count": B.length,
|
|
1057
|
+
"blank_screen.valid_sample_count": r.validCount
|
|
1058
|
+
})).end());
|
|
1059
|
+
}, h = (t) => {
|
|
1060
|
+
if (s !== t || c === t || document.visibilityState === "hidden") return;
|
|
1061
|
+
let n;
|
|
518
1062
|
try {
|
|
519
|
-
|
|
520
|
-
let i = document.querySelector(n), a = 0, o = 0;
|
|
521
|
-
for (let [e, t] of R) {
|
|
522
|
-
let n = document.elementFromPoint(window.innerWidth * e, window.innerHeight * t);
|
|
523
|
-
if (nt(n, c)) {
|
|
524
|
-
o += 1;
|
|
525
|
-
continue;
|
|
526
|
-
}
|
|
527
|
-
(n === i || n === document.body || n === document.documentElement) && (a += 1);
|
|
528
|
-
}
|
|
529
|
-
let u = R.length - o;
|
|
530
|
-
if (u === 0) return;
|
|
531
|
-
let d = a / u, f = d >= s, p = tt(document.elementFromPoint(window.innerWidth / 2, window.innerHeight / 2)), m = E(E({}, F({
|
|
532
|
-
errorType: f ? "blank_screen" : "none",
|
|
533
|
-
eventLabel: "白屏",
|
|
534
|
-
result: f ? N.error : N.success,
|
|
535
|
-
spanSubtype: "blank_screen",
|
|
536
|
-
spanType: P.error,
|
|
537
|
-
targetLabel: n,
|
|
538
|
-
targetValue: d
|
|
539
|
-
})), {}, {
|
|
540
|
-
"blank_screen.score": d,
|
|
541
|
-
"blank_screen.threshold": s,
|
|
542
|
-
"blank_screen.root": n,
|
|
543
|
-
"blank_screen.detected": f,
|
|
544
|
-
"blank_screen.sample_total": R.length,
|
|
545
|
-
"blank_screen.sample_valid": u,
|
|
546
|
-
"blank_screen.sample_loading": o,
|
|
547
|
-
"blank_screen.center_element": p,
|
|
548
|
-
"blank_screen.dom_node_count": (t = (r = document.body) == null ? void 0 : r.getElementsByTagName("*").length) == null ? 0 : t
|
|
549
|
-
});
|
|
550
|
-
f && (l.add(1, e.applyRedact(E(E(E({}, e.config.hooks.getMetricAttributes()), I(e.getRuntimeAttributes())), {}, { "blank_screen.root": n }))), e.startSpan("browser.blank_screen", m).end());
|
|
1063
|
+
n = It(i, o);
|
|
551
1064
|
} catch (t) {
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
}
|
|
1065
|
+
var l;
|
|
1066
|
+
e.config.debug && ((l = globalThis.console) == null || l.warn("[bk-ot][blank-screen] detection failed:", t));
|
|
1067
|
+
return;
|
|
556
1068
|
}
|
|
1069
|
+
!n.validCount || n.score < a || (u = setTimeout(() => {
|
|
1070
|
+
if (s !== t || document.visibilityState === "hidden") return;
|
|
1071
|
+
let n;
|
|
1072
|
+
try {
|
|
1073
|
+
n = It(i, o);
|
|
1074
|
+
} catch (t) {
|
|
1075
|
+
var r;
|
|
1076
|
+
e.config.debug && ((r = globalThis.console) == null || r.warn("[bk-ot][blank-screen] confirmation failed:", t));
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1079
|
+
n.validCount && n.score >= a && m(t, n);
|
|
1080
|
+
}, r));
|
|
1081
|
+
}, g = (e) => {
|
|
1082
|
+
p(), document.visibilityState !== "hidden" && (u = setTimeout(() => h(e), n));
|
|
557
1083
|
};
|
|
558
|
-
|
|
559
|
-
|
|
1084
|
+
d = e.onViewChange((t) => {
|
|
1085
|
+
if (t.id !== s && (p(), l == null || l(), l = void 0, s = t.id, c = void 0, t.id)) {
|
|
1086
|
+
let n = t.id;
|
|
1087
|
+
l = St(e, Date.now(), () => {
|
|
1088
|
+
l = void 0, g(n);
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
560
1091
|
});
|
|
1092
|
+
let _ = () => {
|
|
1093
|
+
document.visibilityState === "hidden" ? p() : s && c !== s && g(s);
|
|
1094
|
+
};
|
|
1095
|
+
document.addEventListener("visibilitychange", _), f = () => document.removeEventListener("visibilitychange", _);
|
|
561
1096
|
},
|
|
562
1097
|
shutdown() {
|
|
563
|
-
|
|
1098
|
+
clearTimeout(u), u = void 0, d(), l == null || l(), l = void 0, f == null || f(), f = void 0, s = void 0, c = void 0;
|
|
564
1099
|
}
|
|
565
1100
|
};
|
|
566
|
-
},
|
|
567
|
-
|
|
568
|
-
t.
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
1101
|
+
}, Rt = 100, zt = 200, V = [], Bt = (e) => e.replace(/#.*$/, ""), Vt = (e) => {
|
|
1102
|
+
let t = V.indexOf(e);
|
|
1103
|
+
t >= 0 && V.splice(t, 1), e.timer !== void 0 && clearTimeout(e.timer);
|
|
1104
|
+
}, H = (e, t) => {
|
|
1105
|
+
let n = e.callback;
|
|
1106
|
+
Vt(e), e.callback = void 0, n == null || n(t);
|
|
1107
|
+
}, Ht = (e) => {
|
|
1108
|
+
let t = performance.timeOrigin + e.startTime, n = V.filter((n) => !n.entry && Bt(n.url) === Bt(e.name) && t >= n.startTime - 50).sort((e, n) => Math.abs(e.startTime - t) - Math.abs(n.startTime - t))[0];
|
|
1109
|
+
n && (n.entry = e, n.callback && H(n, e));
|
|
1110
|
+
}, Ut = (e, t = Date.now()) => {
|
|
1111
|
+
let n = {
|
|
1112
|
+
startTime: t,
|
|
1113
|
+
url: e
|
|
1114
|
+
};
|
|
1115
|
+
return V.push(n), V.length > Rt && H(V[0]), {
|
|
1116
|
+
cancel: () => H(n),
|
|
1117
|
+
complete: (e) => {
|
|
1118
|
+
if (n.callback = e, n.entry) {
|
|
1119
|
+
H(n, n.entry);
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
n.timer = setTimeout(() => H(n), zt);
|
|
576
1123
|
}
|
|
1124
|
+
};
|
|
1125
|
+
}, Wt = 10 * 1024, Gt = [
|
|
1126
|
+
/^text\//i,
|
|
1127
|
+
/json/i,
|
|
1128
|
+
"application/x-www-form-urlencoded",
|
|
1129
|
+
"application/graphql"
|
|
1130
|
+
], Kt = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? Math.floor(e) : Wt, qt = (e, t, n) => e ? t.some((t) => typeof t == "string" ? e.toLowerCase().includes(t.toLowerCase()) : (t.lastIndex = 0, t.test(e))) : n, Jt = (e) => {
|
|
1131
|
+
try {
|
|
1132
|
+
var t;
|
|
1133
|
+
return e ? (t = new Headers(e).get("content-type")) == null ? void 0 : t : void 0;
|
|
1134
|
+
} catch (e) {
|
|
1135
|
+
return;
|
|
577
1136
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
1137
|
+
}, Yt = function() {
|
|
1138
|
+
var e = k(function* (e, t) {
|
|
1139
|
+
let n = e.getReader(), r = new TextDecoder(), i = "";
|
|
1140
|
+
try {
|
|
1141
|
+
for (; i.length <= t;) {
|
|
1142
|
+
let { done: e, value: t } = yield n.read();
|
|
1143
|
+
if (e) {
|
|
1144
|
+
i += r.decode();
|
|
1145
|
+
break;
|
|
1146
|
+
}
|
|
1147
|
+
i += r.decode(t, { stream: !0 });
|
|
1148
|
+
}
|
|
1149
|
+
i.length > t && (yield n.cancel().catch(() => void 0));
|
|
1150
|
+
} finally {
|
|
1151
|
+
n.releaseLock();
|
|
1152
|
+
}
|
|
1153
|
+
return i;
|
|
1154
|
+
});
|
|
1155
|
+
return function(t, n) {
|
|
1156
|
+
return e.apply(this, arguments);
|
|
1157
|
+
};
|
|
1158
|
+
}(), Xt = function() {
|
|
1159
|
+
var e = k(function* (e, t) {
|
|
1160
|
+
if (typeof e == "string") return e;
|
|
1161
|
+
if (typeof URLSearchParams < "u" && e instanceof URLSearchParams) return e.toString();
|
|
1162
|
+
if (typeof Blob < "u" && e instanceof Blob) return Yt(e.stream(), t);
|
|
1163
|
+
});
|
|
1164
|
+
return function(t, n) {
|
|
1165
|
+
return e.apply(this, arguments);
|
|
1166
|
+
};
|
|
1167
|
+
}(), Zt = function() {
|
|
1168
|
+
var e = k(function* (e, t) {
|
|
1169
|
+
if (typeof Request < "u" && e instanceof Request) {
|
|
1170
|
+
var n;
|
|
1171
|
+
let r = (n = e.headers.get("content-type")) == null ? void 0 : n, i = e.clone();
|
|
1172
|
+
return {
|
|
1173
|
+
contentType: r,
|
|
1174
|
+
text: i.body ? yield Yt(i.body, t) : ""
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
return {
|
|
1178
|
+
contentType: Jt(e.headers),
|
|
1179
|
+
text: yield Xt(e.body, t)
|
|
1180
|
+
};
|
|
1181
|
+
});
|
|
1182
|
+
return function(t, n) {
|
|
1183
|
+
return e.apply(this, arguments);
|
|
1184
|
+
};
|
|
1185
|
+
}(), Qt = (e) => {
|
|
1186
|
+
if (typeof Request > "u" || !(e instanceof Request)) return e;
|
|
1187
|
+
try {
|
|
1188
|
+
return e.clone();
|
|
1189
|
+
} catch (e) {
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
}, $t = function() {
|
|
1193
|
+
var e = k(function* (e, t) {
|
|
585
1194
|
var n;
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
t
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
1195
|
+
if (!e) return {};
|
|
1196
|
+
let r = (n = e.headers.get("content-type")) == null ? void 0 : n, i = e.clone();
|
|
1197
|
+
return {
|
|
1198
|
+
contentType: r,
|
|
1199
|
+
text: i.body ? yield Yt(i.body, t) : ""
|
|
1200
|
+
};
|
|
1201
|
+
});
|
|
1202
|
+
return function(t, n) {
|
|
1203
|
+
return e.apply(this, arguments);
|
|
1204
|
+
};
|
|
1205
|
+
}(), en = (e) => {
|
|
1206
|
+
var t;
|
|
1207
|
+
let n = (t = e.getResponseHeader("content-type")) == null ? void 0 : t;
|
|
1208
|
+
return e.responseType === "" || e.responseType === "text" ? {
|
|
1209
|
+
contentType: n,
|
|
1210
|
+
text: e.responseText
|
|
1211
|
+
} : e.responseType === "json" ? {
|
|
1212
|
+
contentType: n,
|
|
1213
|
+
text: JSON.stringify(e.response)
|
|
1214
|
+
} : { contentType: n };
|
|
1215
|
+
}, tn = (e, t, n, r, i) => {
|
|
1216
|
+
if (i === void 0) return;
|
|
1217
|
+
let a = Kt(e.maxSize), o = i.length > a, s = {
|
|
1218
|
+
body: i.slice(0, a * 2),
|
|
1219
|
+
contentType: r,
|
|
1220
|
+
kind: n,
|
|
1221
|
+
method: t.resource.method,
|
|
1222
|
+
statusCode: t.resource.statusCode,
|
|
1223
|
+
truncated: o,
|
|
1224
|
+
type: t.resource.type,
|
|
1225
|
+
url: t.resource.url
|
|
1226
|
+
}, c = e.redact(s);
|
|
1227
|
+
if (c !== void 0) return {
|
|
1228
|
+
body: c.slice(0, a),
|
|
1229
|
+
contentType: r,
|
|
1230
|
+
truncated: o || c.length > a
|
|
1231
|
+
};
|
|
1232
|
+
}, nn = function() {
|
|
1233
|
+
var e = k(function* ({ bodyConfig: e, domainContext: t, event: n, fetchRequest: r, runtimeContext: i, span: a }) {
|
|
1234
|
+
var o, s;
|
|
1235
|
+
let c = n.resource.statusCode, u = c === void 0 || c === 0 || c >= 400;
|
|
1236
|
+
if (((o = e.capture) == null ? "errors" : o) === "errors" && !u) return;
|
|
1237
|
+
let f = Kt(e.maxSize) * 2, p = (s = e.allowedContentTypes) == null ? Gt : s, m = {}, h = {};
|
|
1238
|
+
try {
|
|
1239
|
+
t.type === "fetch" ? [m, h] = yield Promise.all([Zt(r == null ? t.request : r, f), $t(t.response, f)]) : (m = { text: yield Xt(t.requestBody, f) }, h = en(t.xhr));
|
|
1240
|
+
} catch (e) {
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1243
|
+
let g, _;
|
|
1244
|
+
try {
|
|
1245
|
+
g = qt(m.contentType, p, !0) ? tn(e, n, "request", m.contentType, m.text) : void 0, _ = qt(h.contentType, p, !1) ? tn(e, n, "response", h.contentType, h.text) : void 0;
|
|
1246
|
+
} catch (e) {
|
|
1247
|
+
return;
|
|
1248
|
+
}
|
|
1249
|
+
if (!g && !_) return;
|
|
1250
|
+
let v = a.spanContext();
|
|
1251
|
+
i.emitLog({
|
|
1252
|
+
attributes: O(O(O({}, n.attributes), {}, {
|
|
1253
|
+
"span.id": v.spanId,
|
|
1254
|
+
"trace.id": v.traceId
|
|
1255
|
+
}, g ? {
|
|
1256
|
+
"request.body": g.body,
|
|
1257
|
+
"request.body.content_type": g.contentType,
|
|
1258
|
+
"request.body.truncated": g.truncated
|
|
1259
|
+
} : {}), _ ? {
|
|
1260
|
+
"response.body": _.body,
|
|
1261
|
+
"response.body.content_type": _.contentType,
|
|
1262
|
+
"response.body.truncated": _.truncated
|
|
1263
|
+
} : {}),
|
|
1264
|
+
body: "browser.request.body",
|
|
1265
|
+
context: d.setSpan(l.active(), a),
|
|
1266
|
+
eventName: "browser.request.body",
|
|
1267
|
+
severityNumber: u ? w.ERROR : w.INFO,
|
|
1268
|
+
severityText: u ? "ERROR" : "INFO"
|
|
1269
|
+
});
|
|
1270
|
+
});
|
|
1271
|
+
return function(t) {
|
|
1272
|
+
return e.apply(this, arguments);
|
|
622
1273
|
};
|
|
1274
|
+
}(), rn = (e) => e.deliveryType === "cache" || e.transferSize === 0 && e.decodedBodySize > 0 ? !0 : void 0, an = (...e) => e.every((t, n) => n === 0 || e[n - 1] <= t), U = (e, t, n, r, i) => {
|
|
1275
|
+
an(n, r, i) && (e[`resource.${t}.start`] = r - n, e[`resource.${t}.duration`] = i - r);
|
|
1276
|
+
}, on = (e) => {
|
|
1277
|
+
let t = {}, n = [
|
|
1278
|
+
e.startTime,
|
|
1279
|
+
e.fetchStart,
|
|
1280
|
+
e.domainLookupStart,
|
|
1281
|
+
e.domainLookupEnd,
|
|
1282
|
+
e.connectStart,
|
|
1283
|
+
e.connectEnd,
|
|
1284
|
+
e.requestStart,
|
|
1285
|
+
e.responseStart,
|
|
1286
|
+
e.responseEnd
|
|
1287
|
+
];
|
|
1288
|
+
return !n.every(Number.isFinite) || !an(...n) ? t : (U(t, "first_byte", e.startTime, e.requestStart, e.responseStart), U(t, "download", e.startTime, e.responseStart, e.responseEnd), e.workerStart > 0 && e.workerStart < e.fetchStart && U(t, "worker", e.startTime, e.workerStart, e.fetchStart), e.fetchStart < e.domainLookupEnd && U(t, "dns", e.startTime, e.domainLookupStart, e.domainLookupEnd), e.fetchStart < e.connectEnd && (U(t, "connect", e.startTime, e.connectStart, e.connectEnd), e.connectStart <= e.secureConnectionStart && e.secureConnectionStart <= e.connectEnd && U(t, "ssl", e.startTime, e.secureConnectionStart, e.connectEnd)), e.redirectEnd > e.startTime && an(e.startTime, e.redirectStart, e.redirectEnd, e.fetchStart) && U(t, "redirect", e.startTime, e.redirectStart, e.redirectEnd), t);
|
|
1289
|
+
}, sn = (e) => e.duration === 0 && e.responseEnd > e.startTime ? e.responseEnd - e.startTime : e.duration, cn = (e) => {
|
|
1290
|
+
let t = typeof e.deliveryType == "string" ? e.deliveryType || "other" : void 0;
|
|
1291
|
+
return O(O(O(O({
|
|
1292
|
+
[T.transferSize]: e.transferSize,
|
|
1293
|
+
[T.cacheHit]: rn(e),
|
|
1294
|
+
[T.nextHopProtocol]: e.nextHopProtocol
|
|
1295
|
+
}, on(e)), t ? { "resource.delivery_type": t } : {}), e.renderBlockingStatus ? { "resource.render_blocking_status": e.renderBlockingStatus } : {}), {}, {
|
|
1296
|
+
"resource.encoded_body_size": e.encodedBodySize,
|
|
1297
|
+
"resource.decoded_body_size": e.decodedBodySize
|
|
1298
|
+
});
|
|
1299
|
+
}, ln = (e = !0) => {
|
|
1300
|
+
let t;
|
|
623
1301
|
return {
|
|
624
|
-
name: "
|
|
625
|
-
|
|
1302
|
+
name: "resource",
|
|
1303
|
+
init(n) {
|
|
1304
|
+
var r;
|
|
1305
|
+
if (typeof PerformanceObserver > "u" || !((r = PerformanceObserver.supportedEntryTypes) != null && r.includes("resource"))) return;
|
|
1306
|
+
let i = (t) => {
|
|
1307
|
+
if (!t.name || ke(n.config, t.name)) return;
|
|
1308
|
+
if (t.initiatorType === "fetch" || t.initiatorType === "xmlhttprequest") {
|
|
1309
|
+
Ht(t);
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
if (t.duration < 0) return;
|
|
1313
|
+
let r = n.config.hooks.redactUrl(t.name), i = sn(t), a = performance.timeOrigin + t.startTime, o = a + i;
|
|
1314
|
+
e && n.startSpan("browser.resource", O(O(O({}, n.config.hooks.getPageAttributes()), et({
|
|
1315
|
+
duration: i,
|
|
1316
|
+
initiatorType: t.initiatorType || "other",
|
|
1317
|
+
responseStatus: t.responseStatus,
|
|
1318
|
+
transferSize: t.transferSize,
|
|
1319
|
+
url: r,
|
|
1320
|
+
urlPathTemplate: n.config.hooks.getViewPathGroup(t.name)
|
|
1321
|
+
})), {}, {
|
|
1322
|
+
"url.full": r,
|
|
1323
|
+
initiator_type: t.initiatorType || "other"
|
|
1324
|
+
}, cn(t)), { startTime: a }).end(o), n.notifyActivity({
|
|
1325
|
+
endTime: o,
|
|
1326
|
+
startTime: a,
|
|
1327
|
+
type: "resource",
|
|
1328
|
+
url: t.name
|
|
1329
|
+
});
|
|
1330
|
+
};
|
|
1331
|
+
try {
|
|
1332
|
+
t = new PerformanceObserver((e) => {
|
|
1333
|
+
for (let t of e.getEntries()) i(t);
|
|
1334
|
+
}), t.observe({
|
|
1335
|
+
type: "resource",
|
|
1336
|
+
buffered: !0
|
|
1337
|
+
});
|
|
1338
|
+
} catch (e) {
|
|
1339
|
+
t = void 0;
|
|
1340
|
+
}
|
|
1341
|
+
},
|
|
1342
|
+
shutdown() {
|
|
1343
|
+
t == null || t.disconnect(), t = void 0;
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1346
|
+
}, un = (e) => typeof e.config.tracking.request == "object" ? e.config.tracking.request : void 0, dn = (e) => {
|
|
1347
|
+
if (e.type === "xhr") return e.xhr.status;
|
|
1348
|
+
if (e.response) return e.response.status;
|
|
1349
|
+
if (typeof e.error == "object" && e.error && "status" in e.error) {
|
|
1350
|
+
let t = e.error.status;
|
|
1351
|
+
return typeof t == "number" ? t : void 0;
|
|
1352
|
+
}
|
|
1353
|
+
}, fn = (e) => typeof e == "string" || e instanceof URL ? j(String(e)) : j(e.url), pn = (e, t) => {
|
|
1354
|
+
var n;
|
|
1355
|
+
return ((n = t == null ? void 0 : t.method) == null ? typeof Request < "u" && e instanceof Request ? e.method : "GET" : n).toUpperCase();
|
|
1356
|
+
}, mn = (e, t) => typeof Request < "u" && e instanceof Request ? e : t == null ? {} : t, hn = (e, t, n) => {
|
|
1357
|
+
var r;
|
|
1358
|
+
let i = typeof Request < "u" && e instanceof Request ? e.headers : void 0, a = new Headers((r = t == null ? void 0 : t.headers) == null ? i : r);
|
|
1359
|
+
return u.inject(d.setSpan(l.active(), n), a, { set: (e, t, n) => e.set(t, n) }), O(O({}, t), {}, { headers: a });
|
|
1360
|
+
}, gn = (e, t) => {
|
|
1361
|
+
let n = {};
|
|
1362
|
+
u.inject(d.setSpan(l.active(), t), n);
|
|
1363
|
+
for (let [t, r] of Object.entries(n)) e.setRequestHeader(t, r);
|
|
1364
|
+
}, _n = (e, t) => ke(e.config, t) || M(e.config.view.excludedActivityUrls, t), vn = (e, t) => {
|
|
1365
|
+
if (_n(e, t)) return () => {};
|
|
1366
|
+
let n = N("request");
|
|
1367
|
+
e.notifyActivity({
|
|
1368
|
+
id: n,
|
|
1369
|
+
time: Date.now(),
|
|
1370
|
+
type: "request_start",
|
|
1371
|
+
url: t
|
|
1372
|
+
});
|
|
1373
|
+
let r = !1;
|
|
1374
|
+
return () => {
|
|
1375
|
+
r || (r = !0, e.notifyActivity({
|
|
1376
|
+
id: n,
|
|
1377
|
+
time: Date.now(),
|
|
1378
|
+
type: "request_end"
|
|
1379
|
+
}));
|
|
1380
|
+
};
|
|
1381
|
+
}, yn = (e, t) => e.config.transport.traces === !1 ? {
|
|
1382
|
+
cancel() {},
|
|
1383
|
+
complete(e) {
|
|
1384
|
+
e();
|
|
1385
|
+
}
|
|
1386
|
+
} : Ut(t), bn = (e, t, n) => {
|
|
1387
|
+
var r;
|
|
1388
|
+
return e.startSpan("browser.resource", O(O(O({}, e.config.hooks.getPageAttributes()), et({
|
|
1389
|
+
initiatorType: t,
|
|
1390
|
+
method: n.method,
|
|
1391
|
+
url: (r = n.url) == null ? "" : r,
|
|
1392
|
+
urlPathTemplate: n.url ? e.config.hooks.getViewPathGroup(n.url) : void 0
|
|
1393
|
+
})), n.url ? { "resource.url": e.config.hooks.redactUrl(n.url) } : {}), { kind: s.CLIENT });
|
|
1394
|
+
}, xn = (e, t, n, r, i = {}, a) => {
|
|
1395
|
+
var o;
|
|
1396
|
+
let s = i.url, l = s ? e.config.hooks.redactUrl(s) : void 0, u = dn(r), d = i.method, f = {
|
|
1397
|
+
attributes: O(O(O({}, e.config.hooks.getPageAttributes()), et({
|
|
1398
|
+
initiatorType: n,
|
|
1399
|
+
method: d,
|
|
1400
|
+
networkError: r.type === "fetch" ? !r.response : r.xhr.status === 0,
|
|
1401
|
+
responseStatus: u,
|
|
1402
|
+
url: l == null ? "" : l,
|
|
1403
|
+
urlPathTemplate: s ? e.config.hooks.getViewPathGroup(s) : void 0
|
|
1404
|
+
})), l ? {
|
|
1405
|
+
"resource.url": l,
|
|
1406
|
+
"url.full": l
|
|
1407
|
+
} : {}),
|
|
1408
|
+
resource: {
|
|
1409
|
+
method: d,
|
|
1410
|
+
statusCode: u,
|
|
1411
|
+
type: n,
|
|
1412
|
+
url: l
|
|
1413
|
+
},
|
|
1414
|
+
type: "resource"
|
|
1415
|
+
}, p = !0;
|
|
1416
|
+
try {
|
|
1417
|
+
var m, h;
|
|
1418
|
+
p = (m = un(e)) == null || (h = m.beforeSend) == null ? void 0 : h.call(m, f, r);
|
|
1419
|
+
} catch (t) {
|
|
1420
|
+
var g;
|
|
1421
|
+
e.config.debug && ((g = globalThis.console) == null || g.warn("[bk-ot] request.beforeSend failed:", t));
|
|
1422
|
+
}
|
|
1423
|
+
if (t.setAttributes(e.applyRedact(f.attributes)), p === !1) {
|
|
1424
|
+
t.setAttribute(Le, !0);
|
|
1425
|
+
return;
|
|
1426
|
+
}
|
|
1427
|
+
((u == null ? 0 : u) >= 400 || u === 0 || r.type === "fetch" && r.error) && t.setStatus({ code: c.ERROR });
|
|
1428
|
+
let _ = e.config.transport.logs === !1 || (o = un(e)) == null ? void 0 : o.body;
|
|
1429
|
+
_ && nn({
|
|
1430
|
+
bodyConfig: _,
|
|
1431
|
+
domainContext: r,
|
|
1432
|
+
event: f,
|
|
1433
|
+
fetchRequest: a,
|
|
1434
|
+
runtimeContext: e,
|
|
1435
|
+
span: t
|
|
1436
|
+
});
|
|
1437
|
+
}, Sn = (e) => {
|
|
1438
|
+
let t = [], n = /* @__PURE__ */ new Set();
|
|
1439
|
+
return {
|
|
1440
|
+
name: "request",
|
|
1441
|
+
enabled: e !== !1,
|
|
626
1442
|
init(e) {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
1443
|
+
if (!(typeof window > "u")) {
|
|
1444
|
+
if (typeof window.fetch == "function") {
|
|
1445
|
+
let r = window.fetch, i = /* @__PURE__ */ function() {
|
|
1446
|
+
var t = k(function* (t, i) {
|
|
1447
|
+
var a;
|
|
1448
|
+
let o = fn(t);
|
|
1449
|
+
if (Me(e.config, o)) return r.call(this, t, i);
|
|
1450
|
+
let s = {
|
|
1451
|
+
method: pn(t, i),
|
|
1452
|
+
url: o
|
|
1453
|
+
}, c = bn(e, "fetch", s), l = yn(e, o), u = vn(e, o), d = mn(t, i), f = e.config.transport.logs !== !1 && (a = un(e)) != null && a.body ? Qt(d) : void 0, p = Ne(e.config, o) ? hn(t, i, c) : i, m = !1, h = (t) => {
|
|
1454
|
+
m || (m = !0, n.delete(g), t && c.setAttributes(e.applyRedact(cn(t))), c.end());
|
|
1455
|
+
}, g = () => {
|
|
1456
|
+
l.cancel(), h();
|
|
1457
|
+
};
|
|
1458
|
+
n.add(g);
|
|
1459
|
+
try {
|
|
1460
|
+
let n = yield r.call(this, t, p);
|
|
1461
|
+
return xn(e, c, "fetch", {
|
|
1462
|
+
request: d,
|
|
1463
|
+
response: n,
|
|
1464
|
+
type: "fetch"
|
|
1465
|
+
}, s, f), l.complete(h), n;
|
|
1466
|
+
} catch (t) {
|
|
1467
|
+
throw xn(e, c, "fetch", {
|
|
1468
|
+
error: t,
|
|
1469
|
+
request: d,
|
|
1470
|
+
type: "fetch"
|
|
1471
|
+
}, s, f), t instanceof Error && c.recordException(t), l.complete(h), t;
|
|
1472
|
+
} finally {
|
|
1473
|
+
u();
|
|
1474
|
+
}
|
|
1475
|
+
});
|
|
1476
|
+
return function(e, n) {
|
|
1477
|
+
return t.apply(this, arguments);
|
|
1478
|
+
};
|
|
1479
|
+
}();
|
|
1480
|
+
window.fetch = i, t.push(() => {
|
|
1481
|
+
window.fetch === i && (window.fetch = r);
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
if (typeof XMLHttpRequest < "u") {
|
|
1485
|
+
let r = /* @__PURE__ */ new WeakMap(), i = XMLHttpRequest.prototype.open, a = XMLHttpRequest.prototype.send, o = function(e, t, n = !0, a, o) {
|
|
1486
|
+
return r.set(this, {
|
|
1487
|
+
method: e.toUpperCase(),
|
|
1488
|
+
url: j(String(t))
|
|
1489
|
+
}), i.call(this, e, String(t), n, a, o);
|
|
1490
|
+
}, s = function(t) {
|
|
1491
|
+
var i;
|
|
1492
|
+
let o = (i = r.get(this)) == null ? {} : i;
|
|
1493
|
+
if (!o.url || Me(e.config, o.url)) return a.call(this, t);
|
|
1494
|
+
let s = bn(e, "xhr", o), c = yn(e, o.url), l = vn(e, o.url);
|
|
1495
|
+
Ne(e.config, o.url) && gn(this, s);
|
|
1496
|
+
let u = !1, d = () => {
|
|
1497
|
+
c.cancel(), !u && (u = !0, n.delete(d), l(), s.end());
|
|
1498
|
+
};
|
|
1499
|
+
n.add(d);
|
|
1500
|
+
let f = () => {
|
|
1501
|
+
u || (xn(e, s, "xhr", {
|
|
1502
|
+
requestBody: t,
|
|
1503
|
+
type: "xhr",
|
|
1504
|
+
xhr: this
|
|
1505
|
+
}, o), l(), c.complete((t) => {
|
|
1506
|
+
u || (u = !0, n.delete(d), t && s.setAttributes(e.applyRedact(cn(t))), s.end());
|
|
1507
|
+
}));
|
|
1508
|
+
};
|
|
1509
|
+
this.addEventListener("loadend", f, { once: !0 });
|
|
1510
|
+
try {
|
|
1511
|
+
return a.call(this, t);
|
|
1512
|
+
} catch (e) {
|
|
1513
|
+
throw e instanceof Error && s.recordException(e), f(), e;
|
|
1514
|
+
}
|
|
1515
|
+
};
|
|
1516
|
+
XMLHttpRequest.prototype.open = o, XMLHttpRequest.prototype.send = s, t.push(() => {
|
|
1517
|
+
XMLHttpRequest.prototype.open === o && (XMLHttpRequest.prototype.open = i), XMLHttpRequest.prototype.send === s && (XMLHttpRequest.prototype.send = a);
|
|
1518
|
+
});
|
|
656
1519
|
}
|
|
657
|
-
|
|
658
|
-
})();
|
|
1520
|
+
}
|
|
659
1521
|
},
|
|
660
1522
|
shutdown() {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
}
|
|
1523
|
+
var e;
|
|
1524
|
+
for (let e of [...n]) e();
|
|
1525
|
+
for (; t.length;) (e = t.pop()) == null || e();
|
|
665
1526
|
}
|
|
666
1527
|
};
|
|
667
|
-
},
|
|
1528
|
+
}, W = (e) => {
|
|
668
1529
|
let t = 5381;
|
|
669
1530
|
for (let n = 0; n < e.length; n++) t = t * 33 ^ e.charCodeAt(n);
|
|
670
1531
|
return (t >>> 0).toString(36);
|
|
671
|
-
},
|
|
1532
|
+
}, Cn = (e, t) => {
|
|
672
1533
|
let n = /* @__PURE__ */ new Map(), r = 0, i = (t) => {
|
|
673
1534
|
if (!(t - r < e)) {
|
|
674
1535
|
r = t;
|
|
@@ -690,24 +1551,24 @@ var qe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Je = (e) => {
|
|
|
690
1551
|
count: o.count
|
|
691
1552
|
});
|
|
692
1553
|
} };
|
|
693
|
-
},
|
|
694
|
-
if (t) return
|
|
695
|
-
},
|
|
1554
|
+
}, wn = 6e4, Tn = 5, En = /^https?:|^\/\//i, Dn = (e, t) => {
|
|
1555
|
+
if (t) return En.test(t) ? e(t) : t;
|
|
1556
|
+
}, On = () => {
|
|
696
1557
|
let e;
|
|
697
1558
|
return {
|
|
698
1559
|
name: "csp-violation",
|
|
699
1560
|
init(t) {
|
|
700
1561
|
if (typeof window > "u" || typeof document > "u") return;
|
|
701
|
-
let n =
|
|
702
|
-
let r =
|
|
1562
|
+
let n = Cn(wn, Tn), r = (e) => {
|
|
1563
|
+
let r = W(`${e.violatedDirective}|${e.blockedURI}|${e.sourceFile}|${e.lineNumber}`), i = n.allow(r);
|
|
703
1564
|
if (!i.allowed) return;
|
|
704
|
-
let a =
|
|
705
|
-
t.startSpan("csp.violation",
|
|
1565
|
+
let a = Dn(t.config.hooks.redactUrl, e.blockedURI), o = e.sourceFile ? t.config.hooks.redactUrl(e.sourceFile) : void 0, s = i.count === 1;
|
|
1566
|
+
t.startSpan("csp.violation", O(O(O({}, t.config.hooks.getPageAttributes()), I({
|
|
706
1567
|
errorType: "csp",
|
|
707
1568
|
eventLabel: "CSP 错误",
|
|
708
|
-
result:
|
|
1569
|
+
result: P.error,
|
|
709
1570
|
spanSubtype: "csp",
|
|
710
|
-
spanType:
|
|
1571
|
+
spanType: F.error,
|
|
711
1572
|
targetLabel: a == null ? e.effectiveDirective : a,
|
|
712
1573
|
targetValue: e.statusCode
|
|
713
1574
|
})), {}, {
|
|
@@ -721,7 +1582,7 @@ var qe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Je = (e) => {
|
|
|
721
1582
|
"csp.status_code": e.statusCode,
|
|
722
1583
|
"csp.fingerprint": r,
|
|
723
1584
|
"csp.window_count": i.count,
|
|
724
|
-
[
|
|
1585
|
+
[T.exceptionFingerprint]: r,
|
|
725
1586
|
"error.source": "csp"
|
|
726
1587
|
}, s ? { "csp.original_policy": e.originalPolicy } : {})).end();
|
|
727
1588
|
};
|
|
@@ -731,7 +1592,7 @@ var qe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Je = (e) => {
|
|
|
731
1592
|
e == null || e(), e = void 0;
|
|
732
1593
|
}
|
|
733
1594
|
};
|
|
734
|
-
},
|
|
1595
|
+
}, kn = "BK_RUM_DEVICE_ID", An = 250, jn = () => navigator.connection, Mn = () => navigator.userAgentData, Nn = (e) => {
|
|
735
1596
|
for (let [t, n] of [
|
|
736
1597
|
["Edge", /Edg\/([\d.]+)/],
|
|
737
1598
|
["Chrome", /Chrome\/([\d.]+)/],
|
|
@@ -748,21 +1609,21 @@ var qe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Je = (e) => {
|
|
|
748
1609
|
name: "Other",
|
|
749
1610
|
version: void 0
|
|
750
1611
|
};
|
|
751
|
-
},
|
|
1612
|
+
}, Pn = (e, t) => {
|
|
752
1613
|
let n = `${t == null ? "" : t} ${e}`;
|
|
753
1614
|
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";
|
|
754
|
-
},
|
|
1615
|
+
}, Fn = (e) => {
|
|
755
1616
|
let t = null;
|
|
756
1617
|
try {
|
|
757
1618
|
t = window.localStorage.getItem(e);
|
|
758
1619
|
} catch (e) {}
|
|
759
1620
|
if (t) return t;
|
|
760
|
-
let n =
|
|
1621
|
+
let n = N("device");
|
|
761
1622
|
try {
|
|
762
1623
|
window.localStorage.setItem(e, n);
|
|
763
1624
|
} catch (e) {}
|
|
764
1625
|
return n;
|
|
765
|
-
},
|
|
1626
|
+
}, In = () => {
|
|
766
1627
|
var e, t;
|
|
767
1628
|
return typeof window > "u" ? {} : {
|
|
768
1629
|
"browser.viewport.width": window.innerWidth,
|
|
@@ -770,8 +1631,8 @@ var qe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Je = (e) => {
|
|
|
770
1631
|
"browser.screen.width": (e = window.screen) == null ? void 0 : e.width,
|
|
771
1632
|
"browser.screen.height": (t = window.screen) == null ? void 0 : t.height
|
|
772
1633
|
};
|
|
773
|
-
},
|
|
774
|
-
let e =
|
|
1634
|
+
}, Ln = () => {
|
|
1635
|
+
let e = jn();
|
|
775
1636
|
return e ? {
|
|
776
1637
|
"network.effective_type": e.effectiveType,
|
|
777
1638
|
"network.connection_type": e.type,
|
|
@@ -779,60 +1640,57 @@ var qe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Je = (e) => {
|
|
|
779
1640
|
"network.rtt": e.rtt,
|
|
780
1641
|
"network.save_data": e.saveData
|
|
781
1642
|
} : {};
|
|
782
|
-
},
|
|
1643
|
+
}, Rn = () => {
|
|
783
1644
|
if (typeof navigator > "u") return {};
|
|
784
|
-
let e =
|
|
1645
|
+
let e = Mn(), t = navigator.userAgent, n = Nn(t), r = Pn(t, e == null ? void 0 : e.platform), i = e != null && e.mobile || /mobi|android|iphone|ipad|ipod/i.test(t) ? "mobile" : "desktop";
|
|
785
1646
|
return {
|
|
786
1647
|
"device.memory": navigator.deviceMemory,
|
|
787
1648
|
"device.cpu_cores": navigator.hardwareConcurrency,
|
|
788
1649
|
"device.platform": e == null ? void 0 : e.platform,
|
|
789
1650
|
"device.mobile": e == null ? void 0 : e.mobile,
|
|
790
|
-
[
|
|
791
|
-
[
|
|
792
|
-
[
|
|
793
|
-
[
|
|
794
|
-
"user_agent.name": n.name,
|
|
795
|
-
"user_agent.version": n.version,
|
|
796
|
-
"user_agent.os.name": r
|
|
1651
|
+
[T.browserName]: n.name,
|
|
1652
|
+
[T.browserVersion]: n.version,
|
|
1653
|
+
[T.deviceType]: i,
|
|
1654
|
+
[T.osName]: r
|
|
797
1655
|
};
|
|
798
|
-
},
|
|
1656
|
+
}, zn = (e, t) => {
|
|
799
1657
|
let n;
|
|
800
1658
|
return () => {
|
|
801
1659
|
n !== void 0 && window.clearTimeout(n), n = window.setTimeout(() => {
|
|
802
1660
|
n = void 0, e();
|
|
803
1661
|
}, t);
|
|
804
1662
|
};
|
|
805
|
-
},
|
|
806
|
-
|
|
807
|
-
let n = [], r = (t = e.storageKey) == null ? bt : t;
|
|
1663
|
+
}, Bn = (e = {}) => {
|
|
1664
|
+
let t = [];
|
|
808
1665
|
return {
|
|
809
1666
|
name: "device",
|
|
810
|
-
init(
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
1667
|
+
init(n) {
|
|
1668
|
+
var r;
|
|
1669
|
+
let i = (r = e.storageKey) == null ? `${kn}_${W(n.config.application.name)}` : r, a = typeof window > "u" || e.persistentId !== !0 ? N("device") : Fn(i);
|
|
1670
|
+
if (n.setRuntimeAttributes(O(O(O({ "device.id": a }, Rn()), In()), Ln())), typeof window > "u") return;
|
|
1671
|
+
let o = zn(() => {
|
|
1672
|
+
n.setRuntimeAttributes(In());
|
|
1673
|
+
}, An);
|
|
1674
|
+
window.addEventListener("resize", o), window.addEventListener("orientationchange", o), t.push(() => window.removeEventListener("resize", o), () => window.removeEventListener("orientationchange", o));
|
|
1675
|
+
let s = jn();
|
|
1676
|
+
if (s && typeof s.addEventListener == "function") {
|
|
1677
|
+
let e = () => {
|
|
1678
|
+
n.setRuntimeAttributes(Ln());
|
|
821
1679
|
};
|
|
822
|
-
|
|
823
|
-
var
|
|
824
|
-
(
|
|
1680
|
+
s.addEventListener("change", e), t.push(() => {
|
|
1681
|
+
var t;
|
|
1682
|
+
(t = s.removeEventListener) == null || t.call(s, "change", e);
|
|
825
1683
|
});
|
|
826
1684
|
}
|
|
827
1685
|
},
|
|
828
1686
|
shutdown() {
|
|
829
|
-
for (;
|
|
1687
|
+
for (; t.length;) {
|
|
830
1688
|
var e;
|
|
831
|
-
(e =
|
|
1689
|
+
(e = t.pop()) == null || e();
|
|
832
1690
|
}
|
|
833
1691
|
}
|
|
834
1692
|
};
|
|
835
|
-
},
|
|
1693
|
+
}, Vn = 6e4, Hn = 5, Un = (e, t) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : t, Wn = (e) => {
|
|
836
1694
|
if (e instanceof Error) return e.message;
|
|
837
1695
|
if (typeof e == "string") return e;
|
|
838
1696
|
try {
|
|
@@ -840,63 +1698,67 @@ var qe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Je = (e) => {
|
|
|
840
1698
|
} catch (t) {
|
|
841
1699
|
return String(e);
|
|
842
1700
|
}
|
|
843
|
-
},
|
|
1701
|
+
}, Gn = (e) => {
|
|
844
1702
|
var t;
|
|
845
1703
|
return e instanceof Error ? (t = e.stack) == null ? "" : t : "";
|
|
846
|
-
},
|
|
1704
|
+
}, Kn = (e) => e.slice(0, 80), qn = (e) => {
|
|
847
1705
|
var t, n;
|
|
848
1706
|
return (t = (n = e.split("\n").find((e) => e.trim().startsWith("at "))) == null ? void 0 : n.trim()) == null ? "" : t;
|
|
849
|
-
},
|
|
850
|
-
let
|
|
1707
|
+
}, Jn = (e) => e === "unhandledrejection" ? "promise" : e === "resource" ? "resource_load" : "js", Yn = ({ context: e, error: t, exceptionType: n, extra: r = {}, source: i, spanName: a, throttle: o }) => {
|
|
1708
|
+
let s = Wn(t), l = Gn(t), u = W(`${i}|${s}|${l.slice(0, 256)}`), d = o.allow(u);
|
|
851
1709
|
if (!d.allowed) return;
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
}
|
|
856
|
-
|
|
1710
|
+
e.notifyActivity({
|
|
1711
|
+
time: Date.now(),
|
|
1712
|
+
type: "error"
|
|
1713
|
+
});
|
|
1714
|
+
let f = t instanceof Error ? t : {
|
|
1715
|
+
message: s,
|
|
1716
|
+
name: n == null ? i : n
|
|
1717
|
+
}, p = O(O(O(O({}, e.config.hooks.getPageAttributes()), e.config.hooks.getErrorAttributes()), I({
|
|
1718
|
+
errorType: Jn(i),
|
|
857
1719
|
eventLabel: "错误",
|
|
858
|
-
result:
|
|
859
|
-
spanSubtype:
|
|
860
|
-
spanType:
|
|
861
|
-
targetLabel:
|
|
1720
|
+
result: P.error,
|
|
1721
|
+
spanSubtype: Jn(i),
|
|
1722
|
+
spanType: F.error,
|
|
1723
|
+
targetLabel: t instanceof Error ? t.name : n == null ? i : n
|
|
862
1724
|
})), {}, {
|
|
863
|
-
"exception.message":
|
|
864
|
-
[
|
|
1725
|
+
"exception.message": s,
|
|
1726
|
+
[T.exceptionMessageShort]: Kn(s),
|
|
865
1727
|
"exception.stacktrace": l,
|
|
866
|
-
[
|
|
867
|
-
"exception.type":
|
|
868
|
-
[
|
|
1728
|
+
[T.exceptionStackTopFrame]: qn(l),
|
|
1729
|
+
"exception.type": t instanceof Error ? t.name : n == null ? i : n,
|
|
1730
|
+
[T.exceptionFingerprint]: u,
|
|
869
1731
|
"error.handled": !1,
|
|
870
|
-
"error.source":
|
|
1732
|
+
"error.source": i,
|
|
871
1733
|
"error.window_count": d.count
|
|
872
|
-
},
|
|
1734
|
+
}, r), m = e.startSpan(a, p);
|
|
873
1735
|
m.recordException(f), m.setStatus({
|
|
874
|
-
code:
|
|
875
|
-
message:
|
|
1736
|
+
code: c.ERROR,
|
|
1737
|
+
message: s
|
|
876
1738
|
}), m.end();
|
|
877
|
-
},
|
|
878
|
-
let t = [], n =
|
|
1739
|
+
}, Xn = (e = {}) => {
|
|
1740
|
+
let t = [], n = Un(e.windowMs, Vn), r = Un(e.maxPerWindow, Hn);
|
|
879
1741
|
return {
|
|
880
1742
|
name: "error",
|
|
881
1743
|
init(e) {
|
|
882
1744
|
if (typeof window > "u") return;
|
|
883
|
-
let i =
|
|
1745
|
+
let i = Cn(n, r), a = (t) => {
|
|
884
1746
|
var n;
|
|
885
1747
|
let r = !t.error && !t.filename && t.message === "Script error.";
|
|
886
|
-
|
|
1748
|
+
Yn({
|
|
887
1749
|
context: e,
|
|
888
1750
|
throttle: i,
|
|
889
1751
|
spanName: "browser.error",
|
|
890
1752
|
source: "window.error",
|
|
891
1753
|
error: (n = t.error) == null ? t.message : n,
|
|
892
|
-
extra:
|
|
1754
|
+
extra: O({
|
|
893
1755
|
"code.filepath": t.filename,
|
|
894
1756
|
"code.lineno": t.lineno,
|
|
895
1757
|
"code.column": t.colno
|
|
896
1758
|
}, r ? { "error.cross_origin": !0 } : {})
|
|
897
1759
|
});
|
|
898
1760
|
}, o = (t) => {
|
|
899
|
-
|
|
1761
|
+
Yn({
|
|
900
1762
|
context: e,
|
|
901
1763
|
throttle: i,
|
|
902
1764
|
spanName: "browser.unhandledrejection",
|
|
@@ -909,7 +1771,7 @@ var qe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Je = (e) => {
|
|
|
909
1771
|
let n = t.target;
|
|
910
1772
|
if (!(n instanceof Element)) return;
|
|
911
1773
|
let r = n, a = r.src || r.href || n.currentSrc || "";
|
|
912
|
-
|
|
1774
|
+
Yn({
|
|
913
1775
|
context: e,
|
|
914
1776
|
throttle: i,
|
|
915
1777
|
spanName: "browser.resource_error",
|
|
@@ -931,350 +1793,313 @@ var qe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Je = (e) => {
|
|
|
931
1793
|
}
|
|
932
1794
|
}
|
|
933
1795
|
};
|
|
934
|
-
},
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
},
|
|
951
|
-
let t =
|
|
952
|
-
return e.forEach((e, n) => {
|
|
953
|
-
t[n] = e instanceof File ? `[File name=${e.name} type=${e.type || "unknown"} size=${e.size}]` : e;
|
|
954
|
-
}), JSON.stringify(t);
|
|
955
|
-
}, Yt = function() {
|
|
956
|
-
var e = A(function* (e) {
|
|
957
|
-
return e == null ? "" : typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : e instanceof FormData ? Jt(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);
|
|
958
|
-
});
|
|
959
|
-
return function(t) {
|
|
960
|
-
return e.apply(this, arguments);
|
|
961
|
-
};
|
|
962
|
-
}(), Xt = function() {
|
|
963
|
-
var e = A(function* (e, t, n) {
|
|
964
|
-
let r = yield Yt(e);
|
|
965
|
-
if (r) return E(E({}, Kt(r, t)), {}, { contentType: n });
|
|
966
|
-
});
|
|
967
|
-
return function(t, n, r) {
|
|
968
|
-
return e.apply(this, arguments);
|
|
969
|
-
};
|
|
970
|
-
}(), H = function() {
|
|
971
|
-
var e = A(function* (e, t, n) {
|
|
972
|
-
try {
|
|
973
|
-
return yield Xt(e, t, n);
|
|
974
|
-
} catch (e) {
|
|
975
|
-
return;
|
|
976
|
-
}
|
|
977
|
-
});
|
|
978
|
-
return function(t, n, r) {
|
|
979
|
-
return e.apply(this, arguments);
|
|
980
|
-
};
|
|
981
|
-
}(), Zt = (e) => e instanceof Request ? e.url : String(e), Qt = (e, t) => t != null && t.method ? t.method : e instanceof Request ? e.method : "GET", $t = (e, t, n) => t != null && t.body ? () => H(t.body, n, qt(t.headers, "content-type")) : (e instanceof Request, () => Promise.resolve(void 0)), en = function() {
|
|
982
|
-
var e = A(function* (e, t) {
|
|
983
|
-
try {
|
|
984
|
-
let n = e.headers.get("content-type") || void 0, r = e.headers.get("content-length");
|
|
985
|
-
if (r) {
|
|
986
|
-
let e = Number(r);
|
|
987
|
-
if (Number.isFinite(e) && e > t * Ut) return {
|
|
988
|
-
body: "",
|
|
989
|
-
contentType: n,
|
|
990
|
-
truncated: !0
|
|
991
|
-
};
|
|
992
|
-
}
|
|
993
|
-
let i = e.clone();
|
|
994
|
-
return H(i.body ? yield i.text() : "", t, n);
|
|
995
|
-
} catch (e) {
|
|
996
|
-
return;
|
|
997
|
-
}
|
|
998
|
-
});
|
|
999
|
-
return function(t, n) {
|
|
1000
|
-
return e.apply(this, arguments);
|
|
1001
|
-
};
|
|
1002
|
-
}(), tn = (e, t) => {
|
|
1003
|
-
if (e.responseType === "" || e.responseType === "text") return E(E({}, Kt(e.responseText || "", t)), {}, { contentType: e.getResponseHeader("content-type") || void 0 });
|
|
1004
|
-
if (e.responseType === "json") return E(E({}, Kt(JSON.stringify(e.response), t)), {}, { contentType: e.getResponseHeader("content-type") || void 0 });
|
|
1005
|
-
}, nn = (e, t, n) => {
|
|
1006
|
-
if (n) return e.redact(E(E({}, t), {}, {
|
|
1007
|
-
body: n.body,
|
|
1008
|
-
truncated: n.truncated
|
|
1009
|
-
}));
|
|
1010
|
-
}, U = ({ config: e, context: t, duration: n, error: r, method: i, request: a, response: s, status: c, subtype: l, url: u }) => {
|
|
1011
|
-
let d = !!r || typeof c == "number" && c >= 400, f = i.toUpperCase(), p = d ? nn(e, {
|
|
1012
|
-
contentType: a == null ? void 0 : a.contentType,
|
|
1013
|
-
method: f,
|
|
1014
|
-
status: c,
|
|
1015
|
-
type: "request",
|
|
1016
|
-
url: u
|
|
1017
|
-
}, a) : void 0, m = d ? nn(e, {
|
|
1018
|
-
contentType: s == null ? void 0 : s.contentType,
|
|
1019
|
-
method: f,
|
|
1020
|
-
status: c,
|
|
1021
|
-
type: "response",
|
|
1022
|
-
url: u
|
|
1023
|
-
}, s) : void 0, h = E(E(E({}, t.config.hooks.getPageAttributes()), ze({
|
|
1024
|
-
duration: n,
|
|
1025
|
-
method: f,
|
|
1026
|
-
statusCode: c,
|
|
1027
|
-
subtype: l,
|
|
1028
|
-
url: t.config.hooks.redactUrl(u),
|
|
1029
|
-
urlPathTemplate: t.config.hooks.getViewPathGroup(u)
|
|
1030
|
-
})), {}, {
|
|
1031
|
-
"http.duration": n,
|
|
1032
|
-
"http.request.method": f,
|
|
1033
|
-
"url.full": t.config.hooks.redactUrl(u)
|
|
1034
|
-
});
|
|
1035
|
-
if (typeof c == "number" && (h["http.response.status_code"] = c), p != null && (h["http.request.body"] = p), m != null && (h["http.response.body"] = m), d) {
|
|
1036
|
-
var g, _;
|
|
1037
|
-
h["http_body.request.truncated"] = (g = a == null ? void 0 : a.truncated) == null ? !1 : g, h["http_body.response.truncated"] = (_ = s == null ? void 0 : s.truncated) == null ? !1 : _;
|
|
1038
|
-
}
|
|
1039
|
-
if (r instanceof Error) {
|
|
1040
|
-
var v;
|
|
1041
|
-
h["exception.message"] = r.message, h["exception.type"] = r.name, h["exception.stacktrace"] = (v = r.stack) == null ? "" : v;
|
|
1042
|
-
}
|
|
1043
|
-
t.emitLog({
|
|
1044
|
-
severityNumber: d ? o.ERROR : o.INFO,
|
|
1045
|
-
severityText: d ? "ERROR" : "INFO",
|
|
1046
|
-
body: d ? "HTTP request completed with error" : "HTTP request completed",
|
|
1047
|
-
attributes: h
|
|
1048
|
-
});
|
|
1049
|
-
}, rn = (e = {}) => {
|
|
1050
|
-
var t;
|
|
1051
|
-
let n = [], r = {
|
|
1052
|
-
maxBodySize: Gt(e.maxBodySize, Ht),
|
|
1053
|
-
redact: (t = e.redact) == null ? Wt : t
|
|
1054
|
-
};
|
|
1055
|
-
return {
|
|
1056
|
-
name: "http-body",
|
|
1057
|
-
init(e) {
|
|
1058
|
-
if (typeof window > "u") return;
|
|
1059
|
-
let { maxBodySize: t } = r, i = window.fetch;
|
|
1060
|
-
if (typeof i == "function") {
|
|
1061
|
-
let a = function() {
|
|
1062
|
-
var n = A(function* (n, a) {
|
|
1063
|
-
let o = Zt(n);
|
|
1064
|
-
if (M(e.config, o)) return i(n, a);
|
|
1065
|
-
let s = Qt(n, a), c = $t(n, a, t), l = performance.now();
|
|
1066
|
-
try {
|
|
1067
|
-
let u = yield i(n, a), d = performance.now() - l, f = u.status >= 400;
|
|
1068
|
-
return U({
|
|
1069
|
-
config: r,
|
|
1070
|
-
context: e,
|
|
1071
|
-
duration: d,
|
|
1072
|
-
method: s,
|
|
1073
|
-
request: f ? yield c() : void 0,
|
|
1074
|
-
response: f ? yield en(u, t) : void 0,
|
|
1075
|
-
status: u.status,
|
|
1076
|
-
subtype: "fetch",
|
|
1077
|
-
url: o
|
|
1078
|
-
}), u;
|
|
1079
|
-
} catch (t) {
|
|
1080
|
-
let n = yield c();
|
|
1081
|
-
throw U({
|
|
1082
|
-
config: r,
|
|
1083
|
-
context: e,
|
|
1084
|
-
duration: performance.now() - l,
|
|
1085
|
-
error: t,
|
|
1086
|
-
method: s,
|
|
1087
|
-
request: n,
|
|
1088
|
-
subtype: "fetch",
|
|
1089
|
-
url: o
|
|
1090
|
-
}), t;
|
|
1091
|
-
}
|
|
1092
|
-
});
|
|
1093
|
-
return function(e, t) {
|
|
1094
|
-
return n.apply(this, arguments);
|
|
1095
|
-
};
|
|
1096
|
-
}();
|
|
1097
|
-
window.fetch = a, n.push(() => {
|
|
1098
|
-
window.fetch === a && (window.fetch = i);
|
|
1099
|
-
});
|
|
1100
|
-
}
|
|
1101
|
-
let a = XMLHttpRequest.prototype.open, o = XMLHttpRequest.prototype.send, s = XMLHttpRequest.prototype.setRequestHeader, c = function(e, t, ...n) {
|
|
1102
|
-
var r;
|
|
1103
|
-
return V.set(this, {
|
|
1104
|
-
method: e,
|
|
1105
|
-
startTime: performance.now(),
|
|
1106
|
-
url: String(t)
|
|
1107
|
-
}), a.call(this, e, t, (r = n[0]) == null ? !0 : r, n[1], n[2]);
|
|
1108
|
-
}, l = function(e, t) {
|
|
1109
|
-
let n = V.get(this);
|
|
1110
|
-
if (n) {
|
|
1111
|
-
var r;
|
|
1112
|
-
let i = e.toLowerCase(), a = (r = n.requestHeaders) == null ? {} : r, o = a[i];
|
|
1113
|
-
a[i] = o ? `${o}, ${t}` : t, n.requestHeaders = a;
|
|
1114
|
-
}
|
|
1115
|
-
return s.call(this, e, t);
|
|
1116
|
-
}, u = function(n) {
|
|
1117
|
-
var i = this;
|
|
1118
|
-
let a = V.get(this);
|
|
1119
|
-
if (a) {
|
|
1120
|
-
var s;
|
|
1121
|
-
a.requestBody = n, a.requestContentType = (s = a.requestHeaders) == null ? void 0 : s["content-type"];
|
|
1122
|
-
}
|
|
1123
|
-
return this.addEventListener("abort", () => {
|
|
1124
|
-
let e = V.get(this);
|
|
1125
|
-
e && (e.aborted = !0);
|
|
1126
|
-
}, { once: !0 }), this.addEventListener("error", () => {
|
|
1127
|
-
let e = V.get(this);
|
|
1128
|
-
e && (e.networkError = !0);
|
|
1129
|
-
}, { once: !0 }), this.addEventListener("loadend", () => {
|
|
1130
|
-
A(function* () {
|
|
1131
|
-
let n = V.get(i);
|
|
1132
|
-
if (!n || M(e.config, n.url) || n.aborted) return;
|
|
1133
|
-
let a = n.networkError || i.status >= 400, o = a ? tn(i, t) : void 0, s = a ? yield H(n.requestBody, t, n.requestContentType) : void 0;
|
|
1134
|
-
U({
|
|
1135
|
-
config: r,
|
|
1136
|
-
context: e,
|
|
1137
|
-
duration: performance.now() - n.startTime,
|
|
1138
|
-
error: n.networkError ? /* @__PURE__ */ Error("XHR network error") : void 0,
|
|
1139
|
-
method: n.method,
|
|
1140
|
-
request: s,
|
|
1141
|
-
response: o,
|
|
1142
|
-
status: i.status,
|
|
1143
|
-
subtype: "xhr",
|
|
1144
|
-
url: n.url
|
|
1145
|
-
});
|
|
1146
|
-
})();
|
|
1147
|
-
}, { once: !0 }), o.call(this, n);
|
|
1148
|
-
};
|
|
1149
|
-
XMLHttpRequest.prototype.open = c, XMLHttpRequest.prototype.setRequestHeader = l, XMLHttpRequest.prototype.send = u, n.push(() => {
|
|
1150
|
-
XMLHttpRequest.prototype.open === c && (XMLHttpRequest.prototype.open = a), XMLHttpRequest.prototype.setRequestHeader === l && (XMLHttpRequest.prototype.setRequestHeader = s), XMLHttpRequest.prototype.send === u && (XMLHttpRequest.prototype.send = o);
|
|
1151
|
-
});
|
|
1152
|
-
},
|
|
1153
|
-
shutdown() {
|
|
1154
|
-
for (; n.length;) {
|
|
1155
|
-
var e;
|
|
1156
|
-
(e = n.pop()) == null || e();
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
};
|
|
1160
|
-
}, an = 50, on = (e, t) => typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : t, sn = (e = {}) => {
|
|
1161
|
-
let t, n = on(e.threshold, an);
|
|
1796
|
+
}, Zn = 50, Qn = 100, $n = 700, er = (e, t) => typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : t, tr = (e) => Number.isFinite(e) ? e : void 0, nr = (e, t) => {
|
|
1797
|
+
var n;
|
|
1798
|
+
let r = (n = e.attribution) == null ? void 0 : n[0];
|
|
1799
|
+
return r != null && r.containerSrc ? t(r.containerSrc) : (r == null ? void 0 : r.containerName) || (r == null ? void 0 : r.name) || e.name || "unknown";
|
|
1800
|
+
}, rr = (e, t) => ({
|
|
1801
|
+
"long_task.script.duration": e.duration,
|
|
1802
|
+
"long_task.script.execution_start": e.executionStart,
|
|
1803
|
+
"long_task.script.forced_style_and_layout_duration": e.forcedStyleAndLayoutDuration,
|
|
1804
|
+
"long_task.script.invoker": e.invoker,
|
|
1805
|
+
"long_task.script.invoker_type": e.invokerType,
|
|
1806
|
+
"long_task.script.pause_duration": e.pauseDuration,
|
|
1807
|
+
"long_task.script.source_char_position": e.sourceCharPosition,
|
|
1808
|
+
"long_task.script.source_function_name": e.sourceFunctionName,
|
|
1809
|
+
"long_task.script.source_url": e.sourceURL ? t(e.sourceURL) : "",
|
|
1810
|
+
"long_task.script.start_time": e.startTime,
|
|
1811
|
+
"long_task.script.window_attribution": e.windowAttribution
|
|
1812
|
+
}), ir = (e = {}) => {
|
|
1813
|
+
let t = er(e.threshold, Zn), n = Math.max(t, er(e.warningThreshold, Qn)), r, i, a = [];
|
|
1162
1814
|
return {
|
|
1163
1815
|
name: "long-task",
|
|
1164
1816
|
init(e) {
|
|
1165
|
-
var
|
|
1166
|
-
if (typeof PerformanceObserver > "u" ||
|
|
1167
|
-
let
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1817
|
+
var o;
|
|
1818
|
+
if (typeof PerformanceObserver > "u" || typeof performance > "u") return;
|
|
1819
|
+
let s = (o = PerformanceObserver.supportedEntryTypes) == null ? [] : o, c = s.includes("long-animation-frame") ? "long-animation-frame" : s.includes("longtask") ? "longtask" : void 0;
|
|
1820
|
+
if (!c) return;
|
|
1821
|
+
let l = e.meter.createCounter("browser.long_task.count", { description: "Number of long tasks and long animation frames" }), u = e.meter.createHistogram("browser.long_task.duration", {
|
|
1822
|
+
description: "Duration of long tasks and long animation frames",
|
|
1823
|
+
unit: "ms"
|
|
1824
|
+
}), d = e.meter.createHistogram("browser.long_task.blocking_duration", {
|
|
1825
|
+
description: "Blocking duration of long animation frames",
|
|
1826
|
+
unit: "ms"
|
|
1827
|
+
}), f = (r) => {
|
|
1828
|
+
var i, a, o;
|
|
1829
|
+
if (!Number.isFinite(r.duration) || r.duration < t) return;
|
|
1830
|
+
let s = r.entryType === "long-animation-frame", c = s ? r : void 0, f = (i = c == null ? void 0 : c.scripts) == null ? [] : i, p = f.reduce((e, t) => !e || t.duration > e.duration ? t : e, void 0), m = N("long-task"), h = performance.timeOrigin + r.startTime, g = h + r.duration, _ = r.duration >= n ? P.warning : P.success, v = s ? "long-animation-frame" : "long-task", y = p != null && p.sourceURL ? e.config.hooks.redactUrl(p.sourceURL) : void 0, b = s ? void 0 : nr(r, e.config.hooks.redactUrl), x = y || (p == null ? void 0 : p.sourceFunctionName) || b || "unknown", S = e.startSpan("browser.long_task", O(O(O(O(O(O(O(O({}, e.config.hooks.getPageAttributes()), I({
|
|
1831
|
+
duration: r.duration,
|
|
1832
|
+
errorType: _ === P.warning ? "main_thread_blocked" : "none",
|
|
1833
|
+
eventLabel: s ? "长动画帧" : "长任务",
|
|
1834
|
+
result: _,
|
|
1835
|
+
spanSubtype: v,
|
|
1836
|
+
spanType: F.longtask,
|
|
1837
|
+
targetLabel: x,
|
|
1838
|
+
targetValue: (a = c == null ? void 0 : c.blockingDuration) == null ? r.duration : a
|
|
1839
|
+
})), {}, {
|
|
1840
|
+
[T.longTaskBlockingDuration]: (o = c == null ? void 0 : c.blockingDuration) == null ? r.duration : o,
|
|
1841
|
+
[T.longTaskDuration]: r.duration,
|
|
1842
|
+
[T.longTaskEntryType]: v,
|
|
1843
|
+
[T.longTaskId]: m,
|
|
1844
|
+
[T.longTaskIsFrozenFrame]: r.duration >= $n,
|
|
1845
|
+
[T.longTaskScriptCount]: f.length
|
|
1846
|
+
}, b ? { [T.longTaskCulprit]: b } : {}), p ? {
|
|
1847
|
+
[T.longTaskCulprit]: x,
|
|
1848
|
+
"long_task.culprit.duration": p.duration,
|
|
1849
|
+
"long_task.culprit.forced_style_and_layout_duration": p.forcedStyleAndLayoutDuration,
|
|
1850
|
+
"long_task.culprit.function_name": p.sourceFunctionName,
|
|
1851
|
+
"long_task.culprit.invoker_type": p.invokerType
|
|
1852
|
+
} : {}), tr(c == null ? void 0 : c.firstUIEventTimestamp) === void 0 ? {} : { "long_task.first_ui_event_timestamp": c.firstUIEventTimestamp }), tr(c == null ? void 0 : c.renderStart) === void 0 ? {} : { "long_task.render_start": c.renderStart }), tr(c == null ? void 0 : c.styleAndLayoutStart) === void 0 ? {} : { "long_task.style_and_layout_start": c.styleAndLayoutStart }), c ? { [T.longTaskStartTime]: c.startTime } : {}), { startTime: h });
|
|
1853
|
+
f.forEach((t) => {
|
|
1854
|
+
S.addEvent("long_task.script", e.applyRedact(rr(t, e.config.hooks.redactUrl)), performance.timeOrigin + t.startTime);
|
|
1855
|
+
}), S.end(g), e.notifyActivity({
|
|
1856
|
+
endTime: g,
|
|
1857
|
+
startTime: h,
|
|
1858
|
+
type: "long_task"
|
|
1859
|
+
});
|
|
1860
|
+
let C = e.applyRedact(O(O(O({}, e.config.hooks.getMetricAttributes()), z(e.getRuntimeAttributes())), {}, { [T.longTaskEntryType]: v }));
|
|
1861
|
+
l.add(1, C), u.record(r.duration, C), c && d.record(c.blockingDuration, C);
|
|
1862
|
+
}, p = (e) => e.forEach((e) => f(e));
|
|
1171
1863
|
try {
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
eventLabel: "长任务",
|
|
1182
|
-
result: _,
|
|
1183
|
-
spanSubtype: (l = t == null ? void 0 : t.name) == null ? "unknown" : l,
|
|
1184
|
-
spanType: P.longtask,
|
|
1185
|
-
targetLabel: (u = (d = (f = t == null ? void 0 : t.containerSrc) == null ? t == null ? void 0 : t.containerName : f) == null ? t == null ? void 0 : t.name : d) == null ? "unknown" : u,
|
|
1186
|
-
targetValue: h.duration
|
|
1187
|
-
})), {}, {
|
|
1188
|
-
[x.longtaskBlockingDuration]: h.duration,
|
|
1189
|
-
[x.longtaskAttributionScript]: (p = (m = t == null ? void 0 : t.containerSrc) == null ? t == null ? void 0 : t.name : m) == null ? "unknown" : p
|
|
1190
|
-
}), { startTime: performance.timeOrigin + h.startTime }).end(performance.timeOrigin + h.startTime + h.duration), i.add(1, g), a.record(h.duration, g);
|
|
1191
|
-
}
|
|
1192
|
-
}), t.observe({
|
|
1193
|
-
type: "longtask",
|
|
1864
|
+
let e = !0;
|
|
1865
|
+
r = new PerformanceObserver((t) => {
|
|
1866
|
+
let n = t.getEntries();
|
|
1867
|
+
e ? (a.push(...n), i || (i = setTimeout(() => {
|
|
1868
|
+
let e = a;
|
|
1869
|
+
a = [], i = void 0, p(e);
|
|
1870
|
+
}))) : p(n);
|
|
1871
|
+
}), r.observe({
|
|
1872
|
+
type: c,
|
|
1194
1873
|
buffered: !0
|
|
1195
|
-
});
|
|
1874
|
+
}), e = !1;
|
|
1196
1875
|
} catch (e) {
|
|
1197
|
-
|
|
1876
|
+
r = void 0;
|
|
1198
1877
|
}
|
|
1199
1878
|
},
|
|
1200
1879
|
shutdown() {
|
|
1201
|
-
|
|
1880
|
+
r == null || r.disconnect(), r = void 0, clearTimeout(i), i = void 0, a = [];
|
|
1202
1881
|
}
|
|
1203
1882
|
};
|
|
1204
|
-
},
|
|
1883
|
+
}, G = /* @__PURE__ */ new Set(), K = "", q, J, ar = !1, Y = () => typeof location > "u" ? "" : location.href, or = (e, t) => {
|
|
1205
1884
|
let n = Y();
|
|
1206
|
-
|
|
1885
|
+
K = n;
|
|
1207
1886
|
let r = {
|
|
1208
1887
|
fromUrl: t,
|
|
1209
1888
|
source: e,
|
|
1210
1889
|
toUrl: n
|
|
1211
1890
|
};
|
|
1212
|
-
for (let e of Array.from(
|
|
1213
|
-
},
|
|
1214
|
-
|
|
1215
|
-
},
|
|
1216
|
-
|
|
1217
|
-
},
|
|
1218
|
-
|
|
1219
|
-
let r =
|
|
1891
|
+
for (let e of Array.from(G)) e(r);
|
|
1892
|
+
}, sr = () => {
|
|
1893
|
+
or("popstate", K || Y());
|
|
1894
|
+
}, cr = () => {
|
|
1895
|
+
or("hashchange", K || Y());
|
|
1896
|
+
}, lr = () => {
|
|
1897
|
+
ar || typeof window > "u" || typeof history > "u" || (ar = !0, K = Y(), q = history.pushState, J = history.replaceState, history.pushState = function(e, t, n) {
|
|
1898
|
+
let r = K || Y(), i = q == null ? void 0 : q.apply(this, [
|
|
1220
1899
|
e,
|
|
1221
1900
|
t,
|
|
1222
1901
|
n
|
|
1223
1902
|
]);
|
|
1224
|
-
return
|
|
1903
|
+
return or("pushState", r), i;
|
|
1225
1904
|
}, history.replaceState = function(e, t, n) {
|
|
1226
|
-
let r =
|
|
1905
|
+
let r = K || Y(), i = J == null ? void 0 : J.apply(this, [
|
|
1227
1906
|
e,
|
|
1228
1907
|
t,
|
|
1229
1908
|
n
|
|
1230
1909
|
]);
|
|
1231
|
-
return
|
|
1232
|
-
}, window.addEventListener("popstate",
|
|
1233
|
-
},
|
|
1234
|
-
!
|
|
1235
|
-
},
|
|
1236
|
-
|
|
1237
|
-
}),
|
|
1910
|
+
return or("replaceState", r), i;
|
|
1911
|
+
}, window.addEventListener("popstate", sr), window.addEventListener("hashchange", cr));
|
|
1912
|
+
}, ur = () => {
|
|
1913
|
+
!ar || typeof window > "u" || typeof history > "u" || (q && (history.pushState = q), J && (history.replaceState = J), window.removeEventListener("popstate", sr), window.removeEventListener("hashchange", cr), q = void 0, J = void 0, ar = !1, K = "");
|
|
1914
|
+
}, dr = (e) => typeof window > "u" || typeof history > "u" ? () => {} : (lr(), G.add(e), () => {
|
|
1915
|
+
G.delete(e), G.size === 0 && ur();
|
|
1916
|
+
}), fr = ["span", "stopLoadingTime"], pr = new Set([...Object.values(T), A]), mr = () => typeof location > "u" ? "" : location.href, hr = () => {
|
|
1917
|
+
if (typeof performance > "u") return {};
|
|
1918
|
+
let e = performance.getEntriesByType("navigation")[0];
|
|
1919
|
+
if (!e) return {};
|
|
1920
|
+
let t = {}, n = (e, n) => {
|
|
1921
|
+
Number.isFinite(n) && n > 0 && (t[e] = n);
|
|
1922
|
+
};
|
|
1923
|
+
return n(T.viewFirstByte, e.responseStart), n(T.viewDomInteractive, e.domInteractive), n(T.viewDomContentLoaded, e.domContentLoadedEventEnd), n(T.viewDomComplete, e.domComplete), n(T.viewLoadEvent, e.loadEventEnd), t;
|
|
1924
|
+
}, gr = (e) => {
|
|
1925
|
+
let t = e.indexOf("?");
|
|
1926
|
+
return t < 0 ? e : e.slice(0, t);
|
|
1927
|
+
}, _r = (e) => {
|
|
1928
|
+
let t = e.slice(1);
|
|
1929
|
+
if (!t || typeof document > "u" || typeof document.getElementById != "function") return !1;
|
|
1930
|
+
try {
|
|
1931
|
+
return !!document.getElementById(decodeURIComponent(t));
|
|
1932
|
+
} catch (e) {
|
|
1933
|
+
return !!document.getElementById(t);
|
|
1934
|
+
}
|
|
1935
|
+
}, vr = (e, t) => {
|
|
1936
|
+
try {
|
|
1937
|
+
let n = typeof location > "u" ? "http://localhost" : location.href, r = new URL(e, n), i = new URL(t, n);
|
|
1938
|
+
return r.pathname !== i.pathname || !_r(i.hash) && gr(r.hash) !== gr(i.hash);
|
|
1939
|
+
} catch (n) {
|
|
1940
|
+
return e !== t;
|
|
1941
|
+
}
|
|
1942
|
+
}, yr = () => {
|
|
1238
1943
|
let e = [];
|
|
1239
1944
|
return {
|
|
1240
1945
|
name: "page-view",
|
|
1241
1946
|
init(t) {
|
|
1242
1947
|
if (typeof window > "u") return;
|
|
1243
|
-
let n
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1948
|
+
let n, r, i = t.config.view.loadingTime ? t.meter.createHistogram("browser.view.loading_time", {
|
|
1949
|
+
description: "Time from view start until network and DOM activity become idle",
|
|
1950
|
+
unit: "ms"
|
|
1951
|
+
}) : void 0, a = (e = Date.now()) => t.setView({}, e), o = (e, n, r = Date.now(), i) => {
|
|
1952
|
+
e.documentVersion += 1, t.emitLog({
|
|
1953
|
+
attributes: O(O(O(O(O({}, t.config.hooks.getPageAttributes()), e.attributes), e.snapshotAttributes), {}, {
|
|
1954
|
+
"event.type": "view",
|
|
1955
|
+
"view.document_version": e.documentVersion,
|
|
1956
|
+
"view.duration": Math.max(0, r - e.startedAt),
|
|
1957
|
+
"view.is_active": n !== "final",
|
|
1958
|
+
"view.snapshot.type": n
|
|
1959
|
+
}, i ? { "view.end_reason": i } : {}), e.loadingTime === void 0 ? {} : {
|
|
1960
|
+
[T.viewLoadingTime]: e.loadingTime,
|
|
1961
|
+
"view.loading_time.source": e.loadingTimeSource
|
|
1962
|
+
}),
|
|
1963
|
+
body: "browser.view",
|
|
1964
|
+
eventName: "browser.view",
|
|
1965
|
+
severityNumber: w.INFO,
|
|
1966
|
+
severityText: "INFO",
|
|
1967
|
+
timestamp: r
|
|
1968
|
+
});
|
|
1969
|
+
}, s = (e, r = !0, s = Date.now()) => {
|
|
1970
|
+
var c;
|
|
1971
|
+
if (!n) {
|
|
1972
|
+
r && a(s);
|
|
1973
|
+
return;
|
|
1974
|
+
}
|
|
1975
|
+
let l = O({}, n);
|
|
1976
|
+
(c = n.stopLoadingTime) == null || c.call(n), n.loadingTime !== void 0 && (i == null || i.record(n.loadingTime, t.applyRedact(O(O(O({}, t.config.hooks.getMetricAttributes()), z(t.getRuntimeAttributes())), {}, { "view.loading_type": n.loadingType })))), o(n, "final", s, e), n.span.setAttribute("view.end_reason", e), n.span.end(s), n = void 0, r && a(s);
|
|
1977
|
+
let { span: u, stopLoadingTime: d } = l;
|
|
1978
|
+
return Fe(l, fr);
|
|
1979
|
+
}, c = (e, t, r) => {
|
|
1980
|
+
if (n !== e || !Number.isFinite(t) || t < 0) return;
|
|
1981
|
+
let i = O(O({}, e.loadingType === "initial_load" ? hr() : {}), {}, {
|
|
1982
|
+
[T.viewLoadingTime]: t,
|
|
1983
|
+
"view.loading_time.source": r
|
|
1253
1984
|
});
|
|
1254
|
-
|
|
1985
|
+
e.span.setAttributes(i), Object.assign(e.snapshotAttributes, i), e.loadingTime = t, e.loadingTimeSource = r, o(e, "update");
|
|
1986
|
+
}, l = (e) => {
|
|
1987
|
+
if (!t.config.view.loadingTime || document.visibilityState === "hidden") return;
|
|
1988
|
+
let r = !1, i, a = e.loadingType !== "initial_load", o, s, l = !1, u, d = () => {
|
|
1989
|
+
var t;
|
|
1990
|
+
if (l || !r || !a || n !== e) return;
|
|
1991
|
+
let s = [i, o].filter((e) => e !== void 0);
|
|
1992
|
+
s.length && c(e, Math.max(...s), "auto"), (t = e.stopLoadingTime) == null || t.call(e), e.stopLoadingTime = void 0;
|
|
1993
|
+
}, f = () => {
|
|
1994
|
+
var t, n;
|
|
1995
|
+
let r = (t = (n = performance).getEntriesByType) == null ? void 0 : t.call(n, "navigation")[0];
|
|
1996
|
+
return r != null && r.loadEventEnd ? (o = Math.max(0, performance.timeOrigin + r.loadEventEnd - e.startedAt), a = !0, !0) : !1;
|
|
1997
|
+
};
|
|
1998
|
+
if (!a && !f()) {
|
|
1999
|
+
let t = () => {
|
|
2000
|
+
setTimeout(() => {
|
|
2001
|
+
n === e && (f(), a = !0, d());
|
|
2002
|
+
});
|
|
2003
|
+
};
|
|
2004
|
+
window.addEventListener("load", t, { once: !0 }), s = () => window.removeEventListener("load", t);
|
|
2005
|
+
}
|
|
2006
|
+
let p = St(t, e.startedAt, (t) => {
|
|
2007
|
+
r = !0, t.hadActivity && (i = Math.max(0, t.endTime - e.startedAt)), d();
|
|
2008
|
+
}), m = () => {
|
|
2009
|
+
var t;
|
|
2010
|
+
document.visibilityState === "hidden" && (l = !0, (t = e.stopLoadingTime) == null || t.call(e), e.stopLoadingTime = void 0);
|
|
2011
|
+
};
|
|
2012
|
+
document.addEventListener("visibilitychange", m), u = () => document.removeEventListener("visibilitychange", m), e.stopLoadingTime = () => {
|
|
2013
|
+
p(), s == null || s(), s = void 0, u == null || u(), u = void 0;
|
|
2014
|
+
}, d();
|
|
2015
|
+
}, u = (e) => {
|
|
2016
|
+
let n = t.applyRedact(e == null ? {} : e);
|
|
2017
|
+
return Object.fromEntries(Object.entries(n).filter(([e, t]) => t !== void 0 && !pr.has(e)));
|
|
2018
|
+
}, d = (e, r, i, a = ((e) => (e = n == null ? void 0 : n.rawUrl) == null ? "" : e)()) => {
|
|
2019
|
+
var c, d;
|
|
2020
|
+
if (!t.isSessionActive()) return;
|
|
2021
|
+
let f = (c = e.url) == null ? mr() : c, p = t.config.hooks.getViewPathGroup(f), m = (d = e.name) == null ? p : d, h = u(e.attributes);
|
|
2022
|
+
s(r, !1);
|
|
2023
|
+
let g = N("view"), _ = t.config.hooks.redactUrl(f), v = t.config.hooks.redactUrl(a), y = i === "initial_load", b = y && typeof performance < "u" ? performance.timeOrigin : Date.now(), x = y ? hr() : {};
|
|
2024
|
+
t.setView({
|
|
2025
|
+
attributes: h,
|
|
2026
|
+
id: g,
|
|
2027
|
+
loadingType: i,
|
|
2028
|
+
name: m,
|
|
2029
|
+
startedAt: b,
|
|
2030
|
+
url: _,
|
|
2031
|
+
urlPathGroup: p
|
|
2032
|
+
}, b);
|
|
2033
|
+
let S = O(O(O(O(O({}, h), t.config.hooks.getPageAttributes()), x), I({
|
|
1255
2034
|
errorType: "none",
|
|
1256
|
-
eventLabel:
|
|
1257
|
-
spanSubtype:
|
|
1258
|
-
spanType:
|
|
1259
|
-
targetLabel:
|
|
1260
|
-
traceScene:
|
|
2035
|
+
eventLabel: y ? "文档加载" : "路由切换",
|
|
2036
|
+
spanSubtype: y ? "navigate" : r,
|
|
2037
|
+
spanType: y ? F.document : F.route,
|
|
2038
|
+
targetLabel: p,
|
|
2039
|
+
traceScene: y ? "page_load" : "route_change"
|
|
1261
2040
|
})), {}, {
|
|
1262
|
-
[
|
|
1263
|
-
[
|
|
1264
|
-
[
|
|
1265
|
-
[
|
|
1266
|
-
|
|
1267
|
-
"
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
2041
|
+
[T.viewId]: g,
|
|
2042
|
+
[T.viewName]: m,
|
|
2043
|
+
[T.viewUrl]: _,
|
|
2044
|
+
[T.viewUrlPathGroup]: p,
|
|
2045
|
+
[T.viewLoadingType]: i,
|
|
2046
|
+
"url.previous": v,
|
|
2047
|
+
"event.source": r
|
|
2048
|
+
}, y ? { "document.referrer": t.config.hooks.redactUrl(document.referrer || "") } : {});
|
|
2049
|
+
n = {
|
|
2050
|
+
attributes: h,
|
|
2051
|
+
documentVersion: 0,
|
|
2052
|
+
id: g,
|
|
2053
|
+
loadingType: i,
|
|
2054
|
+
name: m,
|
|
2055
|
+
rawUrl: f,
|
|
2056
|
+
snapshotAttributes: S,
|
|
2057
|
+
span: t.startSpan("browser.view", S, { startTime: b }),
|
|
2058
|
+
startedAt: b,
|
|
2059
|
+
url: _,
|
|
2060
|
+
urlPathGroup: p
|
|
2061
|
+
}, o(n, "create", b), l(n);
|
|
2062
|
+
}, f = t.onViewCommand((e) => {
|
|
2063
|
+
if (e.type === "start") {
|
|
2064
|
+
d(e.options, "manual", n ? "route_change" : "initial_load");
|
|
2065
|
+
return;
|
|
2066
|
+
}
|
|
2067
|
+
if (n) {
|
|
2068
|
+
if (e.type === "set_loading_time") {
|
|
2069
|
+
var r;
|
|
2070
|
+
(r = n.stopLoadingTime) == null || r.call(n), n.stopLoadingTime = void 0, c(n, Math.max(0, e.time - n.startedAt), "manual");
|
|
2071
|
+
return;
|
|
2072
|
+
}
|
|
2073
|
+
n.name = e.name, n.span.setAttribute(T.viewName, e.name), n.snapshotAttributes[T.viewName] = e.name, t.setView({
|
|
2074
|
+
attributes: n.attributes,
|
|
2075
|
+
id: n.id,
|
|
2076
|
+
loadingType: n.loadingType,
|
|
2077
|
+
name: n.name,
|
|
2078
|
+
startedAt: n.startedAt,
|
|
2079
|
+
url: n.url,
|
|
2080
|
+
urlPathGroup: n.urlPathGroup
|
|
2081
|
+
}), o(n, "update");
|
|
2082
|
+
}
|
|
2083
|
+
}), p = () => {};
|
|
2084
|
+
t.config.view.tracking === "auto" && (n || d({}, "load", "initial_load"), p = dr((e) => {
|
|
2085
|
+
vr(e.fromUrl, e.toUrl) && d({}, e.source, "route_change", e.fromUrl);
|
|
2086
|
+
}));
|
|
2087
|
+
let m = (e) => {
|
|
2088
|
+
e.persisted || s("pagehide");
|
|
2089
|
+
}, h = (e) => {
|
|
2090
|
+
e.persisted && t.config.view.tracking === "auto" && d({}, "bfCache", "bf_cache", n == null ? void 0 : n.rawUrl);
|
|
2091
|
+
}, g = t.onSessionLifecycle((e) => {
|
|
2092
|
+
if (e.type === "expired") {
|
|
2093
|
+
r = s("session_expired", !0, e.expiredAt);
|
|
2094
|
+
return;
|
|
2095
|
+
}
|
|
2096
|
+
r && (d({
|
|
2097
|
+
attributes: r.attributes,
|
|
2098
|
+
name: r.name,
|
|
2099
|
+
url: r.rawUrl
|
|
2100
|
+
}, "sessionRenewal", "session_renewal", r.rawUrl), r = void 0);
|
|
1272
2101
|
});
|
|
1273
|
-
|
|
1274
|
-
let o = () => {
|
|
1275
|
-
r == null || r.setAttribute("view.end_reason", "shutdown"), r == null || r.end(), r = void 0;
|
|
1276
|
-
};
|
|
1277
|
-
window.addEventListener("pagehide", o), e.push(a, () => window.removeEventListener("pagehide", o), o);
|
|
2102
|
+
window.addEventListener("pagehide", m), window.addEventListener("pageshow", h), e.push(p, g, f, () => window.removeEventListener("pagehide", m), () => window.removeEventListener("pageshow", h), () => s("shutdown"));
|
|
1278
2103
|
},
|
|
1279
2104
|
shutdown() {
|
|
1280
2105
|
for (; e.length;) {
|
|
@@ -1283,253 +2108,248 @@ var qe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Je = (e) => {
|
|
|
1283
2108
|
}
|
|
1284
2109
|
}
|
|
1285
2110
|
};
|
|
1286
|
-
},
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
let r = `${e.name}|${e.startTime}`;
|
|
1296
|
-
if (t.has(r)) return;
|
|
1297
|
-
t.add(r);
|
|
1298
|
-
let i = n.config.hooks.redactUrl(e.name), a = e.duration;
|
|
1299
|
-
n.startSpan("browser.resource", E(E(E({}, n.config.hooks.getPageAttributes()), Be({
|
|
1300
|
-
duration: a,
|
|
1301
|
-
initiatorType: e.initiatorType || "other",
|
|
1302
|
-
responseStatus: e.responseStatus,
|
|
1303
|
-
transferSize: e.transferSize,
|
|
1304
|
-
url: i,
|
|
1305
|
-
urlPathTemplate: n.config.hooks.getViewPathGroup(e.name)
|
|
1306
|
-
})), {}, {
|
|
1307
|
-
"url.full": i,
|
|
1308
|
-
[x.transferSize]: e.transferSize,
|
|
1309
|
-
[x.cacheHit]: hn(e),
|
|
1310
|
-
[x.nextHopProtocol]: e.nextHopProtocol,
|
|
1311
|
-
initiator_type: e.initiatorType || "other",
|
|
1312
|
-
"resource.encoded_body_size": e.encodedBodySize,
|
|
1313
|
-
"resource.decoded_body_size": e.decodedBodySize
|
|
1314
|
-
}), { startTime: performance.timeOrigin + e.startTime }).end(performance.timeOrigin + e.startTime + a);
|
|
1315
|
-
};
|
|
1316
|
-
try {
|
|
1317
|
-
e = new PerformanceObserver((e) => {
|
|
1318
|
-
for (let t of e.getEntries()) i(t);
|
|
1319
|
-
}), e.observe({
|
|
1320
|
-
type: "resource",
|
|
1321
|
-
buffered: !0
|
|
1322
|
-
});
|
|
1323
|
-
} catch (t) {
|
|
1324
|
-
e = void 0;
|
|
1325
|
-
}
|
|
1326
|
-
},
|
|
1327
|
-
shutdown() {
|
|
1328
|
-
e == null || e.disconnect(), e = void 0, t.clear();
|
|
1329
|
-
}
|
|
1330
|
-
};
|
|
1331
|
-
}, _n = () => {
|
|
1332
|
-
let e = [], t = !1;
|
|
1333
|
-
return {
|
|
1334
|
-
name: "route-timing",
|
|
1335
|
-
init(n) {
|
|
1336
|
-
if (typeof window > "u" || typeof history > "u") return;
|
|
1337
|
-
let r = n.meter.createHistogram("browser.route_change.duration", {
|
|
1338
|
-
unit: "ms",
|
|
1339
|
-
description: "Estimated SPA route change duration (route start to next idle)"
|
|
1340
|
-
}), i = (e, i, a) => {
|
|
1341
|
-
if (t) return;
|
|
1342
|
-
let o = performance.now(), s = performance.timeOrigin + o, c = () => {
|
|
1343
|
-
if (t || typeof document < "u" && document.visibilityState === "hidden") return;
|
|
1344
|
-
let c = performance.now() - o, l = c > 500 ? N.warning : N.success, u = n.applyRedact(E(E(E(E({}, n.config.hooks.getPageAttributes()), n.config.hooks.getMetricAttributes()), I(n.getRuntimeAttributes())), {}, { "route.change.source": e }));
|
|
1345
|
-
r.record(c, u), n.startSpan("browser.route_change", E(E(E({}, u), F({
|
|
1346
|
-
duration: c,
|
|
1347
|
-
errorType: l === N.warning ? "slow" : "none",
|
|
1348
|
-
eventLabel: "路由切换",
|
|
1349
|
-
result: l,
|
|
1350
|
-
spanSubtype: e,
|
|
1351
|
-
spanType: P.route,
|
|
1352
|
-
targetLabel: n.config.hooks.getViewPathGroup(a),
|
|
1353
|
-
targetValue: c,
|
|
1354
|
-
traceScene: "route_change"
|
|
1355
|
-
})), {}, {
|
|
1356
|
-
"url.full": n.config.hooks.redactUrl(a),
|
|
1357
|
-
"url.previous": n.config.hooks.redactUrl(i)
|
|
1358
|
-
}), { startTime: s }).end();
|
|
1359
|
-
};
|
|
1360
|
-
requestAnimationFrame(() => requestAnimationFrame(() => setTimeout(c, 0)));
|
|
1361
|
-
}, a = fn((e) => {
|
|
1362
|
-
e.fromUrl !== e.toUrl && i(e.source, e.fromUrl, e.toUrl);
|
|
1363
|
-
});
|
|
1364
|
-
e.push(a);
|
|
1365
|
-
},
|
|
1366
|
-
shutdown() {
|
|
1367
|
-
for (t = !0; e.length;) {
|
|
1368
|
-
var n;
|
|
1369
|
-
(n = e.pop()) == null || n();
|
|
1370
|
-
}
|
|
1371
|
-
}
|
|
1372
|
-
};
|
|
1373
|
-
}, vn = 1800 * 1e3, yn = 1440 * 60 * 1e3, bn = 6e4, xn = 5e3, Sn = [
|
|
1374
|
-
"click",
|
|
1375
|
-
"keydown",
|
|
1376
|
-
"scroll",
|
|
1377
|
-
"mousemove",
|
|
1378
|
-
"touchstart"
|
|
1379
|
-
], Cn = (e, t) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : t, wn = (e, t) => typeof e == "number" && Number.isFinite(e) && e > 0 && e <= t + xn, Tn = (e, t) => {
|
|
2111
|
+
}, br = 5e3, xr = (e) => typeof e == "number" && Number.isFinite(e) && e > 0, Sr = (e, t, n, r) => ({
|
|
2112
|
+
expiresAt: Math.min(t + n, t + r),
|
|
2113
|
+
id: e,
|
|
2114
|
+
startedAt: t,
|
|
2115
|
+
status: "active"
|
|
2116
|
+
}), X = (e, t, n) => {
|
|
2117
|
+
if (t >= e.startedAt + n) return "maxLifetime";
|
|
2118
|
+
if (t >= e.expiresAt) return "inactivity";
|
|
2119
|
+
}, Cr = (e, t, n, r) => O(O({}, e), {}, { expiresAt: Math.min(t + n, e.startedAt + r) }), wr = (e, t, n) => {
|
|
1380
2120
|
if (!e) return null;
|
|
1381
2121
|
try {
|
|
1382
|
-
let
|
|
1383
|
-
if (typeof
|
|
2122
|
+
let r = JSON.parse(e);
|
|
2123
|
+
if (r.status === "active" && typeof r.id == "string" && r.id.length > 0 && xr(r.startedAt) && r.startedAt <= t + br && xr(r.expiresAt) && r.expiresAt >= r.startedAt && r.expiresAt <= r.startedAt + n || r.status === "expired" && typeof r.previousId == "string" && r.previousId.length > 0 && (r.reason === "inactivity" || r.reason === "maxLifetime") && xr(r.expiredAt) && r.expiredAt <= t + br) return r;
|
|
1384
2124
|
} catch (e) {}
|
|
1385
2125
|
return null;
|
|
1386
|
-
},
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
let
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
}, Dn = (e, t) => {
|
|
1399
|
-
if (typeof window > "u") return;
|
|
1400
|
-
let n = JSON.stringify(t);
|
|
1401
|
-
try {
|
|
1402
|
-
window.sessionStorage.setItem(e, n);
|
|
1403
|
-
} catch (e) {}
|
|
1404
|
-
try {
|
|
1405
|
-
window.localStorage.setItem(e, n);
|
|
1406
|
-
} catch (e) {}
|
|
1407
|
-
}, On = (e, t, n) => {
|
|
1408
|
-
let r = Date.now(), i = En(e, r);
|
|
1409
|
-
if (i) {
|
|
1410
|
-
let a = r - i.ts >= t, o = r - i.startedAt >= n;
|
|
1411
|
-
if (!a && !o) {
|
|
1412
|
-
let t = E(E({}, i), {}, { ts: r });
|
|
1413
|
-
return Dn(e, t), {
|
|
1414
|
-
id: t.id,
|
|
1415
|
-
rotated: !1
|
|
1416
|
-
};
|
|
2126
|
+
}, Tr = 900 * 1e3, Z = 14400 * 1e3, Er = 1e3, Dr = 6e4, Or = [
|
|
2127
|
+
"click",
|
|
2128
|
+
"keydown",
|
|
2129
|
+
"scroll",
|
|
2130
|
+
"touchstart"
|
|
2131
|
+
], kr = /* @__PURE__ */ new Map(), Ar = (e) => {
|
|
2132
|
+
let t = typeof window < "u", n = () => {
|
|
2133
|
+
var n;
|
|
2134
|
+
if (t) try {
|
|
2135
|
+
return window.localStorage.getItem(e);
|
|
2136
|
+
} catch (e) {
|
|
2137
|
+
t = !1;
|
|
1417
2138
|
}
|
|
1418
|
-
|
|
1419
|
-
id: B("session"),
|
|
1420
|
-
startedAt: r,
|
|
1421
|
-
ts: r
|
|
1422
|
-
};
|
|
1423
|
-
return Dn(e, c), {
|
|
1424
|
-
id: c.id,
|
|
1425
|
-
prevId: i.id,
|
|
1426
|
-
reason: s,
|
|
1427
|
-
rotated: !0
|
|
1428
|
-
};
|
|
1429
|
-
}
|
|
1430
|
-
let a = {
|
|
1431
|
-
id: B("session"),
|
|
1432
|
-
startedAt: r,
|
|
1433
|
-
ts: r
|
|
2139
|
+
return (n = kr.get(e)) == null ? null : n;
|
|
1434
2140
|
};
|
|
1435
|
-
return
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
2141
|
+
return n(), {
|
|
2142
|
+
isLocalStorage: () => t,
|
|
2143
|
+
read: n,
|
|
2144
|
+
write: (n) => {
|
|
2145
|
+
let r = JSON.stringify(n);
|
|
2146
|
+
if (kr.set(e, r), t) try {
|
|
2147
|
+
window.localStorage.setItem(e, r);
|
|
2148
|
+
} catch (e) {
|
|
2149
|
+
t = !1;
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
1439
2152
|
};
|
|
1440
|
-
},
|
|
1441
|
-
let
|
|
2153
|
+
}, jr = (e, t) => {
|
|
2154
|
+
let n = "";
|
|
1442
2155
|
try {
|
|
1443
|
-
|
|
1444
|
-
} catch (
|
|
1445
|
-
|
|
1446
|
-
}
|
|
1447
|
-
return `bk_ot_session__${
|
|
1448
|
-
},
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
e.emitLog({
|
|
1452
|
-
severityNumber: o.INFO,
|
|
2156
|
+
n = new URL(e).host;
|
|
2157
|
+
} catch (t) {
|
|
2158
|
+
n = e;
|
|
2159
|
+
}
|
|
2160
|
+
return `bk_ot_session__${W(`${t}\0${n || "default"}`)}`;
|
|
2161
|
+
}, Mr = (e, t) => {
|
|
2162
|
+
t.reason && e.emitLog({
|
|
2163
|
+
severityNumber: w.INFO,
|
|
1453
2164
|
severityText: "INFO",
|
|
1454
2165
|
body: t.reason === "init" ? "session.start" : "session.rotate",
|
|
1455
|
-
attributes:
|
|
1456
|
-
[
|
|
1457
|
-
[
|
|
1458
|
-
[
|
|
2166
|
+
attributes: O(O({}, e.config.hooks.getPageAttributes()), {}, {
|
|
2167
|
+
[T.sessionHasReplay]: !1,
|
|
2168
|
+
[T.sessionId]: t.record.id,
|
|
2169
|
+
[T.sessionStartTime]: t.record.startedAt,
|
|
1459
2170
|
"session.rotate.reason": t.reason
|
|
1460
|
-
}, t.
|
|
2171
|
+
}, t.previousId ? { "session.previous_id": t.previousId } : {})
|
|
1461
2172
|
});
|
|
1462
|
-
},
|
|
1463
|
-
let t = []
|
|
2173
|
+
}, Nr = (e = {}) => {
|
|
2174
|
+
let t = [];
|
|
1464
2175
|
return {
|
|
1465
2176
|
name: "session",
|
|
1466
|
-
init(
|
|
1467
|
-
var
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
2177
|
+
init(n) {
|
|
2178
|
+
var r;
|
|
2179
|
+
if (typeof window > "u" || typeof document > "u") {
|
|
2180
|
+
n.setRuntimeAttributes({
|
|
2181
|
+
[T.sessionHasReplay]: !1,
|
|
2182
|
+
[T.sessionId]: N("session")
|
|
2183
|
+
});
|
|
2184
|
+
return;
|
|
2185
|
+
}
|
|
2186
|
+
let i = (r = e.storageKey) == null ? jr(n.config.transport.endpoint, n.config.application.name) : r, a = Ar(i), o = typeof performance < "u" && Number.isFinite(performance.timeOrigin) ? performance.timeOrigin : Date.now(), s, c, l = (e = Date.now()) => wr(a.read(), e, Z), u = () => {
|
|
2187
|
+
c !== void 0 && (clearTimeout(c), c = void 0);
|
|
2188
|
+
}, d = (e, t = Date.now()) => {
|
|
2189
|
+
let r = s;
|
|
2190
|
+
r && (n.notifySessionLifecycle({
|
|
2191
|
+
expiredAt: t,
|
|
2192
|
+
id: r,
|
|
2193
|
+
reason: e,
|
|
2194
|
+
type: "expired"
|
|
2195
|
+
}), u(), s = void 0, n.setRuntimeAttributes({
|
|
2196
|
+
[T.sessionHasReplay]: void 0,
|
|
2197
|
+
[T.sessionId]: void 0
|
|
2198
|
+
}, t), n.flush());
|
|
2199
|
+
}, f = () => {
|
|
2200
|
+
let e = Date.now(), t = l(e);
|
|
2201
|
+
if (!t) {
|
|
2202
|
+
d("external", e);
|
|
2203
|
+
return;
|
|
2204
|
+
}
|
|
2205
|
+
if (t.status === "expired") {
|
|
2206
|
+
d(t.reason, t.expiredAt);
|
|
2207
|
+
return;
|
|
2208
|
+
}
|
|
2209
|
+
if (t.id !== s) {
|
|
2210
|
+
d("external", e);
|
|
2211
|
+
return;
|
|
2212
|
+
}
|
|
2213
|
+
let n = X(t, e, Z);
|
|
2214
|
+
if (!n) {
|
|
2215
|
+
p(t);
|
|
2216
|
+
return;
|
|
2217
|
+
}
|
|
2218
|
+
let r = {
|
|
2219
|
+
expiredAt: e,
|
|
2220
|
+
previousId: t.id,
|
|
2221
|
+
reason: n,
|
|
2222
|
+
status: "expired"
|
|
2223
|
+
};
|
|
2224
|
+
a.write(r), d(n, e);
|
|
2225
|
+
}, p = (e) => {
|
|
2226
|
+
u();
|
|
2227
|
+
let t = Math.min(e.expiresAt, e.startedAt + Z);
|
|
2228
|
+
c = setTimeout(f, Math.max(0, t - Date.now()));
|
|
2229
|
+
}, m = (e, t) => {
|
|
2230
|
+
let r = e.id !== s;
|
|
2231
|
+
s = e.id, n.setRuntimeAttributes({
|
|
2232
|
+
[T.sessionHasReplay]: !1,
|
|
2233
|
+
[T.sessionId]: e.id
|
|
2234
|
+
}, Math.min(e.startedAt, o)), p(e), r && t && n.notifySessionLifecycle({
|
|
2235
|
+
id: e.id,
|
|
2236
|
+
previousId: t.previousId,
|
|
2237
|
+
reason: t.reason,
|
|
2238
|
+
startedAt: e.startedAt,
|
|
2239
|
+
type: "renewed"
|
|
2240
|
+
});
|
|
2241
|
+
}, h = (e = !1) => {
|
|
2242
|
+
let t = Date.now(), r = l(t);
|
|
2243
|
+
if ((r == null ? void 0 : r.status) === "active" && !X(r, t, Z)) {
|
|
2244
|
+
let e = Cr(r, t, Tr, Z);
|
|
2245
|
+
a.write(e), m(e, s ? void 0 : { reason: "shared" });
|
|
2246
|
+
return;
|
|
2247
|
+
}
|
|
2248
|
+
let i = (r == null ? void 0 : r.status) === "expired" ? r.previousId : r == null ? void 0 : r.id, o = (r == null ? void 0 : r.status) === "expired" ? r.reason : r ? X(r, t, Z) : e ? "init" : void 0, c = Sr(N("session"), t, Tr, Z);
|
|
2249
|
+
a.write(c), m(c, {
|
|
2250
|
+
previousId: i,
|
|
2251
|
+
reason: o == null ? "init" : o
|
|
2252
|
+
}), Mr(n, {
|
|
2253
|
+
previousId: i,
|
|
2254
|
+
reason: o == null ? "init" : o,
|
|
2255
|
+
record: c
|
|
2256
|
+
});
|
|
2257
|
+
}, g = () => {
|
|
2258
|
+
if (!s) return;
|
|
2259
|
+
let e = Date.now(), t = l(e);
|
|
2260
|
+
if ((t == null ? void 0 : t.status) !== "active" || t.id !== s || X(t, e, Z)) {
|
|
2261
|
+
f();
|
|
1474
2262
|
return;
|
|
1475
2263
|
}
|
|
1476
|
-
let
|
|
1477
|
-
|
|
1478
|
-
[x.sessionHasReplay]: !1,
|
|
1479
|
-
[x.sessionId]: e.id
|
|
1480
|
-
}), e.id !== s && (s = e.id, An(i, e));
|
|
2264
|
+
let n = Cr(t, e, Tr, Z);
|
|
2265
|
+
a.write(n), m(n);
|
|
1481
2266
|
};
|
|
1482
|
-
|
|
1483
|
-
let
|
|
2267
|
+
h(!0);
|
|
2268
|
+
let _ = 0, v = () => {
|
|
1484
2269
|
let e = Date.now();
|
|
1485
|
-
e -
|
|
1486
|
-
},
|
|
2270
|
+
e - _ < Er || (_ = e, h());
|
|
2271
|
+
}, y = {
|
|
1487
2272
|
capture: !0,
|
|
1488
2273
|
passive: !0
|
|
1489
2274
|
};
|
|
1490
|
-
|
|
1491
|
-
window.
|
|
1492
|
-
}), t.push(() => {
|
|
1493
|
-
Sn.forEach((e) => {
|
|
1494
|
-
window.removeEventListener(e, u, d);
|
|
1495
|
-
});
|
|
2275
|
+
Or.forEach((e) => window.addEventListener(e, v, y)), t.push(() => {
|
|
2276
|
+
Or.forEach((e) => window.removeEventListener(e, v, y));
|
|
1496
2277
|
});
|
|
1497
|
-
let
|
|
1498
|
-
document.visibilityState === "visible" &&
|
|
2278
|
+
let b = () => {
|
|
2279
|
+
document.visibilityState === "visible" && g();
|
|
1499
2280
|
};
|
|
1500
|
-
document.addEventListener("visibilitychange",
|
|
1501
|
-
let
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
2281
|
+
document.addEventListener("visibilitychange", b);
|
|
2282
|
+
let x = window.setInterval(b, Dr);
|
|
2283
|
+
t.push(() => {
|
|
2284
|
+
document.removeEventListener("visibilitychange", b), window.clearInterval(x);
|
|
2285
|
+
});
|
|
2286
|
+
let S = (e) => {
|
|
2287
|
+
if (!a.isLocalStorage() || e.storageArea !== window.localStorage || e.key !== i) return;
|
|
2288
|
+
let t = Date.now(), n = wr(e.newValue, t, Z);
|
|
2289
|
+
if ((n == null ? void 0 : n.status) === "active" && n.id === s && !X(n, t, Z)) {
|
|
2290
|
+
p(n);
|
|
2291
|
+
return;
|
|
1510
2292
|
}
|
|
2293
|
+
d((n == null ? void 0 : n.status) === "expired" ? n.reason : "external", (n == null ? void 0 : n.status) === "expired" ? n.expiredAt : t);
|
|
1511
2294
|
};
|
|
1512
|
-
window.addEventListener("storage",
|
|
2295
|
+
window.addEventListener("storage", S), t.push(() => window.removeEventListener("storage", S)), t.push(u);
|
|
1513
2296
|
},
|
|
1514
2297
|
shutdown() {
|
|
1515
|
-
for (; t.length;)
|
|
1516
|
-
var e;
|
|
1517
|
-
(e = t.pop()) == null || e();
|
|
1518
|
-
}
|
|
2298
|
+
for (var e; t.length;) (e = t.pop()) == null || e();
|
|
1519
2299
|
}
|
|
1520
2300
|
};
|
|
1521
|
-
},
|
|
1522
|
-
if (typeof performance > "u") return
|
|
2301
|
+
}, Pr = "unknown", Fr = 10, Ir = 6e4, Lr = 5e3, Rr = 1e3, zr = (e) => e ? e.replace(/_/g, "-") : Pr, Br = () => {
|
|
2302
|
+
if (typeof performance > "u") return Pr;
|
|
1523
2303
|
let e = performance.getEntriesByType("navigation")[0];
|
|
1524
|
-
return
|
|
1525
|
-
},
|
|
2304
|
+
return zr(e == null ? void 0 : e.type);
|
|
2305
|
+
}, Vr = (e, t) => {
|
|
2306
|
+
let [n, r] = e === "CLS" ? [.1, .25] : [200, 500];
|
|
2307
|
+
return t <= n ? "good" : t <= r ? "needs-improvement" : "poor";
|
|
2308
|
+
}, Hr = (e) => {
|
|
2309
|
+
var t, n, r;
|
|
2310
|
+
if (!(typeof Element > "u" || !(e instanceof Element))) return (t = (n = (r = e.getAttribute("data-bk-action-name")) == null ? e.getAttribute("aria-label") : r) == null ? e.getAttribute("name") : n) == null ? e.tagName.toLowerCase() : t;
|
|
2311
|
+
}, Ur = () => {
|
|
2312
|
+
if (typeof performance > "u") return;
|
|
2313
|
+
let e = performance.interactionCount;
|
|
2314
|
+
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
2315
|
+
}, Wr = (e, t) => {
|
|
2316
|
+
var n, r;
|
|
2317
|
+
let i = (n = t.value) == null ? 0 : n;
|
|
2318
|
+
if (!(t.hadRecentInput || !Number.isFinite(i))) {
|
|
2319
|
+
if (e.clsWindowStart === void 0 || t.startTime - ((r = e.clsWindowEnd) == null ? t.startTime : r) >= Rr || t.startTime - e.clsWindowStart >= Lr) {
|
|
2320
|
+
var a;
|
|
2321
|
+
e.clsWindowStart = t.startTime, e.clsWindowValue = i, e.clsWindowLargestShiftValue = i, e.clsWindowLargestShiftTarget = Hr((a = t.sources) == null || (a = a[0]) == null ? void 0 : a.node);
|
|
2322
|
+
} else if (e.clsWindowValue += i, i > e.clsWindowLargestShiftValue) {
|
|
2323
|
+
var o;
|
|
2324
|
+
e.clsWindowLargestShiftValue = i, e.clsWindowLargestShiftTarget = Hr((o = t.sources) == null || (o = o[0]) == null ? void 0 : o.node);
|
|
2325
|
+
}
|
|
2326
|
+
e.clsWindowEnd = t.startTime, e.clsWindowValue > e.cls && (e.cls = Math.round(e.clsWindowValue * 1e4) / 1e4, e.largestShiftValue = e.clsWindowLargestShiftValue, e.largestShiftTarget = e.clsWindowLargestShiftTarget);
|
|
2327
|
+
}
|
|
2328
|
+
}, Gr = (e, t) => {
|
|
2329
|
+
var n, r;
|
|
2330
|
+
if (!t.interactionId || !Number.isFinite(t.duration)) return;
|
|
2331
|
+
e.interactionIdMin = Math.min(e.interactionIdMin, t.interactionId), e.interactionIdMax = Math.max(e.interactionIdMax, t.interactionId);
|
|
2332
|
+
let i = (n = t.processingStart) == null ? t.startTime : n, a = (r = t.processingEnd) == null ? i : r, o = {
|
|
2333
|
+
duration: Math.min(t.duration, Ir),
|
|
2334
|
+
inputDelay: Math.max(0, i - t.startTime),
|
|
2335
|
+
interactionId: t.interactionId,
|
|
2336
|
+
interactionTarget: Hr(t.target),
|
|
2337
|
+
interactionType: t.name,
|
|
2338
|
+
presentationDelay: Math.max(0, t.startTime + t.duration - a),
|
|
2339
|
+
processingDuration: Math.max(0, a - i)
|
|
2340
|
+
}, s = e.inpCandidates.findIndex((e) => e.interactionId === t.interactionId);
|
|
2341
|
+
s >= 0 ? o.duration > e.inpCandidates[s].duration && (e.inpCandidates[s] = o) : e.inpCandidates.push(o), e.inpCandidates.sort((e, t) => t.duration - e.duration).splice(Fr);
|
|
2342
|
+
}, Kr = (e) => {
|
|
2343
|
+
let t = Ur(), n = t !== void 0 && e.interactionCountAtStart !== void 0 ? Math.max(0, t - e.interactionCountAtStart) : e.interactionIdMin === Infinity ? 0 : (e.interactionIdMax - e.interactionIdMin) / 7 + 1;
|
|
2344
|
+
if (e.inpCandidates.length) return e.inpCandidates[Math.min(e.inpCandidates.length - 1, Math.floor(n / 50))];
|
|
2345
|
+
}, qr = (e, t) => {
|
|
1526
2346
|
var n;
|
|
1527
2347
|
return {
|
|
1528
2348
|
"rum.navigation.type": (n = e.navigationType) == null ? t : n,
|
|
1529
|
-
[
|
|
1530
|
-
[
|
|
2349
|
+
[T.vitalMetric]: e.name.toLowerCase(),
|
|
2350
|
+
[T.vitalRating]: e.rating
|
|
1531
2351
|
};
|
|
1532
|
-
},
|
|
2352
|
+
}, Jr = (e, t) => {
|
|
1533
2353
|
var n;
|
|
1534
2354
|
let r = (n = e.attribution) == null ? {} : n, i = {}, a = (e) => r[e], o = (e, t, n) => {
|
|
1535
2355
|
t != null && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") && (i[e] = typeof t == "string" && n ? n(t) : t);
|
|
@@ -1553,60 +2373,125 @@ var qe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Je = (e) => {
|
|
|
1553
2373
|
default: break;
|
|
1554
2374
|
}
|
|
1555
2375
|
return i;
|
|
1556
|
-
},
|
|
1557
|
-
let e = !1;
|
|
2376
|
+
}, Yr = () => {
|
|
2377
|
+
let e, t = !1;
|
|
1558
2378
|
return {
|
|
1559
2379
|
name: "web-vitals",
|
|
1560
|
-
init(
|
|
1561
|
-
return
|
|
2380
|
+
init(n) {
|
|
2381
|
+
return k(function* () {
|
|
1562
2382
|
if (typeof window > "u") return;
|
|
1563
|
-
let
|
|
2383
|
+
let r;
|
|
1564
2384
|
try {
|
|
1565
|
-
|
|
2385
|
+
r = yield import("web-vitals/attribution");
|
|
1566
2386
|
} catch (e) {
|
|
1567
|
-
if (
|
|
1568
|
-
var
|
|
1569
|
-
(
|
|
2387
|
+
if (n.config.debug) {
|
|
2388
|
+
var i;
|
|
2389
|
+
(i = globalThis.console) == null || i.warn("[bk-ot] web-vitals load failed:", e);
|
|
1570
2390
|
}
|
|
1571
2391
|
return;
|
|
1572
2392
|
}
|
|
1573
|
-
if (
|
|
1574
|
-
let {
|
|
2393
|
+
if (t) return;
|
|
2394
|
+
let { onFCP: a, onLCP: o, onTTFB: s } = r, c = Br(), l = n.meter.createHistogram("browser.web_vital.cls", {
|
|
1575
2395
|
unit: "1",
|
|
1576
2396
|
description: "Cumulative Layout Shift"
|
|
1577
|
-
}),
|
|
2397
|
+
}), u = n.meter.createHistogram("browser.web_vital.duration", {
|
|
1578
2398
|
unit: "ms",
|
|
1579
2399
|
description: "Web Vitals duration metrics, including FCP, INP, LCP and TTFB"
|
|
1580
|
-
}),
|
|
1581
|
-
let
|
|
1582
|
-
|
|
2400
|
+
}), d = (e, t, r) => {
|
|
2401
|
+
let i = e.name.toLowerCase();
|
|
2402
|
+
n.startSpan("browser.web_vital", O(O(O(O(O({}, n.config.hooks.getPageAttributes()), t), qr(e, c)), I({
|
|
1583
2403
|
duration: e.name === "CLS" ? void 0 : e.value,
|
|
1584
2404
|
errorType: e.rating === "good" ? "none" : "slow",
|
|
1585
2405
|
eventLabel: "Web 指标",
|
|
1586
|
-
result:
|
|
1587
|
-
spanSubtype:
|
|
1588
|
-
spanType:
|
|
1589
|
-
targetLabel:
|
|
2406
|
+
result: Qe(e.rating),
|
|
2407
|
+
spanSubtype: i,
|
|
2408
|
+
spanType: F.vital,
|
|
2409
|
+
targetLabel: i,
|
|
1590
2410
|
targetValue: e.value
|
|
1591
2411
|
})), {}, {
|
|
1592
|
-
[
|
|
1593
|
-
[
|
|
1594
|
-
[
|
|
2412
|
+
[T.vitalMetric]: i,
|
|
2413
|
+
[T.vitalValue]: e.value,
|
|
2414
|
+
[T.vitalRating]: e.rating,
|
|
1595
2415
|
"vital.id": e.id
|
|
1596
|
-
},
|
|
1597
|
-
},
|
|
1598
|
-
|
|
2416
|
+
}, Jr(e, n.config.hooks.redactUrl)), r === void 0 ? void 0 : { contextTime: r }).end();
|
|
2417
|
+
}, f = (e) => {
|
|
2418
|
+
if (t || !Number.isFinite(e.value)) return;
|
|
2419
|
+
let r = e.entries[0], i = r && typeof performance < "u" ? performance.timeOrigin + r.startTime : void 0, a = i === void 0 ? n.getRuntimeAttributes() : n.getRuntimeAttributesAt(i);
|
|
2420
|
+
u.record(e.value, n.applyRedact(O(O(O({}, n.config.hooks.getMetricAttributes()), z(a)), qr(e, c)))), d(e, a, i);
|
|
2421
|
+
}, p, m, h, g = (e, t, r) => {
|
|
2422
|
+
let i = n.applyRedact(O(O(O({}, n.config.hooks.getMetricAttributes()), z(t)), qr(e, c)));
|
|
2423
|
+
e.name === "CLS" ? l.record(e.value, i) : u.record(e.value, i), d(e, t, r);
|
|
2424
|
+
}, _ = () => {
|
|
2425
|
+
let e = p;
|
|
2426
|
+
if (!e) return;
|
|
2427
|
+
g({
|
|
2428
|
+
attribution: {
|
|
2429
|
+
largestShiftTarget: e.largestShiftTarget,
|
|
2430
|
+
largestShiftValue: e.largestShiftValue
|
|
2431
|
+
},
|
|
2432
|
+
entries: [],
|
|
2433
|
+
id: N("vital"),
|
|
2434
|
+
name: "CLS",
|
|
2435
|
+
navigationType: c,
|
|
2436
|
+
rating: Vr("CLS", e.cls),
|
|
2437
|
+
value: e.cls
|
|
2438
|
+
}, e.runtimeAttributes, e.startedAt);
|
|
2439
|
+
let t = Kr(e);
|
|
2440
|
+
t && g({
|
|
2441
|
+
attribution: {
|
|
2442
|
+
inputDelay: t.inputDelay,
|
|
2443
|
+
interactionTarget: t.interactionTarget,
|
|
2444
|
+
interactionType: t.interactionType,
|
|
2445
|
+
presentationDelay: t.presentationDelay,
|
|
2446
|
+
processingDuration: t.processingDuration
|
|
2447
|
+
},
|
|
2448
|
+
entries: [],
|
|
2449
|
+
id: N("vital"),
|
|
2450
|
+
name: "INP",
|
|
2451
|
+
navigationType: c,
|
|
2452
|
+
rating: Vr("INP", t.duration),
|
|
2453
|
+
value: t.duration
|
|
2454
|
+
}, e.runtimeAttributes, e.startedAt);
|
|
2455
|
+
}, v = n.onViewChange((e) => {
|
|
2456
|
+
var t;
|
|
2457
|
+
_(), p = e.id ? {
|
|
2458
|
+
cls: 0,
|
|
2459
|
+
clsWindowLargestShiftValue: 0,
|
|
2460
|
+
clsWindowValue: 0,
|
|
2461
|
+
interactionCountAtStart: Ur(),
|
|
2462
|
+
interactionIdMax: 0,
|
|
2463
|
+
interactionIdMin: Infinity,
|
|
2464
|
+
inpCandidates: [],
|
|
2465
|
+
largestShiftValue: 0,
|
|
2466
|
+
runtimeAttributes: n.getRuntimeAttributes(),
|
|
2467
|
+
startedAt: (t = e.startedAt) == null ? Date.now() : t
|
|
2468
|
+
} : void 0;
|
|
2469
|
+
});
|
|
2470
|
+
if (typeof PerformanceObserver < "u") {
|
|
2471
|
+
var y, b;
|
|
2472
|
+
(y = PerformanceObserver.supportedEntryTypes) != null && y.includes("layout-shift") && (h = new PerformanceObserver((e) => {
|
|
2473
|
+
if (p) for (let t of e.getEntries()) performance.timeOrigin + t.startTime < p.startedAt || Wr(p, t);
|
|
2474
|
+
}), h.observe({
|
|
2475
|
+
buffered: !0,
|
|
2476
|
+
type: "layout-shift"
|
|
2477
|
+
})), (b = PerformanceObserver.supportedEntryTypes) != null && b.includes("event") && (m = new PerformanceObserver((e) => {
|
|
2478
|
+
if (p) for (let t of e.getEntries()) performance.timeOrigin + t.startTime < p.startedAt || !t.interactionId || !Number.isFinite(t.duration) || Gr(p, t);
|
|
2479
|
+
}), m.observe({
|
|
2480
|
+
buffered: !0,
|
|
2481
|
+
durationThreshold: 40,
|
|
2482
|
+
type: "event"
|
|
2483
|
+
}));
|
|
2484
|
+
}
|
|
2485
|
+
a(f), o(f), s(f), e = () => {
|
|
2486
|
+
_(), p = void 0, v(), h == null || h.disconnect(), m == null || m.disconnect();
|
|
1599
2487
|
};
|
|
1600
|
-
i((n) => {
|
|
1601
|
-
e || !Number.isFinite(n.value) || (u.record(n.value, t.applyRedact(E(E(E(E({}, t.config.hooks.getPageAttributes()), t.config.hooks.getMetricAttributes()), I(t.getRuntimeAttributes())), Fn(n, l)))), f(n));
|
|
1602
|
-
}), a(p), o(p), s(p), c(p);
|
|
1603
2488
|
})();
|
|
1604
2489
|
},
|
|
1605
2490
|
shutdown() {
|
|
1606
|
-
|
|
2491
|
+
t = !0, e == null || e(), e = void 0;
|
|
1607
2492
|
}
|
|
1608
2493
|
};
|
|
1609
|
-
},
|
|
2494
|
+
}, Xr = 64 * 1024, Zr = 6e4, Qr = 5, $r = (e) => e == null ? 0 : typeof e == "string" ? e.length > Xr || 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, ei = (e, t) => {
|
|
1610
2495
|
let n = {
|
|
1611
2496
|
"network.protocol.name": "websocket",
|
|
1612
2497
|
"url.full": t(e)
|
|
@@ -1619,71 +2504,71 @@ var qe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Je = (e) => {
|
|
|
1619
2504
|
metricAttributes: r,
|
|
1620
2505
|
spanAttributes: n
|
|
1621
2506
|
};
|
|
1622
|
-
},
|
|
1623
|
-
var
|
|
1624
|
-
let { bytesCounter:
|
|
2507
|
+
}, ti = (e, t) => {
|
|
2508
|
+
var n;
|
|
2509
|
+
let { bytesCounter: r, connectDurationHistogram: i, context: a, errorCounter: o, errorThrottle: s, isDisposed: l, messageCounter: u, url: d } = t, { metricAttributes: f, spanAttributes: p } = ei(d, a.config.hooks.redactUrl), m = a.applyRedact(O(O(O({}, a.config.hooks.getMetricAttributes()), z(a.getRuntimeAttributes())), f)), h = (n = p["server.address"]) == null ? p["url.full"] : n, g = a.startSpan("websocket.connect", O(O(O({}, p), I({
|
|
1625
2510
|
errorType: "none",
|
|
1626
2511
|
eventLabel: "WebSocket",
|
|
1627
2512
|
spanSubtype: "websocket",
|
|
1628
|
-
spanType:
|
|
1629
|
-
targetLabel:
|
|
1630
|
-
})),
|
|
1631
|
-
if (
|
|
1632
|
-
|
|
1633
|
-
let
|
|
1634
|
-
e === "error" &&
|
|
1635
|
-
code:
|
|
2513
|
+
spanType: F.custom,
|
|
2514
|
+
targetLabel: h
|
|
2515
|
+
})), p["server.address"] ? { [T.targetDomain]: p["server.address"] } : {})), _ = performance.now(), v = !1, y = (e) => {
|
|
2516
|
+
if (v) return;
|
|
2517
|
+
v = !0;
|
|
2518
|
+
let t = performance.now() - _;
|
|
2519
|
+
e === "error" && g.setStatus({
|
|
2520
|
+
code: c.ERROR,
|
|
1636
2521
|
message: "websocket connect failed"
|
|
1637
|
-
}),
|
|
1638
|
-
duration:
|
|
2522
|
+
}), g.setAttributes(I({
|
|
2523
|
+
duration: t,
|
|
1639
2524
|
errorType: e === "error" ? "network" : "none",
|
|
1640
2525
|
eventLabel: "WebSocket",
|
|
1641
|
-
result: e === "error" ?
|
|
2526
|
+
result: e === "error" ? P.error : P.success,
|
|
1642
2527
|
spanSubtype: "websocket",
|
|
1643
|
-
spanType:
|
|
1644
|
-
targetLabel:
|
|
1645
|
-
targetValue:
|
|
1646
|
-
})),
|
|
2528
|
+
spanType: F.custom,
|
|
2529
|
+
targetLabel: h,
|
|
2530
|
+
targetValue: t
|
|
2531
|
+
})), g.end(), e === "opened" && !l() && i.record(t, m);
|
|
1647
2532
|
};
|
|
1648
2533
|
e.addEventListener("open", () => {
|
|
1649
|
-
|
|
2534
|
+
l() || y("opened");
|
|
1650
2535
|
}), e.addEventListener("message", (e) => {
|
|
1651
|
-
if (
|
|
1652
|
-
let t =
|
|
1653
|
-
|
|
2536
|
+
if (l()) return;
|
|
2537
|
+
let t = O(O({}, m), {}, { "websocket.direction": "in" });
|
|
2538
|
+
u.add(1, t), r.add($r(e.data), t);
|
|
1654
2539
|
}), e.addEventListener("error", () => {
|
|
1655
|
-
if (
|
|
1656
|
-
let e =
|
|
1657
|
-
|
|
1658
|
-
let t =
|
|
1659
|
-
t.allowed &&
|
|
1660
|
-
severityNumber:
|
|
2540
|
+
if (l()) return;
|
|
2541
|
+
let e = v ? "runtime" : "connect";
|
|
2542
|
+
o.add(1, O(O({}, m), {}, { "websocket.error.phase": e })), y("error");
|
|
2543
|
+
let t = s.allow(`ws:error:${d}`);
|
|
2544
|
+
t.allowed && a.emitLog({
|
|
2545
|
+
severityNumber: w.ERROR,
|
|
1661
2546
|
severityText: "ERROR",
|
|
1662
2547
|
body: "websocket.error",
|
|
1663
|
-
attributes:
|
|
2548
|
+
attributes: O(O(O({}, p), I({
|
|
1664
2549
|
errorType: "network",
|
|
1665
2550
|
eventLabel: "WebSocket 错误",
|
|
1666
|
-
result:
|
|
2551
|
+
result: P.error,
|
|
1667
2552
|
spanSubtype: "websocket",
|
|
1668
|
-
spanType:
|
|
1669
|
-
targetLabel:
|
|
2553
|
+
spanType: F.custom,
|
|
2554
|
+
targetLabel: h
|
|
1670
2555
|
})), {}, {
|
|
1671
2556
|
"websocket.error.phase": e,
|
|
1672
2557
|
"websocket.error.window_count": t.count
|
|
1673
2558
|
})
|
|
1674
2559
|
});
|
|
1675
2560
|
}), e.addEventListener("close", (e) => {
|
|
1676
|
-
|
|
1677
|
-
severityNumber:
|
|
2561
|
+
l() || (v || y("error"), a.emitLog({
|
|
2562
|
+
severityNumber: w.INFO,
|
|
1678
2563
|
severityText: "INFO",
|
|
1679
2564
|
body: "websocket.close",
|
|
1680
|
-
attributes:
|
|
2565
|
+
attributes: O(O(O({}, p), I({
|
|
1681
2566
|
errorType: e.wasClean ? "none" : "network",
|
|
1682
2567
|
eventLabel: "WebSocket 关闭",
|
|
1683
|
-
result: e.wasClean ?
|
|
2568
|
+
result: e.wasClean ? P.success : P.warning,
|
|
1684
2569
|
spanSubtype: "websocket",
|
|
1685
|
-
spanType:
|
|
1686
|
-
targetLabel:
|
|
2570
|
+
spanType: F.custom,
|
|
2571
|
+
targetLabel: h,
|
|
1687
2572
|
targetValue: e.code
|
|
1688
2573
|
})), {}, {
|
|
1689
2574
|
"websocket.close.code": e.code,
|
|
@@ -1692,15 +2577,15 @@ var qe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Je = (e) => {
|
|
|
1692
2577
|
})
|
|
1693
2578
|
}));
|
|
1694
2579
|
});
|
|
1695
|
-
let
|
|
2580
|
+
let b = e.send.bind(e);
|
|
1696
2581
|
e.send = (e) => {
|
|
1697
|
-
if (!
|
|
1698
|
-
let t =
|
|
1699
|
-
|
|
2582
|
+
if (!l()) {
|
|
2583
|
+
let t = O(O({}, m), {}, { "websocket.direction": "out" });
|
|
2584
|
+
u.add(1, t), r.add($r(e), t);
|
|
1700
2585
|
}
|
|
1701
|
-
return
|
|
2586
|
+
return b(e);
|
|
1702
2587
|
};
|
|
1703
|
-
},
|
|
2588
|
+
}, ni = () => {
|
|
1704
2589
|
let e, t, n = !1;
|
|
1705
2590
|
return {
|
|
1706
2591
|
name: "websocket",
|
|
@@ -1714,12 +2599,12 @@ var qe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Je = (e) => {
|
|
|
1714
2599
|
}), s = r.meter.createCounter("browser.websocket.error.count", { description: "Total number of WebSocket error events" }), c = r.meter.createHistogram("browser.websocket.connect.duration", {
|
|
1715
2600
|
unit: "ms",
|
|
1716
2601
|
description: "WebSocket connection establishment duration (only successful connects)"
|
|
1717
|
-
}), l =
|
|
2602
|
+
}), l = Cn(Zr, Qr), u = () => n;
|
|
1718
2603
|
t = new Proxy(i, { construct(e, t, i) {
|
|
1719
2604
|
let d = Reflect.construct(e, t, i);
|
|
1720
2605
|
if (n) return d;
|
|
1721
2606
|
let f = t[0] == null ? "" : String(t[0]);
|
|
1722
|
-
return !f ||
|
|
2607
|
+
return !f || ke(r.config, f) || ti(d, {
|
|
1723
2608
|
bytesCounter: o,
|
|
1724
2609
|
connectDurationHistogram: c,
|
|
1725
2610
|
context: r,
|
|
@@ -1735,164 +2620,288 @@ var qe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Je = (e) => {
|
|
|
1735
2620
|
n = !0, typeof window < "u" && e && window.WebSocket === t && (window.WebSocket = e), t = void 0, e = void 0;
|
|
1736
2621
|
}
|
|
1737
2622
|
};
|
|
1738
|
-
},
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
if (t) return t === "1";
|
|
1744
|
-
let n = Math.random() < e.rate;
|
|
1745
|
-
return sessionStorage.setItem(Z, n ? "1" : "0"), qn(Z, n), n;
|
|
1746
|
-
} catch (t) {
|
|
1747
|
-
let n = Kn(Z);
|
|
1748
|
-
return typeof n == "boolean" ? n : qn(Z, Math.random() < e.rate);
|
|
2623
|
+
}, ri = class {
|
|
2624
|
+
constructor() {
|
|
2625
|
+
D(this, "listeners", /* @__PURE__ */ new Set()), D(this, "notify", (e) => {
|
|
2626
|
+
this.listeners.forEach((t) => t(e));
|
|
2627
|
+
}), D(this, "subscribe", (e) => (this.listeners.add(e), () => this.listeners.delete(e)));
|
|
1749
2628
|
}
|
|
1750
|
-
},
|
|
2629
|
+
}, ii = (e) => ({
|
|
1751
2630
|
url: e.endpoint,
|
|
1752
2631
|
headers: e.headers,
|
|
1753
2632
|
concurrencyLimit: e.concurrencyLimit,
|
|
1754
2633
|
timeoutMillis: e.timeoutMillis
|
|
1755
|
-
}),
|
|
2634
|
+
}), ai = "bk-rum", oi = class {
|
|
2635
|
+
constructor(e) {
|
|
2636
|
+
this.isSampled = e;
|
|
2637
|
+
}
|
|
2638
|
+
shouldSample() {
|
|
2639
|
+
return { decision: this.isSampled() ? S.RECORD_AND_SAMPLED : S.NOT_RECORD };
|
|
2640
|
+
}
|
|
2641
|
+
toString() {
|
|
2642
|
+
return "RumSessionSampler";
|
|
2643
|
+
}
|
|
2644
|
+
}, Q, si = () => {
|
|
2645
|
+
if (Q) Q.users += 1;
|
|
2646
|
+
else {
|
|
2647
|
+
let e = new f().enable(), n = l.setGlobalContextManager(e);
|
|
2648
|
+
n || e.disable(), Q = {
|
|
2649
|
+
contextManager: n ? e : void 0,
|
|
2650
|
+
ownsContext: n,
|
|
2651
|
+
ownsPropagator: u.setGlobalPropagator(new t()),
|
|
2652
|
+
users: 1
|
|
2653
|
+
};
|
|
2654
|
+
}
|
|
2655
|
+
let e = !1;
|
|
2656
|
+
return () => {
|
|
2657
|
+
e || !Q || (e = !0, --Q.users, !(Q.users > 0) && (Q.ownsContext && l.disable(), Q.ownsPropagator && u.disable(), Q = void 0));
|
|
2658
|
+
};
|
|
2659
|
+
}, ci = (e, t, n) => n ? new Proxy(e, { get(e, n, r) {
|
|
1756
2660
|
if (n === "export") return (n, r) => {
|
|
1757
2661
|
var i;
|
|
1758
2662
|
return (i = globalThis.console) == null || i.log(`[bk-ot][${t}]`, n), e.export(n, r);
|
|
1759
2663
|
};
|
|
1760
2664
|
let i = Reflect.get(e, n, r);
|
|
1761
2665
|
return typeof i == "function" ? i.bind(e) : i;
|
|
1762
|
-
} }) : e,
|
|
1763
|
-
|
|
1764
|
-
...$(e.
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
...$(e.
|
|
1770
|
-
...$(e.
|
|
1771
|
-
...$(e.
|
|
1772
|
-
...$(e.
|
|
1773
|
-
...$(e.
|
|
1774
|
-
...$(e.
|
|
1775
|
-
...$(e.
|
|
1776
|
-
],
|
|
2666
|
+
} }) : e, li = (e) => [Sn(e.tracking.request)], ui = (e) => [
|
|
2667
|
+
Nr(e.session),
|
|
2668
|
+
...$(e.tracking.device, !0, Bn),
|
|
2669
|
+
bt(),
|
|
2670
|
+
yr(),
|
|
2671
|
+
ln(di(e.tracking.resource, !0))
|
|
2672
|
+
], di = (e, t) => e === void 0 ? t : e !== !1, fi = (e) => typeof e == "object" && e ? e : void 0, $ = (e, t, n) => di(e, t) ? [n(fi(e))] : [], pi = (e) => [
|
|
2673
|
+
...$(e.error, !0, Xn),
|
|
2674
|
+
...$(e.webVitals, !0, Yr),
|
|
2675
|
+
...$(e.blankScreen, !0, Lt),
|
|
2676
|
+
...$(e.action, !0, _t),
|
|
2677
|
+
...$(e.websocket, !1, ni),
|
|
2678
|
+
...$(e.longTask, !1, ir),
|
|
2679
|
+
...$(e.cspViolation, !1, On)
|
|
2680
|
+
], mi = class {
|
|
1777
2681
|
assertBeforeStart(e) {
|
|
1778
2682
|
if (this.phase !== "idle") throw Error(`[bk-ot] ${e}() must be called before start(); set autoStart: false before registration.`);
|
|
1779
2683
|
}
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
2684
|
+
createPluginContext() {
|
|
2685
|
+
return {
|
|
2686
|
+
applyRedact: this.applyRedact,
|
|
2687
|
+
config: this.config,
|
|
2688
|
+
emitLog: this.emitLog,
|
|
2689
|
+
flush: this.flush,
|
|
2690
|
+
getRuntimeAttributes: this.getRuntimeAttributes,
|
|
2691
|
+
getRuntimeAttributesAt: this.getRuntimeAttributesAt,
|
|
2692
|
+
isSampled: this.isSampled,
|
|
2693
|
+
isSessionActive: this.isSessionActive,
|
|
2694
|
+
isViewActive: this.isViewActive,
|
|
2695
|
+
logger: this.logger,
|
|
2696
|
+
meter: this.meter,
|
|
2697
|
+
notifySessionLifecycle: this.notifySessionLifecycle,
|
|
2698
|
+
notifyActivity: this.activityObserver.notify,
|
|
2699
|
+
onActivity: this.activityObserver.subscribe,
|
|
2700
|
+
onSessionLifecycle: this.onSessionLifecycle,
|
|
2701
|
+
onViewCommand: this.runtimeContext.onViewCommand,
|
|
2702
|
+
onViewChange: this.runtimeContext.onViewChange,
|
|
2703
|
+
registerInstrumentations: this.registerInstrumentations,
|
|
2704
|
+
setRuntimeAttributes: this.setRuntimeAttributes,
|
|
2705
|
+
setUser: this.setUser,
|
|
2706
|
+
setView: this.runtimeContext.setView,
|
|
2707
|
+
startSpan: this.startSpan,
|
|
2708
|
+
tracer: this.tracer
|
|
2709
|
+
};
|
|
2710
|
+
}
|
|
2711
|
+
createPluginManager() {
|
|
2712
|
+
var e;
|
|
2713
|
+
return new Se([
|
|
2714
|
+
...ui(this.config),
|
|
2715
|
+
...li(this.config),
|
|
2716
|
+
...pi(this.config.tracking),
|
|
2717
|
+
...(e = this.config.extensions.plugins) == null ? [] : e
|
|
2718
|
+
]);
|
|
2719
|
+
}
|
|
2720
|
+
constructor(e) {
|
|
2721
|
+
var t = this;
|
|
2722
|
+
D(this, "activityObserver", new ri()), D(this, "flushProviders", k(function* () {
|
|
2723
|
+
yield t.tracerProvider.forceFlush(), yield t.meterProvider.forceFlush(), yield t.loggerProvider.forceFlush();
|
|
2724
|
+
})), D(this, "loggerProvider", void 0), D(this, "meterProvider", void 0), D(this, "phase", "idle"), D(this, "pluginManager", void 0), D(this, "registeredInstrumentations", void 0), D(this, "releaseOtelGlobals", void 0), D(this, "runtimeContext", void 0), D(this, "sampled", !1), D(this, "startCollection", k(function* () {
|
|
2725
|
+
if (t.pluginManager || !t.config.enabled || t.config.trackingConsent !== "granted") return;
|
|
2726
|
+
t.config.transport.traces !== !1 && (t.releaseOtelGlobals = si());
|
|
2727
|
+
let e = t.createPluginManager();
|
|
2728
|
+
t.pluginManager = e;
|
|
2729
|
+
try {
|
|
2730
|
+
var n;
|
|
2731
|
+
yield e.start(t.createPluginContext()), t.registerInstrumentations((n = t.config.extensions.instrumentations) == null ? [] : n);
|
|
2732
|
+
} catch (n) {
|
|
2733
|
+
var r, i, a;
|
|
2734
|
+
for (yield e.shutdown(), t.pluginManager = void 0; t.registeredInstrumentations.length;) (r = t.registeredInstrumentations.pop()) == null || (i = r.disable) == null || i.call(r);
|
|
2735
|
+
throw (a = t.releaseOtelGlobals) == null || a.call(t), t.releaseOtelGlobals = void 0, n;
|
|
2736
|
+
}
|
|
2737
|
+
})), D(this, "stopCollection", function() {
|
|
2738
|
+
var e = k(function* (e) {
|
|
2739
|
+
var n, r, i;
|
|
2740
|
+
let a = t.pluginManager;
|
|
2741
|
+
if (a) {
|
|
2742
|
+
for (yield a.shutdown(), t.pluginManager = void 0; t.registeredInstrumentations.length;) (n = t.registeredInstrumentations.pop()) == null || (r = n.disable) == null || r.call(n);
|
|
2743
|
+
t.setRuntimeAttributes({
|
|
2744
|
+
[T.sessionHasReplay]: void 0,
|
|
2745
|
+
[T.sessionId]: void 0
|
|
2746
|
+
}), e && (yield t.flushProviders()), (i = t.releaseOtelGlobals) == null || i.call(t), t.releaseOtelGlobals = void 0;
|
|
2747
|
+
}
|
|
2748
|
+
});
|
|
2749
|
+
return function(t) {
|
|
2750
|
+
return e.apply(this, arguments);
|
|
2751
|
+
};
|
|
2752
|
+
}()), D(this, "teardownCallbacks", []), D(this, "tracerProvider", void 0), D(this, "applyRedact", (e) => this.config.hooks.redactAttributes(e)), D(this, "config", void 0), D(this, "emitLog", (e) => {
|
|
1783
2753
|
var t;
|
|
1784
|
-
let n =
|
|
1785
|
-
this.logger.emit(
|
|
1786
|
-
}),
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
2754
|
+
let i = e.timestamp ? n(r(e.timestamp)) : void 0, a = O(O({}, e), {}, { attributes: this.applyRedact(O(O({}, i === void 0 ? this.getRuntimeAttributes() : this.getRuntimeAttributesAt(i)), (t = e.attributes) == null ? {} : t)) });
|
|
2755
|
+
this.logger.emit(a);
|
|
2756
|
+
}), D(this, "flush", k(function* () {
|
|
2757
|
+
var e;
|
|
2758
|
+
yield (e = t.pluginManager) == null ? void 0 : e.flush(), yield t.flushProviders();
|
|
2759
|
+
})), D(this, "getRuntimeAttributes", () => this.runtimeContext.getAttributes()), D(this, "getRuntimeAttributesAt", (e) => this.runtimeContext.getAttributesAt(e)), D(this, "isSampled", () => this.sampled), D(this, "isSessionActive", () => this.runtimeContext.isSessionActive()), D(this, "isViewActive", () => this.runtimeContext.isViewActive()), D(this, "logger", void 0), D(this, "meter", void 0), D(this, "notifySessionLifecycle", (e) => {
|
|
2760
|
+
this.runtimeContext.notifySessionLifecycle(e);
|
|
2761
|
+
}), D(this, "onSessionLifecycle", (e) => this.runtimeContext.onSessionLifecycle(e)), D(this, "registerInstrumentations", (e) => {
|
|
2762
|
+
e.length && (_({
|
|
2763
|
+
instrumentations: e,
|
|
2764
|
+
meterProvider: this.meterProvider,
|
|
2765
|
+
tracerProvider: this.tracerProvider
|
|
2766
|
+
}), this.registeredInstrumentations.push(...e));
|
|
2767
|
+
}), D(this, "reportAction", ({ attributes: e = {}, name: t }) => {
|
|
2768
|
+
if (!this.isSampled()) return;
|
|
2769
|
+
let n = N("action");
|
|
2770
|
+
this.startSpan("action.custom", O(O(O(O({}, this.config.hooks.getPageAttributes()), e), I({
|
|
1793
2771
|
errorType: "none",
|
|
1794
2772
|
eventLabel: "用户操作",
|
|
1795
|
-
spanSubtype:
|
|
1796
|
-
spanType:
|
|
1797
|
-
targetLabel:
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
2773
|
+
spanSubtype: "custom",
|
|
2774
|
+
spanType: F.action,
|
|
2775
|
+
targetLabel: t,
|
|
2776
|
+
traceScene: "user_action"
|
|
2777
|
+
})), {}, {
|
|
2778
|
+
[T.actionId]: n,
|
|
2779
|
+
[T.actionName]: t,
|
|
2780
|
+
[T.actionType]: "custom"
|
|
2781
|
+
})).end();
|
|
2782
|
+
}), D(this, "reportCustomEvent", ({ attributes: e = {}, error: t, name: n }) => {
|
|
2783
|
+
if (!this.isSampled()) {
|
|
1801
2784
|
if (this.config.debug) {
|
|
1802
|
-
var
|
|
1803
|
-
(
|
|
2785
|
+
var r;
|
|
2786
|
+
(r = globalThis.console) == null || r.warn("[bk-ot] custom event dropped (not sampled):", n);
|
|
1804
2787
|
}
|
|
1805
2788
|
return;
|
|
1806
2789
|
}
|
|
1807
|
-
let
|
|
1808
|
-
errorType:
|
|
2790
|
+
let i = this.startSpan(`custom.${n}`, O(O(O(O(O({}, this.config.hooks.getPageAttributes()), this.config.hooks.getCustomAttributes()), I({
|
|
2791
|
+
errorType: t ? "custom" : "none",
|
|
1809
2792
|
eventLabel: "自定义事件",
|
|
1810
|
-
result:
|
|
1811
|
-
spanSubtype:
|
|
1812
|
-
spanType:
|
|
1813
|
-
targetLabel:
|
|
1814
|
-
})), e), {}, { "rum.custom.name":
|
|
1815
|
-
|
|
1816
|
-
code:
|
|
1817
|
-
message:
|
|
1818
|
-
})),
|
|
1819
|
-
}),
|
|
1820
|
-
|
|
1821
|
-
|
|
2793
|
+
result: t ? P.error : P.success,
|
|
2794
|
+
spanSubtype: n,
|
|
2795
|
+
spanType: F.custom,
|
|
2796
|
+
targetLabel: n
|
|
2797
|
+
})), e), {}, { "rum.custom.name": n }));
|
|
2798
|
+
t && (i.recordException(t), i.setStatus({
|
|
2799
|
+
code: c.ERROR,
|
|
2800
|
+
message: t.message
|
|
2801
|
+
})), i.end();
|
|
2802
|
+
}), D(this, "setRuntimeAttributes", (e, t) => {
|
|
2803
|
+
let n = O({}, e);
|
|
2804
|
+
if (T.sessionId in e) {
|
|
2805
|
+
let t = e[T.sessionId];
|
|
2806
|
+
this.sampled = this.config.enabled && typeof t == "string" && t.length > 0 ? we(this.config, t) : !1, n[A] = this.sampled;
|
|
2807
|
+
}
|
|
2808
|
+
this.runtimeContext.setAttributes(n, t);
|
|
2809
|
+
}), D(this, "setTrackingConsent", function() {
|
|
2810
|
+
var e = k(function* (e) {
|
|
2811
|
+
t.config.trackingConsent !== e && (t.config.trackingConsent = e, t.phase === "started" && (e === "granted" ? yield t.startCollection() : yield t.stopCollection(!0)));
|
|
2812
|
+
});
|
|
2813
|
+
return function(t) {
|
|
2814
|
+
return e.apply(this, arguments);
|
|
2815
|
+
};
|
|
2816
|
+
}()), D(this, "setUser", (e) => {
|
|
1822
2817
|
this.runtimeContext.setUser(e);
|
|
1823
|
-
}),
|
|
1824
|
-
this.runtimeContext.
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
2818
|
+
}), D(this, "setViewLoadingTime", () => {
|
|
2819
|
+
this.isSampled() && this.runtimeContext.dispatchViewCommand({
|
|
2820
|
+
time: Date.now(),
|
|
2821
|
+
type: "set_loading_time"
|
|
2822
|
+
});
|
|
2823
|
+
}), D(this, "setViewName", (e) => {
|
|
2824
|
+
this.isSampled() && this.runtimeContext.dispatchViewCommand({
|
|
2825
|
+
name: e,
|
|
2826
|
+
type: "set_name"
|
|
2827
|
+
});
|
|
2828
|
+
}), D(this, "shutdown", k(function* () {
|
|
2829
|
+
if (t.phase !== "stopped") {
|
|
2830
|
+
for (yield t.stopCollection(!1), yield t.flushProviders(); t.teardownCallbacks.length;) {
|
|
1828
2831
|
var e;
|
|
1829
|
-
(e =
|
|
2832
|
+
(e = t.teardownCallbacks.pop()) == null || e();
|
|
1830
2833
|
}
|
|
1831
|
-
|
|
1832
|
-
var t, i;
|
|
1833
|
-
(t = S.registeredInstrumentations.pop()) == null || (i = t.disable) == null || i.call(t);
|
|
1834
|
-
}
|
|
1835
|
-
yield S.tracerProvider.shutdown(), yield S.meterProvider.shutdown(), yield S.loggerProvider.shutdown(), a.disable(), r.disable(), n.disable(), S.phase = "stopped";
|
|
2834
|
+
yield t.tracerProvider.shutdown(), yield t.meterProvider.shutdown(), yield t.loggerProvider.shutdown(), t.phase = "stopped";
|
|
1836
2835
|
}
|
|
1837
|
-
})),
|
|
1838
|
-
if (!(
|
|
1839
|
-
if (
|
|
1840
|
-
if (!
|
|
1841
|
-
|
|
2836
|
+
})), D(this, "start", k(function* () {
|
|
2837
|
+
if (!(t.phase === "started" || t.phase === "starting")) {
|
|
2838
|
+
if (t.phase === "stopped") throw Error("[bk-ot] instance has been shut down and cannot be restarted; create a new instance instead.");
|
|
2839
|
+
if (!t.config.enabled) {
|
|
2840
|
+
t.phase = "started";
|
|
1842
2841
|
return;
|
|
1843
2842
|
}
|
|
1844
|
-
|
|
2843
|
+
t.phase = "starting";
|
|
1845
2844
|
try {
|
|
1846
|
-
if (
|
|
1847
|
-
instrumentations: S.registeredInstrumentations,
|
|
1848
|
-
meterProvider: S.meterProvider,
|
|
1849
|
-
tracerProvider: S.tracerProvider
|
|
1850
|
-
}), yield S.pluginManager.start(S), typeof window < "u" && typeof document < "u") {
|
|
2845
|
+
if (yield t.startCollection(), typeof window < "u" && typeof document < "u") {
|
|
1851
2846
|
let e = () => {
|
|
1852
|
-
|
|
1853
|
-
},
|
|
1854
|
-
document.visibilityState === "hidden" &&
|
|
2847
|
+
t.flush();
|
|
2848
|
+
}, n = () => {
|
|
2849
|
+
document.visibilityState === "hidden" && t.flush();
|
|
1855
2850
|
};
|
|
1856
|
-
window.addEventListener("pagehide", e), document.addEventListener("visibilitychange",
|
|
2851
|
+
window.addEventListener("pagehide", e), document.addEventListener("visibilitychange", n), t.teardownCallbacks.push(() => window.removeEventListener("pagehide", e), () => document.removeEventListener("visibilitychange", n));
|
|
1857
2852
|
}
|
|
1858
|
-
} catch (
|
|
1859
|
-
for (;
|
|
2853
|
+
} catch (n) {
|
|
2854
|
+
for (; t.teardownCallbacks.length;) {
|
|
1860
2855
|
var e;
|
|
1861
|
-
(e =
|
|
1862
|
-
}
|
|
1863
|
-
yield S.pluginManager.shutdown();
|
|
1864
|
-
for (let e of S.registeredInstrumentations) {
|
|
1865
|
-
var t;
|
|
1866
|
-
(t = e.disable) == null || t.call(e);
|
|
2856
|
+
(e = t.teardownCallbacks.pop()) == null || e();
|
|
1867
2857
|
}
|
|
1868
|
-
throw
|
|
2858
|
+
throw yield t.stopCollection(!1), t.phase = "idle", n;
|
|
1869
2859
|
}
|
|
1870
|
-
|
|
2860
|
+
t.phase = "started";
|
|
1871
2861
|
}
|
|
1872
|
-
})),
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
2862
|
+
})), D(this, "startSpan", (e, t = {}, n) => {
|
|
2863
|
+
var r, i;
|
|
2864
|
+
let a = (r = n == null ? void 0 : n.contextTime) == null ? typeof (n == null ? void 0 : n.startTime) == "number" ? n.startTime : void 0 : r, o = a === void 0 ? this.getRuntimeAttributes() : this.runtimeContext.getAttributesAt(a);
|
|
2865
|
+
return this.tracer.startSpan(e, {
|
|
2866
|
+
kind: (i = n == null ? void 0 : n.kind) == null ? s.INTERNAL : i,
|
|
2867
|
+
startTime: n == null ? void 0 : n.startTime,
|
|
2868
|
+
attributes: this.applyRedact(O(O({}, o), t))
|
|
2869
|
+
});
|
|
2870
|
+
}), D(this, "startView", (e = {}) => {
|
|
2871
|
+
this.isSampled() && this.runtimeContext.dispatchViewCommand({
|
|
2872
|
+
options: e,
|
|
2873
|
+
type: "start"
|
|
2874
|
+
});
|
|
2875
|
+
}), D(this, "tracer", void 0), D(this, "use", (e) => {
|
|
2876
|
+
var t;
|
|
2877
|
+
return this.assertBeforeStart("use"), (t = this.config.extensions.plugins) == null || t.push(e), this;
|
|
2878
|
+
}), D(this, "useInstrumentation", (e) => {
|
|
2879
|
+
var t;
|
|
2880
|
+
return this.assertBeforeStart("useInstrumentation"), this.config.enabled && ((t = this.config.extensions.instrumentations) == null || t.push(e)), this;
|
|
2881
|
+
}), this.config = ve(e), this.runtimeContext = new qe({ [A]: !1 }, this.config.user);
|
|
2882
|
+
let i = v(this.config.resourceAttributes), l = (() => {
|
|
2883
|
+
if (this.config.transport.traces === !1) return [];
|
|
2884
|
+
let e = ci(new g(ii(this.config.transport.traces)), "traces", this.config.debug);
|
|
2885
|
+
return [new Ue(this.config.spanProcessor === "simple" ? new C(e) : new x(e, this.config.spanBatch), this.config, () => this.applyRedact(O(O({}, this.runtimeContext.getAttributes()), this.config.hooks.getPageAttributes())))];
|
|
2886
|
+
})(), u = this.config.transport.metrics === !1 ? [] : [new o({
|
|
2887
|
+
exporter: new Ge(ci(new h(O(O({}, ii(this.config.transport.metrics)), {}, { temporalityPreference: m.DELTA })), "metrics", this.config.debug)),
|
|
1879
2888
|
exportIntervalMillis: this.config.metricIntervalMillis
|
|
1880
|
-
}),
|
|
1881
|
-
this.tracerProvider = new
|
|
1882
|
-
resource:
|
|
1883
|
-
sampler: new
|
|
1884
|
-
spanProcessors:
|
|
1885
|
-
}), this.meterProvider = new
|
|
1886
|
-
resource:
|
|
1887
|
-
readers:
|
|
1888
|
-
}), this.loggerProvider = new
|
|
1889
|
-
resource:
|
|
1890
|
-
processors:
|
|
1891
|
-
}), this.tracer = this.tracerProvider.getTracer(
|
|
2889
|
+
})], d = this.config.transport.logs === !1 ? [] : [new He(new y(ci(new p(ii(this.config.transport.logs)), "logs", this.config.debug)), this.config)];
|
|
2890
|
+
this.tracerProvider = new ee({
|
|
2891
|
+
resource: i,
|
|
2892
|
+
sampler: new oi(() => this.config.transport.traces !== !1 && this.isSampled()),
|
|
2893
|
+
spanProcessors: l
|
|
2894
|
+
}), this.meterProvider = new a({
|
|
2895
|
+
resource: i,
|
|
2896
|
+
readers: u
|
|
2897
|
+
}), this.loggerProvider = new b({
|
|
2898
|
+
resource: i,
|
|
2899
|
+
processors: d
|
|
2900
|
+
}), this.tracer = this.tracerProvider.getTracer(ai), this.meter = this.meterProvider.getMeter(ai), this.logger = this.loggerProvider.getLogger(ai), this.registeredInstrumentations = [], this.config.autoStart && this.start().catch((e) => {
|
|
1892
2901
|
var t;
|
|
1893
2902
|
(t = globalThis.console) == null || t.warn("[bk-ot] auto start failed:", e);
|
|
1894
2903
|
});
|
|
1895
2904
|
}
|
|
1896
2905
|
};
|
|
1897
2906
|
//#endregion
|
|
1898
|
-
export {
|
|
2907
|
+
export { mi as BkOpenTelemetry, vt as EXCLUDED_ACTIVITY_MUTATIONS_ATTRIBUTE, He as FilteringLogRecordProcessor, Ge as FilteringMetricExporter, Ue as FilteringSpanProcessor, T as RUM_ATTRIBUTES, P as RUM_SPAN_RESULT, F as RUM_SPAN_TYPE, qe as RumRuntimeContext, I as buildRumSpanAttributes, _t as createActionPlugin, Lt as createBlankScreenPlugin, Sn as createCommonInstrumentationsPlugin, On as createCspViolationPlugin, Bn as createDevicePlugin, Xn as createErrorPlugin, ir as createLongTaskPlugin, xe as createPlugin, ln as createResourcePlugin, Nr as createSessionPlugin, ni as createWebSocketPlugin, Yr as createWebVitalsPlugin, Je as getDurationBucket, ve as resolveConfig };
|