493 lines
18 KiB
JavaScript
493 lines
18 KiB
JavaScript
// Metro module 1092 (f1093).
|
|
import { TRACING_DEFAULTS, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, startIdleSpan, addNonEnumerableProperty, getCurrentScope, spanIsSampled, getDynamicSamplingContextFromSpan, dateTimestampInSeconds, startInactiveSpan, spanToJSON, debug, SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON, registerSpanErrorInstrumentation, GLOBAL_OBJ, timestampInSeconds, getClient, getIsolationScope, generateTraceId, hasSpansEnabled, generateSpanId, propagationContextFromHeaders, getLocationHref, browserPerformanceTimeOrigin, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, parseStringToURLObject } from "./Module817";
|
|
import { defaultRequestInstrumentationOptions, instrumentOutgoingRequests } from "./shouldAttachHeaders";
|
|
import { WINDOW, getHttpRequestData } from "./ignoreNextOnError";
|
|
import { addPerformanceEntries, startTrackingWebVitals, startTrackingINP, startTrackingElementTiming, startTrackingLongAnimationFrames, startTrackingLongTasks, startTrackingInteractions, addHistoryInstrumentationHandler, registerInpInteractionListener } from "./Module1033";
|
|
import { DEBUG_BUILD } from "./Module1072";
|
|
import { linkTraces } from "./addPreviousTraceSpanLink";
|
|
import { registerBackgroundTabDetection } from "./Module1095";
|
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
value: "Module"
|
|
});
|
|
const name = "BrowserTracing";
|
|
let c902_3 = {
|
|
...TRACING_DEFAULTS,
|
|
instrumentNavigation: true,
|
|
instrumentPageLoad: true,
|
|
markBackgroundSpan: true,
|
|
enableLongTask: true,
|
|
enableLongAnimationFrame: true,
|
|
enableInp: true,
|
|
enableElementTiming: true,
|
|
ignoreResourceSpans: [],
|
|
ignorePerformanceApiSpans: [],
|
|
detectRedirects: true,
|
|
linkPreviousTrace: "in-memory",
|
|
consistentTraceSampling: false,
|
|
enableReportPageLoaded: false,
|
|
_experiments: {},
|
|
...defaultRequestInstrumentationOptions
|
|
};
|
|
let c902_4 = "_sentry_idleSpan";
|
|
let c902_5 = 1.5;
|
|
export const BROWSER_TRACING_INTEGRATION_ID = "BrowserTracing";
|
|
export const browserTracingIntegration = function(r4 = {}) {
|
|
let c12787_0, c12787_1, c12787_2, c12787_3, document2, enableInp, enableElementTiming, enableLongTask, enableLongAnimationFrame, enableInteractions, enableStandaloneClsSpans, enableStandaloneLcpSpans, beforeStartSpan, idleTimeout, finalTimeout, childSpanTimeout, markBackgroundSpan, traceFetch, traceXHR, trackFetchStreamPerformance, shouldCreateSpanForRequest, enableHTTPTimings, ignoreResourceSpans, ignorePerformanceApiSpans, instrumentPageLoad, instrumentNavigation, detectRedirects, linkPreviousTrace, consistentTraceSampling, enableReportPageLoaded, onRequestSpanStart, onRequestSpanEnd;
|
|
c12787_0 = void 0;
|
|
c12787_1 = void 0;
|
|
c12787_2 = void 0;
|
|
document2 = void 0;
|
|
enableInp = void 0;
|
|
enableElementTiming = void 0;
|
|
enableLongTask = void 0;
|
|
enableLongAnimationFrame = void 0;
|
|
enableInteractions = void 0;
|
|
enableStandaloneClsSpans = void 0;
|
|
enableStandaloneLcpSpans = void 0;
|
|
beforeStartSpan = void 0;
|
|
idleTimeout = void 0;
|
|
finalTimeout = void 0;
|
|
childSpanTimeout = void 0;
|
|
markBackgroundSpan = void 0;
|
|
traceFetch = void 0;
|
|
traceXHR = void 0;
|
|
trackFetchStreamPerformance = void 0;
|
|
shouldCreateSpanForRequest = void 0;
|
|
enableHTTPTimings = void 0;
|
|
ignoreResourceSpans = void 0;
|
|
ignorePerformanceApiSpans = void 0;
|
|
instrumentPageLoad = void 0;
|
|
instrumentNavigation = void 0;
|
|
detectRedirects = void 0;
|
|
linkPreviousTrace = void 0;
|
|
consistentTraceSampling = void 0;
|
|
enableReportPageLoaded = void 0;
|
|
onRequestSpanStart = void 0;
|
|
onRequestSpanEnd = void 0;
|
|
const _createRouteSpan2 = function _createRouteSpan(a0, a1) {
|
|
let c24186_2;
|
|
let c24186_0 = a0;
|
|
let r4 = arguments[2];
|
|
if (r4 === void 0) {
|
|
r4 = true;
|
|
}
|
|
c24186_2 = void 0;
|
|
let disableAutoFinish = a1.op === "pageload";
|
|
let c24186_1 = disableAutoFinish;
|
|
const name2 = a1.name;
|
|
const r11 = beforeStartSpan ? beforeStartSpan(a1) : a1;
|
|
const attributes = r11.attributes || {};
|
|
if (name2 !== r11.name) {
|
|
attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] = "custom";
|
|
r11.attributes = attributes;
|
|
}
|
|
if (r4) {
|
|
c12787_3.name = r11.name;
|
|
c12787_3.source = attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
|
|
const r61 = startIdleSpan(r11, {
|
|
idleTimeout,
|
|
finalTimeout,
|
|
childSpanTimeout,
|
|
disableAutoFinish,
|
|
beforeSpanEnd: (a0) => {
|
|
if (c12787_0 != null) {
|
|
c12787_0();
|
|
}
|
|
addPerformanceEntries(a0, {
|
|
recordClsOnPageloadSpan: !enableStandaloneClsSpans,
|
|
recordLcpOnPageloadSpan: !enableStandaloneLcpSpans,
|
|
ignoreResourceSpans,
|
|
ignorePerformanceApiSpans
|
|
});
|
|
addNonEnumerableProperty(c24186_0, c902_4, void 0);
|
|
const currentScope = getCurrentScope();
|
|
const propagationContext = currentScope.getPropagationContext();
|
|
currentScope.setPropagationContext({
|
|
...propagationContext,
|
|
traceId: c24186_2.spanContext().traceId,
|
|
sampled: spanIsSampled(c24186_2),
|
|
dsc: getDynamicSamplingContextFromSpan(a0)
|
|
});
|
|
if (c24186_1) {
|
|
c12787_2 = void 0;
|
|
}
|
|
},
|
|
trimIdleSpanEndTimestamp: !enableReportPageLoaded
|
|
});
|
|
c24186_2 = r61;
|
|
if (disableAutoFinish ? enableReportPageLoaded : disableAutoFinish) {
|
|
c12787_2 = r61;
|
|
}
|
|
addNonEnumerableProperty(a0, c902_4, r61);
|
|
if (disableAutoFinish) {
|
|
disableAutoFinish = !enableReportPageLoaded;
|
|
}
|
|
if (disableAutoFinish) {
|
|
disableAutoFinish = document2;
|
|
}
|
|
if (disableAutoFinish) {
|
|
document2.addEventListener("readystatechange", () => {
|
|
if (document2 ? ["interactive", "complete"].includes(document2.readyState) : document2) {
|
|
c24186_0.emit("idleSpanEnableAutoFinish", c24186_2);
|
|
}
|
|
});
|
|
if (document2 ? ["interactive", "complete"].includes(document2.readyState) : document2) {
|
|
a0.emit("idleSpanEnableAutoFinish", r61);
|
|
}
|
|
}
|
|
} else {
|
|
const startTime = dateTimestampInSeconds();
|
|
startInactiveSpan({
|
|
...r11,
|
|
startTime
|
|
}).end(startTime);
|
|
}
|
|
};
|
|
c12787_3 = {
|
|
name: void 0,
|
|
source: void 0
|
|
};
|
|
document2 = WINDOW.document;
|
|
const r14 = {
|
|
...c902_3,
|
|
...r4
|
|
};
|
|
enableInp = r14.enableInp;
|
|
enableElementTiming = r14.enableElementTiming;
|
|
enableLongTask = r14.enableLongTask;
|
|
enableLongAnimationFrame = r14.enableLongAnimationFrame;
|
|
const _experiments = r14._experiments;
|
|
enableInteractions = _experiments.enableInteractions;
|
|
enableStandaloneClsSpans = _experiments.enableStandaloneClsSpans;
|
|
enableStandaloneLcpSpans = _experiments.enableStandaloneLcpSpans;
|
|
beforeStartSpan = r14.beforeStartSpan;
|
|
idleTimeout = r14.idleTimeout;
|
|
finalTimeout = r14.finalTimeout;
|
|
childSpanTimeout = r14.childSpanTimeout;
|
|
markBackgroundSpan = r14.markBackgroundSpan;
|
|
traceFetch = r14.traceFetch;
|
|
traceXHR = r14.traceXHR;
|
|
trackFetchStreamPerformance = r14.trackFetchStreamPerformance;
|
|
shouldCreateSpanForRequest = r14.shouldCreateSpanForRequest;
|
|
enableHTTPTimings = r14.enableHTTPTimings;
|
|
ignoreResourceSpans = r14.ignoreResourceSpans;
|
|
ignorePerformanceApiSpans = r14.ignorePerformanceApiSpans;
|
|
instrumentPageLoad = r14.instrumentPageLoad;
|
|
instrumentNavigation = r14.instrumentNavigation;
|
|
detectRedirects = r14.detectRedirects;
|
|
linkPreviousTrace = r14.linkPreviousTrace;
|
|
consistentTraceSampling = r14.consistentTraceSampling;
|
|
enableReportPageLoaded = r14.enableReportPageLoaded;
|
|
onRequestSpanStart = r14.onRequestSpanStart;
|
|
onRequestSpanEnd = r14.onRequestSpanEnd;
|
|
return {
|
|
name,
|
|
setup: (a0) => {
|
|
let c24187_0 = a0;
|
|
const maybeEndActiveSpan2 = function maybeEndActiveSpan() {
|
|
const r10 = c24187_0[c902_4];
|
|
if (r10 && !spanToJSON(r10).timestamp) {
|
|
if (DEBUG_BUILD) {
|
|
debug.log(`[Tracing] Finishing current active span with op: ${spanToJSON(r10).op}`);
|
|
}
|
|
r10.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON, "cancelled");
|
|
r10.end();
|
|
}
|
|
};
|
|
registerSpanErrorInstrumentation();
|
|
let recordClsStandaloneSpans = enableStandaloneClsSpans;
|
|
if (!enableStandaloneClsSpans) {
|
|
recordClsStandaloneSpans = false;
|
|
}
|
|
let recordLcpStandaloneSpans = enableStandaloneLcpSpans;
|
|
if (!enableStandaloneLcpSpans) {
|
|
recordLcpStandaloneSpans = false;
|
|
}
|
|
c12787_0 = startTrackingWebVitals({
|
|
recordClsStandaloneSpans,
|
|
recordLcpStandaloneSpans,
|
|
client: a0
|
|
});
|
|
if (enableInp) {
|
|
startTrackingINP();
|
|
}
|
|
if (enableElementTiming) {
|
|
startTrackingElementTiming();
|
|
}
|
|
if (enableLongAnimationFrame && (GLOBAL_OBJ.PerformanceObserver && (PerformanceObserver.supportedEntryTypes && PerformanceObserver.supportedEntryTypes.includes("long-animation-frame")))) {
|
|
startTrackingLongAnimationFrames();
|
|
} else if (enableLongTask) {
|
|
startTrackingLongTasks();
|
|
}
|
|
if (enableInteractions) {
|
|
startTrackingInteractions();
|
|
}
|
|
if (detectRedirects && document2) {
|
|
const interactionHandler = () => {
|
|
c12787_1 = timestampInSeconds();
|
|
};
|
|
addEventListener("click", interactionHandler, {
|
|
capture: true
|
|
});
|
|
addEventListener("keydown", interactionHandler, {
|
|
capture: true,
|
|
passive: true
|
|
});
|
|
}
|
|
a0.on("startNavigationSpan", (a0, a1) => {
|
|
const client = getClient();
|
|
if (client === c24187_0) {
|
|
if (a1?.isRedirect) {
|
|
if (DEBUG_BUILD) {
|
|
debug.warn("[Tracing] Detected redirect, navigation span will not be the root span, but a child span.");
|
|
}
|
|
_createRouteSpan2(c24187_0, {
|
|
op: "navigation.redirect",
|
|
...a0
|
|
}, false);
|
|
return void 0;
|
|
}
|
|
c12787_1 = void 0;
|
|
maybeEndActiveSpan2();
|
|
getIsolationScope().setPropagationContext({
|
|
traceId: generateTraceId(),
|
|
sampleRand: Math.random(),
|
|
propagationSpanId: hasSpansEnabled() ? void 0 : generateSpanId()
|
|
});
|
|
const currentScope = getCurrentScope();
|
|
currentScope.setPropagationContext({
|
|
traceId: generateTraceId(),
|
|
sampleRand: Math.random(),
|
|
propagationSpanId: hasSpansEnabled() ? void 0 : generateSpanId()
|
|
});
|
|
currentScope.setSDKProcessingMetadata({
|
|
normalizedRequest: void 0
|
|
});
|
|
_createRouteSpan2(c24187_0, {
|
|
op: "navigation",
|
|
...a0,
|
|
parentSpan: null,
|
|
forceTransaction: true
|
|
});
|
|
}
|
|
});
|
|
a0.on("startPageLoadSpan", function(a0, r3 = {}) {
|
|
const client = getClient();
|
|
if (client === c24187_0) {
|
|
maybeEndActiveSpan2();
|
|
let sentryTrace = r3.sentryTrace;
|
|
if (!sentryTrace) {
|
|
const document3 = WINDOW.document;
|
|
const r11 = document3 == null ? void 0 : document3.querySelector(`meta[name=sentry-trace]`);
|
|
sentryTrace = (r11 == null ? void 0 : r11.getAttribute("content")) || void 0;
|
|
}
|
|
let baggage = r3.baggage;
|
|
if (!baggage) {
|
|
const document4 = WINDOW.document;
|
|
const r42 = document4 == null ? void 0 : document4.querySelector(`meta[name=baggage]`);
|
|
baggage = (r42 == null ? void 0 : r42.getAttribute("content")) || void 0;
|
|
}
|
|
const r58 = propagationContextFromHeaders(sentryTrace, baggage);
|
|
const currentScope = getCurrentScope();
|
|
currentScope.setPropagationContext(r58);
|
|
if (!hasSpansEnabled()) {
|
|
currentScope.getPropagationContext().propagationSpanId = generateSpanId();
|
|
}
|
|
currentScope.setSDKProcessingMetadata({
|
|
normalizedRequest: getHttpRequestData()
|
|
});
|
|
_createRouteSpan2(c24187_0, {
|
|
op: "pageload",
|
|
...a0
|
|
});
|
|
}
|
|
});
|
|
a0.on("endPageloadSpan", () => {
|
|
let r2 = enableReportPageLoaded;
|
|
if (enableReportPageLoaded) {
|
|
r2 = c12787_2;
|
|
}
|
|
if (r2) {
|
|
c12787_2.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON, "reportPageLoaded");
|
|
c12787_2.end();
|
|
}
|
|
});
|
|
},
|
|
afterAllSetup: (a0) => {
|
|
let c24188_0 = a0;
|
|
const locationHref = getLocationHref();
|
|
if (linkPreviousTrace !== "off") {
|
|
linkTraces(a0, {
|
|
linkPreviousTrace,
|
|
consistentTraceSampling
|
|
});
|
|
}
|
|
if (WINDOW.location) {
|
|
if (instrumentPageLoad) {
|
|
const r29 = browserPerformanceTimeOrigin();
|
|
const attributes = {};
|
|
attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] = "url";
|
|
attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = "auto.pageload.browser";
|
|
const r35 = {
|
|
name: WINDOW.location.pathname,
|
|
startTime: r29 ? r29 / 1000 : void 0,
|
|
attributes
|
|
};
|
|
a0.emit("startPageLoadSpan", r35, void 0);
|
|
getCurrentScope().setTransactionName(r35.name);
|
|
const r56 = a0[c902_4];
|
|
if (r56) {
|
|
a0.emit("afterStartPageLoadSpan", r56);
|
|
}
|
|
}
|
|
if (instrumentNavigation) {
|
|
addHistoryInstrumentationHandler((a0) => {
|
|
L22: {
|
|
const to = a0.to;
|
|
if (a0.from === void 0) {
|
|
if ((locationHref == null ? void 0 : locationHref.indexOf(to)) !== -1) {
|
|
locationHref = void 0;
|
|
break L22;
|
|
}
|
|
}
|
|
locationHref = void 0;
|
|
const r27 = parseStringToURLObject(to);
|
|
const r17 = c24188_0[c902_4];
|
|
let isRedirect2 = r17 && detectRedirects;
|
|
if (isRedirect2) {
|
|
const r34 = spanToJSON(r17);
|
|
const r38 = dateTimestampInSeconds();
|
|
isRedirect2 = r38 - r34.start_timestamp > c902_5 ? false : c12787_1 ? r38 - c12787_1 <= c902_5 ? false : true : true;
|
|
}
|
|
const name2 = r27?.pathname || WINDOW.location.pathname;
|
|
const attributes = {};
|
|
attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] = "url";
|
|
attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = "auto.navigation.browser";
|
|
const r50 = {
|
|
name: name2,
|
|
attributes
|
|
};
|
|
const r60 = {
|
|
url: to,
|
|
isRedirect: isRedirect2
|
|
};
|
|
const { url, isRedirect } = r60;
|
|
c24188_0.emit("beforeStartNavigationSpan", r50, {
|
|
isRedirect
|
|
});
|
|
c24188_0.emit("startNavigationSpan", r50, {
|
|
isRedirect
|
|
});
|
|
const currentScope = getCurrentScope();
|
|
currentScope.setTransactionName(r50.name);
|
|
if (url && !isRedirect) {
|
|
currentScope.setSDKProcessingMetadata({
|
|
normalizedRequest: {
|
|
...getHttpRequestData(),
|
|
url
|
|
}
|
|
});
|
|
}
|
|
c24188_0[c902_4];
|
|
}
|
|
});
|
|
}
|
|
}
|
|
if (markBackgroundSpan) {
|
|
registerBackgroundTabDetection();
|
|
}
|
|
if (enableInteractions) {
|
|
let c24189_5;
|
|
let c24189_0 = a0;
|
|
const idleTimeout2 = idleTimeout;
|
|
const finalTimeout2 = finalTimeout;
|
|
const childSpanTimeout2 = childSpanTimeout;
|
|
let c24189_4 = c12787_3;
|
|
if (WINDOW.document) {
|
|
addEventListener("click", () => {
|
|
const r8 = c24189_0[c902_4];
|
|
if (r8 && ["navigation", "pageload"].includes(spanToJSON(r8).op)) {
|
|
if (DEBUG_BUILD) {
|
|
debug.warn(`[Tracing] Did not create ui.action.click span because a pageload or navigation span is in progress.`);
|
|
}
|
|
return void 0;
|
|
}
|
|
const r9 = c24189_5;
|
|
if (r9) {
|
|
r9.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON, "interactionInterrupted");
|
|
c24189_5.end();
|
|
c24189_5 = void 0;
|
|
}
|
|
if (c24189_4.name) {
|
|
const r58 = c24189_4.source || "url";
|
|
const attributes = {};
|
|
attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] = r58;
|
|
c24189_5 = startIdleSpan({
|
|
name: c24189_4.name,
|
|
op: "ui.action.click",
|
|
attributes
|
|
}, {
|
|
idleTimeout: idleTimeout2,
|
|
finalTimeout: finalTimeout2,
|
|
childSpanTimeout: childSpanTimeout2
|
|
});
|
|
} else if (DEBUG_BUILD) {
|
|
debug.warn(`[Tracing] Did not create ui.action.click transaction because _latestRouteName is missing.`);
|
|
}
|
|
}, {
|
|
capture: true
|
|
});
|
|
}
|
|
}
|
|
if (enableInp) {
|
|
registerInpInteractionListener();
|
|
}
|
|
instrumentOutgoingRequests(a0, {
|
|
traceFetch,
|
|
traceXHR,
|
|
trackFetchStreamPerformance,
|
|
tracePropagationTargets: a0.getOptions().tracePropagationTargets,
|
|
shouldCreateSpanForRequest,
|
|
enableHTTPTimings,
|
|
onRequestSpanStart,
|
|
onRequestSpanEnd
|
|
});
|
|
}
|
|
};
|
|
};
|
|
export function getMetaContent(a0) {
|
|
const document3 = WINDOW.document;
|
|
const r6 = document3 == null ? void 0 : document3.querySelector(`meta[name=${a0}]`);
|
|
return (r6 == null ? void 0 : r6.getAttribute("content")) || void 0;
|
|
}
|
|
export function startBrowserTracingNavigationSpan(a0, a1, a2) {
|
|
const r5 = a2 ? a2 : {};
|
|
const { url, isRedirect } = r5;
|
|
a0.emit("beforeStartNavigationSpan", a1, {
|
|
isRedirect
|
|
});
|
|
a0.emit("startNavigationSpan", a1, {
|
|
isRedirect
|
|
});
|
|
const currentScope = getCurrentScope();
|
|
currentScope.setTransactionName(a1.name);
|
|
if (url && !isRedirect) {
|
|
currentScope.setSDKProcessingMetadata({
|
|
normalizedRequest: {
|
|
...getHttpRequestData(),
|
|
url
|
|
}
|
|
});
|
|
}
|
|
return a0[c902_4];
|
|
}
|
|
export function startBrowserTracingPageLoadSpan(a0, a1, a2) {
|
|
a0.emit("startPageLoadSpan", a1, a2);
|
|
getCurrentScope().setTransactionName(a1.name);
|
|
const r18 = a0[c902_4];
|
|
if (r18) {
|
|
a0.emit("afterStartPageLoadSpan", r18);
|
|
}
|
|
return r18;
|
|
}
|