decord/source/1137_discardEmptyNavigationSpan.js

199 lines
7.6 KiB
JavaScript
Raw Normal View History

2026-07-20 16:05:17 +00:00
// Module ID: 1137
2026-07-25 08:10:48 +00:00
// Function ID: 12938
2026-07-20 16:05:17 +00:00
// Name: discardEmptyNavigationSpan
2026-07-23 10:11:24 +00:00
// Dependencies: [27, 1098, 794]
2026-07-20 16:05:17 +00:00
// Exports: adjustTransactionDuration, cancelInBackground, ignoreEmptyBackNavigation, ignoreEmptyRouteChangeTransactions, onThisSpanEnd, onlySampleIfChildSpans
// Module 1137 (discardEmptyNavigationSpan)
2026-07-23 10:11:24 +00:00
import { AppState } from "get ActivityIndicator";
function discardEmptyNavigationSpan(on, closure_2, arg2, arg3) {
const _require = closure_2;
2026-07-20 16:05:17 +00:00
const dependencyMap = arg2;
2026-07-23 10:11:24 +00:00
closure_2 = arg3;
2026-07-20 16:05:17 +00:00
if (on) {
2026-07-23 10:11:24 +00:00
if (closure_2) {
if (tmpResult.isRootSpan(closure_2)) {
if (obj2.isSentrySpan(closure_2)) {
2026-07-20 16:05:17 +00:00
on.on("spanEnd", (arg0) => {
2026-07-23 10:11:24 +00:00
if (arg0 === closure_0) {
if (callback(closure_0)) {
if ((function getMeaningfulChildSpans(closure_0) {
const callback = closure_0;
const spanDescendants = callback(table[2]).getSpanDescendants(closure_0);
2026-07-20 16:05:17 +00:00
return spanDescendants.filter((spanContext) => {
2026-07-23 10:11:24 +00:00
let tmp = spanContext.spanContext().spanId !== lib.spanContext().spanId;
2026-07-20 16:05:17 +00:00
if (tmp) {
2026-07-23 10:11:24 +00:00
tmp = "ui.load.initial_display" !== lib(794).spanToJSON(spanContext).op;
const obj = lib(794);
2026-07-20 16:05:17 +00:00
}
if (tmp) {
2026-07-23 10:11:24 +00:00
tmp = "navigation.processing" !== lib(794).spanToJSON(spanContext).op;
const obj2 = lib(794);
2026-07-20 16:05:17 +00:00
}
return tmp;
});
2026-07-23 10:11:24 +00:00
})(closure_0).length <= 0) {
callback2(closure_0);
closure_0._sampled = false;
2026-07-20 16:05:17 +00:00
}
}
}
});
}
2026-07-23 10:11:24 +00:00
obj2 = _require(1098);
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
const debug3 = _require(794).debug;
2026-07-20 16:05:17 +00:00
debug3.warn("Not sampling empty navigation spans only works for Sentry Transactions (Root Spans).");
2026-07-23 10:11:24 +00:00
tmpResult = tmp(1098);
2026-07-20 16:05:17 +00:00
} else {
2026-07-23 10:11:24 +00:00
const debug2 = tmp(794).debug;
2026-07-20 16:05:17 +00:00
debug2.warn("Could not hook on spanEnd event because span is not defined.");
}
} else {
2026-07-23 10:11:24 +00:00
const debug = tmp(794).debug;
2026-07-20 16:05:17 +00:00
debug.warn("Could not hook on spanEnd event because client is not defined.");
}
}
export const onThisSpanEnd = function onThisSpanEnd(on) {
2026-07-23 10:11:24 +00:00
let closure_0 = arg1;
let closure_1 = arg2;
2026-07-20 16:05:17 +00:00
on.on("spanEnd", (arg0) => {
2026-07-23 10:11:24 +00:00
if (closure_0 === arg0) {
callback(arg0);
2026-07-20 16:05:17 +00:00
}
});
};
2026-07-23 10:11:24 +00:00
export const adjustTransactionDuration = function adjustTransactionDuration(client, outer1_0, finalTimeout) {
const _require = outer1_0;
2026-07-20 16:05:17 +00:00
const dependencyMap = finalTimeout;
2026-07-23 10:11:24 +00:00
if (obj.isRootSpan(outer1_0)) {
client.on("spanEnd", (arg0) => {
if (arg0 === outer1_0) {
let timestamp = outer1_0(794).spanToJSON(outer1_0).timestamp;
const obj2 = outer1_0(794);
const start_timestamp = outer1_0(794).spanToJSON(outer1_0).start_timestamp;
2026-07-20 16:05:17 +00:00
if (timestamp) {
if (start_timestamp) {
const diff = timestamp - start_timestamp;
if (timestamp) {
2026-07-23 10:11:24 +00:00
let tmp3 = diff > dependencyMap;
2026-07-20 16:05:17 +00:00
if (!tmp3) {
tmp3 = diff < 0;
}
timestamp = tmp3;
}
if (timestamp) {
2026-07-23 10:11:24 +00:00
const obj = { code: outer1_0(794).SPAN_STATUS_ERROR, message: "deadline_exceeded" };
outer1_0.setStatus(obj);
const attr = outer1_0.setAttribute("maxTransactionDurationExceeded", "true");
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-23 10:11:24 +00:00
const obj3 = outer1_0(794);
2026-07-20 16:05:17 +00:00
}
});
} else {
2026-07-23 10:11:24 +00:00
const debug = _require(794).debug;
2026-07-20 16:05:17 +00:00
debug.warn("Not sampling empty back spans only works for Sentry Transactions (Root Spans).");
}
};
2026-07-23 10:11:24 +00:00
export const ignoreEmptyBackNavigation = function ignoreEmptyBackNavigation(client, closure_2) {
discardEmptyNavigationSpan(client, closure_2, (arg0) => {
const data = outer1_0(outer1_1[2]).spanToJSON(arg0).data;
2026-07-20 16:05:17 +00:00
let prop;
if (null !== data) {
if (undefined !== data) {
2026-07-23 10:11:24 +00:00
prop = data["route.has_been_seen"];
2026-07-20 16:05:17 +00:00
}
}
return true === prop;
}, () => {
2026-07-23 10:11:24 +00:00
const debug = outer1_0(outer1_1[2]).debug;
2026-07-20 16:05:17 +00:00
debug.log("Not sampling transaction as route has been seen before. Pass ignoreEmptyBackNavigationTransactions = false to disable this feature.");
});
};
2026-07-23 10:11:24 +00:00
export const ignoreEmptyRouteChangeTransactions = function ignoreEmptyRouteChangeTransactions(client, closure_2, DEFAULT_NAVIGATION_SPAN_NAME, arg3) {
let closure_0 = client;
let closure_1 = DEFAULT_NAVIGATION_SPAN_NAME;
closure_2 = arg3;
discardEmptyNavigationSpan(client, closure_2, (arg0) => {
const spanToJSONResult = client(DEFAULT_NAVIGATION_SPAN_NAME[2]).spanToJSON(arg0);
let tmp2 = spanToJSONResult.description === DEFAULT_NAVIGATION_SPAN_NAME;
2026-07-20 16:05:17 +00:00
if (tmp2) {
const data = spanToJSONResult.data;
let prop;
if (null !== data) {
if (undefined !== data) {
2026-07-23 10:11:24 +00:00
prop = data["route.name"];
2026-07-20 16:05:17 +00:00
}
}
tmp2 = !prop;
}
if (tmp2) {
2026-07-23 10:11:24 +00:00
tmp2 = callback();
2026-07-20 16:05:17 +00:00
}
return tmp2;
}, (arg0) => {
2026-07-23 10:11:24 +00:00
const debug = client(DEFAULT_NAVIGATION_SPAN_NAME[2]).debug;
debug.log("Discarding empty \"" + DEFAULT_NAVIGATION_SPAN_NAME + "\" transaction that never received route information.");
if (null != client) {
client.recordDroppedEvent("sample_rate", "transaction");
2026-07-20 16:05:17 +00:00
}
});
};
export const onlySampleIfChildSpans = function onlySampleIfChildSpans(client, startIdleSpanResult) {
2026-07-23 10:11:24 +00:00
const _require = startIdleSpanResult;
2026-07-20 16:05:17 +00:00
if (obj.isRootSpan(startIdleSpanResult)) {
if (obj2.isSentrySpan(startIdleSpanResult)) {
client.on("spanEnd", (arg0) => {
2026-07-23 10:11:24 +00:00
if (arg0 === startIdleSpanResult) {
if (obj2.getSpanDescendants(startIdleSpanResult).length <= 1) {
const debug = startIdleSpanResult(outer1_1[2]).debug;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
2026-07-23 10:11:24 +00:00
debug.log("Not sampling as " + startIdleSpanResult(outer1_1[2]).spanToJSON(startIdleSpanResult).op + " transaction has no child spans.");
startIdleSpanResult._sampled = false;
const obj = startIdleSpanResult(outer1_1[2]);
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
obj2 = startIdleSpanResult(outer1_1[2]);
2026-07-20 16:05:17 +00:00
}
});
}
}
2026-07-23 10:11:24 +00:00
let debug = _require(794).debug;
2026-07-20 16:05:17 +00:00
debug.warn("Not sampling childless spans only works for Sentry Transactions (Root Spans).");
};
export const cancelInBackground = function cancelInBackground(client, startIdleSpanResult) {
2026-07-23 10:11:24 +00:00
let closure_0 = startIdleSpanResult;
const listener = AppState.addEventListener("change", (arg0) => {
2026-07-20 16:05:17 +00:00
if ("background" === arg0) {
2026-07-23 10:11:24 +00:00
const debug = startIdleSpanResult(listener[2]).debug;
let obj = startIdleSpanResult(listener[2]);
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
2026-07-23 10:11:24 +00:00
debug.log("Setting " + obj.spanToJSON(startIdleSpanResult).op + " transaction to cancelled because the app is in the background.");
obj = { code: startIdleSpanResult(listener[2]).SPAN_STATUS_ERROR, message: "cancelled" };
startIdleSpanResult.setStatus(obj);
startIdleSpanResult.end();
2026-07-20 16:05:17 +00:00
}
});
if (listener) {
client.on("spanEnd", (arg0) => {
2026-07-23 10:11:24 +00:00
if (arg0 === startIdleSpanResult) {
const debug = startIdleSpanResult(listener[2]).debug;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
2026-07-23 10:11:24 +00:00
debug.log("Removing AppState listener for " + startIdleSpanResult(listener[2]).spanToJSON(startIdleSpanResult).op + " transaction.");
2026-07-20 16:05:17 +00:00
let remove;
if (null != listener) {
remove = listener.remove;
}
if (!tmp3) {
remove.call(listener);
}
2026-07-23 10:11:24 +00:00
const obj = startIdleSpanResult(listener[2]);
tmp3 = null === remove || undefined === remove;
2026-07-20 16:05:17 +00:00
}
});
}
};