// Metro module 1161 (f1162). import * as _Module17 from "react-native"; import { isRootSpan, isSentrySpan } from "./Module1122"; import { spanToJSON, SPAN_STATUS_ERROR, debug, getSpanDescendants } from "./Module817"; function $mk68251($env) { return (a0) => { const r3 = $env; const r2 = r3[0]; if (a0 === r2 && (0, r3[1])(r2)) { const r5 = $env.$parent; let env24258 = { $parent: r5 }; env24258[0] = r2; if ((0, r5[0])(r5[1][2]).getSpanDescendants(r2).filter((item) => { let r0 = item.spanContext().spanId !== env24258[0].spanContext().spanId; if (r0) { const r11 = env24258.$parent; r0 = (0, r11[0])(r11[1][2]).spanToJSON(item).op !== "ui.load.initial_display"; } if (r0) { const r20 = env24258.$parent; r0 = (0, r20[0])(r20[1][2]).spanToJSON(item).op !== "navigation.processing"; } return r0; }).length <= 0) { (0, r3[2])(r2); r2._sampled = false; } } }; } let env964 = {}; export function onThisSpanEnd(a0, c12861_0, c12861_1) { a0.on("spanEnd", (a0) => { if (c12861_0 === a0) { c12861_1(a0); } }); } export const adjustTransactionDuration = (a0, a1, c12862_1) => { if (isRootSpan(a1)) { a0.on("spanEnd", (a0) => { if (a0 === a1) { let timestamp = spanToJSON(a1).timestamp; const start_timestamp = spanToJSON(a1).start_timestamp; if (timestamp && start_timestamp) { const r20 = timestamp - start_timestamp; if (timestamp) { timestamp = r20 > c12862_1 || r20 < 0; } if (timestamp) { a1.setStatus({ code: SPAN_STATUS_ERROR, message: "deadline_exceeded" }); a1.setAttribute("maxTransactionDurationExceeded", "true"); } } } }); } else { debug.warn("Not sampling empty back spans only works for Sentry Transactions (Root Spans)."); } }; export const ignoreEmptyBackNavigation = (a0, a1) => { let env12863; L8: { const r1 = env12863 = { $parent: env964 }; env12863[0] = a1; env12863[1] = (a0) => { const data = spanToJSON(a0).data; return (data !== null ? data !== void 0 ? data["route.has_been_seen"] : void 0 : void 0) === true; }; env12863[2] = () => { debug.log("Not sampling transaction as route has been seen before. Pass ignoreEmptyBackNavigationTransactions = false to disable this feature."); }; if (a0) { if (a1) { if (isRootSpan(a1) && isSentrySpan(a1)) { a0.on("spanEnd", $mk68251(r1)); break L8; } debug.warn("Not sampling empty navigation spans only works for Sentry Transactions (Root Spans)."); } else { debug.warn("Could not hook on spanEnd event because span is not defined."); } } else { debug.warn("Could not hook on spanEnd event because client is not defined."); } } }; export const ignoreEmptyRouteChangeTransactions = (a0, a1, a2, a3) => { let c12864_0, c12864_1, c12864_2; let env12865; L8: { c12864_0 = a0; c12864_1 = a2; c12864_2 = a3; const r10 = env12865 = { $parent: env964 }; env12865[0] = a1; env12865[1] = (a0) => { const r10 = spanToJSON(a0); let r13 = r10.description === c12864_1; if (r13) { const data = r10.data; r13 = !(data !== null ? data !== void 0 ? data["route.name"] : void 0 : void 0); } if (r13) { r13 = c12864_2(); } return r13; }; env12865[2] = (a0) => { debug.log(`Discarding empty "${c12864_1}" transaction that never received route information.`); if (c12864_0 != null) { c12864_0.recordDroppedEvent("sample_rate", "transaction"); } }; if (a0) { if (a1) { if (isRootSpan(a1) && isSentrySpan(a1)) { a0.on("spanEnd", $mk68251(r10)); break L8; } debug.warn("Not sampling empty navigation spans only works for Sentry Transactions (Root Spans)."); } else { debug.warn("Could not hook on spanEnd event because span is not defined."); } } else { debug.warn("Could not hook on spanEnd event because client is not defined."); } } }; export const onlySampleIfChildSpans = (a0, a1) => { if (isRootSpan(a1) && isSentrySpan(a1)) { a0.on("spanEnd", (a0) => { if (a0 === a1) { if (getSpanDescendants(a1).length <= 1) { debug.log(`Not sampling as ${spanToJSON(a1).op} transaction has no child spans.`); a1._sampled = false; } } }); } else { debug.warn("Not sampling childless spans only works for Sentry Transactions (Root Spans)."); } }; export const cancelInBackground = (a0, c12867_0) => { let c12867_1; const r8 = _Module17.AppState.addEventListener("change", (a0) => { if (a0 === "background") { debug.log(`Setting ${spanToJSON(c12867_0).op} transaction to cancelled because the app is in the background.`); c12867_0.setStatus({ code: SPAN_STATUS_ERROR, message: "cancelled" }); c12867_0.end(); } }); c12867_1 = r8; if (r8) { a0.on("spanEnd", (a0) => { if (a0 === c12867_0) { debug.log(`Removing AppState listener for ${spanToJSON(c12867_0).op} transaction.`); const remove = c12867_1?.remove; if (!(remove === null || remove === void 0)) { remove.call(c12867_1); } } }); } };