429 lines
16 KiB
TypeScript
429 lines
16 KiB
TypeScript
// Metro module 1209 (f1210).
|
||
import { NativeModules } from "react-native";
|
||
import { AnalyticEvents, Endpoints } from "../../../Constants";
|
||
import { PRIMARY_DOMAIN } from "../../../_bundle/Module505";
|
||
import { reactNavigationIntegration, init, featureFlagsIntegration, reactNativeTracingIntegration, setTag } from "../../../_bundle/Module810";
|
||
import Logger from "../../debug/Logger";
|
||
import { SentryTelemetry, ZoomedInTelemetry } from "../../telemetry_ring/native/index";
|
||
import { getHistory } from "../../routing/router_utils";
|
||
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
|
||
import { AppCrashedReasons } from "../../../_bundle/Module13256";
|
||
import MonitoringAgent from "../../monitoring/MonitoringAgent";
|
||
import { MetricEvents } from "../../../_bundle/Module5872";
|
||
import { filterThrottle } from "../CommonSentryInitUtils";
|
||
import SentryUtils_native from "../../../utils/SentryUtils.native";
|
||
import { getConstants } from "../../../utils/native/ClientInfoUtils";
|
||
import { isStable } from "../../../utils/ReleaseChannelUtils.native";
|
||
import { isAndroid } from "../../../utils/PlatformUtils";
|
||
import { getDevice } from "../../../utils/native/DeviceUtils";
|
||
import * as _MetaQuestUtils_android from "../../device/MetaQuestUtils.android";
|
||
import ProcessUtils_native from "../../../utils/ProcessUtils.native";
|
||
import { DesignIds } from "../../../_bundle/Module673";
|
||
import * as _FabricUtils from "../../../utils/native/FabricUtils";
|
||
import { isFabric } from "../../../utils/native/FabricUtils";
|
||
function $mk113741($env) {
|
||
return function maybeBackfillMissingBreadcrumbsFromTelemetryRing() {
|
||
return _maybeBackfillMissingBreadcrumbsFromTelemetryRing.apply(this, arguments);
|
||
};
|
||
}
|
||
let c1018_8, c1018_9, c1018_10, _excluded, c1018_12, c1018_13, c1018_14, filterError, getCrashErrorMessage, getErrorStackTrace, trackCrash, c1018_20;
|
||
let _maybeBackfillMissingBreadcrumbsFromTelemetryRing = function _maybeBackfillMissingBreadcrumbsFromTelemetryRing() {
|
||
const r8 = async (c24321_0) => {
|
||
let c24321_1;
|
||
L19: {
|
||
L10: {
|
||
let env28862;
|
||
const r11 = env28862 = {};
|
||
c24321_1 = r11;
|
||
env28862[0] = c24321_0;
|
||
env28862[1] = void 0;
|
||
const breadcrumbs = c24321_0.breadcrumbs;
|
||
if (Array.isArray(breadcrumbs) && breadcrumbs.length > 0) {
|
||
break L10;
|
||
}
|
||
env28862[1] = await Promise.race([SentryTelemetry.snapshotForBreadcrumbs(), new Promise((resolve, c31228_0) => setTimeout(() => c31228_0(new Error("TelemetryRing breadcrumb timeout")), 200))]).catch(() => null);
|
||
if (!(env28862[1] != null && Array.isArray(env28862[1].entries) && env28862[1].entries.length !== 0)) {
|
||
break L19;
|
||
}
|
||
env28862[0].breadcrumbs = env28862[1].entries.map((entry) => {
|
||
let message = entry.message;
|
||
if (message == null) {
|
||
message = entry.key;
|
||
}
|
||
return {
|
||
message,
|
||
category: "telemetry_ring",
|
||
timestamp: entry.timestamp / 1000,
|
||
data: entry.data
|
||
};
|
||
});
|
||
break L19;
|
||
}
|
||
return void 0;
|
||
}
|
||
};
|
||
_maybeBackfillMissingBreadcrumbsFromTelemetryRing = r8;
|
||
return r8.apply(this, arguments);
|
||
};
|
||
filterError = function filterError(a0, a1) {
|
||
let r13, r17;
|
||
const originalException = a1?.originalException;
|
||
const status = originalException?.status;
|
||
if (status) {
|
||
const r2 = status >= 400;
|
||
r13 = true;
|
||
if (!r2) {
|
||
r17 = originalException?.captchaFields != null ? originalException?.code : null;
|
||
r13 = r17 ? r17 < 0 ? true : false : false;
|
||
}
|
||
} else {
|
||
r17 = originalException?.captchaFields != null ? originalException?.code : null;
|
||
r13 = r17 ? r17 < 0 ? true : false : false;
|
||
}
|
||
if (!r13) {
|
||
const originalException2 = a1?.originalException;
|
||
r13 = (originalException2 == null ? void 0 : originalException2.err?.code) === "ABORTED" ? true : false;
|
||
}
|
||
L44: {
|
||
if (!r13) {
|
||
const status2 = a1?.originalException?.status;
|
||
if (status2 != null) {
|
||
if (a0.tags == null) {
|
||
a0.tags = {};
|
||
}
|
||
a0.tags.httpStatusCode = status2;
|
||
}
|
||
let r37 = c1018_12;
|
||
if (a0.level === "error") {
|
||
r37 = c1018_13;
|
||
}
|
||
L39: {
|
||
if (!c1018_14) {
|
||
if (c1018_20() && Math.random() <= r37) {
|
||
break L39;
|
||
}
|
||
trackCrash(a0, a1, false);
|
||
break L44;
|
||
}
|
||
}
|
||
return (async () => {
|
||
let r87;
|
||
let c24322_0, c24322_1;
|
||
let c24322_2 = 0;
|
||
const r12 = void 0;
|
||
L12: {
|
||
try {
|
||
c24322_1 = r12;
|
||
c24322_0 = r12;
|
||
c24322_2 = 1;
|
||
await Promise.race([ZoomedInTelemetry.flushNow(), new Promise((resolve) => setTimeout(resolve, 200))]);
|
||
await $mk113741(void 0)(a0);
|
||
c24322_2 = 0;
|
||
(0, trackCrash)(a0, a1);
|
||
r87 = a0;
|
||
} catch ($e) {
|
||
let r29 = $e;
|
||
if (c24322_2 !== 0) {
|
||
while (true) {
|
||
try {
|
||
c24322_2 = 0;
|
||
(0, trackCrash)(a0, a1);
|
||
r87 = a0;
|
||
break L12;
|
||
} catch ($e) {
|
||
r29 = $e;
|
||
if (c24322_2 === 0) {
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
throw r29;
|
||
}
|
||
}
|
||
return r87;
|
||
})();
|
||
}
|
||
const event_id = a0.event_id;
|
||
if (typeof event_id === "string" ? event_id.length !== 0 : typeof event_id === "string") {
|
||
SentryUtils_native.markCrashHandled(event_id);
|
||
}
|
||
}
|
||
return null;
|
||
};
|
||
getCrashErrorMessage = function getCrashErrorMessage(a0) {
|
||
const exception = a0.exception;
|
||
const r2 = exception == null;
|
||
let r4 = void 0;
|
||
if (!r2) {
|
||
const values = exception.values;
|
||
r4 = values == null ? void 0 : values[0];
|
||
}
|
||
if (r4 == null) {
|
||
const persisted_error_message2 = a0.extra?.persisted_error_message;
|
||
let r27 = typeof persisted_error_message2 === "string" ? persisted_error_message2.length > 0 ? persisted_error_message2 : void 0 : void 0;
|
||
if (r27 == null) {
|
||
r27 = a0.message;
|
||
}
|
||
return r27;
|
||
}
|
||
const { type, value } = r4;
|
||
if (type != null && value != null) {
|
||
return `${type}: ${value}`;
|
||
}
|
||
const persisted_error_message = a0.extra?.persisted_error_message;
|
||
let r15 = type;
|
||
if (r15 == null) {
|
||
r15 = value;
|
||
}
|
||
if (r15 == null) {
|
||
r15 = a0.message;
|
||
}
|
||
if (r15 == null) {
|
||
r15 = typeof persisted_error_message === "string" ? persisted_error_message.length > 0 ? persisted_error_message : void 0 : void 0;
|
||
}
|
||
return r15;
|
||
};
|
||
getErrorStackTrace = function getErrorStackTrace(a0) {
|
||
const exception = a0.exception;
|
||
const r3 = exception == null;
|
||
let r5 = void 0;
|
||
if (!r3) {
|
||
const values = exception.values;
|
||
r5 = values == null ? void 0 : values[0];
|
||
}
|
||
if (r5 == null) {
|
||
const persisted_error_stack2 = a0.extra?.persisted_error_stack;
|
||
return typeof persisted_error_stack2 === "string" ? persisted_error_stack2.length > 0 ? persisted_error_stack2 : void 0 : void 0;
|
||
}
|
||
const stacktrace = r5.stacktrace;
|
||
const r12 = stacktrace == null;
|
||
let r13 = void 0;
|
||
if (!r12) {
|
||
const frames = stacktrace.frames;
|
||
r13 = frames == null ? void 0 : frames.map((frame) => `${frame.filename}:${frame.lineno}:${frame.colno}`).join("\n");
|
||
}
|
||
if (r13 != null && r13.length > 0) {
|
||
return r13;
|
||
}
|
||
const persisted_error_stack = a0.extra?.persisted_error_stack;
|
||
return typeof persisted_error_stack === "string" ? persisted_error_stack.length > 0 ? persisted_error_stack : void 0 : void 0;
|
||
};
|
||
trackCrash = function trackCrash(a0, a1, r2 = true) {
|
||
let r31, client_track_timestamp;
|
||
c1018_10.info("Crash", {
|
||
event: a0,
|
||
hint: a1
|
||
});
|
||
let level = a0.level;
|
||
if (a0.extra?.native_is_native != null) {
|
||
r31 = a0.extra.native_is_native === "true";
|
||
} else {
|
||
const tags = a0.tags;
|
||
r31 = (tags == null ? void 0 : tags["event.origin"]) !== "javascript";
|
||
}
|
||
if (!(level !== "fatal" && (level !== "error" && level != null))) {
|
||
const r0 = r31 || level !== "error" ? 1 : 0.01;
|
||
if (!c1018_14 && !(Math.random() <= r0)) {
|
||
const event_id = a0.event_id;
|
||
if (typeof event_id === "string" ? event_id.length !== 0 : typeof event_id === "string") {
|
||
SentryUtils_native.markCrashHandled(event_id);
|
||
}
|
||
return void 0;
|
||
}
|
||
const location2 = getHistory().location;
|
||
let sentry_issue_id = null;
|
||
if (r2) {
|
||
let event_id2 = a0.event_id;
|
||
if (event_id2 == null) {
|
||
event_id2 = null;
|
||
}
|
||
sentry_issue_id = event_id2;
|
||
}
|
||
L36: {
|
||
const timestamp = a0.timestamp;
|
||
const r60 = timestamp != null;
|
||
client_track_timestamp = void 0;
|
||
if (r60) {
|
||
if (typeof timestamp === "number" && !isNaN(timestamp)) {
|
||
client_track_timestamp = 1000 * timestamp;
|
||
break L36;
|
||
}
|
||
if (timestamp instanceof Date) {
|
||
client_track_timestamp = timestamp.getTime();
|
||
} else {
|
||
client_track_timestamp = void 0;
|
||
if (typeof timestamp === "string") {
|
||
const r69 = Date.parse(timestamp);
|
||
client_track_timestamp = Number.isNaN(r69) ? void 0 : r69;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (client_track_timestamp == null) {
|
||
client_track_timestamp = Date.now();
|
||
}
|
||
if (r31) {
|
||
const APP_NATIVE_CRASH = AnalyticEvents.APP_NATIVE_CRASH;
|
||
let extra = a0.extra;
|
||
if (extra == null) {
|
||
extra = {};
|
||
}
|
||
const native_exit_reason = extra.native_exit_reason;
|
||
const exit_reason = typeof native_exit_reason === "string" ? native_exit_reason.length > 0 ? native_exit_reason : null : null;
|
||
const native_exit_description = extra.native_exit_description;
|
||
const exit_description = typeof native_exit_description === "string" ? native_exit_description.length > 0 ? native_exit_description : null : null;
|
||
const native_tombstone_hash = extra.native_tombstone_hash;
|
||
const tombstone_hash = typeof native_tombstone_hash === "string" ? native_tombstone_hash.length > 0 ? native_tombstone_hash : null : null;
|
||
const native_tombstone_cause = extra.native_tombstone_cause;
|
||
const tombstone_cause = typeof native_tombstone_cause === "string" ? native_tombstone_cause.length > 0 ? native_tombstone_cause : null : null;
|
||
const native_tombstone = extra.native_tombstone;
|
||
const tombstone = typeof native_tombstone === "string" ? native_tombstone.length > 0 ? native_tombstone : null : null;
|
||
const native_tombstone_group_by = extra.native_tombstone_group_by;
|
||
const call_stack_tree = typeof native_tombstone_group_by === "string" ? native_tombstone_group_by.length > 0 ? native_tombstone_group_by : null : null;
|
||
const native_tombstone_origin = extra.native_tombstone_origin;
|
||
const r94 = {
|
||
did_crash: true,
|
||
sentry_issue_id,
|
||
client_track_timestamp,
|
||
exit_reason,
|
||
exit_description,
|
||
tombstone_hash,
|
||
tombstone_cause,
|
||
tombstone,
|
||
call_stack_tree,
|
||
binary_name: typeof native_tombstone_origin === "string" ? native_tombstone_origin.length > 0 ? native_tombstone_origin : null : null,
|
||
exception_message: getCrashErrorMessage(a0),
|
||
exception_stacktrace: getErrorStackTrace(a0),
|
||
js_error_message: null,
|
||
js_error_stacktrace: null
|
||
};
|
||
const persisted_error_message = extra.persisted_error_message;
|
||
r94.js_error_message = typeof persisted_error_message === "string" ? persisted_error_message.length > 0 ? persisted_error_message : null : null;
|
||
const persisted_error_stack = extra.persisted_error_stack;
|
||
r94.js_error_stacktrace = typeof persisted_error_stack === "string" ? persisted_error_stack.length > 0 ? persisted_error_stack : null : null;
|
||
AnalyticsUtils.track(APP_NATIVE_CRASH, r94);
|
||
} else {
|
||
AnalyticsUtils.track(AnalyticEvents.APP_CRASHED, {
|
||
path: location2.pathname,
|
||
client_track_timestamp,
|
||
sentry_issue_id,
|
||
extra: a1,
|
||
error_message: getCrashErrorMessage(a0),
|
||
error_level: level == null ? void 0 : level,
|
||
error_stack: getErrorStackTrace(a0)
|
||
});
|
||
}
|
||
const event_id3 = a0.event_id;
|
||
if (typeof event_id3 === "string" ? event_id3.length !== 0 : typeof event_id3 === "string") {
|
||
SentryUtils_native.markCrashHandled(event_id3);
|
||
}
|
||
const tags2 = [`reason:${r31 ? AppCrashedReasons.UNHANDLED_NATIVE_ERROR : AppCrashedReasons.UNHANDLED_JS_ERROR}`, ,];
|
||
if (level == null) {
|
||
level = "unknown";
|
||
}
|
||
tags2[1] = `level:${level}`;
|
||
MonitoringAgent.increment({
|
||
name: MetricEvents.APP_CRASHED,
|
||
tags: tags2
|
||
}, true);
|
||
}
|
||
return a0;
|
||
};
|
||
c1018_8 = reactNavigationIntegration();
|
||
c1018_9 = [new RegExp(`/v${window.GLOBAL_ENV.API_VERSION}${Endpoints.METRICS}`, "g"), new RegExp(`/v${window.GLOBAL_ENV.API_VERSION}${Endpoints.METRICS_V2}`, "g"), new RegExp(`/v${window.GLOBAL_ENV.API_VERSION}${Endpoints.TRACK}`, "g")];
|
||
c1018_10 = new Logger("Sentry");
|
||
_excluded = ["The operation couldn’t be completed. (com.apple.CallKit.error.requesttransaction", "Request has been terminated", "couldn't execute statement: database is disabled", "couldn't delete database: database is currently open", "database is no longer open"];
|
||
c1018_12 = 0.05;
|
||
c1018_13 = 0.005;
|
||
c1018_14 = false;
|
||
c1018_20 = filterThrottle({
|
||
maxBudgetMinute: 1,
|
||
maxBudgetHour: 15
|
||
});
|
||
export { c1018_8 as routingInstrumentation };
|
||
export function initSentry() {
|
||
const CrashReportingManager = NativeModules.CrashReportingManager;
|
||
if (CrashReportingManager != null) {
|
||
CrashReportingManager.getIsUserStaffForCrashReporting((a0) => {
|
||
let dsn;
|
||
L14: {
|
||
c1018_14 = a0;
|
||
const constants = getConstants();
|
||
const ReleaseChannel = constants.ReleaseChannel;
|
||
if (ReleaseChannel.indexOf("debug") === -1 && ReleaseChannel.indexOf("developer") === -1) {
|
||
c1018_10.verbose("Initialize", {
|
||
releaseChannel: ReleaseChannel,
|
||
isProductionChannel: isStable
|
||
});
|
||
if (isAndroid() && isStable && getDevice().indexOf("vivo") !== -1) {
|
||
break L14;
|
||
}
|
||
c1018_12 = 0.05;
|
||
const SentryDsn = constants.SentryDsn;
|
||
if (isStable) {
|
||
const isMetaQuest = _MetaQuestUtils_android.isMetaQuest();
|
||
dsn = SentryDsn;
|
||
if (isMetaQuest) {
|
||
c1018_12 = 1;
|
||
c1018_13 = 1;
|
||
dsn = SentryDsn;
|
||
}
|
||
} else {
|
||
c1018_12 = 1;
|
||
dsn = constants.SentryAlphaBetaDsn;
|
||
}
|
||
if (a0) {
|
||
dsn = constants.SentryStaffDsn;
|
||
c1018_12 = 1;
|
||
}
|
||
SentryUtils_native.getLastCrashReport().then((result) => {
|
||
if (result != null) {
|
||
trackCrash(result, {
|
||
crash_event_source: "startup_reconcile"
|
||
});
|
||
}
|
||
}).catch((error) => {
|
||
c1018_10.warn("Failed to replay pending crash report", error);
|
||
});
|
||
init({
|
||
tunnel: "/error-reporting-proxy/" + (isAndroid() ? "android" : "ios"),
|
||
autoInitializeNativeSdk: false,
|
||
beforeSend: filterError,
|
||
dist: "6099",
|
||
dsn,
|
||
environment: ReleaseChannel,
|
||
tracesSampleRate: 0,
|
||
sampleRate: 1,
|
||
ignoreErrors: _excluded,
|
||
release: "[email protected]+341202",
|
||
tracePropagationTargets: [PRIMARY_DOMAIN],
|
||
integrations: [c1018_8, featureFlagsIntegration(), reactNativeTracingIntegration({
|
||
shouldCreateSpanForRequest: (c28863_0) => !c1018_9.some((item) => c28863_0.match(item) != null)
|
||
})],
|
||
beforeBreadcrumb: (a0) => {
|
||
if (a0.data == null) {
|
||
a0.data = {};
|
||
}
|
||
const currentMemoryUsageKB = ProcessUtils_native.getCurrentMemoryUsageKB();
|
||
if (currentMemoryUsageKB != null) {
|
||
a0.data.client_performance_memory = currentMemoryUsageKB;
|
||
}
|
||
const currentCPUUsagePercent = ProcessUtils_native.getCurrentCPUUsagePercent();
|
||
if (currentCPUUsagePercent != null) {
|
||
a0.data.client_performance_cpu = currentCPUUsagePercent;
|
||
}
|
||
return a0;
|
||
}
|
||
});
|
||
setTag("buildNumber", "6099");
|
||
setTag("appVersion", constants.Version);
|
||
setTag("design_id", `${DesignIds.DESIGN_TABS_IA}`);
|
||
setTag("newArchEnabled", isFabric());
|
||
setTag("isBridgeless", _FabricUtils.isBridgeless);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|