@sentry/react-native 3.2.3 → 3.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -2
- package/RNSentry.podspec +1 -1
- package/android/build.gradle +1 -1
- package/dist/js/integrations/reactnativeerrorhandlers.d.ts +8 -0
- package/dist/js/integrations/reactnativeerrorhandlers.d.ts.map +1 -1
- package/dist/js/integrations/reactnativeerrorhandlers.js +51 -36
- package/dist/js/integrations/reactnativeerrorhandlers.js.map +1 -1
- package/dist/js/version.d.ts +1 -1
- package/dist/js/version.js +1 -1
- package/dist/js/version.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 3.2.4
|
|
4
4
|
|
|
5
|
-
- fix
|
|
5
|
+
- fix: Warn when promise rejections won't be caught #1886
|
|
6
|
+
- Bump: Sentry Android to 5.4.3 and Sentry Cocoa to 7.5.4 #1920
|
|
6
7
|
|
|
7
8
|
## 3.2.3
|
|
8
9
|
|
package/RNSentry.podspec
CHANGED
package/android/build.gradle
CHANGED
|
@@ -26,6 +26,14 @@ export declare class ReactNativeErrorHandlers implements Integration {
|
|
|
26
26
|
* Handle Promises
|
|
27
27
|
*/
|
|
28
28
|
private _handleUnhandledRejections;
|
|
29
|
+
/**
|
|
30
|
+
* Gets the promise rejection handlers, tries to get React Native's default one but otherwise will default to console.logging unhandled rejections.
|
|
31
|
+
*/
|
|
32
|
+
private _getPromiseRejectionTrackingOptions;
|
|
33
|
+
/**
|
|
34
|
+
* Checks if the promise is the same one or not, if not it will warn the user
|
|
35
|
+
*/
|
|
36
|
+
private _checkPromiseVersion;
|
|
29
37
|
/**
|
|
30
38
|
* Handle errors
|
|
31
39
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactnativeerrorhandlers.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/reactnativeerrorhandlers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAY,MAAM,eAAe,CAAC;AAKtD,uCAAuC;AACvC,UAAU,+BAA+B;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;CAC/B;
|
|
1
|
+
{"version":3,"file":"reactnativeerrorhandlers.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/reactnativeerrorhandlers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAY,MAAM,eAAe,CAAC;AAKtD,uCAAuC;AACvC,UAAU,+BAA+B;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAWD,2CAA2C;AAC3C,qBAAa,wBAAyB,YAAW,WAAW;IAC1D;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAA8B;IAEtD;;OAEG;IACI,IAAI,EAAE,MAAM,CAA+B;IAElD,yBAAyB;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkC;IAE3D,kBAAkB;gBACC,OAAO,CAAC,EAAE,+BAA+B;IAQ5D;;OAEG;IACI,SAAS,IAAI,IAAI;IAKxB;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAoClC;;OAEG;IACH,OAAO,CAAC,mCAAmC;IAmB3C;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAqB5B;;OAEG;IACH,OAAO,CAAC,cAAc;CAkEvB"}
|
|
@@ -24,59 +24,74 @@ export class ReactNativeErrorHandlers {
|
|
|
24
24
|
* Handle Promises
|
|
25
25
|
*/
|
|
26
26
|
_handleUnhandledRejections() {
|
|
27
|
-
var _a, _b;
|
|
28
27
|
if (this._options.onunhandledrejection) {
|
|
28
|
+
/*
|
|
29
|
+
In newer RN versions >=0.63, the global promise is not the same reference as the one imported from the promise library.
|
|
30
|
+
This is due to a version mismatch between promise versions. The version will need to be fixed with a package resolution.
|
|
31
|
+
We first run a check and show a warning if needed.
|
|
32
|
+
*/
|
|
33
|
+
this._checkPromiseVersion();
|
|
29
34
|
const tracking = require("promise/setimmediate/rejection-tracking");
|
|
35
|
+
const promiseRejectionTrackingOptions = this._getPromiseRejectionTrackingOptions();
|
|
30
36
|
tracking.disable();
|
|
31
37
|
tracking.enable({
|
|
32
38
|
allRejections: true,
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
39
|
onUnhandled: (id, error) => {
|
|
35
40
|
if (__DEV__) {
|
|
36
|
-
|
|
37
|
-
// eslint-disable-next-line no-console
|
|
38
|
-
console.warn(id, error);
|
|
41
|
+
promiseRejectionTrackingOptions.onUnhandled(id, error);
|
|
39
42
|
}
|
|
40
43
|
getCurrentHub().captureException(error, {
|
|
41
44
|
data: { id },
|
|
42
45
|
originalException: error,
|
|
43
46
|
});
|
|
44
47
|
},
|
|
48
|
+
onHandled: (id) => {
|
|
49
|
+
promiseRejectionTrackingOptions.onHandled(id);
|
|
50
|
+
},
|
|
45
51
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Gets the promise rejection handlers, tries to get React Native's default one but otherwise will default to console.logging unhandled rejections.
|
|
56
|
+
*/
|
|
57
|
+
_getPromiseRejectionTrackingOptions() {
|
|
58
|
+
try {
|
|
59
|
+
// Here we try to use React Native's original promise rejection handler.
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-member-access
|
|
61
|
+
return require("react-native/Libraries/promiseRejectionTrackingOptions")
|
|
62
|
+
.default;
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
// Default behavior if the React Native promise rejection handlers are not available such as an older RN version
|
|
66
|
+
return {
|
|
67
|
+
allRejections: true,
|
|
68
|
+
onUnhandled: (_id, error) => {
|
|
69
|
+
// eslint-disable-next-line no-console
|
|
70
|
+
console.warn(error);
|
|
71
|
+
},
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
73
|
+
onHandled: (_id) => { },
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Checks if the promise is the same one or not, if not it will warn the user
|
|
79
|
+
*/
|
|
80
|
+
_checkPromiseVersion() {
|
|
81
|
+
try {
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,import/no-extraneous-dependencies
|
|
52
83
|
const Promise = require("promise/setimmediate/core");
|
|
53
84
|
const _global = getGlobalObject();
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
Note: We do not want to overwrite the whole promise in case there are extensions present.
|
|
57
|
-
|
|
58
|
-
If the global promise is the same as the imported promise (expected in RN <0.63), we do nothing.
|
|
59
|
-
*/
|
|
60
|
-
const _onHandle = (_a = Promise._onHandle) !== null && _a !== void 0 ? _a : Promise._Y;
|
|
61
|
-
const _onReject = (_b = Promise._onReject) !== null && _b !== void 0 ? _b : Promise._Z;
|
|
62
|
-
if (Promise !== _global.Promise &&
|
|
63
|
-
typeof _onHandle !== "undefined" &&
|
|
64
|
-
typeof _onReject !== "undefined") {
|
|
65
|
-
if ("_onHandle" in _global.Promise && "_onReject" in _global.Promise) {
|
|
66
|
-
_global.Promise._onHandle = _onHandle;
|
|
67
|
-
_global.Promise._onReject = _onReject;
|
|
68
|
-
}
|
|
69
|
-
else if ("_Y" in _global.Promise && "_Z" in _global.Promise) {
|
|
70
|
-
_global.Promise._Y = _onHandle;
|
|
71
|
-
_global.Promise._Z = _onReject;
|
|
72
|
-
}
|
|
85
|
+
if (Promise !== _global.Promise) {
|
|
86
|
+
logger.warn("Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page.");
|
|
73
87
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
else {
|
|
89
|
+
logger.log("Unhandled promise rejections will be caught by Sentry.");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
// Do Nothing
|
|
94
|
+
logger.warn("Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page.");
|
|
80
95
|
}
|
|
81
96
|
}
|
|
82
97
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactnativeerrorhandlers.js","sourceRoot":"","sources":["../../../src/js/integrations/reactnativeerrorhandlers.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAe,QAAQ,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAa/E,2CAA2C;AAC3C,MAAM,OAAO,wBAAwB;IAcnC,kBAAkB;IAClB,YAAmB,OAAyC;QAT5D;;WAEG;QACI,SAAI,GAAW,wBAAwB,CAAC,EAAE,CAAC;QAOhD,IAAI,CAAC,QAAQ,mBACX,OAAO,EAAE,IAAI,EACb,oBAAoB,EAAE,IAAI,IACvB,OAAO,CACX,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,SAAS;QACd,IAAI,CAAC,0BAA0B,EAAE,CAAC;QAClC,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACK,0BAA0B;;QAChC,IAAI,IAAI,CAAC,QAAQ,CAAC,oBAAoB,EAAE;YACtC,MAAM,QAAQ,GAIV,OAAO,CAAC,yCAAyC,CAAC,CAAC;YAEvD,QAAQ,CAAC,OAAO,EAAE,CAAC;YACnB,QAAQ,CAAC,MAAM,CAAC;gBACd,aAAa,EAAE,IAAI;gBACnB,8DAA8D;gBAC9D,WAAW,EAAE,CAAC,EAAO,EAAE,KAAU,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,CAAC,GAAG,EAAE;wBAC3D,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;oBACjC,CAAC,CAAC,CAAC;iBACJ;qBAAM;oBACL,gFAAgF;oBAChF,mCAAmC;oBACnC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;iBAChC;YACH,CAAC,CAAA,CAAC,CAAC;SACJ;IACH,CAAC;;AArKD;;GAEG;AACW,2BAAE,GAAW,0BAA0B,CAAC","sourcesContent":["import { eventFromException } from \"@sentry/browser\";\nimport { getCurrentHub } from \"@sentry/core\";\nimport { Integration, Severity } from \"@sentry/types\";\nimport { addExceptionMechanism, getGlobalObject, logger } from \"@sentry/utils\";\n\nimport { ReactNativeClient } from \"../client\";\n\n/** ReactNativeErrorHandlers Options */\ninterface ReactNativeErrorHandlersOptions {\n onerror: boolean;\n onunhandledrejection: boolean;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ndeclare const global: any;\n\n/** ReactNativeErrorHandlers Integration */\nexport class ReactNativeErrorHandlers implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = \"ReactNativeErrorHandlers\";\n\n /**\n * @inheritDoc\n */\n public name: string = ReactNativeErrorHandlers.id;\n\n /** ReactNativeOptions */\n private readonly _options: ReactNativeErrorHandlersOptions;\n\n /** Constructor */\n public constructor(options?: ReactNativeErrorHandlersOptions) {\n this._options = {\n onerror: true,\n onunhandledrejection: true,\n ...options,\n };\n }\n\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n this._handleUnhandledRejections();\n this._handleOnError();\n }\n\n /**\n * Handle Promises\n */\n private _handleUnhandledRejections(): void {\n if (this._options.onunhandledrejection) {\n const tracking: {\n disable: () => void;\n enable: (arg: unknown) => void;\n // eslint-disable-next-line @typescript-eslint/no-var-requires,import/no-extraneous-dependencies\n } = require(\"promise/setimmediate/rejection-tracking\");\n\n tracking.disable();\n tracking.enable({\n allRejections: true,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onUnhandled: (id: any, error: any) => {\n if (__DEV__) {\n // We mimic the behavior of unhandled promise rejections showing up as a warning.\n // eslint-disable-next-line no-console\n console.warn(id, error);\n }\n getCurrentHub().captureException(error, {\n data: { id },\n originalException: error,\n });\n },\n });\n\n /* eslint-disable\n @typescript-eslint/no-var-requires,\n import/no-extraneous-dependencies,\n @typescript-eslint/no-explicit-any,\n @typescript-eslint/no-unsafe-member-access\n */\n const Promise = require(\"promise/setimmediate/core\");\n const _global = getGlobalObject<any>();\n\n /* In newer RN versions >=0.63, the global promise is not the same reference as the one imported from the promise library.\n Due to this, we need to take the methods that tracking.enable sets, and then set them on the global promise.\n Note: We do not want to overwrite the whole promise in case there are extensions present.\n\n If the global promise is the same as the imported promise (expected in RN <0.63), we do nothing.\n */\n const _onHandle = Promise._onHandle ?? Promise._Y;\n const _onReject = Promise._onReject ?? Promise._Z;\n\n if (\n Promise !== _global.Promise &&\n typeof _onHandle !== \"undefined\" &&\n typeof _onReject !== \"undefined\"\n ) {\n if (\"_onHandle\" in _global.Promise && \"_onReject\" in _global.Promise) {\n _global.Promise._onHandle = _onHandle;\n _global.Promise._onReject = _onReject;\n } else if (\"_Y\" in _global.Promise && \"_Z\" in _global.Promise) {\n _global.Promise._Y = _onHandle;\n _global.Promise._Z = _onReject;\n }\n }\n /* eslint-enable\n @typescript-eslint/no-var-requires,\n import/no-extraneous-dependencies,\n @typescript-eslint/no-explicit-any,\n @typescript-eslint/no-unsafe-member-access\n */\n }\n }\n /**\n * Handle errors\n */\n private _handleOnError(): void {\n if (this._options.onerror) {\n let handlingFatal = false;\n\n const defaultHandler =\n ErrorUtils.getGlobalHandler && ErrorUtils.getGlobalHandler();\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ErrorUtils.setGlobalHandler(async (error: any, isFatal?: boolean) => {\n // We want to handle fatals, but only in production mode.\n const shouldHandleFatal = isFatal && !__DEV__;\n if (shouldHandleFatal) {\n if (handlingFatal) {\n logger.log(\n \"Encountered multiple fatals in a row. The latest:\",\n error\n );\n return;\n }\n handlingFatal = true;\n }\n\n const currentHub = getCurrentHub();\n const client = currentHub.getClient<ReactNativeClient>();\n\n if (!client) {\n logger.error(\n \"Sentry client is missing, the error event might be lost.\",\n error\n );\n\n // If there is no client something is fishy, anyway we call the default handler\n defaultHandler(error, isFatal);\n\n return;\n }\n\n const options = client.getOptions();\n\n const event = await eventFromException(options, error, {\n originalException: error,\n });\n\n if (isFatal) {\n event.level = Severity.Fatal;\n\n addExceptionMechanism(event, {\n handled: false,\n type: \"onerror\",\n });\n }\n\n currentHub.captureEvent(event);\n\n if (!__DEV__) {\n void client.flush(options.shutdownTimeout || 2000).then(() => {\n defaultHandler(error, isFatal);\n });\n } else {\n // If in dev, we call the default handler anyway and hope the error will be sent\n // Just for a better dev experience\n defaultHandler(error, isFatal);\n }\n });\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"reactnativeerrorhandlers.js","sourceRoot":"","sources":["../../../src/js/integrations/reactnativeerrorhandlers.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAe,QAAQ,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAmB/E,2CAA2C;AAC3C,MAAM,OAAO,wBAAwB;IAcnC,kBAAkB;IAClB,YAAmB,OAAyC;QAT5D;;WAEG;QACI,SAAI,GAAW,wBAAwB,CAAC,EAAE,CAAC;QAOhD,IAAI,CAAC,QAAQ,mBACX,OAAO,EAAE,IAAI,EACb,oBAAoB,EAAE,IAAI,IACvB,OAAO,CACX,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,SAAS;QACd,IAAI,CAAC,0BAA0B,EAAE,CAAC;QAClC,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACK,0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AU,EAAE,CAAC;gBAEpC,MAAM,KAAK,GAAG,MAAM,kBAAkB,CAAC,OAAO,EAAE,KAAK,EAAE;oBACrD,iBAAiB,EAAE,KAAK;iBACzB,CAAC,CAAC;gBAEH,IAAI,OAAO,EAAE;oBACX,KAAK,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;oBAE7B,qBAAqB,CAAC,KAAK,EAAE;wBAC3B,OAAO,EAAE,KAAK;wBACd,IAAI,EAAE,SAAS;qBAChB,CAAC,CAAC;iBACJ;gBAED,UAAU,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;gBAE/B,IAAI,CAAC,OAAO,EAAE;oBACZ,KAAK,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;wBAC3D,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;oBACjC,CAAC,CAAC,CAAC;iBACJ;qBAAM;oBACL,gFAAgF;oBAChF,mCAAmC;oBACnC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;iBAChC;YACH,CAAC,CAAA,CAAC,CAAC;SACJ;IACH,CAAC;;AAvLD;;GAEG;AACW,2BAAE,GAAW,0BAA0B,CAAC","sourcesContent":["import { eventFromException } from \"@sentry/browser\";\nimport { getCurrentHub } from \"@sentry/core\";\nimport { Integration, Severity } from \"@sentry/types\";\nimport { addExceptionMechanism, getGlobalObject, logger } from \"@sentry/utils\";\n\nimport { ReactNativeClient } from \"../client\";\n\n/** ReactNativeErrorHandlers Options */\ninterface ReactNativeErrorHandlersOptions {\n onerror: boolean;\n onunhandledrejection: boolean;\n}\n\ninterface PromiseRejectionTrackingOptions {\n allRejections: boolean;\n onUnhandled: (id: string, error: unknown) => void;\n onHandled: (id: string) => void;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ndeclare const global: any;\n\n/** ReactNativeErrorHandlers Integration */\nexport class ReactNativeErrorHandlers implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = \"ReactNativeErrorHandlers\";\n\n /**\n * @inheritDoc\n */\n public name: string = ReactNativeErrorHandlers.id;\n\n /** ReactNativeOptions */\n private readonly _options: ReactNativeErrorHandlersOptions;\n\n /** Constructor */\n public constructor(options?: ReactNativeErrorHandlersOptions) {\n this._options = {\n onerror: true,\n onunhandledrejection: true,\n ...options,\n };\n }\n\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n this._handleUnhandledRejections();\n this._handleOnError();\n }\n\n /**\n * Handle Promises\n */\n private _handleUnhandledRejections(): void {\n if (this._options.onunhandledrejection) {\n /*\n In newer RN versions >=0.63, the global promise is not the same reference as the one imported from the promise library.\n This is due to a version mismatch between promise versions. The version will need to be fixed with a package resolution.\n We first run a check and show a warning if needed.\n */\n this._checkPromiseVersion();\n\n const tracking: {\n disable: () => void;\n enable: (arg: unknown) => void;\n // eslint-disable-next-line @typescript-eslint/no-var-requires,import/no-extraneous-dependencies\n } = require(\"promise/setimmediate/rejection-tracking\");\n\n const promiseRejectionTrackingOptions = this._getPromiseRejectionTrackingOptions();\n\n tracking.disable();\n tracking.enable({\n allRejections: true,\n onUnhandled: (id: string, error: Error) => {\n if (__DEV__) {\n promiseRejectionTrackingOptions.onUnhandled(id, error);\n }\n\n getCurrentHub().captureException(error, {\n data: { id },\n originalException: error,\n });\n },\n onHandled: (id: string) => {\n promiseRejectionTrackingOptions.onHandled(id);\n },\n });\n }\n }\n /**\n * Gets the promise rejection handlers, tries to get React Native's default one but otherwise will default to console.logging unhandled rejections.\n */\n private _getPromiseRejectionTrackingOptions(): PromiseRejectionTrackingOptions {\n try {\n // Here we try to use React Native's original promise rejection handler.\n // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-member-access\n return require(\"react-native/Libraries/promiseRejectionTrackingOptions\")\n .default;\n } catch (e) {\n // Default behavior if the React Native promise rejection handlers are not available such as an older RN version\n return {\n allRejections: true,\n onUnhandled: (_id: string, error: unknown) => {\n // eslint-disable-next-line no-console\n console.warn(error);\n },\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n onHandled: (_id: string) => {},\n };\n }\n }\n /**\n * Checks if the promise is the same one or not, if not it will warn the user\n */\n private _checkPromiseVersion(): void {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires,import/no-extraneous-dependencies\n const Promise = require(\"promise/setimmediate/core\");\n\n const _global = getGlobalObject<{ Promise: typeof Promise }>();\n\n if (Promise !== _global.Promise) {\n logger.warn(\n \"Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page.\"\n );\n } else {\n logger.log(\"Unhandled promise rejections will be caught by Sentry.\");\n }\n } catch (e) {\n // Do Nothing\n logger.warn(\n \"Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page.\"\n );\n }\n }\n /**\n * Handle errors\n */\n private _handleOnError(): void {\n if (this._options.onerror) {\n let handlingFatal = false;\n\n const defaultHandler =\n ErrorUtils.getGlobalHandler && ErrorUtils.getGlobalHandler();\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ErrorUtils.setGlobalHandler(async (error: any, isFatal?: boolean) => {\n // We want to handle fatals, but only in production mode.\n const shouldHandleFatal = isFatal && !__DEV__;\n if (shouldHandleFatal) {\n if (handlingFatal) {\n logger.log(\n \"Encountered multiple fatals in a row. The latest:\",\n error\n );\n return;\n }\n handlingFatal = true;\n }\n\n const currentHub = getCurrentHub();\n const client = currentHub.getClient<ReactNativeClient>();\n\n if (!client) {\n logger.error(\n \"Sentry client is missing, the error event might be lost.\",\n error\n );\n\n // If there is no client something is fishy, anyway we call the default handler\n defaultHandler(error, isFatal);\n\n return;\n }\n\n const options = client.getOptions();\n\n const event = await eventFromException(options, error, {\n originalException: error,\n });\n\n if (isFatal) {\n event.level = Severity.Fatal;\n\n addExceptionMechanism(event, {\n handled: false,\n type: \"onerror\",\n });\n }\n\n currentHub.captureEvent(event);\n\n if (!__DEV__) {\n void client.flush(options.shutdownTimeout || 2000).then(() => {\n defaultHandler(error, isFatal);\n });\n } else {\n // If in dev, we call the default handler anyway and hope the error will be sent\n // Just for a better dev experience\n defaultHandler(error, isFatal);\n }\n });\n }\n }\n}\n"]}
|
package/dist/js/version.d.ts
CHANGED
package/dist/js/version.js
CHANGED
package/dist/js/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC","sourcesContent":["export const SDK_NAME = \"sentry.javascript.react-native\";\nexport const SDK_VERSION = \"3.2.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC","sourcesContent":["export const SDK_NAME = \"sentry.javascript.react-native\";\nexport const SDK_VERSION = \"3.2.4\";\n"]}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@sentry/react-native",
|
|
3
3
|
"homepage": "https://github.com/getsentry/sentry-react-native",
|
|
4
4
|
"repository": "https://github.com/getsentry/sentry-react-native",
|
|
5
|
-
"version": "3.2.
|
|
5
|
+
"version": "3.2.4",
|
|
6
6
|
"description": "Official Sentry SDK for react-native",
|
|
7
7
|
"typings": "dist/js/index.d.ts",
|
|
8
8
|
"types": "dist/js/index.d.ts",
|