@blueking/open-telemetry 0.0.16 → 0.0.17
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/dist/bk-rum.global.js +2 -2
- package/dist/bk-rum.global.js.map +1 -1
- package/dist/core/config.d.ts +2 -0
- package/dist/core/metric.d.ts +2 -0
- package/dist/core/sdk.d.ts +4 -0
- package/dist/core/signal.d.ts +3 -0
- package/dist/core/telemetry-attributes.d.ts +1 -0
- package/dist/core/throttle.d.ts +2 -2
- package/dist/index.js +525 -456
- package/dist/index.js.map +1 -1
- package/dist/plugins/blank-screen.d.ts +4 -0
- package/dist/plugins/common.d.ts +1 -0
- package/dist/plugins/csp-violation.d.ts +1 -1
- package/dist/plugins/long-task.d.ts +4 -0
- package/dist/plugins/request-body.d.ts +2 -1
- package/dist/plugins/resource.d.ts +4 -0
- package/dist/plugins/web-vitals.d.ts +2 -0
- package/package.json +1 -1
- package/skills/bk-rum-otele/references/data-model.md +1 -1
- package/skills/bk-rum-otele/references/plugins.md +1 -1
- package/skills/bk-rum-otele/references/telemetry-reference.md +12 -10
package/dist/index.js
CHANGED
|
@@ -564,13 +564,13 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
564
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()));
|
|
565
565
|
}), this.setAttributes(e), t && this.setUser(t);
|
|
566
566
|
}
|
|
567
|
-
}, N = (e) => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`, P = {
|
|
567
|
+
}, N = (e) => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`, P = (e, t) => e.isSampled() && e.config.transport[t] !== !1, F = {
|
|
568
568
|
abort: "abort",
|
|
569
569
|
error: "error",
|
|
570
570
|
success: "success",
|
|
571
571
|
timeout: "timeout",
|
|
572
572
|
warning: "warning"
|
|
573
|
-
},
|
|
573
|
+
}, I = {
|
|
574
574
|
action: "action",
|
|
575
575
|
custom: "custom",
|
|
576
576
|
document: "document",
|
|
@@ -579,7 +579,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
579
579
|
resource: "resource",
|
|
580
580
|
route: "route",
|
|
581
581
|
vital: "vital"
|
|
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 ?
|
|
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 ? F.timeout : typeof e == "number" && e >= 400 ? F.error : F.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" ? F.success : F.warning, $e = (e, t) => {
|
|
583
583
|
if (!e) return {};
|
|
584
584
|
try {
|
|
585
585
|
let n = new URL(e, typeof location > "u" ? "http://localhost" : location.href), r = t == null ? n.pathname : t;
|
|
@@ -594,21 +594,21 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
594
594
|
pathTemplate: t == null ? e : t
|
|
595
595
|
};
|
|
596
596
|
}
|
|
597
|
-
},
|
|
597
|
+
}, L = ({ duration: e, errorType: t = "none", eventLabel: n, result: r = F.success, spanSubtype: i, spanType: a, targetLabel: o, targetValue: s, traceScene: c }) => O(O(O(O(O({
|
|
598
598
|
[T.spanType]: a,
|
|
599
599
|
[T.spanSubtype]: i,
|
|
600
600
|
[T.result]: r,
|
|
601
601
|
[T.errorType]: t
|
|
602
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
603
|
var c;
|
|
604
|
-
let l = $e(o, s), u = t === "fetch" || t === "xhr", d = r ?
|
|
605
|
-
return O(O(O(O(O(O(O({},
|
|
604
|
+
let l = $e(o, s), u = t === "fetch" || t === "xhr", d = r ? F.error : typeof i == "number" ? Xe(i) : F.success, f = n == null ? void 0 : n.toUpperCase();
|
|
605
|
+
return O(O(O(O(O(O(O({}, L({
|
|
606
606
|
duration: e,
|
|
607
607
|
errorType: r ? "network" : typeof i == "number" ? Ze(i) : "none",
|
|
608
608
|
eventLabel: u ? "请求资源" : "静态资源",
|
|
609
609
|
result: d,
|
|
610
610
|
spanSubtype: t,
|
|
611
|
-
spanType:
|
|
611
|
+
spanType: I.resource,
|
|
612
612
|
targetLabel: (c = l.label) == null ? o : c,
|
|
613
613
|
targetValue: u ? i : a
|
|
614
614
|
})), l.domain ? { [T.targetDomain]: l.domain } : {}), l.pathTemplate ? { [T.targetPathTemplate]: l.pathTemplate } : {}), {}, {
|
|
@@ -621,26 +621,26 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
621
621
|
"http.response.status_code": i,
|
|
622
622
|
"resource.status_code": i
|
|
623
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,
|
|
624
|
+
}, tt = 100, nt = 100, rt = 1e3, it = 100, at = 1e4, ot = "data-bk-action-name", st = 100, ct = 10, lt = (e) => e.replace(/\s+/g, " ").trim().slice(0, st), ut = (e) => {
|
|
625
625
|
var t;
|
|
626
626
|
if (e.parentElement) return e.parentElement;
|
|
627
627
|
let n = (t = e.getRootNode) == null ? void 0 : t.call(e);
|
|
628
628
|
return typeof ShadowRoot < "u" && n instanceof ShadowRoot ? n.host : null;
|
|
629
|
-
},
|
|
629
|
+
}, dt = (e, t) => {
|
|
630
630
|
let n = e;
|
|
631
631
|
for (; n;) {
|
|
632
632
|
let e = n.getAttribute(t);
|
|
633
|
-
if (e) return
|
|
634
|
-
n =
|
|
633
|
+
if (e) return lt(e);
|
|
634
|
+
n = ut(n);
|
|
635
635
|
}
|
|
636
|
-
},
|
|
636
|
+
}, ft = (e) => {
|
|
637
637
|
var t;
|
|
638
|
-
return e.isContentEditable ? "" :
|
|
639
|
-
},
|
|
638
|
+
return e.isContentEditable ? "" : lt((t = e.textContent) == null ? "" : t);
|
|
639
|
+
}, pt = (e) => {
|
|
640
640
|
var t, n;
|
|
641
641
|
let r = e, i = (t = r.labels) == null ? void 0 : t[0];
|
|
642
642
|
if (i) {
|
|
643
|
-
let e =
|
|
643
|
+
let e = ft(i);
|
|
644
644
|
if (e) return e;
|
|
645
645
|
}
|
|
646
646
|
let a = e.tagName.toLowerCase(), o = (n = e.getAttribute("type")) == null ? void 0 : n.toLowerCase();
|
|
@@ -650,11 +650,11 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
650
650
|
"submit"
|
|
651
651
|
].includes(o == null ? "" : o)) {
|
|
652
652
|
var s;
|
|
653
|
-
let e =
|
|
653
|
+
let e = lt((s = r.value) == null ? "" : s);
|
|
654
654
|
if (e) return e;
|
|
655
655
|
}
|
|
656
656
|
if (a === "button" || a === "label" || e.getAttribute("role") === "button") {
|
|
657
|
-
let t =
|
|
657
|
+
let t = ft(e);
|
|
658
658
|
if (t) return t;
|
|
659
659
|
}
|
|
660
660
|
for (let t of [
|
|
@@ -665,39 +665,39 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
665
665
|
"placeholder"
|
|
666
666
|
]) {
|
|
667
667
|
var c;
|
|
668
|
-
let n =
|
|
668
|
+
let n = lt((c = e.getAttribute(t)) == null ? "" : c);
|
|
669
669
|
if (n) return n;
|
|
670
670
|
}
|
|
671
|
-
},
|
|
672
|
-
let r =
|
|
671
|
+
}, mt = (e, t = ot, n = !1) => {
|
|
672
|
+
let r = dt(e, t);
|
|
673
673
|
if (r) return r;
|
|
674
674
|
if (!n) return e.tagName.toLowerCase();
|
|
675
675
|
let i = e, a = 0;
|
|
676
676
|
for (; i && a <= ct;) {
|
|
677
677
|
let e = i.tagName.toLowerCase();
|
|
678
678
|
if (e === "body" || e === "html" || e === "head") break;
|
|
679
|
-
let t =
|
|
679
|
+
let t = pt(i);
|
|
680
680
|
if (t) return t;
|
|
681
681
|
if (e === "form") break;
|
|
682
|
-
i =
|
|
682
|
+
i = ut(i), a += 1;
|
|
683
683
|
}
|
|
684
684
|
for (i = e, a = 0; i && a <= ct;) {
|
|
685
685
|
let e = i.tagName.toLowerCase();
|
|
686
686
|
if (e === "body" || e === "html" || e === "head") break;
|
|
687
|
-
let t =
|
|
687
|
+
let t = ft(i);
|
|
688
688
|
if (t) return t;
|
|
689
689
|
if (e === "form") break;
|
|
690
|
-
i =
|
|
690
|
+
i = ut(i), a += 1;
|
|
691
691
|
}
|
|
692
692
|
return e.tagName.toLowerCase();
|
|
693
|
-
},
|
|
693
|
+
}, ht = (e) => {
|
|
694
694
|
var t;
|
|
695
695
|
let n = (t = e.composedPath) == null ? void 0 : t.call(e)[0];
|
|
696
696
|
return n instanceof Element ? n : e.target instanceof Element ? e.target : void 0;
|
|
697
|
-
},
|
|
697
|
+
}, gt = (e) => {
|
|
698
698
|
let t = e.timeStamp;
|
|
699
699
|
return !Number.isFinite(t) || t <= 0 ? Date.now() : t > 0xe8d4a51000 ? t : typeof performance > "u" ? Date.now() : performance.timeOrigin + t;
|
|
700
|
-
},
|
|
700
|
+
}, _t = (e, t) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : t, vt = (e) => {
|
|
701
701
|
let t = e;
|
|
702
702
|
if (t.tagName.toLowerCase() === "label" && t.hasAttribute("for")) {
|
|
703
703
|
var n;
|
|
@@ -717,13 +717,13 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
717
717
|
"submit"
|
|
718
718
|
].includes((r = (i = t.getAttribute("type")) == null ? void 0 : i.toLowerCase()) == null ? "text" : r);
|
|
719
719
|
}
|
|
720
|
-
t =
|
|
720
|
+
t = ut(t);
|
|
721
721
|
}
|
|
722
722
|
return !1;
|
|
723
|
-
},
|
|
724
|
-
let t = [], n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = e.actionNameAttribute || ot, a =
|
|
723
|
+
}, yt = (e = {}) => {
|
|
724
|
+
let t = [], n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = e.actionNameAttribute || ot, a = _t(e.maxDuration, at), o = [], s, c = () => {
|
|
725
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 && !
|
|
726
|
+
}, l = (e) => !e.hadActivity && !e.userActivity.input && !e.userActivity.scroll && !e.userActivity.selection && !vt(e.target), u = (e) => {
|
|
727
727
|
var t;
|
|
728
728
|
if (!r.delete(e) || !s || !e.completed || e.discardedByRage) return;
|
|
729
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");
|
|
@@ -731,13 +731,14 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
731
731
|
"rage_click",
|
|
732
732
|
"dead_click",
|
|
733
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
|
|
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;
|
|
735
|
+
s.startSpan("action.click", O(O(O(O(O({}, s.config.hooks.getPageAttributes()), L({
|
|
735
736
|
duration: a ? o : void 0,
|
|
736
737
|
errorType: e.counts.error ? "js" : n.length ? "frustration" : "none",
|
|
737
738
|
eventLabel: "用户操作",
|
|
738
|
-
result: c ?
|
|
739
|
+
result: c ? F.warning : F.success,
|
|
739
740
|
spanSubtype: "click",
|
|
740
|
-
spanType:
|
|
741
|
+
spanType: I.action,
|
|
741
742
|
targetLabel: e.targetName,
|
|
742
743
|
targetValue: a ? o : void 0,
|
|
743
744
|
traceScene: "user_action"
|
|
@@ -751,8 +752,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
751
752
|
[T.actionErrorCount]: e.counts.error,
|
|
752
753
|
[T.actionLongTaskCount]: e.counts.longTask,
|
|
753
754
|
[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);
|
|
755
|
+
}, n.length ? { [T.actionFrustrationType]: n } : {}), a ? { [T.actionLoadingTime]: o } : {}), { startTime: e.startTime }).end(a ? i : e.startTime);
|
|
756
756
|
}, d = (e, t, i) => {
|
|
757
757
|
if (!n.delete(e.id) || !s) return;
|
|
758
758
|
clearTimeout(e.validationTimer), clearTimeout(e.quietTimer), clearTimeout(e.maxDurationTimer), c(), e.completed = {
|
|
@@ -821,10 +821,10 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
821
821
|
capture: !0,
|
|
822
822
|
passive: !0
|
|
823
823
|
}, p = (t) => {
|
|
824
|
-
if ("button" in t && typeof t.button == "number" && t.button !== 0) return;
|
|
825
|
-
let r =
|
|
824
|
+
if (!P(l, "traces") || "button" in t && typeof t.button == "number" && t.button !== 0) return;
|
|
825
|
+
let r = ht(t);
|
|
826
826
|
if (!r) return;
|
|
827
|
-
let o =
|
|
827
|
+
let o = gt(t), s = N("action"), u = {
|
|
828
828
|
counts: {
|
|
829
829
|
error: 0,
|
|
830
830
|
longTask: 0,
|
|
@@ -839,7 +839,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
839
839
|
runtimeAttributes: l.getRuntimeAttributes(),
|
|
840
840
|
startTime: o,
|
|
841
841
|
target: r,
|
|
842
|
-
targetName:
|
|
842
|
+
targetName: mt(r, i, e.nameCollection === "text"),
|
|
843
843
|
targetTag: r.tagName.toLowerCase(),
|
|
844
844
|
userActivity: {
|
|
845
845
|
input: !1,
|
|
@@ -887,16 +887,16 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
887
887
|
o = [], s = void 0;
|
|
888
888
|
}
|
|
889
889
|
};
|
|
890
|
-
},
|
|
890
|
+
}, bt = "data-bk-excluded-activity-mutations", xt = (e) => {
|
|
891
891
|
let t = e.type === "characterData" ? e.target.parentElement : e.target;
|
|
892
892
|
return t instanceof Element && !!t.closest("[data-bk-excluded-activity-mutations]");
|
|
893
|
-
},
|
|
893
|
+
}, St = () => {
|
|
894
894
|
let e, t = [];
|
|
895
895
|
return {
|
|
896
896
|
name: "activity",
|
|
897
897
|
init(n) {
|
|
898
898
|
if (typeof document < "u" && typeof MutationObserver < "u" && (e = new MutationObserver((e) => {
|
|
899
|
-
e.length && !e.every(
|
|
899
|
+
e.length && !e.every(xt) && n.notifyActivity({
|
|
900
900
|
time: Date.now(),
|
|
901
901
|
type: "dom_mutation"
|
|
902
902
|
});
|
|
@@ -920,7 +920,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
920
920
|
for (e == null || e.disconnect(), e = void 0; t.length;) (n = t.pop()) == null || n();
|
|
921
921
|
}
|
|
922
922
|
};
|
|
923
|
-
},
|
|
923
|
+
}, Ct = (e, t) => !!(t && M(e.config.view.excludedActivityUrls, t)), wt = (e, t, n) => {
|
|
924
924
|
let r = /* @__PURE__ */ new Set(), i = !1, a = !1, o = t, s, c = (e) => {
|
|
925
925
|
i || (i = !0, clearTimeout(f), clearTimeout(s), d(), n(e));
|
|
926
926
|
}, l = () => {
|
|
@@ -933,7 +933,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
933
933
|
}, d = e.onActivity((n) => {
|
|
934
934
|
if (!(n.type === "error" || n.type === "long_task")) {
|
|
935
935
|
if (n.type === "request_start") {
|
|
936
|
-
if (n.time < t ||
|
|
936
|
+
if (n.time < t || Ct(e, n.url)) return;
|
|
937
937
|
r.add(n.id), u(n.time);
|
|
938
938
|
return;
|
|
939
939
|
}
|
|
@@ -943,7 +943,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
943
943
|
return;
|
|
944
944
|
}
|
|
945
945
|
if (n.type === "resource") {
|
|
946
|
-
if (n.endTime < t ||
|
|
946
|
+
if (n.endTime < t || Ct(e, n.url)) return;
|
|
947
947
|
u(n.endTime);
|
|
948
948
|
return;
|
|
949
949
|
}
|
|
@@ -955,10 +955,10 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
955
955
|
return () => {
|
|
956
956
|
i || (i = !0, clearTimeout(f), clearTimeout(s), d());
|
|
957
957
|
};
|
|
958
|
-
},
|
|
959
|
-
let t =
|
|
958
|
+
}, Tt = /^(?:\d+|[0-9a-f]{8}-[0-9a-f-]{27,}|[0-9a-f]{16,})$/i, Et = (e) => e.split(/[?#]/, 1)[0].split("/").map((e) => Tt.test(e) ? ":id" : e).join("/"), Dt = (e) => typeof e == "string" && e.length > 0 ? Et(e) : void 0, Ot = (e) => {
|
|
959
|
+
let t = Dt(e);
|
|
960
960
|
return t ? { [T.viewUrlPathGroup]: t } : {};
|
|
961
|
-
},
|
|
961
|
+
}, R = (e) => O(O({}, Ot(e[T.viewUrlPathGroup])), {}, { [A]: e[A] === !0 }), kt = 1e3, At = 200, jt = "body", Mt = .8, Nt = [
|
|
962
962
|
"[data-loading=\"true\"]",
|
|
963
963
|
"[aria-busy=\"true\"]",
|
|
964
964
|
".loading",
|
|
@@ -966,7 +966,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
966
966
|
".spinner",
|
|
967
967
|
".skeleton",
|
|
968
968
|
".bk-loading"
|
|
969
|
-
],
|
|
969
|
+
], z = [
|
|
970
970
|
[.2, .2],
|
|
971
971
|
[.5, .2],
|
|
972
972
|
[.8, .2],
|
|
@@ -976,45 +976,45 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
976
976
|
[.2, .8],
|
|
977
977
|
[.5, .8],
|
|
978
978
|
[.8, .8]
|
|
979
|
-
],
|
|
979
|
+
], Pt = (e, t) => typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : t, Ft = (e, t) => typeof e == "number" && Number.isFinite(e) ? Math.max(0, Math.min(1, e)) : t, It = (e) => {
|
|
980
980
|
if (!e) return "";
|
|
981
981
|
let t = e.tagName.toLowerCase();
|
|
982
982
|
return e.id ? `${t}#${e.id}` : t;
|
|
983
|
-
},
|
|
983
|
+
}, Lt = (e, t) => t.some((t) => {
|
|
984
984
|
try {
|
|
985
985
|
return e.matches(t) || !!e.closest(t);
|
|
986
986
|
} catch (e) {
|
|
987
987
|
return !1;
|
|
988
988
|
}
|
|
989
|
-
}),
|
|
989
|
+
}), Rt = (e) => {
|
|
990
990
|
if (typeof getComputedStyle != "function") return !0;
|
|
991
991
|
let t = getComputedStyle(e);
|
|
992
992
|
return t.display !== "none" && t.visibility !== "hidden" && Number(t.opacity || 1) > 0;
|
|
993
|
-
},
|
|
993
|
+
}, zt = (e, t) => {
|
|
994
994
|
if (typeof document.elementsFromPoint == "function") return document.elementsFromPoint(e, t);
|
|
995
995
|
let n = document.elementFromPoint(e, t);
|
|
996
996
|
return n ? [n] : [];
|
|
997
|
-
},
|
|
997
|
+
}, Bt = (e, t) => {
|
|
998
998
|
let n = document.querySelector(e);
|
|
999
999
|
if (!n) return {
|
|
1000
|
-
centerElement:
|
|
1001
|
-
emptyCount:
|
|
1000
|
+
centerElement: It(zt(window.innerWidth / 2, window.innerHeight / 2)[0]),
|
|
1001
|
+
emptyCount: z.length,
|
|
1002
1002
|
ignoredCount: 0,
|
|
1003
1003
|
reason: "missing_root",
|
|
1004
1004
|
rootFound: !1,
|
|
1005
1005
|
score: 1,
|
|
1006
|
-
validCount:
|
|
1006
|
+
validCount: z.length
|
|
1007
1007
|
};
|
|
1008
1008
|
let r = 0, i = 0, a = "";
|
|
1009
|
-
for (let [e, o] of
|
|
1010
|
-
let s =
|
|
1011
|
-
if (e === .5 && o === .5 && (a =
|
|
1009
|
+
for (let [e, o] of z) {
|
|
1010
|
+
let s = zt(window.innerWidth * e, window.innerHeight * o);
|
|
1011
|
+
if (e === .5 && o === .5 && (a = It(s[0])), s.some((e) => Lt(e, t))) {
|
|
1012
1012
|
i += 1;
|
|
1013
1013
|
continue;
|
|
1014
1014
|
}
|
|
1015
|
-
s.some((e) => e !== n && e !== document.body && e !== document.documentElement && n.contains(e) &&
|
|
1015
|
+
s.some((e) => e !== n && e !== document.body && e !== document.documentElement && n.contains(e) && Rt(e)) || (r += 1);
|
|
1016
1016
|
}
|
|
1017
|
-
let o =
|
|
1017
|
+
let o = z.length - i;
|
|
1018
1018
|
return {
|
|
1019
1019
|
centerElement: a,
|
|
1020
1020
|
emptyCount: r,
|
|
@@ -1024,9 +1024,9 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1024
1024
|
score: o ? r / o : 0,
|
|
1025
1025
|
validCount: o
|
|
1026
1026
|
};
|
|
1027
|
-
},
|
|
1027
|
+
}, Vt = (e = {}) => {
|
|
1028
1028
|
var t;
|
|
1029
|
-
let n =
|
|
1029
|
+
let n = Pt(e.checkDelay, kt), r = Pt(e.confirmationDelay, At), i = e.rootSelector || jt, a = Ft(e.threshold, Mt), o = [...Nt, ...(t = e.ignoreSelectors) == null ? [] : t], s, c, l, u, d = () => {}, f;
|
|
1030
1030
|
return {
|
|
1031
1031
|
name: "blank-screen",
|
|
1032
1032
|
init(e) {
|
|
@@ -1034,15 +1034,17 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1034
1034
|
let t = e.meter.createCounter("browser.blank_screen.count", { description: "Number of confirmed blank screens" }), p = () => {
|
|
1035
1035
|
clearTimeout(u), u = void 0;
|
|
1036
1036
|
}, m = (n, r) => {
|
|
1037
|
-
s !== n || c === n
|
|
1037
|
+
if (s !== n || c === n) return;
|
|
1038
|
+
let a = P(e, "metrics"), o = P(e, "traces");
|
|
1039
|
+
!a && !o || (c = n, a && t.add(1, e.applyRedact(O(O(O({}, e.config.hooks.getMetricAttributes()), R(e.getRuntimeAttributes())), {}, {
|
|
1038
1040
|
"blank_screen.reason": r.reason,
|
|
1039
1041
|
"blank_screen.root_selector": i
|
|
1040
|
-
}))), e.startSpan("browser.blank_screen", O(O({},
|
|
1042
|
+
}))), o && e.startSpan("browser.blank_screen", O(O({}, L({
|
|
1041
1043
|
errorType: "blank_screen",
|
|
1042
1044
|
eventLabel: "白屏",
|
|
1043
|
-
result:
|
|
1045
|
+
result: F.error,
|
|
1044
1046
|
spanSubtype: r.reason,
|
|
1045
|
-
spanType:
|
|
1047
|
+
spanType: I.error,
|
|
1046
1048
|
targetLabel: i,
|
|
1047
1049
|
targetValue: r.score
|
|
1048
1050
|
})), {}, {
|
|
@@ -1053,14 +1055,14 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1053
1055
|
"blank_screen.reason": r.reason,
|
|
1054
1056
|
"blank_screen.root_found": r.rootFound,
|
|
1055
1057
|
"blank_screen.root_selector": i,
|
|
1056
|
-
"blank_screen.sample_count":
|
|
1058
|
+
"blank_screen.sample_count": z.length,
|
|
1057
1059
|
"blank_screen.valid_sample_count": r.validCount
|
|
1058
1060
|
})).end());
|
|
1059
1061
|
}, h = (t) => {
|
|
1060
1062
|
if (s !== t || c === t || document.visibilityState === "hidden") return;
|
|
1061
1063
|
let n;
|
|
1062
1064
|
try {
|
|
1063
|
-
n =
|
|
1065
|
+
n = Bt(i, o);
|
|
1064
1066
|
} catch (t) {
|
|
1065
1067
|
var l;
|
|
1066
1068
|
e.config.debug && ((l = globalThis.console) == null || l.warn("[bk-ot][blank-screen] detection failed:", t));
|
|
@@ -1070,7 +1072,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1070
1072
|
if (s !== t || document.visibilityState === "hidden") return;
|
|
1071
1073
|
let n;
|
|
1072
1074
|
try {
|
|
1073
|
-
n =
|
|
1075
|
+
n = Bt(i, o);
|
|
1074
1076
|
} catch (t) {
|
|
1075
1077
|
var r;
|
|
1076
1078
|
e.config.debug && ((r = globalThis.console) == null || r.warn("[bk-ot][blank-screen] confirmation failed:", t));
|
|
@@ -1078,13 +1080,13 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1078
1080
|
}
|
|
1079
1081
|
n.validCount && n.score >= a && m(t, n);
|
|
1080
1082
|
}, r));
|
|
1081
|
-
}, g = (
|
|
1082
|
-
p(), document.visibilityState
|
|
1083
|
+
}, g = (t) => {
|
|
1084
|
+
p(), !(document.visibilityState === "hidden" || !P(e, "metrics") && !P(e, "traces")) && (u = setTimeout(() => h(t), n));
|
|
1083
1085
|
};
|
|
1084
1086
|
d = e.onViewChange((t) => {
|
|
1085
1087
|
if (t.id !== s && (p(), l == null || l(), l = void 0, s = t.id, c = void 0, t.id)) {
|
|
1086
1088
|
let n = t.id;
|
|
1087
|
-
l =
|
|
1089
|
+
l = wt(e, Date.now(), () => {
|
|
1088
1090
|
l = void 0, g(n);
|
|
1089
1091
|
});
|
|
1090
1092
|
}
|
|
@@ -1098,43 +1100,43 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1098
1100
|
clearTimeout(u), u = void 0, d(), l == null || l(), l = void 0, f == null || f(), f = void 0, s = void 0, c = void 0;
|
|
1099
1101
|
}
|
|
1100
1102
|
};
|
|
1101
|
-
},
|
|
1102
|
-
let t =
|
|
1103
|
-
t >= 0 &&
|
|
1104
|
-
},
|
|
1103
|
+
}, Ht = 100, Ut = 200, B = [], Wt = (e) => e.replace(/#.*$/, ""), Gt = (e) => {
|
|
1104
|
+
let t = B.indexOf(e);
|
|
1105
|
+
t >= 0 && B.splice(t, 1), e.timer !== void 0 && clearTimeout(e.timer);
|
|
1106
|
+
}, V = (e, t) => {
|
|
1105
1107
|
let n = e.callback;
|
|
1106
|
-
|
|
1107
|
-
},
|
|
1108
|
-
let t = performance.timeOrigin + e.startTime, n =
|
|
1109
|
-
n && (n.entry = e, n.callback &&
|
|
1110
|
-
},
|
|
1108
|
+
Gt(e), e.callback = void 0, n == null || n(t);
|
|
1109
|
+
}, Kt = (e) => {
|
|
1110
|
+
let t = performance.timeOrigin + e.startTime, n = B.filter((n) => !n.entry && Wt(n.url) === Wt(e.name) && t >= n.startTime - 50).sort((e, n) => Math.abs(e.startTime - t) - Math.abs(n.startTime - t))[0];
|
|
1111
|
+
n && (n.entry = e, n.callback && V(n, e));
|
|
1112
|
+
}, qt = (e, t = Date.now()) => {
|
|
1111
1113
|
let n = {
|
|
1112
1114
|
startTime: t,
|
|
1113
1115
|
url: e
|
|
1114
1116
|
};
|
|
1115
|
-
return
|
|
1116
|
-
cancel: () =>
|
|
1117
|
+
return B.push(n), B.length > Ht && V(B[0]), {
|
|
1118
|
+
cancel: () => V(n),
|
|
1117
1119
|
complete: (e) => {
|
|
1118
1120
|
if (n.callback = e, n.entry) {
|
|
1119
|
-
|
|
1121
|
+
V(n, n.entry);
|
|
1120
1122
|
return;
|
|
1121
1123
|
}
|
|
1122
|
-
n.timer = setTimeout(() =>
|
|
1124
|
+
n.timer = setTimeout(() => V(n), Ut);
|
|
1123
1125
|
}
|
|
1124
1126
|
};
|
|
1125
|
-
},
|
|
1127
|
+
}, Jt = 10 * 1024, Yt = [
|
|
1126
1128
|
/^text\//i,
|
|
1127
1129
|
/json/i,
|
|
1128
1130
|
"application/x-www-form-urlencoded",
|
|
1129
1131
|
"application/graphql"
|
|
1130
|
-
],
|
|
1132
|
+
], Xt = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? Math.floor(e) : Jt, Zt = (e, t, n) => e ? t.some((t) => typeof t == "string" ? e.toLowerCase().includes(t.toLowerCase()) : (t.lastIndex = 0, t.test(e))) : n, Qt = (e) => {
|
|
1131
1133
|
try {
|
|
1132
1134
|
var t;
|
|
1133
1135
|
return e ? (t = new Headers(e).get("content-type")) == null ? void 0 : t : void 0;
|
|
1134
1136
|
} catch (e) {
|
|
1135
1137
|
return;
|
|
1136
1138
|
}
|
|
1137
|
-
},
|
|
1139
|
+
}, $t = function() {
|
|
1138
1140
|
var e = k(function* (e, t) {
|
|
1139
1141
|
let n = e.getReader(), r = new TextDecoder(), i = "";
|
|
1140
1142
|
try {
|
|
@@ -1155,54 +1157,54 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1155
1157
|
return function(t, n) {
|
|
1156
1158
|
return e.apply(this, arguments);
|
|
1157
1159
|
};
|
|
1158
|
-
}(),
|
|
1160
|
+
}(), en = function() {
|
|
1159
1161
|
var e = k(function* (e, t) {
|
|
1160
1162
|
if (typeof e == "string") return e;
|
|
1161
1163
|
if (typeof URLSearchParams < "u" && e instanceof URLSearchParams) return e.toString();
|
|
1162
|
-
if (typeof Blob < "u" && e instanceof Blob) return
|
|
1164
|
+
if (typeof Blob < "u" && e instanceof Blob) return $t(e.stream(), t);
|
|
1163
1165
|
});
|
|
1164
1166
|
return function(t, n) {
|
|
1165
1167
|
return e.apply(this, arguments);
|
|
1166
1168
|
};
|
|
1167
|
-
}(),
|
|
1169
|
+
}(), tn = function() {
|
|
1168
1170
|
var e = k(function* (e, t) {
|
|
1169
1171
|
if (typeof Request < "u" && e instanceof Request) {
|
|
1170
1172
|
var n;
|
|
1171
1173
|
let r = (n = e.headers.get("content-type")) == null ? void 0 : n, i = e.clone();
|
|
1172
1174
|
return {
|
|
1173
1175
|
contentType: r,
|
|
1174
|
-
text: i.body ? yield
|
|
1176
|
+
text: i.body ? yield $t(i.body, t) : ""
|
|
1175
1177
|
};
|
|
1176
1178
|
}
|
|
1177
1179
|
return {
|
|
1178
|
-
contentType:
|
|
1179
|
-
text: yield
|
|
1180
|
+
contentType: Qt(e.headers),
|
|
1181
|
+
text: yield en(e.body, t)
|
|
1180
1182
|
};
|
|
1181
1183
|
});
|
|
1182
1184
|
return function(t, n) {
|
|
1183
1185
|
return e.apply(this, arguments);
|
|
1184
1186
|
};
|
|
1185
|
-
}(),
|
|
1187
|
+
}(), nn = (e) => {
|
|
1186
1188
|
if (typeof Request > "u" || !(e instanceof Request)) return e;
|
|
1187
1189
|
try {
|
|
1188
1190
|
return e.clone();
|
|
1189
1191
|
} catch (e) {
|
|
1190
1192
|
return;
|
|
1191
1193
|
}
|
|
1192
|
-
},
|
|
1194
|
+
}, rn = function() {
|
|
1193
1195
|
var e = k(function* (e, t) {
|
|
1194
1196
|
var n;
|
|
1195
1197
|
if (!e) return {};
|
|
1196
1198
|
let r = (n = e.headers.get("content-type")) == null ? void 0 : n, i = e.clone();
|
|
1197
1199
|
return {
|
|
1198
1200
|
contentType: r,
|
|
1199
|
-
text: i.body ? yield
|
|
1201
|
+
text: i.body ? yield $t(i.body, t) : ""
|
|
1200
1202
|
};
|
|
1201
1203
|
});
|
|
1202
1204
|
return function(t, n) {
|
|
1203
1205
|
return e.apply(this, arguments);
|
|
1204
1206
|
};
|
|
1205
|
-
}(),
|
|
1207
|
+
}(), an = (e) => {
|
|
1206
1208
|
var t;
|
|
1207
1209
|
let n = (t = e.getResponseHeader("content-type")) == null ? void 0 : t;
|
|
1208
1210
|
return e.responseType === "" || e.responseType === "text" ? {
|
|
@@ -1212,9 +1214,9 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1212
1214
|
contentType: n,
|
|
1213
1215
|
text: JSON.stringify(e.response)
|
|
1214
1216
|
} : { contentType: n };
|
|
1215
|
-
},
|
|
1217
|
+
}, on = (e, t, n, r, i) => {
|
|
1216
1218
|
if (i === void 0) return;
|
|
1217
|
-
let a =
|
|
1219
|
+
let a = Xt(e.maxSize), o = i.length > a, s = {
|
|
1218
1220
|
body: i.slice(0, a * 2),
|
|
1219
1221
|
contentType: r,
|
|
1220
1222
|
kind: n,
|
|
@@ -1229,51 +1231,47 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1229
1231
|
contentType: r,
|
|
1230
1232
|
truncated: o || c.length > a
|
|
1231
1233
|
};
|
|
1232
|
-
},
|
|
1233
|
-
var e = k(function* ({ bodyConfig: e, domainContext: t, event: n, fetchRequest: r,
|
|
1234
|
-
var
|
|
1235
|
-
let
|
|
1236
|
-
if (((
|
|
1237
|
-
let
|
|
1234
|
+
}, sn = function() {
|
|
1235
|
+
var e = k(function* ({ bodyConfig: e, domainContext: t, event: n, fetchRequest: r, occurredAt: i, runtimeContext: a, span: o }) {
|
|
1236
|
+
var s, c;
|
|
1237
|
+
let u = n.resource.statusCode, f = u === void 0 || u === 0 || u >= 400;
|
|
1238
|
+
if (((s = e.capture) == null ? "errors" : s) === "errors" && !f) return;
|
|
1239
|
+
let p = Xt(e.maxSize) * 2, m = (c = e.allowedContentTypes) == null ? Yt : c, h = {}, g = {};
|
|
1238
1240
|
try {
|
|
1239
|
-
t.type === "fetch" ? [
|
|
1241
|
+
t.type === "fetch" ? [h, g] = yield Promise.all([tn(r == null ? t.request : r, p), rn(t.response, p)]) : (h = { text: yield en(t.requestBody, p) }, g = an(t.xhr));
|
|
1240
1242
|
} catch (e) {
|
|
1241
1243
|
return;
|
|
1242
1244
|
}
|
|
1243
|
-
let
|
|
1245
|
+
let _, v;
|
|
1244
1246
|
try {
|
|
1245
|
-
|
|
1247
|
+
_ = Zt(h.contentType, m, !0) ? on(e, n, "request", h.contentType, h.text) : void 0, v = Zt(g.contentType, m, !1) ? on(e, n, "response", g.contentType, g.text) : void 0;
|
|
1246
1248
|
} catch (e) {
|
|
1247
1249
|
return;
|
|
1248
1250
|
}
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
"
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
"
|
|
1257
|
-
"
|
|
1258
|
-
"request.body.truncated": g.truncated
|
|
1259
|
-
} : {}), _ ? {
|
|
1260
|
-
"response.body": _.body,
|
|
1261
|
-
"response.body.content_type": _.contentType,
|
|
1262
|
-
"response.body.truncated": _.truncated
|
|
1251
|
+
!_ && !v || a.emitLog({
|
|
1252
|
+
attributes: O(O(O({}, n.attributes), _ ? {
|
|
1253
|
+
"request.body": _.body,
|
|
1254
|
+
"request.body.content_type": _.contentType,
|
|
1255
|
+
"request.body.truncated": _.truncated
|
|
1256
|
+
} : {}), v ? {
|
|
1257
|
+
"response.body": v.body,
|
|
1258
|
+
"response.body.content_type": v.contentType,
|
|
1259
|
+
"response.body.truncated": v.truncated
|
|
1263
1260
|
} : {}),
|
|
1264
1261
|
body: "browser.request.body",
|
|
1265
|
-
context: d.setSpan(l.active(),
|
|
1262
|
+
context: d.setSpan(l.active(), o),
|
|
1266
1263
|
eventName: "browser.request.body",
|
|
1267
|
-
severityNumber:
|
|
1268
|
-
severityText:
|
|
1264
|
+
severityNumber: f ? w.ERROR : w.INFO,
|
|
1265
|
+
severityText: f ? "ERROR" : "INFO",
|
|
1266
|
+
timestamp: i
|
|
1269
1267
|
});
|
|
1270
1268
|
});
|
|
1271
1269
|
return function(t) {
|
|
1272
1270
|
return e.apply(this, arguments);
|
|
1273
1271
|
};
|
|
1274
|
-
}(),
|
|
1275
|
-
|
|
1276
|
-
},
|
|
1272
|
+
}(), cn = (e) => e.deliveryType === "cache" || e.transferSize === 0 && e.decodedBodySize > 0 ? !0 : void 0, ln = (...e) => e.every((t, n) => n === 0 || e[n - 1] <= t), H = (e, t, n, r, i) => {
|
|
1273
|
+
ln(n, r, i) && (e[`resource.${t}.start`] = r - n, e[`resource.${t}.duration`] = i - r);
|
|
1274
|
+
}, un = (e) => {
|
|
1277
1275
|
let t = {}, n = [
|
|
1278
1276
|
e.startTime,
|
|
1279
1277
|
e.fetchStart,
|
|
@@ -1285,18 +1283,18 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1285
1283
|
e.responseStart,
|
|
1286
1284
|
e.responseEnd
|
|
1287
1285
|
];
|
|
1288
|
-
return !n.every(Number.isFinite) || !
|
|
1289
|
-
},
|
|
1286
|
+
return !n.every(Number.isFinite) || !ln(...n) ? t : (H(t, "first_byte", e.startTime, e.requestStart, e.responseStart), H(t, "download", e.startTime, e.responseStart, e.responseEnd), e.workerStart > 0 && e.workerStart < e.fetchStart && H(t, "worker", e.startTime, e.workerStart, e.fetchStart), e.fetchStart < e.domainLookupEnd && H(t, "dns", e.startTime, e.domainLookupStart, e.domainLookupEnd), e.fetchStart < e.connectEnd && (H(t, "connect", e.startTime, e.connectStart, e.connectEnd), e.connectStart <= e.secureConnectionStart && e.secureConnectionStart <= e.connectEnd && H(t, "ssl", e.startTime, e.secureConnectionStart, e.connectEnd)), e.redirectEnd > e.startTime && ln(e.startTime, e.redirectStart, e.redirectEnd, e.fetchStart) && H(t, "redirect", e.startTime, e.redirectStart, e.redirectEnd), t);
|
|
1287
|
+
}, dn = (e) => e.duration === 0 && e.responseEnd > e.startTime ? e.responseEnd - e.startTime : e.duration, fn = (e) => {
|
|
1290
1288
|
let t = typeof e.deliveryType == "string" ? e.deliveryType || "other" : void 0;
|
|
1291
1289
|
return O(O(O(O({
|
|
1292
1290
|
[T.transferSize]: e.transferSize,
|
|
1293
|
-
[T.cacheHit]:
|
|
1291
|
+
[T.cacheHit]: cn(e),
|
|
1294
1292
|
[T.nextHopProtocol]: e.nextHopProtocol
|
|
1295
|
-
},
|
|
1293
|
+
}, un(e)), t ? { "resource.delivery_type": t } : {}), e.renderBlockingStatus ? { "resource.render_blocking_status": e.renderBlockingStatus } : {}), {}, {
|
|
1296
1294
|
"resource.encoded_body_size": e.encodedBodySize,
|
|
1297
1295
|
"resource.decoded_body_size": e.decodedBodySize
|
|
1298
1296
|
});
|
|
1299
|
-
},
|
|
1297
|
+
}, pn = (e = !0) => {
|
|
1300
1298
|
let t;
|
|
1301
1299
|
return {
|
|
1302
1300
|
name: "resource",
|
|
@@ -1304,14 +1302,14 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1304
1302
|
var r;
|
|
1305
1303
|
if (typeof PerformanceObserver > "u" || !((r = PerformanceObserver.supportedEntryTypes) != null && r.includes("resource"))) return;
|
|
1306
1304
|
let i = (t) => {
|
|
1307
|
-
if (!t.name || ke(n.config, t.name)) return;
|
|
1305
|
+
if (!n.isSampled() || !t.name || ke(n.config, t.name)) return;
|
|
1308
1306
|
if (t.initiatorType === "fetch" || t.initiatorType === "xmlhttprequest") {
|
|
1309
|
-
|
|
1307
|
+
Kt(t);
|
|
1310
1308
|
return;
|
|
1311
1309
|
}
|
|
1312
1310
|
if (t.duration < 0) return;
|
|
1313
|
-
let r = n.config.hooks.redactUrl(t.name), i =
|
|
1314
|
-
e && n.startSpan("browser.resource", O(O(O({}, n.config.hooks.getPageAttributes()), et({
|
|
1311
|
+
let r = n.config.hooks.redactUrl(t.name), i = dn(t), a = performance.timeOrigin + t.startTime, o = a + i;
|
|
1312
|
+
e && P(n, "traces") && n.startSpan("browser.resource", O(O(O({}, n.config.hooks.getPageAttributes()), et({
|
|
1315
1313
|
duration: i,
|
|
1316
1314
|
initiatorType: t.initiatorType || "other",
|
|
1317
1315
|
responseStatus: t.responseStatus,
|
|
@@ -1321,7 +1319,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1321
1319
|
})), {}, {
|
|
1322
1320
|
"url.full": r,
|
|
1323
1321
|
initiator_type: t.initiatorType || "other"
|
|
1324
|
-
},
|
|
1322
|
+
}, fn(t)), { startTime: a }).end(o), n.notifyActivity({
|
|
1325
1323
|
endTime: o,
|
|
1326
1324
|
startTime: a,
|
|
1327
1325
|
type: "resource",
|
|
@@ -1343,26 +1341,26 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1343
1341
|
t == null || t.disconnect(), t = void 0;
|
|
1344
1342
|
}
|
|
1345
1343
|
};
|
|
1346
|
-
},
|
|
1344
|
+
}, mn = (e) => typeof e.config.tracking.request == "object" ? e.config.tracking.request : void 0, hn = (e) => {
|
|
1347
1345
|
if (e.type === "xhr") return e.xhr.status;
|
|
1348
1346
|
if (e.response) return e.response.status;
|
|
1349
1347
|
if (typeof e.error == "object" && e.error && "status" in e.error) {
|
|
1350
1348
|
let t = e.error.status;
|
|
1351
1349
|
return typeof t == "number" ? t : void 0;
|
|
1352
1350
|
}
|
|
1353
|
-
},
|
|
1351
|
+
}, gn = (e) => typeof e == "string" || e instanceof URL ? j(String(e)) : j(e.url), _n = (e, t) => {
|
|
1354
1352
|
var n;
|
|
1355
1353
|
return ((n = t == null ? void 0 : t.method) == null ? typeof Request < "u" && e instanceof Request ? e.method : "GET" : n).toUpperCase();
|
|
1356
|
-
},
|
|
1354
|
+
}, vn = (e, t) => typeof Request < "u" && e instanceof Request ? e : t == null ? {} : t, yn = (e, t, n) => {
|
|
1357
1355
|
var r;
|
|
1358
1356
|
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
1357
|
return u.inject(d.setSpan(l.active(), n), a, { set: (e, t, n) => e.set(t, n) }), O(O({}, t), {}, { headers: a });
|
|
1360
|
-
},
|
|
1358
|
+
}, bn = (e, t) => {
|
|
1361
1359
|
let n = {};
|
|
1362
1360
|
u.inject(d.setSpan(l.active(), t), n);
|
|
1363
1361
|
for (let [t, r] of Object.entries(n)) e.setRequestHeader(t, r);
|
|
1364
|
-
},
|
|
1365
|
-
if (
|
|
1362
|
+
}, xn = (e, t) => ke(e.config, t) || M(e.config.view.excludedActivityUrls, t), Sn = (e, t) => {
|
|
1363
|
+
if (xn(e, t)) return () => {};
|
|
1366
1364
|
let n = N("request");
|
|
1367
1365
|
e.notifyActivity({
|
|
1368
1366
|
id: n,
|
|
@@ -1378,12 +1376,12 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1378
1376
|
type: "request_end"
|
|
1379
1377
|
}));
|
|
1380
1378
|
};
|
|
1381
|
-
},
|
|
1379
|
+
}, Cn = (e, t) => e.config.transport.traces === !1 || !e.isSampled() ? {
|
|
1382
1380
|
cancel() {},
|
|
1383
1381
|
complete(e) {
|
|
1384
1382
|
e();
|
|
1385
1383
|
}
|
|
1386
|
-
} :
|
|
1384
|
+
} : qt(t), wn = (e, t, n) => {
|
|
1387
1385
|
var r;
|
|
1388
1386
|
return e.startSpan("browser.resource", O(O(O({}, e.config.hooks.getPageAttributes()), et({
|
|
1389
1387
|
initiatorType: t,
|
|
@@ -1391,9 +1389,9 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1391
1389
|
url: (r = n.url) == null ? "" : r,
|
|
1392
1390
|
urlPathTemplate: n.url ? e.config.hooks.getViewPathGroup(n.url) : void 0
|
|
1393
1391
|
})), n.url ? { "resource.url": e.config.hooks.redactUrl(n.url) } : {}), { kind: s.CLIENT });
|
|
1394
|
-
},
|
|
1392
|
+
}, Tn = (e, t, n, r, i = {}, a) => {
|
|
1395
1393
|
var o;
|
|
1396
|
-
let s = i.url, l = s ? e.config.hooks.redactUrl(s) : void 0, u =
|
|
1394
|
+
let s = i.url, l = s ? e.config.hooks.redactUrl(s) : void 0, u = hn(r), d = i.method, f = {
|
|
1397
1395
|
attributes: O(O(O({}, e.config.hooks.getPageAttributes()), et({
|
|
1398
1396
|
initiatorType: n,
|
|
1399
1397
|
method: d,
|
|
@@ -1415,7 +1413,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1415
1413
|
}, p = !0;
|
|
1416
1414
|
try {
|
|
1417
1415
|
var m, h;
|
|
1418
|
-
p = (m =
|
|
1416
|
+
p = (m = mn(e)) == null || (h = m.beforeSend) == null ? void 0 : h.call(m, f, r);
|
|
1419
1417
|
} catch (t) {
|
|
1420
1418
|
var g;
|
|
1421
1419
|
e.config.debug && ((g = globalThis.console) == null || g.warn("[bk-ot] request.beforeSend failed:", t));
|
|
@@ -1425,16 +1423,17 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1425
1423
|
return;
|
|
1426
1424
|
}
|
|
1427
1425
|
((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 =
|
|
1429
|
-
_ &&
|
|
1426
|
+
let _ = e.config.transport.logs === !1 || (o = mn(e)) == null ? void 0 : o.body;
|
|
1427
|
+
_ && sn({
|
|
1430
1428
|
bodyConfig: _,
|
|
1431
1429
|
domainContext: r,
|
|
1432
1430
|
event: f,
|
|
1433
1431
|
fetchRequest: a,
|
|
1432
|
+
occurredAt: i.startedAt,
|
|
1434
1433
|
runtimeContext: e,
|
|
1435
1434
|
span: t
|
|
1436
1435
|
});
|
|
1437
|
-
},
|
|
1436
|
+
}, En = (e) => {
|
|
1438
1437
|
let t = [], n = /* @__PURE__ */ new Set();
|
|
1439
1438
|
return {
|
|
1440
1439
|
name: "request",
|
|
@@ -1445,26 +1444,27 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1445
1444
|
let r = window.fetch, i = /* @__PURE__ */ function() {
|
|
1446
1445
|
var t = k(function* (t, i) {
|
|
1447
1446
|
var a;
|
|
1448
|
-
let o =
|
|
1449
|
-
if (Me(e.config, o)) return r.call(this, t, i);
|
|
1447
|
+
let o = gn(t);
|
|
1448
|
+
if (!e.isSampled() || Me(e.config, o)) return r.call(this, t, i);
|
|
1450
1449
|
let s = {
|
|
1451
|
-
method:
|
|
1450
|
+
method: _n(t, i),
|
|
1451
|
+
startedAt: Date.now(),
|
|
1452
1452
|
url: o
|
|
1453
|
-
}, c =
|
|
1454
|
-
m || (m = !0, n.delete(g), t && c.setAttributes(e.applyRedact(
|
|
1453
|
+
}, c = wn(e, "fetch", s), l = Cn(e, o), u = Sn(e, o), d = vn(t, i), f = e.config.transport.logs !== !1 && (a = mn(e)) != null && a.body ? nn(d) : void 0, p = Ne(e.config, o) ? yn(t, i, c) : i, m = !1, h = (t) => {
|
|
1454
|
+
m || (m = !0, n.delete(g), t && c.setAttributes(e.applyRedact(fn(t))), c.end());
|
|
1455
1455
|
}, g = () => {
|
|
1456
1456
|
l.cancel(), h();
|
|
1457
1457
|
};
|
|
1458
1458
|
n.add(g);
|
|
1459
1459
|
try {
|
|
1460
1460
|
let n = yield r.call(this, t, p);
|
|
1461
|
-
return
|
|
1461
|
+
return Tn(e, c, "fetch", {
|
|
1462
1462
|
request: d,
|
|
1463
1463
|
response: n,
|
|
1464
1464
|
type: "fetch"
|
|
1465
1465
|
}, s, f), l.complete(h), n;
|
|
1466
1466
|
} catch (t) {
|
|
1467
|
-
throw
|
|
1467
|
+
throw Tn(e, c, "fetch", {
|
|
1468
1468
|
error: t,
|
|
1469
1469
|
request: d,
|
|
1470
1470
|
type: "fetch"
|
|
@@ -1490,20 +1490,21 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1490
1490
|
}, s = function(t) {
|
|
1491
1491
|
var i;
|
|
1492
1492
|
let o = (i = r.get(this)) == null ? {} : i;
|
|
1493
|
-
if (!o.url || Me(e.config, o.url)) return a.call(this, t);
|
|
1494
|
-
|
|
1495
|
-
|
|
1493
|
+
if (!e.isSampled() || !o.url || Me(e.config, o.url)) return a.call(this, t);
|
|
1494
|
+
o.startedAt = Date.now();
|
|
1495
|
+
let s = wn(e, "xhr", o), c = Cn(e, o.url), l = Sn(e, o.url);
|
|
1496
|
+
Ne(e.config, o.url) && bn(this, s);
|
|
1496
1497
|
let u = !1, d = () => {
|
|
1497
1498
|
c.cancel(), !u && (u = !0, n.delete(d), l(), s.end());
|
|
1498
1499
|
};
|
|
1499
1500
|
n.add(d);
|
|
1500
1501
|
let f = () => {
|
|
1501
|
-
u || (
|
|
1502
|
+
u || (Tn(e, s, "xhr", {
|
|
1502
1503
|
requestBody: t,
|
|
1503
1504
|
type: "xhr",
|
|
1504
1505
|
xhr: this
|
|
1505
1506
|
}, o), l(), c.complete((t) => {
|
|
1506
|
-
u || (u = !0, n.delete(d), t && s.setAttributes(e.applyRedact(
|
|
1507
|
+
u || (u = !0, n.delete(d), t && s.setAttributes(e.applyRedact(fn(t))), s.end());
|
|
1507
1508
|
}));
|
|
1508
1509
|
};
|
|
1509
1510
|
this.addEventListener("loadend", f, { once: !0 });
|
|
@@ -1525,11 +1526,11 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1525
1526
|
for (; t.length;) (e = t.pop()) == null || e();
|
|
1526
1527
|
}
|
|
1527
1528
|
};
|
|
1528
|
-
},
|
|
1529
|
+
}, U = (e) => {
|
|
1529
1530
|
let t = 5381;
|
|
1530
1531
|
for (let n = 0; n < e.length; n++) t = t * 33 ^ e.charCodeAt(n);
|
|
1531
1532
|
return (t >>> 0).toString(36);
|
|
1532
|
-
},
|
|
1533
|
+
}, Dn = (e, t) => {
|
|
1533
1534
|
let n = /* @__PURE__ */ new Map(), r = 0, i = (t) => {
|
|
1534
1535
|
if (!(t - r < e)) {
|
|
1535
1536
|
r = t;
|
|
@@ -1551,48 +1552,53 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1551
1552
|
count: o.count
|
|
1552
1553
|
});
|
|
1553
1554
|
} };
|
|
1554
|
-
},
|
|
1555
|
-
if (t) return
|
|
1556
|
-
},
|
|
1555
|
+
}, On = 6e4, kn = 5, An = /^https?:|^\/\//i, jn = (e, t) => {
|
|
1556
|
+
if (t) return An.test(t) ? e(t) : t;
|
|
1557
|
+
}, Mn = () => {
|
|
1557
1558
|
let e;
|
|
1558
1559
|
return {
|
|
1559
1560
|
name: "csp-violation",
|
|
1560
1561
|
init(t) {
|
|
1561
1562
|
if (typeof window > "u" || typeof document > "u") return;
|
|
1562
|
-
let n =
|
|
1563
|
-
let
|
|
1564
|
-
if (!i.
|
|
1565
|
-
|
|
1566
|
-
|
|
1563
|
+
let n = Dn(On, kn), r = t.meter.createCounter("browser.csp_violation.count", { description: "Total number of CSP violations before span throttling" }), i = (e) => {
|
|
1564
|
+
let i = P(t, "metrics"), a = P(t, "traces");
|
|
1565
|
+
if (!i && !a || (i && r.add(1, t.applyRedact(O(O(O({}, t.config.hooks.getMetricAttributes()), R(t.getRuntimeAttributes())), {}, {
|
|
1566
|
+
"csp.disposition": e.disposition,
|
|
1567
|
+
"csp.effective_directive": e.effectiveDirective
|
|
1568
|
+
}))), !a)) return;
|
|
1569
|
+
let o = U(`${e.violatedDirective}|${e.blockedURI}|${e.sourceFile}|${e.lineNumber}`), s = n.allow(o);
|
|
1570
|
+
if (!s.allowed) return;
|
|
1571
|
+
let c = jn(t.config.hooks.redactUrl, e.blockedURI), l = e.sourceFile ? t.config.hooks.redactUrl(e.sourceFile) : void 0, u = s.count === 1;
|
|
1572
|
+
t.startSpan("csp.violation", O(O(O({}, t.config.hooks.getPageAttributes()), L({
|
|
1567
1573
|
errorType: "csp",
|
|
1568
1574
|
eventLabel: "CSP 错误",
|
|
1569
|
-
result:
|
|
1575
|
+
result: F.error,
|
|
1570
1576
|
spanSubtype: "csp",
|
|
1571
|
-
spanType:
|
|
1572
|
-
targetLabel:
|
|
1577
|
+
spanType: I.error,
|
|
1578
|
+
targetLabel: c == null ? e.effectiveDirective : c,
|
|
1573
1579
|
targetValue: e.statusCode
|
|
1574
1580
|
})), {}, {
|
|
1575
|
-
"csp.blocked_uri":
|
|
1581
|
+
"csp.blocked_uri": c,
|
|
1576
1582
|
"csp.violated_directive": e.violatedDirective,
|
|
1577
1583
|
"csp.effective_directive": e.effectiveDirective,
|
|
1578
1584
|
"csp.disposition": e.disposition,
|
|
1579
|
-
"csp.source_file":
|
|
1585
|
+
"csp.source_file": l,
|
|
1580
1586
|
"csp.line_number": e.lineNumber,
|
|
1581
1587
|
"csp.column_number": e.columnNumber,
|
|
1582
1588
|
"csp.status_code": e.statusCode,
|
|
1583
|
-
"csp.fingerprint":
|
|
1584
|
-
"csp.
|
|
1585
|
-
[T.exceptionFingerprint]:
|
|
1589
|
+
"csp.fingerprint": o,
|
|
1590
|
+
"csp.window_occurrence_index": s.count,
|
|
1591
|
+
[T.exceptionFingerprint]: o,
|
|
1586
1592
|
"error.source": "csp"
|
|
1587
|
-
},
|
|
1593
|
+
}, u ? { "csp.original_policy": e.originalPolicy } : {})).end();
|
|
1588
1594
|
};
|
|
1589
|
-
document.addEventListener("securitypolicyviolation",
|
|
1595
|
+
document.addEventListener("securitypolicyviolation", i), e = () => document.removeEventListener("securitypolicyviolation", i);
|
|
1590
1596
|
},
|
|
1591
1597
|
shutdown() {
|
|
1592
1598
|
e == null || e(), e = void 0;
|
|
1593
1599
|
}
|
|
1594
1600
|
};
|
|
1595
|
-
},
|
|
1601
|
+
}, Nn = "BK_RUM_DEVICE_ID", Pn = 250, Fn = () => navigator.connection, In = () => navigator.userAgentData, Ln = (e) => {
|
|
1596
1602
|
for (let [t, n] of [
|
|
1597
1603
|
["Edge", /Edg\/([\d.]+)/],
|
|
1598
1604
|
["Chrome", /Chrome\/([\d.]+)/],
|
|
@@ -1609,10 +1615,10 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1609
1615
|
name: "Other",
|
|
1610
1616
|
version: void 0
|
|
1611
1617
|
};
|
|
1612
|
-
},
|
|
1618
|
+
}, Rn = (e, t) => {
|
|
1613
1619
|
let n = `${t == null ? "" : t} ${e}`;
|
|
1614
1620
|
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";
|
|
1615
|
-
},
|
|
1621
|
+
}, zn = (e) => {
|
|
1616
1622
|
let t = null;
|
|
1617
1623
|
try {
|
|
1618
1624
|
t = window.localStorage.getItem(e);
|
|
@@ -1623,7 +1629,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1623
1629
|
window.localStorage.setItem(e, n);
|
|
1624
1630
|
} catch (e) {}
|
|
1625
1631
|
return n;
|
|
1626
|
-
},
|
|
1632
|
+
}, Bn = () => {
|
|
1627
1633
|
var e, t;
|
|
1628
1634
|
return typeof window > "u" ? {} : {
|
|
1629
1635
|
"browser.viewport.width": window.innerWidth,
|
|
@@ -1631,8 +1637,8 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1631
1637
|
"browser.screen.width": (e = window.screen) == null ? void 0 : e.width,
|
|
1632
1638
|
"browser.screen.height": (t = window.screen) == null ? void 0 : t.height
|
|
1633
1639
|
};
|
|
1634
|
-
},
|
|
1635
|
-
let e =
|
|
1640
|
+
}, Vn = () => {
|
|
1641
|
+
let e = Fn();
|
|
1636
1642
|
return e ? {
|
|
1637
1643
|
"network.effective_type": e.effectiveType,
|
|
1638
1644
|
"network.connection_type": e.type,
|
|
@@ -1640,9 +1646,9 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1640
1646
|
"network.rtt": e.rtt,
|
|
1641
1647
|
"network.save_data": e.saveData
|
|
1642
1648
|
} : {};
|
|
1643
|
-
},
|
|
1649
|
+
}, Hn = () => {
|
|
1644
1650
|
if (typeof navigator > "u") return {};
|
|
1645
|
-
let e =
|
|
1651
|
+
let e = In(), t = navigator.userAgent, n = Ln(t), r = Rn(t, e == null ? void 0 : e.platform), i = e != null && e.mobile || /mobi|android|iphone|ipad|ipod/i.test(t) ? "mobile" : "desktop";
|
|
1646
1652
|
return {
|
|
1647
1653
|
"device.memory": navigator.deviceMemory,
|
|
1648
1654
|
"device.cpu_cores": navigator.hardwareConcurrency,
|
|
@@ -1653,29 +1659,29 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1653
1659
|
[T.deviceType]: i,
|
|
1654
1660
|
[T.osName]: r
|
|
1655
1661
|
};
|
|
1656
|
-
},
|
|
1662
|
+
}, Un = (e, t) => {
|
|
1657
1663
|
let n;
|
|
1658
1664
|
return () => {
|
|
1659
1665
|
n !== void 0 && window.clearTimeout(n), n = window.setTimeout(() => {
|
|
1660
1666
|
n = void 0, e();
|
|
1661
1667
|
}, t);
|
|
1662
1668
|
};
|
|
1663
|
-
},
|
|
1669
|
+
}, Wn = (e = {}) => {
|
|
1664
1670
|
let t = [];
|
|
1665
1671
|
return {
|
|
1666
1672
|
name: "device",
|
|
1667
1673
|
init(n) {
|
|
1668
1674
|
var r;
|
|
1669
|
-
let i = (r = e.storageKey) == null ? `${
|
|
1670
|
-
if (n.setRuntimeAttributes(O(O(O({ "device.id": a },
|
|
1671
|
-
let o =
|
|
1672
|
-
n.setRuntimeAttributes(
|
|
1673
|
-
},
|
|
1675
|
+
let i = (r = e.storageKey) == null ? `${Nn}_${U(n.config.application.name)}` : r, a = typeof window > "u" || e.persistentId !== !0 ? N("device") : zn(i);
|
|
1676
|
+
if (n.setRuntimeAttributes(O(O(O({ "device.id": a }, Hn()), Bn()), Vn())), typeof window > "u") return;
|
|
1677
|
+
let o = Un(() => {
|
|
1678
|
+
n.setRuntimeAttributes(Bn());
|
|
1679
|
+
}, Pn);
|
|
1674
1680
|
window.addEventListener("resize", o), window.addEventListener("orientationchange", o), t.push(() => window.removeEventListener("resize", o), () => window.removeEventListener("orientationchange", o));
|
|
1675
|
-
let s =
|
|
1681
|
+
let s = Fn();
|
|
1676
1682
|
if (s && typeof s.addEventListener == "function") {
|
|
1677
1683
|
let e = () => {
|
|
1678
|
-
n.setRuntimeAttributes(
|
|
1684
|
+
n.setRuntimeAttributes(Vn());
|
|
1679
1685
|
};
|
|
1680
1686
|
s.addEventListener("change", e), t.push(() => {
|
|
1681
1687
|
var t;
|
|
@@ -1690,7 +1696,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1690
1696
|
}
|
|
1691
1697
|
}
|
|
1692
1698
|
};
|
|
1693
|
-
},
|
|
1699
|
+
}, Gn = 6e4, Kn = 5, qn = (e, t) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : t, Jn = (e) => {
|
|
1694
1700
|
if (e instanceof Error) return e.message;
|
|
1695
1701
|
if (typeof e == "string") return e;
|
|
1696
1702
|
try {
|
|
@@ -1698,55 +1704,60 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1698
1704
|
} catch (t) {
|
|
1699
1705
|
return String(e);
|
|
1700
1706
|
}
|
|
1701
|
-
},
|
|
1707
|
+
}, Yn = (e) => {
|
|
1702
1708
|
var t;
|
|
1703
1709
|
return e instanceof Error ? (t = e.stack) == null ? "" : t : "";
|
|
1704
|
-
},
|
|
1710
|
+
}, Xn = (e) => e.slice(0, 80), Zn = (e) => {
|
|
1705
1711
|
var t, n;
|
|
1706
1712
|
return (t = (n = e.split("\n").find((e) => e.trim().startsWith("at "))) == null ? void 0 : n.trim()) == null ? "" : t;
|
|
1707
|
-
},
|
|
1708
|
-
let
|
|
1709
|
-
if (!
|
|
1713
|
+
}, Qn = (e) => e === "unhandledrejection" ? "promise" : e === "resource" ? "resource_load" : "js", $n = ({ context: e, counter: t, error: n, exceptionType: r, extra: i = {}, source: a, spanName: o, throttle: s }) => {
|
|
1714
|
+
let l = P(e, "metrics"), u = P(e, "traces");
|
|
1715
|
+
if (!l && !u) return;
|
|
1716
|
+
let d = Jn(n), f = Yn(n), p = U(`${a}|${d}|${f.slice(0, 256)}`);
|
|
1717
|
+
if (l && t.add(1, e.applyRedact(O(O(O({}, e.config.hooks.getMetricAttributes()), R(e.getRuntimeAttributes())), {}, {
|
|
1718
|
+
"error.source": a,
|
|
1719
|
+
"error.subtype": Qn(a)
|
|
1720
|
+
}))), !u) return;
|
|
1710
1721
|
e.notifyActivity({
|
|
1711
1722
|
time: Date.now(),
|
|
1712
1723
|
type: "error"
|
|
1713
1724
|
});
|
|
1714
|
-
let
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1725
|
+
let m = s.allow(p);
|
|
1726
|
+
if (!m.allowed) return;
|
|
1727
|
+
let h = n instanceof Error ? n : {
|
|
1728
|
+
message: d,
|
|
1729
|
+
name: r == null ? a : r
|
|
1730
|
+
}, g = O(O(O(O({}, e.config.hooks.getPageAttributes()), e.config.hooks.getErrorAttributes()), L({
|
|
1731
|
+
errorType: Qn(a),
|
|
1719
1732
|
eventLabel: "错误",
|
|
1720
|
-
result:
|
|
1721
|
-
spanSubtype:
|
|
1722
|
-
spanType:
|
|
1723
|
-
targetLabel:
|
|
1733
|
+
result: F.error,
|
|
1734
|
+
spanSubtype: Qn(a),
|
|
1735
|
+
spanType: I.error,
|
|
1736
|
+
targetLabel: n instanceof Error ? n.name : r == null ? a : r
|
|
1724
1737
|
})), {}, {
|
|
1725
|
-
|
|
1726
|
-
[T.
|
|
1727
|
-
|
|
1728
|
-
[T.exceptionStackTopFrame]: qn(l),
|
|
1729
|
-
"exception.type": t instanceof Error ? t.name : n == null ? i : n,
|
|
1730
|
-
[T.exceptionFingerprint]: u,
|
|
1738
|
+
[T.exceptionMessageShort]: Xn(d),
|
|
1739
|
+
[T.exceptionStackTopFrame]: Zn(f),
|
|
1740
|
+
[T.exceptionFingerprint]: p,
|
|
1731
1741
|
"error.handled": !1,
|
|
1732
|
-
"error.source":
|
|
1733
|
-
"error.
|
|
1734
|
-
},
|
|
1735
|
-
|
|
1742
|
+
"error.source": a,
|
|
1743
|
+
"error.window_occurrence_index": m.count
|
|
1744
|
+
}, i), _ = e.startSpan(o, g);
|
|
1745
|
+
_.recordException(h), _.setStatus({
|
|
1736
1746
|
code: c.ERROR,
|
|
1737
|
-
message:
|
|
1738
|
-
}),
|
|
1739
|
-
},
|
|
1740
|
-
let t = [], n =
|
|
1747
|
+
message: d
|
|
1748
|
+
}), _.end();
|
|
1749
|
+
}, er = (e = {}) => {
|
|
1750
|
+
let t = [], n = qn(e.windowMs, Gn), r = qn(e.maxPerWindow, Kn);
|
|
1741
1751
|
return {
|
|
1742
1752
|
name: "error",
|
|
1743
1753
|
init(e) {
|
|
1744
1754
|
if (typeof window > "u") return;
|
|
1745
|
-
let i =
|
|
1755
|
+
let i = Dn(n, r), a = e.meter.createCounter("browser.error.count", { description: "Total number of browser errors before span throttling" }), o = (t) => {
|
|
1746
1756
|
var n;
|
|
1747
1757
|
let r = !t.error && !t.filename && t.message === "Script error.";
|
|
1748
|
-
|
|
1758
|
+
$n({
|
|
1749
1759
|
context: e,
|
|
1760
|
+
counter: a,
|
|
1750
1761
|
throttle: i,
|
|
1751
1762
|
spanName: "browser.error",
|
|
1752
1763
|
source: "window.error",
|
|
@@ -1757,34 +1768,36 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1757
1768
|
"code.column": t.colno
|
|
1758
1769
|
}, r ? { "error.cross_origin": !0 } : {})
|
|
1759
1770
|
});
|
|
1760
|
-
},
|
|
1761
|
-
|
|
1771
|
+
}, s = (t) => {
|
|
1772
|
+
$n({
|
|
1762
1773
|
context: e,
|
|
1774
|
+
counter: a,
|
|
1763
1775
|
throttle: i,
|
|
1764
1776
|
spanName: "browser.unhandledrejection",
|
|
1765
1777
|
source: "unhandledrejection",
|
|
1766
1778
|
error: t.reason,
|
|
1767
1779
|
exceptionType: t.reason instanceof Error ? t.reason.name : "UnhandledRejection"
|
|
1768
1780
|
});
|
|
1769
|
-
},
|
|
1781
|
+
}, c = (t) => {
|
|
1770
1782
|
if (t instanceof ErrorEvent) return;
|
|
1771
1783
|
let n = t.target;
|
|
1772
1784
|
if (!(n instanceof Element)) return;
|
|
1773
|
-
let r = n,
|
|
1774
|
-
|
|
1785
|
+
let r = n, o = r.src || r.href || n.currentSrc || "";
|
|
1786
|
+
$n({
|
|
1775
1787
|
context: e,
|
|
1788
|
+
counter: a,
|
|
1776
1789
|
throttle: i,
|
|
1777
1790
|
spanName: "browser.resource_error",
|
|
1778
1791
|
source: "resource",
|
|
1779
|
-
error: /* @__PURE__ */ Error(`Resource load failed: ${n.tagName.toLowerCase()} ${
|
|
1792
|
+
error: /* @__PURE__ */ Error(`Resource load failed: ${n.tagName.toLowerCase()} ${o}`),
|
|
1780
1793
|
exceptionType: "ResourceError",
|
|
1781
1794
|
extra: {
|
|
1782
|
-
"url.full": e.config.hooks.redactUrl(
|
|
1795
|
+
"url.full": e.config.hooks.redactUrl(o),
|
|
1783
1796
|
"html.tag": n.tagName
|
|
1784
1797
|
}
|
|
1785
1798
|
});
|
|
1786
1799
|
};
|
|
1787
|
-
window.addEventListener("error",
|
|
1800
|
+
window.addEventListener("error", o), window.addEventListener("unhandledrejection", s), window.addEventListener("error", c, !0), t.push(() => window.removeEventListener("error", o), () => window.removeEventListener("unhandledrejection", s), () => window.removeEventListener("error", c, !0));
|
|
1788
1801
|
},
|
|
1789
1802
|
shutdown() {
|
|
1790
1803
|
for (; t.length;) {
|
|
@@ -1793,11 +1806,37 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1793
1806
|
}
|
|
1794
1807
|
}
|
|
1795
1808
|
};
|
|
1796
|
-
},
|
|
1809
|
+
}, tr = [
|
|
1810
|
+
0,
|
|
1811
|
+
.01,
|
|
1812
|
+
.025,
|
|
1813
|
+
.05,
|
|
1814
|
+
.075,
|
|
1815
|
+
.1,
|
|
1816
|
+
.15,
|
|
1817
|
+
.25,
|
|
1818
|
+
.5,
|
|
1819
|
+
1
|
|
1820
|
+
], W = [
|
|
1821
|
+
0,
|
|
1822
|
+
50,
|
|
1823
|
+
100,
|
|
1824
|
+
200,
|
|
1825
|
+
300,
|
|
1826
|
+
500,
|
|
1827
|
+
800,
|
|
1828
|
+
1e3,
|
|
1829
|
+
1500,
|
|
1830
|
+
2e3,
|
|
1831
|
+
2500,
|
|
1832
|
+
4e3,
|
|
1833
|
+
5e3,
|
|
1834
|
+
1e4
|
|
1835
|
+
], nr = 50, rr = 100, ir = 700, ar = (e, t) => typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : t, or = (e) => Number.isFinite(e) ? e : void 0, sr = (e, t) => {
|
|
1797
1836
|
var n;
|
|
1798
1837
|
let r = (n = e.attribution) == null ? void 0 : n[0];
|
|
1799
1838
|
return r != null && r.containerSrc ? t(r.containerSrc) : (r == null ? void 0 : r.containerName) || (r == null ? void 0 : r.name) || e.name || "unknown";
|
|
1800
|
-
},
|
|
1839
|
+
}, cr = (e, t) => ({
|
|
1801
1840
|
"long_task.script.duration": e.duration,
|
|
1802
1841
|
"long_task.script.execution_start": e.executionStart,
|
|
1803
1842
|
"long_task.script.forced_style_and_layout_duration": e.forcedStyleAndLayoutDuration,
|
|
@@ -1809,8 +1848,8 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1809
1848
|
"long_task.script.source_url": e.sourceURL ? t(e.sourceURL) : "",
|
|
1810
1849
|
"long_task.script.start_time": e.startTime,
|
|
1811
1850
|
"long_task.script.window_attribution": e.windowAttribution
|
|
1812
|
-
}),
|
|
1813
|
-
let t =
|
|
1851
|
+
}), lr = (e = {}) => {
|
|
1852
|
+
let t = ar(e.threshold, nr), n = Math.max(t, ar(e.warningThreshold, rr)), r, i, a = [];
|
|
1814
1853
|
return {
|
|
1815
1854
|
name: "long-task",
|
|
1816
1855
|
init(e) {
|
|
@@ -1820,45 +1859,54 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1820
1859
|
if (!c) return;
|
|
1821
1860
|
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
1861
|
description: "Duration of long tasks and long animation frames",
|
|
1823
|
-
unit: "ms"
|
|
1862
|
+
unit: "ms",
|
|
1863
|
+
advice: { explicitBucketBoundaries: W }
|
|
1824
1864
|
}), d = e.meter.createHistogram("browser.long_task.blocking_duration", {
|
|
1825
1865
|
description: "Blocking duration of long animation frames",
|
|
1826
|
-
unit: "ms"
|
|
1866
|
+
unit: "ms",
|
|
1867
|
+
advice: { explicitBucketBoundaries: W }
|
|
1827
1868
|
}), f = (r) => {
|
|
1828
|
-
var i
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1869
|
+
var i;
|
|
1870
|
+
let a = P(e, "metrics"), o = P(e, "traces");
|
|
1871
|
+
if (!a && !o || !Number.isFinite(r.duration) || r.duration < t) return;
|
|
1872
|
+
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 ? F.warning : F.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 : sr(r, e.config.hooks.redactUrl), x = y || (p == null ? void 0 : p.sourceFunctionName) || b || "unknown";
|
|
1873
|
+
if (o) {
|
|
1874
|
+
var S, C;
|
|
1875
|
+
let t = e.startSpan("browser.long_task", O(O(O(O(O(O(O(O({}, e.config.hooks.getPageAttributes()), L({
|
|
1876
|
+
duration: r.duration,
|
|
1877
|
+
errorType: _ === F.warning ? "main_thread_blocked" : "none",
|
|
1878
|
+
eventLabel: s ? "长动画帧" : "长任务",
|
|
1879
|
+
result: _,
|
|
1880
|
+
spanSubtype: v,
|
|
1881
|
+
spanType: I.longtask,
|
|
1882
|
+
targetLabel: x,
|
|
1883
|
+
targetValue: (S = c == null ? void 0 : c.blockingDuration) == null ? r.duration : S
|
|
1884
|
+
})), {}, {
|
|
1885
|
+
[T.longTaskBlockingDuration]: (C = c == null ? void 0 : c.blockingDuration) == null ? r.duration : C,
|
|
1886
|
+
[T.longTaskDuration]: r.duration,
|
|
1887
|
+
[T.longTaskEntryType]: v,
|
|
1888
|
+
[T.longTaskId]: m,
|
|
1889
|
+
[T.longTaskIsFrozenFrame]: r.duration >= ir,
|
|
1890
|
+
[T.longTaskScriptCount]: f.length
|
|
1891
|
+
}, b ? { [T.longTaskCulprit]: b } : {}), p ? {
|
|
1892
|
+
[T.longTaskCulprit]: x,
|
|
1893
|
+
"long_task.culprit.duration": p.duration,
|
|
1894
|
+
"long_task.culprit.forced_style_and_layout_duration": p.forcedStyleAndLayoutDuration,
|
|
1895
|
+
"long_task.culprit.function_name": p.sourceFunctionName,
|
|
1896
|
+
"long_task.culprit.invoker_type": p.invokerType
|
|
1897
|
+
} : {}), or(c == null ? void 0 : c.firstUIEventTimestamp) === void 0 ? {} : { "long_task.first_ui_event_timestamp": c.firstUIEventTimestamp }), or(c == null ? void 0 : c.renderStart) === void 0 ? {} : { "long_task.render_start": c.renderStart }), or(c == null ? void 0 : c.styleAndLayoutStart) === void 0 ? {} : { "long_task.style_and_layout_start": c.styleAndLayoutStart }), c ? { [T.longTaskStartTime]: c.startTime } : {}), { startTime: h });
|
|
1898
|
+
f.forEach((n) => {
|
|
1899
|
+
t.addEvent("long_task.script", e.applyRedact(cr(n, e.config.hooks.redactUrl)), performance.timeOrigin + n.startTime);
|
|
1900
|
+
}), t.end(g), e.notifyActivity({
|
|
1901
|
+
endTime: g,
|
|
1902
|
+
startTime: h,
|
|
1903
|
+
type: "long_task"
|
|
1904
|
+
});
|
|
1905
|
+
}
|
|
1906
|
+
if (a) {
|
|
1907
|
+
let t = e.applyRedact(O(O(O({}, e.config.hooks.getMetricAttributes()), R(e.getRuntimeAttributesAt(h))), {}, { [T.longTaskEntryType]: v }));
|
|
1908
|
+
l.add(1, t), u.record(r.duration, t), c && d.record(c.blockingDuration, t);
|
|
1909
|
+
}
|
|
1862
1910
|
}, p = (e) => e.forEach((e) => f(e));
|
|
1863
1911
|
try {
|
|
1864
1912
|
let e = !0;
|
|
@@ -1880,7 +1928,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1880
1928
|
r == null || r.disconnect(), r = void 0, clearTimeout(i), i = void 0, a = [];
|
|
1881
1929
|
}
|
|
1882
1930
|
};
|
|
1883
|
-
}, G = /* @__PURE__ */ new Set(), K = "", q, J,
|
|
1931
|
+
}, G = /* @__PURE__ */ new Set(), K = "", q, J, ur = !1, Y = () => typeof location > "u" ? "" : location.href, dr = (e, t) => {
|
|
1884
1932
|
let n = Y();
|
|
1885
1933
|
K = n;
|
|
1886
1934
|
let r = {
|
|
@@ -1889,31 +1937,31 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1889
1937
|
toUrl: n
|
|
1890
1938
|
};
|
|
1891
1939
|
for (let e of Array.from(G)) e(r);
|
|
1892
|
-
},
|
|
1893
|
-
|
|
1894
|
-
},
|
|
1895
|
-
|
|
1896
|
-
},
|
|
1897
|
-
|
|
1940
|
+
}, fr = () => {
|
|
1941
|
+
dr("popstate", K || Y());
|
|
1942
|
+
}, pr = () => {
|
|
1943
|
+
dr("hashchange", K || Y());
|
|
1944
|
+
}, mr = () => {
|
|
1945
|
+
ur || typeof window > "u" || typeof history > "u" || (ur = !0, K = Y(), q = history.pushState, J = history.replaceState, history.pushState = function(e, t, n) {
|
|
1898
1946
|
let r = K || Y(), i = q == null ? void 0 : q.apply(this, [
|
|
1899
1947
|
e,
|
|
1900
1948
|
t,
|
|
1901
1949
|
n
|
|
1902
1950
|
]);
|
|
1903
|
-
return
|
|
1951
|
+
return dr("pushState", r), i;
|
|
1904
1952
|
}, history.replaceState = function(e, t, n) {
|
|
1905
1953
|
let r = K || Y(), i = J == null ? void 0 : J.apply(this, [
|
|
1906
1954
|
e,
|
|
1907
1955
|
t,
|
|
1908
1956
|
n
|
|
1909
1957
|
]);
|
|
1910
|
-
return
|
|
1911
|
-
}, window.addEventListener("popstate",
|
|
1912
|
-
},
|
|
1913
|
-
!
|
|
1914
|
-
},
|
|
1915
|
-
G.delete(e), G.size === 0 &&
|
|
1916
|
-
}),
|
|
1958
|
+
return dr("replaceState", r), i;
|
|
1959
|
+
}, window.addEventListener("popstate", fr), window.addEventListener("hashchange", pr));
|
|
1960
|
+
}, hr = () => {
|
|
1961
|
+
!ur || typeof window > "u" || typeof history > "u" || (q && (history.pushState = q), J && (history.replaceState = J), window.removeEventListener("popstate", fr), window.removeEventListener("hashchange", pr), q = void 0, J = void 0, ur = !1, K = "");
|
|
1962
|
+
}, gr = (e) => typeof window > "u" || typeof history > "u" ? () => {} : (mr(), G.add(e), () => {
|
|
1963
|
+
G.delete(e), G.size === 0 && hr();
|
|
1964
|
+
}), _r = ["span", "stopLoadingTime"], vr = new Set([...Object.values(T), A]), yr = () => typeof location > "u" ? "" : location.href, br = () => {
|
|
1917
1965
|
if (typeof performance > "u") return {};
|
|
1918
1966
|
let e = performance.getEntriesByType("navigation")[0];
|
|
1919
1967
|
if (!e) return {};
|
|
@@ -1921,10 +1969,10 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1921
1969
|
Number.isFinite(n) && n > 0 && (t[e] = n);
|
|
1922
1970
|
};
|
|
1923
1971
|
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
|
-
},
|
|
1972
|
+
}, xr = (e) => {
|
|
1925
1973
|
let t = e.indexOf("?");
|
|
1926
1974
|
return t < 0 ? e : e.slice(0, t);
|
|
1927
|
-
},
|
|
1975
|
+
}, Sr = (e) => {
|
|
1928
1976
|
let t = e.slice(1);
|
|
1929
1977
|
if (!t || typeof document > "u" || typeof document.getElementById != "function") return !1;
|
|
1930
1978
|
try {
|
|
@@ -1932,14 +1980,14 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1932
1980
|
} catch (e) {
|
|
1933
1981
|
return !!document.getElementById(t);
|
|
1934
1982
|
}
|
|
1935
|
-
},
|
|
1983
|
+
}, Cr = (e, t) => {
|
|
1936
1984
|
try {
|
|
1937
1985
|
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 || !
|
|
1986
|
+
return r.pathname !== i.pathname || !Sr(i.hash) && xr(r.hash) !== xr(i.hash);
|
|
1939
1987
|
} catch (n) {
|
|
1940
1988
|
return e !== t;
|
|
1941
1989
|
}
|
|
1942
|
-
},
|
|
1990
|
+
}, wr = () => {
|
|
1943
1991
|
let e = [];
|
|
1944
1992
|
return {
|
|
1945
1993
|
name: "page-view",
|
|
@@ -1947,9 +1995,10 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1947
1995
|
if (typeof window > "u") return;
|
|
1948
1996
|
let n, r, i = t.config.view.loadingTime ? t.meter.createHistogram("browser.view.loading_time", {
|
|
1949
1997
|
description: "Time from view start until network and DOM activity become idle",
|
|
1950
|
-
unit: "ms"
|
|
1998
|
+
unit: "ms",
|
|
1999
|
+
advice: { explicitBucketBoundaries: W }
|
|
1951
2000
|
}) : void 0, a = (e = Date.now()) => t.setView({}, e), o = (e, n, r = Date.now(), i) => {
|
|
1952
|
-
e.documentVersion += 1, t.emitLog({
|
|
2001
|
+
P(t, "logs") && (e.documentVersion += 1, t.emitLog({
|
|
1953
2002
|
attributes: O(O(O(O(O({}, t.config.hooks.getPageAttributes()), e.attributes), e.snapshotAttributes), {}, {
|
|
1954
2003
|
"event.type": "view",
|
|
1955
2004
|
"view.document_version": e.documentVersion,
|
|
@@ -1965,7 +2014,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1965
2014
|
severityNumber: w.INFO,
|
|
1966
2015
|
severityText: "INFO",
|
|
1967
2016
|
timestamp: r
|
|
1968
|
-
});
|
|
2017
|
+
}));
|
|
1969
2018
|
}, s = (e, r = !0, s = Date.now()) => {
|
|
1970
2019
|
var c;
|
|
1971
2020
|
if (!n) {
|
|
@@ -1973,12 +2022,12 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
1973
2022
|
return;
|
|
1974
2023
|
}
|
|
1975
2024
|
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()),
|
|
2025
|
+
(c = n.stopLoadingTime) == null || c.call(n), n.loadingTime !== void 0 && P(t, "metrics") && (i == null || i.record(n.loadingTime, t.applyRedact(O(O(O({}, t.config.hooks.getMetricAttributes()), R(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
2026
|
let { span: u, stopLoadingTime: d } = l;
|
|
1978
|
-
return Fe(l,
|
|
2027
|
+
return Fe(l, _r);
|
|
1979
2028
|
}, c = (e, t, r) => {
|
|
1980
2029
|
if (n !== e || !Number.isFinite(t) || t < 0) return;
|
|
1981
|
-
let i = O(O({}, e.loadingType === "initial_load" ?
|
|
2030
|
+
let i = O(O({}, e.loadingType === "initial_load" ? br() : {}), {}, {
|
|
1982
2031
|
[T.viewLoadingTime]: t,
|
|
1983
2032
|
"view.loading_time.source": r
|
|
1984
2033
|
});
|
|
@@ -2003,7 +2052,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2003
2052
|
};
|
|
2004
2053
|
window.addEventListener("load", t, { once: !0 }), s = () => window.removeEventListener("load", t);
|
|
2005
2054
|
}
|
|
2006
|
-
let p =
|
|
2055
|
+
let p = wt(t, e.startedAt, (t) => {
|
|
2007
2056
|
r = !0, t.hadActivity && (i = Math.max(0, t.endTime - e.startedAt)), d();
|
|
2008
2057
|
}), m = () => {
|
|
2009
2058
|
var t;
|
|
@@ -2014,13 +2063,13 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2014
2063
|
}, d();
|
|
2015
2064
|
}, u = (e) => {
|
|
2016
2065
|
let n = t.applyRedact(e == null ? {} : e);
|
|
2017
|
-
return Object.fromEntries(Object.entries(n).filter(([e, t]) => t !== void 0 && !
|
|
2066
|
+
return Object.fromEntries(Object.entries(n).filter(([e, t]) => t !== void 0 && !vr.has(e)));
|
|
2018
2067
|
}, d = (e, r, i, a = ((e) => (e = n == null ? void 0 : n.rawUrl) == null ? "" : e)()) => {
|
|
2019
2068
|
var c, d;
|
|
2020
2069
|
if (!t.isSessionActive()) return;
|
|
2021
|
-
let f = (c = e.url) == null ?
|
|
2070
|
+
let f = (c = e.url) == null ? yr() : c, p = t.config.hooks.getViewPathGroup(f), m = (d = e.name) == null ? p : d, h = u(e.attributes);
|
|
2022
2071
|
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 ?
|
|
2072
|
+
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 ? br() : {};
|
|
2024
2073
|
t.setView({
|
|
2025
2074
|
attributes: h,
|
|
2026
2075
|
id: g,
|
|
@@ -2030,11 +2079,11 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2030
2079
|
url: _,
|
|
2031
2080
|
urlPathGroup: p
|
|
2032
2081
|
}, b);
|
|
2033
|
-
let S = O(O(O(O(O({}, h), t.config.hooks.getPageAttributes()), x),
|
|
2082
|
+
let S = O(O(O(O(O({}, h), t.config.hooks.getPageAttributes()), x), L({
|
|
2034
2083
|
errorType: "none",
|
|
2035
2084
|
eventLabel: y ? "文档加载" : "路由切换",
|
|
2036
2085
|
spanSubtype: y ? "navigate" : r,
|
|
2037
|
-
spanType: y ?
|
|
2086
|
+
spanType: y ? I.document : I.route,
|
|
2038
2087
|
targetLabel: p,
|
|
2039
2088
|
traceScene: y ? "page_load" : "route_change"
|
|
2040
2089
|
})), {}, {
|
|
@@ -2070,7 +2119,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2070
2119
|
(r = n.stopLoadingTime) == null || r.call(n), n.stopLoadingTime = void 0, c(n, Math.max(0, e.time - n.startedAt), "manual");
|
|
2071
2120
|
return;
|
|
2072
2121
|
}
|
|
2073
|
-
n.name = e.name, n.span.setAttribute(T.viewName, e.name), n.snapshotAttributes[T.viewName] = e.name, t.setView({
|
|
2122
|
+
n.name !== e.name && (n.name = e.name, n.span.setAttribute(T.viewName, e.name), n.snapshotAttributes[T.viewName] = e.name, t.setView({
|
|
2074
2123
|
attributes: n.attributes,
|
|
2075
2124
|
id: n.id,
|
|
2076
2125
|
loadingType: n.loadingType,
|
|
@@ -2078,11 +2127,11 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2078
2127
|
startedAt: n.startedAt,
|
|
2079
2128
|
url: n.url,
|
|
2080
2129
|
urlPathGroup: n.urlPathGroup
|
|
2081
|
-
}), o(n, "update");
|
|
2130
|
+
}), o(n, "update"));
|
|
2082
2131
|
}
|
|
2083
2132
|
}), p = () => {};
|
|
2084
|
-
t.config.view.tracking === "auto" && (n || d({}, "load", "initial_load"), p =
|
|
2085
|
-
|
|
2133
|
+
t.config.view.tracking === "auto" && (n || d({}, "load", "initial_load"), p = gr((e) => {
|
|
2134
|
+
Cr(e.fromUrl, e.toUrl) && d({}, e.source, "route_change", e.fromUrl);
|
|
2086
2135
|
}));
|
|
2087
2136
|
let m = (e) => {
|
|
2088
2137
|
e.persisted || s("pagehide");
|
|
@@ -2108,7 +2157,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2108
2157
|
}
|
|
2109
2158
|
}
|
|
2110
2159
|
};
|
|
2111
|
-
},
|
|
2160
|
+
}, Tr = 5e3, Er = (e) => typeof e == "number" && Number.isFinite(e) && e > 0, Dr = (e, t, n, r) => ({
|
|
2112
2161
|
expiresAt: Math.min(t + n, t + r),
|
|
2113
2162
|
id: e,
|
|
2114
2163
|
startedAt: t,
|
|
@@ -2116,19 +2165,19 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2116
2165
|
}), X = (e, t, n) => {
|
|
2117
2166
|
if (t >= e.startedAt + n) return "maxLifetime";
|
|
2118
2167
|
if (t >= e.expiresAt) return "inactivity";
|
|
2119
|
-
},
|
|
2168
|
+
}, Or = (e, t, n, r) => O(O({}, e), {}, { expiresAt: Math.min(t + n, e.startedAt + r) }), kr = (e, t, n) => {
|
|
2120
2169
|
if (!e) return null;
|
|
2121
2170
|
try {
|
|
2122
2171
|
let r = JSON.parse(e);
|
|
2123
|
-
if (r.status === "active" && typeof r.id == "string" && r.id.length > 0 &&
|
|
2172
|
+
if (r.status === "active" && typeof r.id == "string" && r.id.length > 0 && Er(r.startedAt) && r.startedAt <= t + Tr && Er(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") && Er(r.expiredAt) && r.expiredAt <= t + Tr) return r;
|
|
2124
2173
|
} catch (e) {}
|
|
2125
2174
|
return null;
|
|
2126
|
-
},
|
|
2175
|
+
}, Ar = 900 * 1e3, Z = 14400 * 1e3, jr = 1e3, Mr = 6e4, Nr = [
|
|
2127
2176
|
"click",
|
|
2128
2177
|
"keydown",
|
|
2129
2178
|
"scroll",
|
|
2130
2179
|
"touchstart"
|
|
2131
|
-
],
|
|
2180
|
+
], Pr = /* @__PURE__ */ new Map(), Fr = (e) => {
|
|
2132
2181
|
let t = typeof window < "u", n = () => {
|
|
2133
2182
|
var n;
|
|
2134
2183
|
if (t) try {
|
|
@@ -2136,29 +2185,29 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2136
2185
|
} catch (e) {
|
|
2137
2186
|
t = !1;
|
|
2138
2187
|
}
|
|
2139
|
-
return (n =
|
|
2188
|
+
return (n = Pr.get(e)) == null ? null : n;
|
|
2140
2189
|
};
|
|
2141
2190
|
return n(), {
|
|
2142
2191
|
isLocalStorage: () => t,
|
|
2143
2192
|
read: n,
|
|
2144
2193
|
write: (n) => {
|
|
2145
2194
|
let r = JSON.stringify(n);
|
|
2146
|
-
if (
|
|
2195
|
+
if (Pr.set(e, r), t) try {
|
|
2147
2196
|
window.localStorage.setItem(e, r);
|
|
2148
2197
|
} catch (e) {
|
|
2149
2198
|
t = !1;
|
|
2150
2199
|
}
|
|
2151
2200
|
}
|
|
2152
2201
|
};
|
|
2153
|
-
},
|
|
2202
|
+
}, Ir = (e, t) => {
|
|
2154
2203
|
let n = "";
|
|
2155
2204
|
try {
|
|
2156
2205
|
n = new URL(e).host;
|
|
2157
2206
|
} catch (t) {
|
|
2158
2207
|
n = e;
|
|
2159
2208
|
}
|
|
2160
|
-
return `bk_ot_session__${
|
|
2161
|
-
},
|
|
2209
|
+
return `bk_ot_session__${U(`${t}\0${n || "default"}`)}`;
|
|
2210
|
+
}, Lr = (e, t) => {
|
|
2162
2211
|
t.reason && e.emitLog({
|
|
2163
2212
|
severityNumber: w.INFO,
|
|
2164
2213
|
severityText: "INFO",
|
|
@@ -2170,7 +2219,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2170
2219
|
"session.rotate.reason": t.reason
|
|
2171
2220
|
}, t.previousId ? { "session.previous_id": t.previousId } : {})
|
|
2172
2221
|
});
|
|
2173
|
-
},
|
|
2222
|
+
}, Rr = (e = {}) => {
|
|
2174
2223
|
let t = [];
|
|
2175
2224
|
return {
|
|
2176
2225
|
name: "session",
|
|
@@ -2183,7 +2232,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2183
2232
|
});
|
|
2184
2233
|
return;
|
|
2185
2234
|
}
|
|
2186
|
-
let i = (r = e.storageKey) == null ?
|
|
2235
|
+
let i = (r = e.storageKey) == null ? Ir(n.config.transport.endpoint, n.config.application.name) : r, a = Fr(i), o = typeof performance < "u" && Number.isFinite(performance.timeOrigin) ? performance.timeOrigin : Date.now(), s, c, l = (e = Date.now()) => kr(a.read(), e, Z), u = () => {
|
|
2187
2236
|
c !== void 0 && (clearTimeout(c), c = void 0);
|
|
2188
2237
|
}, d = (e, t = Date.now()) => {
|
|
2189
2238
|
let r = s;
|
|
@@ -2241,15 +2290,15 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2241
2290
|
}, h = (e = !1) => {
|
|
2242
2291
|
let t = Date.now(), r = l(t);
|
|
2243
2292
|
if ((r == null ? void 0 : r.status) === "active" && !X(r, t, Z)) {
|
|
2244
|
-
let e =
|
|
2293
|
+
let e = Or(r, t, Ar, Z);
|
|
2245
2294
|
a.write(e), m(e, s ? void 0 : { reason: "shared" });
|
|
2246
2295
|
return;
|
|
2247
2296
|
}
|
|
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 =
|
|
2297
|
+
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 = Dr(N("session"), t, Ar, Z);
|
|
2249
2298
|
a.write(c), m(c, {
|
|
2250
2299
|
previousId: i,
|
|
2251
2300
|
reason: o == null ? "init" : o
|
|
2252
|
-
}),
|
|
2301
|
+
}), Lr(n, {
|
|
2253
2302
|
previousId: i,
|
|
2254
2303
|
reason: o == null ? "init" : o,
|
|
2255
2304
|
record: c
|
|
@@ -2261,31 +2310,31 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2261
2310
|
f();
|
|
2262
2311
|
return;
|
|
2263
2312
|
}
|
|
2264
|
-
let n =
|
|
2313
|
+
let n = Or(t, e, Ar, Z);
|
|
2265
2314
|
a.write(n), m(n);
|
|
2266
2315
|
};
|
|
2267
2316
|
h(!0);
|
|
2268
2317
|
let _ = 0, v = () => {
|
|
2269
2318
|
let e = Date.now();
|
|
2270
|
-
e - _ <
|
|
2319
|
+
e - _ < jr || (_ = e, h());
|
|
2271
2320
|
}, y = {
|
|
2272
2321
|
capture: !0,
|
|
2273
2322
|
passive: !0
|
|
2274
2323
|
};
|
|
2275
|
-
|
|
2276
|
-
|
|
2324
|
+
Nr.forEach((e) => window.addEventListener(e, v, y)), t.push(() => {
|
|
2325
|
+
Nr.forEach((e) => window.removeEventListener(e, v, y));
|
|
2277
2326
|
});
|
|
2278
2327
|
let b = () => {
|
|
2279
2328
|
document.visibilityState === "visible" && g();
|
|
2280
2329
|
};
|
|
2281
2330
|
document.addEventListener("visibilitychange", b);
|
|
2282
|
-
let x = window.setInterval(b,
|
|
2331
|
+
let x = window.setInterval(b, Mr);
|
|
2283
2332
|
t.push(() => {
|
|
2284
2333
|
document.removeEventListener("visibilitychange", b), window.clearInterval(x);
|
|
2285
2334
|
});
|
|
2286
2335
|
let S = (e) => {
|
|
2287
2336
|
if (!a.isLocalStorage() || e.storageArea !== window.localStorage || e.key !== i) return;
|
|
2288
|
-
let t = Date.now(), n =
|
|
2337
|
+
let t = Date.now(), n = kr(e.newValue, t, Z);
|
|
2289
2338
|
if ((n == null ? void 0 : n.status) === "active" && n.id === s && !X(n, t, Z)) {
|
|
2290
2339
|
p(n);
|
|
2291
2340
|
return;
|
|
@@ -2298,58 +2347,58 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2298
2347
|
for (var e; t.length;) (e = t.pop()) == null || e();
|
|
2299
2348
|
}
|
|
2300
2349
|
};
|
|
2301
|
-
},
|
|
2302
|
-
if (typeof performance > "u") return
|
|
2350
|
+
}, zr = "unknown", Br = 10, Vr = 6e4, Hr = 5e3, Ur = 1e3, Wr = (e, t) => !!t && e === t, Gr = (e) => e ? e.replace(/_/g, "-") : zr, Kr = () => {
|
|
2351
|
+
if (typeof performance > "u") return zr;
|
|
2303
2352
|
let e = performance.getEntriesByType("navigation")[0];
|
|
2304
|
-
return
|
|
2305
|
-
},
|
|
2353
|
+
return Gr(e == null ? void 0 : e.type);
|
|
2354
|
+
}, qr = (e, t) => {
|
|
2306
2355
|
let [n, r] = e === "CLS" ? [.1, .25] : [200, 500];
|
|
2307
2356
|
return t <= n ? "good" : t <= r ? "needs-improvement" : "poor";
|
|
2308
|
-
},
|
|
2357
|
+
}, Jr = (e) => {
|
|
2309
2358
|
var t, n, r;
|
|
2310
2359
|
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
|
-
},
|
|
2360
|
+
}, Yr = () => {
|
|
2312
2361
|
if (typeof performance > "u") return;
|
|
2313
2362
|
let e = performance.interactionCount;
|
|
2314
2363
|
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
2315
|
-
},
|
|
2364
|
+
}, Xr = (e, t) => {
|
|
2316
2365
|
var n, r;
|
|
2317
2366
|
let i = (n = t.value) == null ? 0 : n;
|
|
2318
2367
|
if (!(t.hadRecentInput || !Number.isFinite(i))) {
|
|
2319
|
-
if (e.clsWindowStart === void 0 || t.startTime - ((r = e.clsWindowEnd) == null ? t.startTime : r) >=
|
|
2368
|
+
if (e.clsWindowStart === void 0 || t.startTime - ((r = e.clsWindowEnd) == null ? t.startTime : r) >= Ur || t.startTime - e.clsWindowStart >= Hr) {
|
|
2320
2369
|
var a;
|
|
2321
|
-
e.clsWindowStart = t.startTime, e.clsWindowValue = i, e.clsWindowLargestShiftValue = i, e.clsWindowLargestShiftTarget =
|
|
2370
|
+
e.clsWindowStart = t.startTime, e.clsWindowValue = i, e.clsWindowLargestShiftValue = i, e.clsWindowLargestShiftTarget = Jr((a = t.sources) == null || (a = a[0]) == null ? void 0 : a.node);
|
|
2322
2371
|
} else if (e.clsWindowValue += i, i > e.clsWindowLargestShiftValue) {
|
|
2323
2372
|
var o;
|
|
2324
|
-
e.clsWindowLargestShiftValue = i, e.clsWindowLargestShiftTarget =
|
|
2373
|
+
e.clsWindowLargestShiftValue = i, e.clsWindowLargestShiftTarget = Jr((o = t.sources) == null || (o = o[0]) == null ? void 0 : o.node);
|
|
2325
2374
|
}
|
|
2326
2375
|
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
2376
|
}
|
|
2328
|
-
},
|
|
2377
|
+
}, Zr = (e, t) => {
|
|
2329
2378
|
var n, r;
|
|
2330
2379
|
if (!t.interactionId || !Number.isFinite(t.duration)) return;
|
|
2331
2380
|
e.interactionIdMin = Math.min(e.interactionIdMin, t.interactionId), e.interactionIdMax = Math.max(e.interactionIdMax, t.interactionId);
|
|
2332
2381
|
let i = (n = t.processingStart) == null ? t.startTime : n, a = (r = t.processingEnd) == null ? i : r, o = {
|
|
2333
|
-
duration: Math.min(t.duration,
|
|
2382
|
+
duration: Math.min(t.duration, Vr),
|
|
2334
2383
|
inputDelay: Math.max(0, i - t.startTime),
|
|
2335
2384
|
interactionId: t.interactionId,
|
|
2336
|
-
interactionTarget:
|
|
2385
|
+
interactionTarget: Jr(t.target),
|
|
2337
2386
|
interactionType: t.name,
|
|
2338
2387
|
presentationDelay: Math.max(0, t.startTime + t.duration - a),
|
|
2339
2388
|
processingDuration: Math.max(0, a - i)
|
|
2340
2389
|
}, 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(
|
|
2342
|
-
},
|
|
2343
|
-
let t =
|
|
2390
|
+
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(Br);
|
|
2391
|
+
}, Qr = (e) => {
|
|
2392
|
+
let t = Yr(), 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
2393
|
if (e.inpCandidates.length) return e.inpCandidates[Math.min(e.inpCandidates.length - 1, Math.floor(n / 50))];
|
|
2345
|
-
},
|
|
2394
|
+
}, $r = (e, t) => {
|
|
2346
2395
|
var n;
|
|
2347
2396
|
return {
|
|
2348
2397
|
"rum.navigation.type": (n = e.navigationType) == null ? t : n,
|
|
2349
2398
|
[T.vitalMetric]: e.name.toLowerCase(),
|
|
2350
2399
|
[T.vitalRating]: e.rating
|
|
2351
2400
|
};
|
|
2352
|
-
},
|
|
2401
|
+
}, ei = (e, t) => {
|
|
2353
2402
|
var n;
|
|
2354
2403
|
let r = (n = e.attribution) == null ? {} : n, i = {}, a = (e) => r[e], o = (e, t, n) => {
|
|
2355
2404
|
t != null && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") && (i[e] = typeof t == "string" && n ? n(t) : t);
|
|
@@ -2373,7 +2422,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2373
2422
|
default: break;
|
|
2374
2423
|
}
|
|
2375
2424
|
return i;
|
|
2376
|
-
},
|
|
2425
|
+
}, ti = () => {
|
|
2377
2426
|
let e, t = !1;
|
|
2378
2427
|
return {
|
|
2379
2428
|
name: "web-vitals",
|
|
@@ -2391,21 +2440,24 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2391
2440
|
return;
|
|
2392
2441
|
}
|
|
2393
2442
|
if (t) return;
|
|
2394
|
-
let { onFCP: a, onLCP: o, onTTFB: s } = r, c =
|
|
2443
|
+
let { onFCP: a, onLCP: o, onTTFB: s } = r, c = Kr(), l = n.meter.createHistogram("browser.web_vital.cls", {
|
|
2395
2444
|
unit: "1",
|
|
2396
|
-
description: "Cumulative Layout Shift"
|
|
2445
|
+
description: "Cumulative Layout Shift",
|
|
2446
|
+
advice: { explicitBucketBoundaries: tr }
|
|
2397
2447
|
}), u = n.meter.createHistogram("browser.web_vital.duration", {
|
|
2398
2448
|
unit: "ms",
|
|
2399
|
-
description: "Web Vitals duration metrics, including FCP, INP, LCP and TTFB"
|
|
2449
|
+
description: "Web Vitals duration metrics, including FCP, INP, LCP and TTFB",
|
|
2450
|
+
advice: { explicitBucketBoundaries: W }
|
|
2400
2451
|
}), d = (e, t, r) => {
|
|
2452
|
+
if (!P(n, "traces")) return;
|
|
2401
2453
|
let i = e.name.toLowerCase();
|
|
2402
|
-
n.startSpan("browser.web_vital", O(O(O(O(O({}, n.config.hooks.getPageAttributes()), t),
|
|
2454
|
+
n.startSpan("browser.web_vital", O(O(O(O(O({}, n.config.hooks.getPageAttributes()), t), $r(e, c)), L({
|
|
2403
2455
|
duration: e.name === "CLS" ? void 0 : e.value,
|
|
2404
2456
|
errorType: e.rating === "good" ? "none" : "slow",
|
|
2405
2457
|
eventLabel: "Web 指标",
|
|
2406
2458
|
result: Qe(e.rating),
|
|
2407
2459
|
spanSubtype: i,
|
|
2408
|
-
spanType:
|
|
2460
|
+
spanType: I.vital,
|
|
2409
2461
|
targetLabel: i,
|
|
2410
2462
|
targetValue: e.value
|
|
2411
2463
|
})), {}, {
|
|
@@ -2413,17 +2465,20 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2413
2465
|
[T.vitalValue]: e.value,
|
|
2414
2466
|
[T.vitalRating]: e.rating,
|
|
2415
2467
|
"vital.id": e.id
|
|
2416
|
-
},
|
|
2468
|
+
}, ei(e, n.config.hooks.redactUrl)), r === void 0 ? void 0 : { contextTime: r }).end();
|
|
2417
2469
|
}, f = (e) => {
|
|
2418
|
-
if (t || !Number.isFinite(e.value)) return;
|
|
2470
|
+
if (t || !Number.isFinite(e.value) || !P(n, "metrics") && !P(n, "traces")) return;
|
|
2419
2471
|
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()),
|
|
2472
|
+
P(n, "metrics") && u.record(e.value, n.applyRedact(O(O(O({}, n.config.hooks.getMetricAttributes()), R(a)), $r(e, c)))), d(e, a, i);
|
|
2421
2473
|
}, p, m, h, g = (e, t, r) => {
|
|
2422
|
-
|
|
2423
|
-
|
|
2474
|
+
if (P(n, "metrics")) {
|
|
2475
|
+
let r = n.applyRedact(O(O(O({}, n.config.hooks.getMetricAttributes()), R(t)), $r(e, c)));
|
|
2476
|
+
e.name === "CLS" ? l.record(e.value, r) : u.record(e.value, r);
|
|
2477
|
+
}
|
|
2478
|
+
d(e, t, r);
|
|
2424
2479
|
}, _ = () => {
|
|
2425
2480
|
let e = p;
|
|
2426
|
-
if (!e) return;
|
|
2481
|
+
if (!e || !P(n, "metrics") && !P(n, "traces")) return;
|
|
2427
2482
|
g({
|
|
2428
2483
|
attribution: {
|
|
2429
2484
|
largestShiftTarget: e.largestShiftTarget,
|
|
@@ -2433,10 +2488,10 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2433
2488
|
id: N("vital"),
|
|
2434
2489
|
name: "CLS",
|
|
2435
2490
|
navigationType: c,
|
|
2436
|
-
rating:
|
|
2491
|
+
rating: qr("CLS", e.cls),
|
|
2437
2492
|
value: e.cls
|
|
2438
2493
|
}, e.runtimeAttributes, e.startedAt);
|
|
2439
|
-
let t =
|
|
2494
|
+
let t = Qr(e);
|
|
2440
2495
|
t && g({
|
|
2441
2496
|
attribution: {
|
|
2442
2497
|
inputDelay: t.inputDelay,
|
|
@@ -2449,19 +2504,30 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2449
2504
|
id: N("vital"),
|
|
2450
2505
|
name: "INP",
|
|
2451
2506
|
navigationType: c,
|
|
2452
|
-
rating:
|
|
2507
|
+
rating: qr("INP", t.duration),
|
|
2453
2508
|
value: t.duration
|
|
2454
2509
|
}, e.runtimeAttributes, e.startedAt);
|
|
2455
2510
|
}, v = n.onViewChange((e) => {
|
|
2456
2511
|
var t;
|
|
2512
|
+
let r = p;
|
|
2513
|
+
if (r && Wr(r.id, e.id)) {
|
|
2514
|
+
r.runtimeAttributes = O(O({}, r.runtimeAttributes), {}, {
|
|
2515
|
+
[T.viewId]: e.id,
|
|
2516
|
+
[T.viewName]: e.name,
|
|
2517
|
+
[T.viewUrl]: e.url,
|
|
2518
|
+
[T.viewUrlPathGroup]: e.urlPathGroup
|
|
2519
|
+
});
|
|
2520
|
+
return;
|
|
2521
|
+
}
|
|
2457
2522
|
_(), p = e.id ? {
|
|
2458
2523
|
cls: 0,
|
|
2459
2524
|
clsWindowLargestShiftValue: 0,
|
|
2460
2525
|
clsWindowValue: 0,
|
|
2461
|
-
interactionCountAtStart:
|
|
2526
|
+
interactionCountAtStart: Yr(),
|
|
2462
2527
|
interactionIdMax: 0,
|
|
2463
2528
|
interactionIdMin: Infinity,
|
|
2464
2529
|
inpCandidates: [],
|
|
2530
|
+
id: e.id,
|
|
2465
2531
|
largestShiftValue: 0,
|
|
2466
2532
|
runtimeAttributes: n.getRuntimeAttributes(),
|
|
2467
2533
|
startedAt: (t = e.startedAt) == null ? Date.now() : t
|
|
@@ -2470,12 +2536,12 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2470
2536
|
if (typeof PerformanceObserver < "u") {
|
|
2471
2537
|
var y, b;
|
|
2472
2538
|
(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 ||
|
|
2539
|
+
if (p) for (let t of e.getEntries()) performance.timeOrigin + t.startTime < p.startedAt || Xr(p, t);
|
|
2474
2540
|
}), h.observe({
|
|
2475
2541
|
buffered: !0,
|
|
2476
2542
|
type: "layout-shift"
|
|
2477
2543
|
})), (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) ||
|
|
2544
|
+
if (p) for (let t of e.getEntries()) performance.timeOrigin + t.startTime < p.startedAt || !t.interactionId || !Number.isFinite(t.duration) || Zr(p, t);
|
|
2479
2545
|
}), m.observe({
|
|
2480
2546
|
buffered: !0,
|
|
2481
2547
|
durationThreshold: 40,
|
|
@@ -2491,7 +2557,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2491
2557
|
t = !0, e == null || e(), e = void 0;
|
|
2492
2558
|
}
|
|
2493
2559
|
};
|
|
2494
|
-
},
|
|
2560
|
+
}, ni = 64 * 1024, ri = 6e4, ii = 5, ai = (e) => e == null ? 0 : typeof e == "string" ? e.length > ni || 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, oi = (e, t) => {
|
|
2495
2561
|
let n = {
|
|
2496
2562
|
"network.protocol.name": "websocket",
|
|
2497
2563
|
"url.full": t(e)
|
|
@@ -2504,71 +2570,71 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2504
2570
|
metricAttributes: r,
|
|
2505
2571
|
spanAttributes: n
|
|
2506
2572
|
};
|
|
2507
|
-
},
|
|
2573
|
+
}, si = (e, t) => {
|
|
2508
2574
|
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 } =
|
|
2575
|
+
let { bytesCounter: r, connectDurationHistogram: i, context: a, errorCounter: o, errorThrottle: s, isDisposed: l, messageCounter: u, url: d } = t, { metricAttributes: f, spanAttributes: p } = oi(d, a.config.hooks.redactUrl), m = a.config.hooks.getMetricAttributes(), h = () => a.applyRedact(O(O(O({}, m), R(a.getRuntimeAttributes())), f)), g = (n = p["server.address"]) == null ? p["url.full"] : n, _ = a.startSpan("websocket.connect", O(O(O({}, p), L({
|
|
2510
2576
|
errorType: "none",
|
|
2511
2577
|
eventLabel: "WebSocket",
|
|
2512
2578
|
spanSubtype: "websocket",
|
|
2513
|
-
spanType:
|
|
2514
|
-
targetLabel:
|
|
2515
|
-
})), p["server.address"] ? { [T.targetDomain]: p["server.address"] } : {})),
|
|
2516
|
-
if (
|
|
2517
|
-
|
|
2518
|
-
let t = performance.now() -
|
|
2519
|
-
e === "error" &&
|
|
2579
|
+
spanType: I.custom,
|
|
2580
|
+
targetLabel: g
|
|
2581
|
+
})), p["server.address"] ? { [T.targetDomain]: p["server.address"] } : {})), v = performance.now(), y = !1, b = (e) => {
|
|
2582
|
+
if (y) return;
|
|
2583
|
+
y = !0;
|
|
2584
|
+
let t = performance.now() - v;
|
|
2585
|
+
e === "error" && _.setStatus({
|
|
2520
2586
|
code: c.ERROR,
|
|
2521
2587
|
message: "websocket connect failed"
|
|
2522
|
-
}),
|
|
2588
|
+
}), _.setAttributes(L({
|
|
2523
2589
|
duration: t,
|
|
2524
2590
|
errorType: e === "error" ? "network" : "none",
|
|
2525
2591
|
eventLabel: "WebSocket",
|
|
2526
|
-
result: e === "error" ?
|
|
2592
|
+
result: e === "error" ? F.error : F.success,
|
|
2527
2593
|
spanSubtype: "websocket",
|
|
2528
|
-
spanType:
|
|
2529
|
-
targetLabel:
|
|
2594
|
+
spanType: I.custom,
|
|
2595
|
+
targetLabel: g,
|
|
2530
2596
|
targetValue: t
|
|
2531
|
-
})),
|
|
2597
|
+
})), _.end(), e === "opened" && !l() && P(a, "metrics") && i.record(t, h());
|
|
2532
2598
|
};
|
|
2533
2599
|
e.addEventListener("open", () => {
|
|
2534
|
-
l() ||
|
|
2600
|
+
l() || b("opened");
|
|
2535
2601
|
}), e.addEventListener("message", (e) => {
|
|
2536
|
-
if (l()) return;
|
|
2537
|
-
let t = O(O({},
|
|
2538
|
-
u.add(1, t), r.add(
|
|
2602
|
+
if (l() || !P(a, "metrics")) return;
|
|
2603
|
+
let t = O(O({}, h()), {}, { "websocket.direction": "in" });
|
|
2604
|
+
u.add(1, t), r.add(ai(e.data), t);
|
|
2539
2605
|
}), e.addEventListener("error", () => {
|
|
2540
2606
|
if (l()) return;
|
|
2541
|
-
let e =
|
|
2542
|
-
o.add(1, O(O({},
|
|
2607
|
+
let e = y ? "runtime" : "connect";
|
|
2608
|
+
if (P(a, "metrics") && o.add(1, O(O({}, h()), {}, { "websocket.error.phase": e })), b("error"), !P(a, "logs")) return;
|
|
2543
2609
|
let t = s.allow(`ws:error:${d}`);
|
|
2544
2610
|
t.allowed && a.emitLog({
|
|
2545
2611
|
severityNumber: w.ERROR,
|
|
2546
2612
|
severityText: "ERROR",
|
|
2547
2613
|
body: "websocket.error",
|
|
2548
|
-
attributes: O(O(O({}, p),
|
|
2614
|
+
attributes: O(O(O({}, p), L({
|
|
2549
2615
|
errorType: "network",
|
|
2550
2616
|
eventLabel: "WebSocket 错误",
|
|
2551
|
-
result:
|
|
2617
|
+
result: F.error,
|
|
2552
2618
|
spanSubtype: "websocket",
|
|
2553
|
-
spanType:
|
|
2554
|
-
targetLabel:
|
|
2619
|
+
spanType: I.custom,
|
|
2620
|
+
targetLabel: g
|
|
2555
2621
|
})), {}, {
|
|
2556
2622
|
"websocket.error.phase": e,
|
|
2557
|
-
"websocket.error.
|
|
2623
|
+
"websocket.error.window_occurrence_index": t.count
|
|
2558
2624
|
})
|
|
2559
2625
|
});
|
|
2560
2626
|
}), e.addEventListener("close", (e) => {
|
|
2561
|
-
l() || (
|
|
2627
|
+
l() || (y || b("error"), P(a, "logs") && a.emitLog({
|
|
2562
2628
|
severityNumber: w.INFO,
|
|
2563
2629
|
severityText: "INFO",
|
|
2564
2630
|
body: "websocket.close",
|
|
2565
|
-
attributes: O(O(O({}, p),
|
|
2631
|
+
attributes: O(O(O({}, p), L({
|
|
2566
2632
|
errorType: e.wasClean ? "none" : "network",
|
|
2567
2633
|
eventLabel: "WebSocket 关闭",
|
|
2568
|
-
result: e.wasClean ?
|
|
2634
|
+
result: e.wasClean ? F.success : F.warning,
|
|
2569
2635
|
spanSubtype: "websocket",
|
|
2570
|
-
spanType:
|
|
2571
|
-
targetLabel:
|
|
2636
|
+
spanType: I.custom,
|
|
2637
|
+
targetLabel: g,
|
|
2572
2638
|
targetValue: e.code
|
|
2573
2639
|
})), {}, {
|
|
2574
2640
|
"websocket.close.code": e.code,
|
|
@@ -2577,15 +2643,15 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2577
2643
|
})
|
|
2578
2644
|
}));
|
|
2579
2645
|
});
|
|
2580
|
-
let
|
|
2646
|
+
let x = e.send.bind(e);
|
|
2581
2647
|
e.send = (e) => {
|
|
2582
|
-
if (!l()) {
|
|
2583
|
-
let t = O(O({},
|
|
2584
|
-
u.add(1, t), r.add(
|
|
2648
|
+
if (!l() && P(a, "metrics")) {
|
|
2649
|
+
let t = O(O({}, h()), {}, { "websocket.direction": "out" });
|
|
2650
|
+
u.add(1, t), r.add(ai(e), t);
|
|
2585
2651
|
}
|
|
2586
|
-
return
|
|
2652
|
+
return x(e);
|
|
2587
2653
|
};
|
|
2588
|
-
},
|
|
2654
|
+
}, ci = () => {
|
|
2589
2655
|
let e, t, n = !1;
|
|
2590
2656
|
return {
|
|
2591
2657
|
name: "websocket",
|
|
@@ -2598,13 +2664,14 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2598
2664
|
description: "Total bytes transferred over WebSocket (best-effort)"
|
|
2599
2665
|
}), s = r.meter.createCounter("browser.websocket.error.count", { description: "Total number of WebSocket error events" }), c = r.meter.createHistogram("browser.websocket.connect.duration", {
|
|
2600
2666
|
unit: "ms",
|
|
2601
|
-
description: "WebSocket connection establishment duration (only successful connects)"
|
|
2602
|
-
|
|
2667
|
+
description: "WebSocket connection establishment duration (only successful connects)",
|
|
2668
|
+
advice: { explicitBucketBoundaries: W }
|
|
2669
|
+
}), l = Dn(ri, ii), u = () => n;
|
|
2603
2670
|
t = new Proxy(i, { construct(e, t, i) {
|
|
2604
2671
|
let d = Reflect.construct(e, t, i);
|
|
2605
|
-
if (n) return d;
|
|
2672
|
+
if (n || !r.isSampled()) return d;
|
|
2606
2673
|
let f = t[0] == null ? "" : String(t[0]);
|
|
2607
|
-
return !f || ke(r.config, f) ||
|
|
2674
|
+
return !f || ke(r.config, f) || si(d, {
|
|
2608
2675
|
bytesCounter: o,
|
|
2609
2676
|
connectDurationHistogram: c,
|
|
2610
2677
|
context: r,
|
|
@@ -2620,18 +2687,18 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2620
2687
|
n = !0, typeof window < "u" && e && window.WebSocket === t && (window.WebSocket = e), t = void 0, e = void 0;
|
|
2621
2688
|
}
|
|
2622
2689
|
};
|
|
2623
|
-
},
|
|
2690
|
+
}, li = class {
|
|
2624
2691
|
constructor() {
|
|
2625
2692
|
D(this, "listeners", /* @__PURE__ */ new Set()), D(this, "notify", (e) => {
|
|
2626
2693
|
this.listeners.forEach((t) => t(e));
|
|
2627
2694
|
}), D(this, "subscribe", (e) => (this.listeners.add(e), () => this.listeners.delete(e)));
|
|
2628
2695
|
}
|
|
2629
|
-
},
|
|
2696
|
+
}, ui = (e) => ({
|
|
2630
2697
|
url: e.endpoint,
|
|
2631
2698
|
headers: e.headers,
|
|
2632
2699
|
concurrencyLimit: e.concurrencyLimit,
|
|
2633
2700
|
timeoutMillis: e.timeoutMillis
|
|
2634
|
-
}),
|
|
2701
|
+
}), di = "bk-rum", fi = class {
|
|
2635
2702
|
constructor(e) {
|
|
2636
2703
|
this.isSampled = e;
|
|
2637
2704
|
}
|
|
@@ -2641,7 +2708,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2641
2708
|
toString() {
|
|
2642
2709
|
return "RumSessionSampler";
|
|
2643
2710
|
}
|
|
2644
|
-
}, Q,
|
|
2711
|
+
}, Q, pi = () => {
|
|
2645
2712
|
if (Q) Q.users += 1;
|
|
2646
2713
|
else {
|
|
2647
2714
|
let e = new f().enable(), n = l.setGlobalContextManager(e);
|
|
@@ -2656,28 +2723,28 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2656
2723
|
return () => {
|
|
2657
2724
|
e || !Q || (e = !0, --Q.users, !(Q.users > 0) && (Q.ownsContext && l.disable(), Q.ownsPropagator && u.disable(), Q = void 0));
|
|
2658
2725
|
};
|
|
2659
|
-
},
|
|
2726
|
+
}, mi = (e, t, n) => n ? new Proxy(e, { get(e, n, r) {
|
|
2660
2727
|
if (n === "export") return (n, r) => {
|
|
2661
2728
|
var i;
|
|
2662
2729
|
return (i = globalThis.console) == null || i.log(`[bk-ot][${t}]`, n), e.export(n, r);
|
|
2663
2730
|
};
|
|
2664
2731
|
let i = Reflect.get(e, n, r);
|
|
2665
2732
|
return typeof i == "function" ? i.bind(e) : i;
|
|
2666
|
-
} }) : e,
|
|
2667
|
-
|
|
2668
|
-
...$(e.tracking.device, !0,
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
],
|
|
2673
|
-
...$(e.error, !0,
|
|
2674
|
-
...$(e.webVitals, !0,
|
|
2675
|
-
...$(e.blankScreen, !0,
|
|
2676
|
-
...$(e.action, !0,
|
|
2677
|
-
...$(e.websocket, !1,
|
|
2678
|
-
...$(e.longTask, !1,
|
|
2679
|
-
...$(e.cspViolation, !1,
|
|
2680
|
-
],
|
|
2733
|
+
} }) : e, hi = (e) => [En(e.tracking.request)], gi = (e) => [
|
|
2734
|
+
Rr(e.session),
|
|
2735
|
+
...$(e.tracking.device, !0, Wn),
|
|
2736
|
+
St(),
|
|
2737
|
+
wr(),
|
|
2738
|
+
pn(_i(e.tracking.resource, !0))
|
|
2739
|
+
], _i = (e, t) => e === void 0 ? t : e !== !1, vi = (e) => typeof e == "object" && e ? e : void 0, $ = (e, t, n) => _i(e, t) ? [n(vi(e))] : [], yi = (e) => [
|
|
2740
|
+
...$(e.error, !0, er),
|
|
2741
|
+
...$(e.webVitals, !0, ti),
|
|
2742
|
+
...$(e.blankScreen, !0, Vt),
|
|
2743
|
+
...$(e.action, !0, yt),
|
|
2744
|
+
...$(e.websocket, !1, ci),
|
|
2745
|
+
...$(e.longTask, !1, lr),
|
|
2746
|
+
...$(e.cspViolation, !1, Mn)
|
|
2747
|
+
], bi = class {
|
|
2681
2748
|
assertBeforeStart(e) {
|
|
2682
2749
|
if (this.phase !== "idle") throw Error(`[bk-ot] ${e}() must be called before start(); set autoStart: false before registration.`);
|
|
2683
2750
|
}
|
|
@@ -2711,19 +2778,19 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2711
2778
|
createPluginManager() {
|
|
2712
2779
|
var e;
|
|
2713
2780
|
return new Se([
|
|
2714
|
-
...
|
|
2715
|
-
...
|
|
2716
|
-
...
|
|
2781
|
+
...gi(this.config),
|
|
2782
|
+
...hi(this.config),
|
|
2783
|
+
...yi(this.config.tracking),
|
|
2717
2784
|
...(e = this.config.extensions.plugins) == null ? [] : e
|
|
2718
2785
|
]);
|
|
2719
2786
|
}
|
|
2720
2787
|
constructor(e) {
|
|
2721
2788
|
var t = this;
|
|
2722
|
-
D(this, "activityObserver", new
|
|
2789
|
+
D(this, "activityObserver", new li()), D(this, "flushProviders", k(function* () {
|
|
2723
2790
|
yield t.tracerProvider.forceFlush(), yield t.meterProvider.forceFlush(), yield t.loggerProvider.forceFlush();
|
|
2724
2791
|
})), 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
2792
|
if (t.pluginManager || !t.config.enabled || t.config.trackingConsent !== "granted") return;
|
|
2726
|
-
t.config.transport.traces !== !1 && (t.releaseOtelGlobals =
|
|
2793
|
+
t.config.transport.traces !== !1 && (t.releaseOtelGlobals = pi());
|
|
2727
2794
|
let e = t.createPluginManager();
|
|
2728
2795
|
t.pluginManager = e;
|
|
2729
2796
|
try {
|
|
@@ -2751,6 +2818,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2751
2818
|
};
|
|
2752
2819
|
}()), 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) => {
|
|
2753
2820
|
var t;
|
|
2821
|
+
if (!this.isSampled() || this.config.transport.logs === !1) return;
|
|
2754
2822
|
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
2823
|
this.logger.emit(a);
|
|
2756
2824
|
}), D(this, "flush", k(function* () {
|
|
@@ -2765,13 +2833,13 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2765
2833
|
tracerProvider: this.tracerProvider
|
|
2766
2834
|
}), this.registeredInstrumentations.push(...e));
|
|
2767
2835
|
}), D(this, "reportAction", ({ attributes: e = {}, name: t }) => {
|
|
2768
|
-
if (!this.isSampled()) return;
|
|
2836
|
+
if (!this.isSampled() || this.config.transport.traces === !1) return;
|
|
2769
2837
|
let n = N("action");
|
|
2770
|
-
this.startSpan("action.custom", O(O(O(O({}, this.config.hooks.getPageAttributes()), e),
|
|
2838
|
+
this.startSpan("action.custom", O(O(O(O({}, this.config.hooks.getPageAttributes()), e), L({
|
|
2771
2839
|
errorType: "none",
|
|
2772
2840
|
eventLabel: "用户操作",
|
|
2773
2841
|
spanSubtype: "custom",
|
|
2774
|
-
spanType:
|
|
2842
|
+
spanType: I.action,
|
|
2775
2843
|
targetLabel: t,
|
|
2776
2844
|
traceScene: "user_action"
|
|
2777
2845
|
})), {}, {
|
|
@@ -2780,19 +2848,19 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2780
2848
|
[T.actionType]: "custom"
|
|
2781
2849
|
})).end();
|
|
2782
2850
|
}), D(this, "reportCustomEvent", ({ attributes: e = {}, error: t, name: n }) => {
|
|
2783
|
-
if (!this.isSampled()) {
|
|
2851
|
+
if (!this.isSampled() || this.config.transport.traces === !1) {
|
|
2784
2852
|
if (this.config.debug) {
|
|
2785
2853
|
var r;
|
|
2786
2854
|
(r = globalThis.console) == null || r.warn("[bk-ot] custom event dropped (not sampled):", n);
|
|
2787
2855
|
}
|
|
2788
2856
|
return;
|
|
2789
2857
|
}
|
|
2790
|
-
let i = this.startSpan(`custom.${n}`, O(O(O(O(O({}, this.config.hooks.getPageAttributes()), this.config.hooks.getCustomAttributes()),
|
|
2858
|
+
let i = this.startSpan(`custom.${n}`, O(O(O(O(O({}, this.config.hooks.getPageAttributes()), this.config.hooks.getCustomAttributes()), L({
|
|
2791
2859
|
errorType: t ? "custom" : "none",
|
|
2792
2860
|
eventLabel: "自定义事件",
|
|
2793
|
-
result: t ?
|
|
2861
|
+
result: t ? F.error : F.success,
|
|
2794
2862
|
spanSubtype: n,
|
|
2795
|
-
spanType:
|
|
2863
|
+
spanType: I.custom,
|
|
2796
2864
|
targetLabel: n
|
|
2797
2865
|
})), e), {}, { "rum.custom.name": n }));
|
|
2798
2866
|
t && (i.recordException(t), i.setStatus({
|
|
@@ -2861,6 +2929,7 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2861
2929
|
}
|
|
2862
2930
|
})), D(this, "startSpan", (e, t = {}, n) => {
|
|
2863
2931
|
var r, i;
|
|
2932
|
+
if (!this.isSampled() || this.config.transport.traces === !1) return this.tracer.startSpan(e);
|
|
2864
2933
|
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
2934
|
return this.tracer.startSpan(e, {
|
|
2866
2935
|
kind: (i = n == null ? void 0 : n.kind) == null ? s.INTERNAL : i,
|
|
@@ -2881,15 +2950,15 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2881
2950
|
}), this.config = ve(e), this.runtimeContext = new qe({ [A]: !1 }, this.config.user);
|
|
2882
2951
|
let i = v(this.config.resourceAttributes), l = (() => {
|
|
2883
2952
|
if (this.config.transport.traces === !1) return [];
|
|
2884
|
-
let e =
|
|
2953
|
+
let e = mi(new g(ui(this.config.transport.traces)), "traces", this.config.debug);
|
|
2885
2954
|
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
2955
|
})(), u = this.config.transport.metrics === !1 ? [] : [new o({
|
|
2887
|
-
exporter: new Ge(
|
|
2956
|
+
exporter: new Ge(mi(new h(O(O({}, ui(this.config.transport.metrics)), {}, { temporalityPreference: m.DELTA })), "metrics", this.config.debug)),
|
|
2888
2957
|
exportIntervalMillis: this.config.metricIntervalMillis
|
|
2889
|
-
})], d = this.config.transport.logs === !1 ? [] : [new He(new y(
|
|
2958
|
+
})], d = this.config.transport.logs === !1 ? [] : [new He(new y(mi(new p(ui(this.config.transport.logs)), "logs", this.config.debug)), this.config)];
|
|
2890
2959
|
this.tracerProvider = new ee({
|
|
2891
2960
|
resource: i,
|
|
2892
|
-
sampler: new
|
|
2961
|
+
sampler: new fi(() => this.config.transport.traces !== !1 && this.isSampled()),
|
|
2893
2962
|
spanProcessors: l
|
|
2894
2963
|
}), this.meterProvider = new a({
|
|
2895
2964
|
resource: i,
|
|
@@ -2897,11 +2966,11 @@ var Ie = ["http.url", "url.full"], Le = "bk.rum.request.discard", Re = (e) => {
|
|
|
2897
2966
|
}), this.loggerProvider = new b({
|
|
2898
2967
|
resource: i,
|
|
2899
2968
|
processors: d
|
|
2900
|
-
}), this.tracer = this.tracerProvider.getTracer(
|
|
2969
|
+
}), this.tracer = this.tracerProvider.getTracer(di), this.meter = this.meterProvider.getMeter(di), this.logger = this.loggerProvider.getLogger(di), this.registeredInstrumentations = [], this.config.autoStart && this.start().catch((e) => {
|
|
2901
2970
|
var t;
|
|
2902
2971
|
(t = globalThis.console) == null || t.warn("[bk-ot] auto start failed:", e);
|
|
2903
2972
|
});
|
|
2904
2973
|
}
|
|
2905
2974
|
};
|
|
2906
2975
|
//#endregion
|
|
2907
|
-
export {
|
|
2976
|
+
export { bi as BkOpenTelemetry, bt as EXCLUDED_ACTIVITY_MUTATIONS_ATTRIBUTE, He as FilteringLogRecordProcessor, Ge as FilteringMetricExporter, Ue as FilteringSpanProcessor, T as RUM_ATTRIBUTES, F as RUM_SPAN_RESULT, I as RUM_SPAN_TYPE, qe as RumRuntimeContext, L as buildRumSpanAttributes, yt as createActionPlugin, Vt as createBlankScreenPlugin, En as createCommonInstrumentationsPlugin, Mn as createCspViolationPlugin, Wn as createDevicePlugin, er as createErrorPlugin, lr as createLongTaskPlugin, xe as createPlugin, pn as createResourcePlugin, Rr as createSessionPlugin, ci as createWebSocketPlugin, ti as createWebVitalsPlugin, Je as getDurationBucket, ve as resolveConfig };
|