1
- import { eventFromException } from " @sentry/browser" ;
2
- import { getCurrentHub } from " @sentry/core" ;
3
- import { Integration , Severity } from " @sentry/types" ;
4
- import { addExceptionMechanism , getGlobalObject , logger } from " @sentry/utils" ;
1
+ import { eventFromException } from ' @sentry/browser' ;
2
+ import { getCurrentHub } from ' @sentry/core' ;
3
+ import { Integration , Severity } from ' @sentry/types' ;
4
+ import { addExceptionMechanism , getGlobalObject , logger } from ' @sentry/utils' ;
5
5
6
- import { ReactNativeClient } from " ../client" ;
6
+ import { ReactNativeClient } from ' ../client' ;
7
7
8
8
/** ReactNativeErrorHandlers Options */
9
9
interface ReactNativeErrorHandlersOptions {
@@ -25,7 +25,7 @@ export class ReactNativeErrorHandlers implements Integration {
25
25
/**
26
26
* @inheritDoc
27
27
*/
28
- public static id : string = " ReactNativeErrorHandlers" ;
28
+ public static id : string = ' ReactNativeErrorHandlers' ;
29
29
30
30
/**
31
31
* @inheritDoc
@@ -79,16 +79,16 @@ export class ReactNativeErrorHandlers implements Integration {
79
79
/* eslint-disable import/no-extraneous-dependencies,@typescript-eslint/no-var-requires */
80
80
const {
81
81
polyfillGlobal,
82
- } = require ( " react-native/Libraries/Utilities/PolyfillFunctions" ) ;
82
+ } = require ( ' react-native/Libraries/Utilities/PolyfillFunctions' ) ;
83
83
84
84
// Below, we follow the exact way React Native initializes its promise library, and we globally replace it.
85
- const Promise = require ( " promise/setimmediate/es6-extensions" ) ;
85
+ const Promise = require ( ' promise/setimmediate/es6-extensions' ) ;
86
86
87
87
// As of RN 0.67 only done and finally are used
88
- require ( " promise/setimmediate/done" ) ;
89
- require ( " promise/setimmediate/finally" ) ;
88
+ require ( ' promise/setimmediate/done' ) ;
89
+ require ( ' promise/setimmediate/finally' ) ;
90
90
91
- polyfillGlobal ( " Promise" , ( ) => Promise ) ;
91
+ polyfillGlobal ( ' Promise' , ( ) => Promise ) ;
92
92
/* eslint-enable import/no-extraneous-dependencies,@typescript-eslint/no-var-requires */
93
93
}
94
94
/**
@@ -99,7 +99,7 @@ export class ReactNativeErrorHandlers implements Integration {
99
99
disable : ( ) => void ;
100
100
enable : ( arg : unknown ) => void ;
101
101
// eslint-disable-next-line import/no-extraneous-dependencies,@typescript-eslint/no-var-requires
102
- } = require ( " promise/setimmediate/rejection-tracking" ) ;
102
+ } = require ( ' promise/setimmediate/rejection-tracking' ) ;
103
103
104
104
const promiseRejectionTrackingOptions : PromiseRejectionTrackingOptions = {
105
105
onUnhandled : ( id , rejection = { } ) => {
@@ -112,7 +112,7 @@ export class ReactNativeErrorHandlers implements Integration {
112
112
// eslint-disable-next-line no-console
113
113
console . warn (
114
114
`Promise Rejection Handled (id: ${ id } )\n` +
115
- " This means you can ignore any previous messages of the form " +
115
+ ' This means you can ignore any previous messages of the form ' +
116
116
`"Possible Unhandled Promise Rejection (id: ${ id } ):"`
117
117
) ;
118
118
} ,
@@ -141,21 +141,21 @@ export class ReactNativeErrorHandlers implements Integration {
141
141
private _checkPromiseAndWarn ( ) : void {
142
142
try {
143
143
// eslint-disable-next-line @typescript-eslint/no-var-requires,import/no-extraneous-dependencies
144
- const Promise = require ( " promise/setimmediate/es6-extensions" ) ;
144
+ const Promise = require ( ' promise/setimmediate/es6-extensions' ) ;
145
145
146
146
const _global = getGlobalObject < { Promise : typeof Promise } > ( ) ;
147
147
148
148
if ( Promise !== _global . Promise ) {
149
149
logger . warn (
150
- " Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page."
150
+ ' Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page.'
151
151
) ;
152
152
} else {
153
- logger . log ( " Unhandled promise rejections will be caught by Sentry." ) ;
153
+ logger . log ( ' Unhandled promise rejections will be caught by Sentry.' ) ;
154
154
}
155
155
} catch ( e ) {
156
156
// Do Nothing
157
157
logger . warn (
158
- " Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page."
158
+ ' Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page.'
159
159
) ;
160
160
}
161
161
}
@@ -176,7 +176,7 @@ export class ReactNativeErrorHandlers implements Integration {
176
176
if ( shouldHandleFatal ) {
177
177
if ( handlingFatal ) {
178
178
logger . log (
179
- " Encountered multiple fatals in a row. The latest:" ,
179
+ ' Encountered multiple fatals in a row. The latest:' ,
180
180
error
181
181
) ;
182
182
return ;
@@ -189,7 +189,7 @@ export class ReactNativeErrorHandlers implements Integration {
189
189
190
190
if ( ! client ) {
191
191
logger . error (
192
- " Sentry client is missing, the error event might be lost." ,
192
+ ' Sentry client is missing, the error event might be lost.' ,
193
193
error
194
194
) ;
195
195
@@ -201,16 +201,16 @@ export class ReactNativeErrorHandlers implements Integration {
201
201
202
202
const options = client . getOptions ( ) ;
203
203
204
- const event = await eventFromException ( options , error , {
204
+ const event = await eventFromException ( error , {
205
205
originalException : error ,
206
- } ) ;
206
+ } , options . attachStacktrace ) ;
207
207
208
208
if ( isFatal ) {
209
209
event . level = Severity . Fatal ;
210
210
211
211
addExceptionMechanism ( event , {
212
212
handled : false ,
213
- type : " onerror" ,
213
+ type : ' onerror' ,
214
214
} ) ;
215
215
}
216
216
0 commit comments