251 lines
9.2 KiB
JavaScript
251 lines
9.2 KiB
JavaScript
// Metro module 1016 (f1017).
|
|
import { isHermesEnabled } from "./Module1002";
|
|
import { RN_GLOBAL_OBJ } from "./Module816";
|
|
import { debug, captureException, getClient, getCurrentScope, addExceptionMechanism } from "./Module817";
|
|
import { isErrorLike, createSyntheticError } from "./Module813";
|
|
import { requireRejectionTracking } from "./getPromisePolyfill";
|
|
function $mk117576($env) {
|
|
return function(a0) {
|
|
a0($env[0]);
|
|
};
|
|
}
|
|
function $mk119073($env) {
|
|
return () => {
|
|
const r1 = $env;
|
|
(0, $env.$parent[1])(r1[0], r1[1]);
|
|
};
|
|
}
|
|
function $mk119074($env) {
|
|
return (a0) => {
|
|
debug.error("[ReactNativeErrorHandlers] Error while flushing the event cache after uncaught error.", a0);
|
|
};
|
|
}
|
|
let c833_3;
|
|
let env833 = {};
|
|
const c833_2 = (this ? this.__awaiter : this) || function(c12625_0, c12625_1, a2, c12625_3) {
|
|
let r2 = a2;
|
|
let Promise2 = a2;
|
|
if (!a2) {
|
|
Promise2 = Promise;
|
|
r2 = Promise2;
|
|
}
|
|
return new r2(function(a0, c23983_1) {
|
|
let rejected2, step2;
|
|
let c23983_0 = a0;
|
|
const fulfilled2 = function fulfilled(a0) {
|
|
try {
|
|
step2(c12625_3.next(a0));
|
|
} catch ($e) {
|
|
c23983_1($e);
|
|
}
|
|
};
|
|
rejected2 = function rejected(a0) {
|
|
try {
|
|
step2(c12625_3.throw(a0));
|
|
} catch ($e) {
|
|
c23983_1($e);
|
|
}
|
|
};
|
|
step2 = function step(a0) {
|
|
if (a0.done) {
|
|
c23983_0(a0.value);
|
|
} else {
|
|
let env28718;
|
|
let value = a0.value;
|
|
const r10 = env28718 = {};
|
|
env28718[0] = value;
|
|
if (!(value instanceof Promise2)) {
|
|
value = new Promise2($mk117576(r10));
|
|
}
|
|
value.then(fulfilled2, rejected2);
|
|
}
|
|
};
|
|
const r16 = c12625_3.apply(c12625_0, c12625_1 || []);
|
|
c12625_3 = r16;
|
|
const r18 = r16.next();
|
|
const { done, value } = r18;
|
|
if (done) {
|
|
a0(value);
|
|
} else {
|
|
let env23984;
|
|
const r21 = env23984 = {};
|
|
env23984[0] = value;
|
|
(value instanceof Promise2 ? value : new Promise2($mk117576(r21))).then(fulfilled2, rejected2);
|
|
}
|
|
});
|
|
};
|
|
c833_3 = {
|
|
onUnhandled: (a0, a1) => {
|
|
captureException(a1, {
|
|
data: {
|
|
id: a0
|
|
},
|
|
originalException: a1,
|
|
syntheticException: isErrorLike(a1) ? void 0 : createSyntheticError(),
|
|
mechanism: {
|
|
handled: true,
|
|
type: "onunhandledrejection"
|
|
}
|
|
});
|
|
},
|
|
onHandled: (a0) => {}
|
|
};
|
|
export const reactNativeErrorHandlersIntegration = function(r1 = {}) {
|
|
let c12626_0 = r1;
|
|
return {
|
|
name: "ReactNativeErrorHandlers",
|
|
setupOnce: () => {
|
|
const r10 = {
|
|
onerror: true,
|
|
onunhandledrejection: true,
|
|
patchGlobalPromise: true,
|
|
...c12626_0
|
|
};
|
|
if (r10.onunhandledrejection) {
|
|
(function setupUnhandledRejectionsTracking(a0) {
|
|
L27: {
|
|
try {
|
|
if (isHermesEnabled()) {
|
|
const HermesInternal2 = require(dependencyMap[1]).RN_GLOBAL_OBJ.HermesInternal;
|
|
if (HermesInternal2 !== null ? HermesInternal2 !== void 0 ? HermesInternal2.enablePromiseRejectionTracker : void 0 : void 0) {
|
|
const r29 = require(dependencyMap[1]).RN_GLOBAL_OBJ !== null ? require(dependencyMap[1]).RN_GLOBAL_OBJ !== void 0 ? require(dependencyMap[1]).RN_GLOBAL_OBJ.HermesInternal : void 0 : void 0;
|
|
const r41 = r29 !== null ? r29 !== void 0 ? r29.hasPromise : void 0 : void 0;
|
|
if (r41 !== null ? r41 !== void 0 ? r41.call(r29) : void 0 : void 0) {
|
|
require(dependencyMap[2]).debug.log("Using Hermes native promise rejection tracking");
|
|
const HermesInternal3 = require(dependencyMap[1]).RN_GLOBAL_OBJ.HermesInternal;
|
|
HermesInternal3.enablePromiseRejectionTracker({
|
|
allRejections: true,
|
|
onUnhandled: c833_3.onUnhandled,
|
|
onHandled: c833_3.onHandled
|
|
});
|
|
require(dependencyMap[2]).debug.log("Unhandled promise rejections will be caught by Sentry.");
|
|
break L27;
|
|
}
|
|
}
|
|
}
|
|
const isWeb = require(dependencyMap[0]).isWeb();
|
|
if (isWeb) {
|
|
require(dependencyMap[2]).debug.log("Using Browser JS promise rejection tracking for React Native Web");
|
|
require(dependencyMap[2]).addGlobalUnhandledRejectionInstrumentationHandler((a0) => {
|
|
captureException(a0, {
|
|
originalException: a0,
|
|
syntheticException: isErrorLike(a0) ? void 0 : createSyntheticError(),
|
|
mechanism: {
|
|
handled: false,
|
|
type: "onunhandledrejection"
|
|
}
|
|
});
|
|
});
|
|
} else if (a0) {
|
|
require(dependencyMap[4]).polyfillPromise();
|
|
(function attachUnhandledRejectionHandler() {
|
|
const r3 = requireRejectionTracking();
|
|
r3.enable({
|
|
allRejections: true,
|
|
onUnhandled: c833_3.onUnhandled,
|
|
onHandled: c833_3.onHandled
|
|
});
|
|
})();
|
|
require(dependencyMap[4]).checkPromiseAndWarn();
|
|
} else {
|
|
require(dependencyMap[2]).debug.log("Unhandled promise rejections will not be caught by Sentry.");
|
|
}
|
|
} catch ($e) {
|
|
debug.warn("Failed to set up promise rejection tracking. Unhandled promise rejections will not be caught by Sentry.See https://docs.sentry.io/platforms/react-native/troubleshooting/ for more details.");
|
|
}
|
|
}
|
|
})(r10.patchGlobalPromise);
|
|
}
|
|
if (r10.onerror) {
|
|
let env23985 = {
|
|
$parent: env833
|
|
};
|
|
env23985[0] = false;
|
|
const ErrorUtils = RN_GLOBAL_OBJ.ErrorUtils;
|
|
if (ErrorUtils) {
|
|
const getGlobalHandler = ErrorUtils.getGlobalHandler;
|
|
env23985[1] = getGlobalHandler !== null ? getGlobalHandler !== void 0 ? getGlobalHandler.call(ErrorUtils) : void 0 : void 0;
|
|
ErrorUtils.setGlobalHandler(async (a0, a1) => {
|
|
let env31866 = {
|
|
$parent: env23985
|
|
};
|
|
env31866[0] = a0;
|
|
env31866[1] = a1;
|
|
let c32090_0, c32090_1;
|
|
L23: {
|
|
L14: {
|
|
L11: {
|
|
let env32157;
|
|
const r28 = env31866;
|
|
c32090_1 = r28;
|
|
const r10 = env32157 = {
|
|
$parent: r28
|
|
};
|
|
c32090_0 = r10;
|
|
env32157[0] = void 0;
|
|
env32157[1] = void 0;
|
|
env32157[2] = void 0;
|
|
if (env31866[1]) {
|
|
if (env23985[0]) {
|
|
debug.log("Encountered multiple fatals in a row. The latest:", env31866[0]);
|
|
break L11;
|
|
}
|
|
env23985[0] = true;
|
|
}
|
|
const client = getClient();
|
|
env32157[0] = client;
|
|
if (client) {
|
|
const originalException = env31866[0];
|
|
const r57 = {
|
|
originalException,
|
|
attachments: getCurrentScope().getScopeData().attachments
|
|
};
|
|
env32157[1] = r57;
|
|
env32157[2] = await client.eventFromException(originalException, r57);
|
|
const r89 = env31866[1];
|
|
const r90 = env32157[2];
|
|
if (r89) {
|
|
r90.level = "fatal";
|
|
addExceptionMechanism(env32157[2], {
|
|
handled: false,
|
|
type: "onerror"
|
|
});
|
|
} else {
|
|
r90.level = "error";
|
|
addExceptionMechanism(env32157[2], {
|
|
handled: true,
|
|
type: "generic"
|
|
});
|
|
}
|
|
env32157[0].captureEvent(env32157[2], env32157[1]);
|
|
const r119 = env32157[0];
|
|
const shutdownTimeout = env32157[0].getOptions().shutdownTimeout;
|
|
if (shutdownTimeout) {
|
|
const r126 = r119.flush(shutdownTimeout);
|
|
const r129 = $mk119074(env23985.$parent);
|
|
r126.then($mk119073(env31866), r129);
|
|
break L23;
|
|
}
|
|
const r136 = r119.flush(2000);
|
|
const r139 = $mk119074(env23985.$parent);
|
|
r136.then($mk119073(env31866), r139);
|
|
break L23;
|
|
}
|
|
const r66 = env31866[0];
|
|
debug.error("Sentry client is missing, the error event might be lost.", r66);
|
|
(0, env23985[1])(r66, env31866[1]);
|
|
break L14;
|
|
}
|
|
return void 0;
|
|
}
|
|
return void 0;
|
|
}
|
|
});
|
|
} else {
|
|
debug.warn("ErrorUtils not found. Can be caused by different environment for example react-native-web.");
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|