Files
discord-decomp/_bundle/Module1190.js
T
2026-11-01 12:12:55 +02:00

146 lines
5.5 KiB
JavaScript

// Metro module 1190 (f1191).
import * as _startIdleSpan from "./startIdleSpan";
import { getDefaultIdleNavigationSpanOptions, DEFAULT_NAVIGATION_SPAN_NAME } from "./startIdleSpan";
import { getReactNativeTracingIntegration } from "./Module1166";
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getClient, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_OP, addBreadcrumb } from "./Module817";
import { SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NATIVE_NAVIGATION } from "./Module1158";
import { ignoreEmptyBackNavigation, ignoreEmptyRouteChangeTransactions } from "./Module1161";
import { isSentrySpan } from "./Module1122";
const name = "ReactNativeNavigation";
export const INTEGRATION_NAME = "ReactNativeNavigation";
export const reactNativeNavigationIntegration = (a0) => {
const { navigation, routeChangeTimeoutMs = 1000 } = a0;
let reactNativeTracingIntegration, _this, c12900_4, pushRecentComponentId2, discardLatestNavigationSpan2, clearStateChangeTimeout2;
let c12900_0 = routeChangeTimeoutMs;
const { enableTabsInstrumentation = false, ignoreEmptyBackNavigationTransactions = true } = a0;
let c12900_1 = ignoreEmptyBackNavigationTransactions;
reactNativeTracingIntegration = void 0;
_this = void 0;
c12900_4 = void 0;
pushRecentComponentId2 = void 0;
discardLatestNavigationSpan2 = void 0;
clearStateChangeTimeout2 = void 0;
let c12900_5 = [];
let defaultIdleOptions = _startIdleSpan.defaultIdleOptions;
let c12900_7 = null;
const startIdleNavigationSpan = () => {
const r3 = c12900_4;
if (r3) {
if (r3) {
if (isSentrySpan(c12900_4)) {
c12900_4._sampled = false;
}
c12900_4.end();
c12900_4 = void 0;
}
if (_this !== void 0) {
clearTimeout(_this);
_this = void 0;
}
}
const r61 = _startIdleSpan.startIdleNavigationSpan((reactNativeTracingIntegration == null ? void 0 : reactNativeTracingIntegration.options.beforeStartSpan) ? reactNativeTracingIntegration.options.beforeStartSpan(getDefaultIdleNavigationSpanOptions()) : getDefaultIdleNavigationSpanOptions(), defaultIdleOptions);
c12900_4 = r61;
if (r61 != null) {
c12900_4.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NATIVE_NAVIGATION);
}
if (c12900_1) {
ignoreEmptyBackNavigation(getClient(), c12900_4);
}
const r90 = c12900_4;
let c24305_0 = r90;
ignoreEmptyRouteChangeTransactions(getClient(), r90, DEFAULT_NAVIGATION_SPAN_NAME, () => c12900_4 === c24305_0);
_this = setTimeout(discardLatestNavigationSpan2.bind(this), c12900_0);
};
navigation.events().registerCommandListener(startIdleNavigationSpan);
if (enableTabsInstrumentation) {
navigation.events().registerBottomTabPressedListener(startIdleNavigationSpan);
}
navigation.events().registerComponentWillAppearListener((a0) => {
L34: {
if (c12900_4) {
if (c12900_7 && a0.componentId === c12900_7.componentId) {
if (c12900_4) {
if (isSentrySpan(c12900_4)) {
c12900_4._sampled = false;
}
c12900_4.end();
c12900_4 = void 0;
}
if (_this === void 0) {
break L34;
}
clearTimeout(_this);
_this = void 0;
break L34;
}
if (_this !== void 0) {
clearTimeout(_this);
_this = void 0;
}
const r10 = c12900_5.includes(a0.componentId);
if (spanToJSON(c12900_4).description === DEFAULT_NAVIGATION_SPAN_NAME) {
c12900_4.updateName(a0.componentName);
}
const r42 = c12900_4;
const r44 = {
"route.name": a0.componentName,
"route.component_id": a0.componentId,
"route.component_type": a0.componentType,
"route.has_been_seen": r10,
"previous_route.name": c12900_7 == null ? void 0 : c12900_7.componentName,
"previous_route.component_id": c12900_7 == null ? void 0 : c12900_7.componentId,
"previous_route.component_type": c12900_7 == null ? void 0 : c12900_7.componentType
};
r44[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] = "component";
r44[SEMANTIC_ATTRIBUTE_SENTRY_OP] = "navigation";
r42.setAttributes(r44);
if (reactNativeTracingIntegration != null) {
reactNativeTracingIntegration.setCurrentRoute(a0.componentName);
}
addBreadcrumb({
category: "navigation",
type: "navigation",
message: `Navigation to ${a0.componentName}`,
data: {
from: c12900_7 == null ? void 0 : c12900_7.componentName,
to: a0.componentName
}
});
c12900_5.push(a0.componentId);
if (c12900_5.length > 200) {
c12900_5 = c12900_5.slice(c12900_5.length - 200);
}
c12900_7 = a0;
c12900_4 = void 0;
}
}
});
pushRecentComponentId2 = (a0) => {};
discardLatestNavigationSpan2 = () => {
if (c12900_4) {
if (isSentrySpan(c12900_4)) {
c12900_4._sampled = false;
}
c12900_4.end();
c12900_4 = void 0;
}
if (_this !== void 0) {
clearTimeout(_this);
_this = void 0;
}
};
clearStateChangeTimeout2 = () => {};
return {
name,
afterAllSetup: (a0) => {
reactNativeTracingIntegration = getReactNativeTracingIntegration(a0);
if (reactNativeTracingIntegration) {
defaultIdleOptions = {
finalTimeout: reactNativeTracingIntegration.options.finalTimeoutMs,
idleTimeout: reactNativeTracingIntegration.options.idleTimeoutMs
};
}
}
};
};