@sentry/react-native 5.0.0-alpha.6 → 5.0.0-alpha.8

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.
Files changed (66) hide show
  1. package/CHANGELOG.md +89 -15
  2. package/RNSentry.podspec +2 -3
  3. package/android/build.gradle +1 -1
  4. package/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +24 -17
  5. package/dist/js/client.d.ts.map +1 -1
  6. package/dist/js/client.js +3 -2
  7. package/dist/js/client.js.map +1 -1
  8. package/dist/js/integrations/debugsymbolicator.d.ts +9 -0
  9. package/dist/js/integrations/debugsymbolicator.d.ts.map +1 -1
  10. package/dist/js/integrations/debugsymbolicator.js +0 -2
  11. package/dist/js/integrations/debugsymbolicator.js.map +1 -1
  12. package/dist/js/integrations/index.d.ts +1 -0
  13. package/dist/js/integrations/index.d.ts.map +1 -1
  14. package/dist/js/integrations/index.js +1 -0
  15. package/dist/js/integrations/index.js.map +1 -1
  16. package/dist/js/integrations/reactnativeerrorhandlers.d.ts.map +1 -1
  17. package/dist/js/integrations/reactnativeerrorhandlers.js +3 -3
  18. package/dist/js/integrations/reactnativeerrorhandlers.js.map +1 -1
  19. package/dist/js/integrations/reactnativeinfo.d.ts +23 -0
  20. package/dist/js/integrations/reactnativeinfo.d.ts.map +1 -0
  21. package/dist/js/integrations/reactnativeinfo.js +43 -0
  22. package/dist/js/integrations/reactnativeinfo.js.map +1 -0
  23. package/dist/js/integrations/sdkinfo.d.ts.map +1 -1
  24. package/dist/js/integrations/sdkinfo.js +0 -1
  25. package/dist/js/integrations/sdkinfo.js.map +1 -1
  26. package/dist/js/options.d.ts +13 -3
  27. package/dist/js/options.d.ts.map +1 -1
  28. package/dist/js/options.js.map +1 -1
  29. package/dist/js/sdk.d.ts +2 -2
  30. package/dist/js/sdk.d.ts.map +1 -1
  31. package/dist/js/sdk.js +8 -9
  32. package/dist/js/sdk.js.map +1 -1
  33. package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
  34. package/dist/js/tracing/reactnativetracing.js +5 -2
  35. package/dist/js/tracing/reactnativetracing.js.map +1 -1
  36. package/dist/js/tracing/reactnavigation.d.ts.map +1 -1
  37. package/dist/js/tracing/reactnavigation.js +4 -4
  38. package/dist/js/tracing/reactnavigation.js.map +1 -1
  39. package/dist/js/tracing/reactnavigationv4.d.ts.map +1 -1
  40. package/dist/js/tracing/reactnavigationv4.js +4 -4
  41. package/dist/js/tracing/reactnavigationv4.js.map +1 -1
  42. package/dist/js/transports/native.d.ts +6 -1
  43. package/dist/js/transports/native.d.ts.map +1 -1
  44. package/dist/js/transports/native.js +6 -4
  45. package/dist/js/transports/native.js.map +1 -1
  46. package/dist/js/user.d.ts +6 -0
  47. package/dist/js/user.d.ts.map +1 -0
  48. package/dist/js/user.js +1 -0
  49. package/dist/js/user.js.map +1 -0
  50. package/dist/js/utils/environment.d.ts +7 -0
  51. package/dist/js/utils/environment.d.ts.map +1 -0
  52. package/dist/js/utils/environment.js +14 -0
  53. package/dist/js/utils/environment.js.map +1 -0
  54. package/dist/js/utils/worldwide.d.ts +13 -0
  55. package/dist/js/utils/worldwide.d.ts.map +1 -0
  56. package/dist/js/utils/worldwide.js +4 -0
  57. package/dist/js/utils/worldwide.js.map +1 -0
  58. package/dist/js/version.d.ts +1 -1
  59. package/dist/js/version.js +1 -1
  60. package/dist/js/version.js.map +1 -1
  61. package/dist/js/wrapper.d.ts +0 -3
  62. package/dist/js/wrapper.d.ts.map +1 -1
  63. package/dist/js/wrapper.js +14 -12
  64. package/dist/js/wrapper.js.map +1 -1
  65. package/ios/RNSentry.mm +17 -19
  66. package/package.json +16 -16
package/CHANGELOG.md CHANGED
@@ -1,10 +1,98 @@
1
1
  # Changelog
2
2
 
3
- # Unreleased
3
+ ## 5.0.0-alpha.8
4
+
5
+ - Latest changes from 4.9.0
6
+
7
+ ## 4.9.0
8
+
9
+ ### Features
10
+
11
+ - Add `maxQueueSize` option ([#2578](https://github.com/getsentry/sentry-react-native/pull/2578))
12
+
13
+ ### Fixes
14
+
15
+ - Use `Scope` class rather than `Scope` type for top-level functions ([#2627](https://github.com/getsentry/sentry-react-native/pull/2627))
16
+
17
+ ### Dependencies
18
+
19
+ - Bump JavaScript SDK from v7.16.0 to v7.20.1 ([#2582](https://github.com/getsentry/sentry-react-native/pull/2582), [#2598](https://github.com/getsentry/sentry-react-native/pull/2598), [#2632](https://github.com/getsentry/sentry-react-native/pull/2632), [#2607](https://github.com/getsentry/sentry-react-native/pull/2607))
20
+ - [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7201)
21
+ - [diff](https://github.com/getsentry/sentry-javascript/compare/7.16.0...7.20.1)
22
+ - Bump Cocoa SDK from v7.29.0 to v7.31.2 ([#2592](https://github.com/getsentry/sentry-react-native/pull/2592), [#2601](https://github.com/getsentry/sentry-react-native/pull/2601), [#2629](https://github.com/getsentry/sentry-react-native/pull/2629))
23
+ - [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7312)
24
+ - [diff](https://github.com/getsentry/sentry-cocoa/compare/7.29.0...7.31.2)
25
+ - Bump Android SDK from v6.6.0 to v6.8.0 ([#2600](https://github.com/getsentry/sentry-react-native/pull/2600), [#2628](https://github.com/getsentry/sentry-react-native/pull/2628))
26
+ - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#680)
27
+ - [diff](https://github.com/getsentry/sentry-java/compare/6.6.0...6.8.0)
28
+
29
+ ## 4.8.0
30
+
31
+ ### Fixes
32
+
33
+ - Message event can have attached stacktrace ([#2577](https://github.com/getsentry/sentry-react-native/pull/2577))
34
+ - Fixed maximum call stack exceeded error resulting from large payloads ([#2579](https://github.com/getsentry/sentry-react-native/pull/2579))
35
+
36
+ ### Dependencies
37
+
38
+ - Bump Android SDK from v6.5.0 to v6.6.0 ([#2572](https://github.com/getsentry/sentry-react-native/pull/2572))
39
+ - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#660)
40
+ - [diff](https://github.com/getsentry/sentry-java/compare/6.5.0...6.6.0)
41
+ - Bump Cocoa SDK from v7.28.0 to v7.29.0 ([#2571](https://github.com/getsentry/sentry-react-native/pull/2571))
42
+ - [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7290)
43
+ - [diff](https://github.com/getsentry/sentry-cocoa/compare/7.28.0...7.29.0)
44
+
45
+ ## 5.0.0-alpha.7
46
+
47
+ - Latest changes from 4.7.1
48
+
49
+ ### Fixes
50
+
51
+ - Remove hardcoded Folly version ([#2558](https://github.com/getsentry/sentry-react-native/pull/2558))
52
+
53
+ ### Features
54
+
55
+ - Send react native js engine, turbo module, fabric flags and component stack in Event contexts ([#2552](https://github.com/getsentry/sentry-react-native/pull/2552))
56
+
57
+ ### Dependencies
58
+
59
+ - Bump CLI from v1.74.4 to v2.7.0 ([#2457](https://github.com/getsentry/sentry-react-native/pull/2457))
60
+ - [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#270)
61
+ - [diff](https://github.com/getsentry/sentry-cli/compare/1.74.4...2.7.0)
62
+ - Bump Android SDK from v6.5.0 to v6.6.0 ([#2572](https://github.com/getsentry/sentry-react-native/pull/2572))
63
+ - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#660)
64
+ - [diff](https://github.com/getsentry/sentry-java/compare/6.5.0...6.6.0)
65
+ - Bump Cocoa SDK from v7.28.0 to v7.29.0 ([#2571](https://github.com/getsentry/sentry-react-native/pull/2571))
66
+ - [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7290)
67
+ - [diff](https://github.com/getsentry/sentry-cocoa/compare/7.28.0...7.29.0)
68
+
69
+ ## 4.7.1
70
+
71
+ ### Fixes
72
+
73
+ - Remove duplicate sdk package record from envelope ([#2570](https://github.com/getsentry/sentry-react-native/pull/2570))
74
+ - Fix `appHangsTimeoutInterval` -> `appHangTimeoutInterval` option name ([#2574](https://github.com/getsentry/sentry-react-native/pull/2574))
75
+
76
+ ## 4.7.0
77
+
78
+ ### Dependencies
79
+
80
+ - Bump Android SDK from v6.4.3 to v6.5.0 ([#2535](https://github.com/getsentry/sentry-react-native/pull/2535))
81
+ - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#650)
82
+ - [diff](https://github.com/getsentry/sentry-java/compare/6.4.3...6.5.0)
83
+ - Bump JavaScript SDK from v7.14.2 to v7.16.0 ([#2536](https://github.com/getsentry/sentry-react-native/pull/2536), [#2561](https://github.com/getsentry/sentry-react-native/pull/2561))
84
+ - [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7160)
85
+ - [diff](https://github.com/getsentry/sentry-javascript/compare/7.14.2...7.16.0)
86
+ - Bump Cocoa SDK from v7.27.1 to v7.28.0 ([#2548](https://github.com/getsentry/sentry-react-native/pull/2548))
87
+ - [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7280)
88
+ - [diff](https://github.com/getsentry/sentry-cocoa/compare/7.27.1...7.28.0)
89
+
90
+ ## 5.0.0-alpha.6
4
91
 
5
92
  - Latest changes from 4.6.1
6
93
 
7
94
  ### Features
95
+
8
96
  - Add initial support for the RN New Architecture, backwards compatible RNSentry Turbo Module ([#2522](https://github.com/getsentry/sentry-react-native/pull/2522))
9
97
 
10
98
  ### Breaking changes
@@ -21,20 +109,6 @@
21
109
  - [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7150)
22
110
  - [diff](https://github.com/getsentry/sentry-javascript/compare/7.14.2...7.15.0)
23
111
 
24
- ## 5.0.0-alpha.6
25
-
26
- ### Various fixes & improvements
27
-
28
- - build(deps-dev): bump eslint-plugin-react from 7.20.6 to 7.31.10 (#2537) by @dependabot
29
- - build(deps): bump async from 2.6.3 to 2.6.4 in /sample (#2491) by @dependabot
30
- - build(deps): bump github/codeql-action from 2.1.26 to 2.1.27 (#2529) by @dependabot
31
- - chore(deps): update JavaScript SDK to v7.15.0 (#2536) by @github-actions
32
- - chore(deps): update Android SDK to v6.5.0 (#2535) by @github-actions
33
- - release: 4.6.1 (3c8631d1) by @getsentry-bot
34
- - chore(deps): update JavaScript SDK to v7.14.2 (#2526) by @github-actions
35
- - Allows collecting app start and slow/frozen frames if Native SDK is inited manually (#2517) by @marandaneto
36
- - Nested breadcrumb data on android was not treated correctly (#2519) by @marandaneto
37
-
38
112
  ## 4.6.1
39
113
 
40
114
  ### Fixes
package/RNSentry.podspec CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'json'
2
2
  version = JSON.parse(File.read('package.json'))["version"]
3
3
 
4
- folly_version = '2021.07.22.00'
5
4
  folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
6
5
 
7
6
  Pod::Spec.new do |s|
@@ -20,7 +19,7 @@ Pod::Spec.new do |s|
20
19
  s.preserve_paths = '*.js'
21
20
 
22
21
  s.dependency 'React-Core'
23
- s.dependency 'Sentry', '7.27.1'
22
+ s.dependency 'Sentry/HybridSDK', '7.31.2'
24
23
 
25
24
  s.source_files = 'ios/RNSentry.{h,mm}'
26
25
  s.public_header_files = 'ios/RNSentry.h'
@@ -34,7 +33,7 @@ Pod::Spec.new do |s|
34
33
  }
35
34
 
36
35
  s.dependency "React-Codegen"
37
- s.dependency "RCT-Folly", folly_version
36
+ s.dependency "RCT-Folly"
38
37
  s.dependency "RCTRequired"
39
38
  s.dependency "RCTTypeSafety"
40
39
  s.dependency "ReactCommon/turbomodule/core"
@@ -42,5 +42,5 @@ android {
42
42
 
43
43
  dependencies {
44
44
  implementation 'com.facebook.react:react-native:+'
45
- api 'io.sentry:sentry-android:6.5.0'
45
+ api 'io.sentry:sentry-android:6.8.0'
46
46
  }
@@ -130,6 +130,9 @@ public class RNSentryModuleImpl {
130
130
  if (rnOptions.hasKey("sendDefaultPii")) {
131
131
  options.setSendDefaultPii(rnOptions.getBoolean("sendDefaultPii"));
132
132
  }
133
+ if (rnOptions.hasKey("maxQueueSize")) {
134
+ options.setMaxQueueSize(rnOptions.getInt("maxQueueSize"));
135
+ }
133
136
 
134
137
  options.setBeforeSend((event, hint) -> {
135
138
  // React native internally throws a JavascriptException
@@ -291,45 +294,49 @@ public class RNSentryModuleImpl {
291
294
  }
292
295
  }
293
296
 
294
- public void setUser(final ReadableMap user, final ReadableMap otherUserKeys) {
297
+ public void setUser(final ReadableMap userKeys, final ReadableMap userDataKeys) {
295
298
  Sentry.configureScope(scope -> {
296
- if (user == null && otherUserKeys == null) {
299
+ if (userKeys == null && userDataKeys == null) {
297
300
  scope.setUser(null);
298
301
  } else {
299
302
  User userInstance = new User();
300
303
 
301
- if (user != null) {
302
- if (user.hasKey("email")) {
303
- userInstance.setEmail(user.getString("email"));
304
+ if (userKeys != null) {
305
+ if (userKeys.hasKey("email")) {
306
+ userInstance.setEmail(userKeys.getString("email"));
307
+ }
308
+
309
+ if (userKeys.hasKey("id")) {
310
+ userInstance.setId(userKeys.getString("id"));
304
311
  }
305
312
 
306
- if (user.hasKey("id")) {
307
- userInstance.setId(user.getString("id"));
313
+ if (userKeys.hasKey("username")) {
314
+ userInstance.setUsername(userKeys.getString("username"));
308
315
  }
309
316
 
310
- if (user.hasKey("username")) {
311
- userInstance.setUsername(user.getString("username"));
317
+ if (userKeys.hasKey("ip_address")) {
318
+ userInstance.setIpAddress(userKeys.getString("ip_address"));
312
319
  }
313
320
 
314
- if (user.hasKey("ip_address")) {
315
- userInstance.setIpAddress(user.getString("ip_address"));
321
+ if (userKeys.hasKey("segment")) {
322
+ userInstance.setSegment(userKeys.getString("segment"));
316
323
  }
317
324
  }
318
325
 
319
- if (otherUserKeys != null) {
320
- HashMap<String, String> otherUserKeysMap = new HashMap<>();
321
- ReadableMapKeySetIterator it = otherUserKeys.keySetIterator();
326
+ if (userDataKeys != null) {
327
+ HashMap<String, String> userDataMap = new HashMap<>();
328
+ ReadableMapKeySetIterator it = userDataKeys.keySetIterator();
322
329
  while (it.hasNextKey()) {
323
330
  String key = it.nextKey();
324
- String value = otherUserKeys.getString(key);
331
+ String value = userDataKeys.getString(key);
325
332
 
326
333
  // other is ConcurrentHashMap and can't have null values
327
334
  if (value != null) {
328
- otherUserKeysMap.put(key, value);
335
+ userDataMap.put(key, value);
329
336
  }
330
337
  }
331
338
 
332
- userInstance.setOthers(otherUserKeysMap);
339
+ userInstance.setData(userDataMap);
333
340
  }
334
341
 
335
342
  scope.setUser(userInstance);
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/js/client.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAGL,QAAQ,EACR,KAAK,EACL,SAAS,EAET,aAAa,EAEb,YAAY,EACb,MAAM,eAAe,CAAC;AAMvB,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAMrD;;;;;GAKG;AACH,qBAAa,iBAAkB,SAAQ,UAAU,CAAC,wBAAwB,CAAC;IAEzE,OAAO,CAAC,eAAe,CAAY;IAEnC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAgB;IAE/C;;;OAGG;gBACiB,OAAO,EAAE,wBAAwB;IAsCrD;;OAEG;IACI,kBAAkB,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC;IAIrF;;OAEG;IACI,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC;IAIxG;;;OAGG;IACI,WAAW,IAAI,IAAI;IAI1B;;OAEG;IACI,KAAK,IAAI,WAAW,CAAC,OAAO,CAAC;IAOpC;;OAEG;IACI,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IAYxD;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,QAAQ,EA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,7 @@ import { dateTimestampInSeconds, logger, SentryError } from '@sentry/utils';
5
5
  // @ts-ignore LogBox introduced in RN 0.63
6
6
  import { Alert, LogBox, YellowBox } from 'react-native';
7
7
  import { defaultSdkInfo } from './integrations/sdkinfo';
8
- import { NativeTransport } from './transports/native';
8
+ import { makeReactNativeTransport } from './transports/native';
9
9
  import { createUserFeedbackEnvelope, items } from './utils/envelope';
10
10
  import { mergeOutcomes } from './utils/outcome';
11
11
  import { NATIVE } from './wrapper';
@@ -24,7 +24,7 @@ export class ReactNativeClient extends BaseClient {
24
24
  if (!options.transport) {
25
25
  options.transport = (options, nativeFetch) => {
26
26
  if (NATIVE.isNativeTransportAvailable()) {
27
- return new NativeTransport();
27
+ return makeReactNativeTransport(options);
28
28
  }
29
29
  return makeFetchTransport(options, nativeFetch);
30
30
  };
@@ -50,6 +50,7 @@ export class ReactNativeClient extends BaseClient {
50
50
  stackParser: options.stackParser || defaultStackParser,
51
51
  integrations: [],
52
52
  _metadata: options._metadata,
53
+ attachStacktrace: options.attachStacktrace,
53
54
  });
54
55
  void this._initNativeSdk();
55
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/js/client.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGxF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAY1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5E,0CAA0C;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAA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AC,kBAAkB,EAAE;YAC/C,KAAK,CAAC,KAAK,CACT,QAAQ,EACR,qOAAqO,CACtO,CAAC;SACH;IACH,CAAC;IAED;;OAEG;IACK,qBAAqB,CAAC,QAAmB,EAAE,QAA8B;QAC/E,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YACvB,MAAM,gBAAgB,GAAqB;gBACzC,EAAE,IAAI,EAAE,eAAe,EAAE;gBACzB;oBACE,SAAS,EAAE,sBAAsB,EAAE;oBACnC,gBAAgB,EAAE,QAAQ;iBAC3B;aACF,CAAC;YAEF,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SACxC;IACH,CAAC;CACF","sourcesContent":["import { BrowserClient, defaultStackParser, makeFetchTransport } from '@sentry/browser';\nimport { BrowserTransportOptions } from '@sentry/browser/types/transports/types';\nimport { FetchImpl } from '@sentry/browser/types/transports/utils';\nimport { BaseClient } from '@sentry/core';\nimport {\n ClientReportEnvelope,\n ClientReportItem,\n Envelope,\n Event,\n EventHint,\n Outcome,\n SeverityLevel,\n Transport,\n UserFeedback,\n} from '@sentry/types';\nimport { dateTimestampInSeconds, logger, SentryError } from '@sentry/utils';\n// @ts-ignore LogBox introduced in RN 0.63\nimport { Alert, LogBox, YellowBox } from 'react-native';\n\nimport { defaultSdkInfo } from './integrations/sdkinfo';\nimport { ReactNativeClientOptions } from './options';\nimport { NativeTransport } from './transports/native';\nimport { createUserFeedbackEnvelope, items } from './utils/envelope';\nimport { mergeOutcomes } from './utils/outcome';\nimport { NATIVE } from './wrapper';\n\n/**\n * The Sentry React Native SDK Client.\n *\n * @see ReactNativeClientOptions for documentation on configuration options.\n * @see SentryClient for usage documentation.\n */\nexport class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {\n\n private _outcomesBuffer: Outcome[];\n\n private readonly _browserClient: BrowserClient;\n\n /**\n * Creates a new React Native SDK instance.\n * @param options Configuration options for this SDK.\n */\n public constructor(options: ReactNativeClientOptions) {\n if (!options.transport) {\n options.transport = (options: BrowserTransportOptions, nativeFetch?: FetchImpl): Transport => {\n if (NATIVE.isNativeTransportAvailable()) {\n return new NativeTransport();\n }\n return makeFetchTransport(options, nativeFetch);\n };\n }\n options._metadata = options._metadata || {};\n options._metadata.sdk = options._metadata.sdk || defaultSdkInfo;\n super(options);\n\n this._outcomesBuffer = [];\n\n // This is a workaround for now using fetch on RN, this is a known issue in react-native and only generates a warning\n // YellowBox deprecated and replaced with with LogBox in RN 0.63\n if (LogBox) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n LogBox.ignoreLogs(['Require cycle:']);\n } else {\n // eslint-disable-next-line deprecation/deprecation\n YellowBox.ignoreWarnings(['Require cycle:']);\n }\n\n this._browserClient = new BrowserClient({\n dsn: options.dsn,\n transport: options.transport,\n transportOptions: options.transportOptions,\n stackParser: options.stackParser || defaultStackParser,\n integrations: [],\n _metadata: options._metadata,\n });\n\n void this._initNativeSdk();\n }\n\n\n /**\n * @inheritDoc\n */\n public eventFromException(_exception: unknown, _hint?: EventHint): PromiseLike<Event> {\n return this._browserClient.eventFromException(_exception, _hint);\n }\n\n /**\n * @inheritDoc\n */\n public eventFromMessage(_message: string, _level?: SeverityLevel, _hint?: EventHint): PromiseLike<Event> {\n return this._browserClient.eventFromMessage(_message, _level, _hint);\n }\n\n /**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\n public nativeCrash(): void {\n NATIVE.nativeCrash();\n }\n\n /**\n * @inheritDoc\n */\n public close(): PromiseLike<boolean> {\n // As super.close() flushes queued events, we wait for that to finish before closing the native SDK.\n return super.close().then((result: boolean) => {\n return NATIVE.closeNativeSdk().then(() => result) as PromiseLike<boolean>;\n });\n }\n\n /**\n * Sends user feedback to Sentry.\n */\n public captureUserFeedback(feedback: UserFeedback): void {\n const envelope = createUserFeedbackEnvelope(\n feedback,\n {\n metadata: this._options._metadata,\n dsn: this.getDsn(),\n tunnel: this._options.tunnel,\n },\n );\n this._sendEnvelope(envelope);\n }\n\n /**\n * @inheritdoc\n */\n protected _sendEnvelope(envelope: Envelope): void {\n const outcomes = this._clearOutcomes();\n this._outcomesBuffer = mergeOutcomes(this._outcomesBuffer, outcomes);\n\n if (this._options.sendClientReports) {\n this._attachClientReportTo(this._outcomesBuffer, envelope as ClientReportEnvelope);\n }\n\n let shouldClearOutcomesBuffer = true;\n if (this._transport && this._dsn) {\n this._transport.send(envelope)\n .then(null, reason => {\n if (reason instanceof SentryError) { // SentryError is thrown by SyncPromise\n shouldClearOutcomesBuffer = false;\n // If this is called asynchronously we want the _outcomesBuffer to be cleared\n logger.error('SentryError while sending event, keeping outcomes buffer:', reason);\n } else {\n logger.error('Error while sending event:', reason);\n }\n });\n } else {\n logger.error('Transport disabled');\n }\n\n if (shouldClearOutcomesBuffer) {\n this._outcomesBuffer = []; // if send fails synchronously the _outcomesBuffer will stay intact\n }\n }\n\n /**\n * Starts native client with dsn and options\n */\n private async _initNativeSdk(): Promise<void> {\n let didCallNativeInit = false;\n\n try {\n didCallNativeInit = await NATIVE.initNativeSdk(this._options);\n } catch (_) {\n this._showCannotConnectDialog();\n } finally {\n try {\n this._options.onReady?.({ didCallNativeInit });\n } catch (error) {\n logger.error('The OnReady callback threw an error: ', error);\n }\n }\n }\n\n /**\n * If the user is in development mode, and the native nagger is enabled then it will show an alert.\n */\n private _showCannotConnectDialog(): void {\n if (__DEV__ && this._options.enableNativeNagger) {\n Alert.alert(\n 'Sentry',\n 'Warning, could not connect to Sentry native SDK.\\nIf you do not want to use the native component please pass `enableNative: false` in the options.\\nVisit: https://docs.sentry.io/platforms/react-native/#linking for more details.'\n );\n }\n }\n\n /**\n * Attaches a client report from outcomes to the envelope.\n */\n private _attachClientReportTo(outcomes: Outcome[], envelope: ClientReportEnvelope): void {\n if (outcomes.length > 0) {\n const clientReportItem: ClientReportItem = [\n { type: 'client_report' },\n {\n timestamp: dateTimestampInSeconds(),\n discarded_events: outcomes,\n },\n ];\n\n envelope[items].push(clientReportItem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EAAE;YAC7B,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC,CAAC,mEAAmE;SAC/F;IACH,CAAC;IAED;;OAEG;IACW,cAAc;;;YAC1B,IAAI,iBAAiB,GAAG,KAAK,CAAC;YAE9B,IAAI;gBACF,iBAAiB,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aAC/D;YAAC,OAAO,CAAC,EAAE;gBACV,IAAI,CAAC,wBAAwB,EAAE,CAAC;aACjC;oBAAS;gBACR,IAAI;oBACF,MAAA,MAAA,IAAI,CAAC,QAAQ,EAAC,OAAO,mDAAG,EAAE,iBAAiB,EAAE,EAAE;iBAChD;gBAAC,OAAO,KAAK,EAAE;oBACd,MAAM,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;iBAC9D;aACF;;KACF;IAED;;OAEG;IACK,wBAAwB;QAC9B,IAAI,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,EAAE;YAC/C,KAAK,CAAC,KAAK,CACT,QAAQ,EACR,qOAAqO,CACtO,CAAC;SACH;IACH,CAAC;IAED;;OAEG;IACK,qBAAqB,CAAC,QAAmB,EAAE,QAA8B;QAC/E,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YACvB,MAAM,gBAAgB,GAAqB;gBACzC,EAAE,IAAI,EAAE,eAAe,EAAE;gBACzB;oBACE,SAAS,EAAE,sBAAsB,EAAE;oBACnC,gBAAgB,EAAE,QAAQ;iBAC3B;aACF,CAAC;YAEF,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SACxC;IACH,CAAC;CACF","sourcesContent":["import { BrowserClient, defaultStackParser, makeFetchTransport } from '@sentry/browser';\nimport { FetchImpl } from '@sentry/browser/types/transports/utils';\nimport { BaseClient } from '@sentry/core';\nimport {\n ClientReportEnvelope,\n ClientReportItem,\n Envelope,\n Event,\n EventHint,\n Outcome,\n SeverityLevel,\n Transport,\n UserFeedback,\n} from '@sentry/types';\nimport { dateTimestampInSeconds, logger, SentryError } from '@sentry/utils';\n// @ts-ignore LogBox introduced in RN 0.63\nimport { Alert, LogBox, YellowBox } from 'react-native';\n\nimport { defaultSdkInfo } from './integrations/sdkinfo';\nimport { ReactNativeClientOptions, ReactNativeTransportOptions } from './options';\nimport { makeReactNativeTransport } from './transports/native';\nimport { createUserFeedbackEnvelope, items } from './utils/envelope';\nimport { mergeOutcomes } from './utils/outcome';\nimport { NATIVE } from './wrapper';\n\n/**\n * The Sentry React Native SDK Client.\n *\n * @see ReactNativeClientOptions for documentation on configuration options.\n * @see SentryClient for usage documentation.\n */\nexport class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {\n\n private _outcomesBuffer: Outcome[];\n\n private readonly _browserClient: BrowserClient;\n\n /**\n * Creates a new React Native SDK instance.\n * @param options Configuration options for this SDK.\n */\n public constructor(options: ReactNativeClientOptions) {\n if (!options.transport) {\n options.transport = (options: ReactNativeTransportOptions, nativeFetch?: FetchImpl): Transport => {\n if (NATIVE.isNativeTransportAvailable()) {\n return makeReactNativeTransport(options);\n }\n return makeFetchTransport(options, nativeFetch);\n };\n }\n options._metadata = options._metadata || {};\n options._metadata.sdk = options._metadata.sdk || defaultSdkInfo;\n super(options);\n\n this._outcomesBuffer = [];\n\n // This is a workaround for now using fetch on RN, this is a known issue in react-native and only generates a warning\n // YellowBox deprecated and replaced with with LogBox in RN 0.63\n if (LogBox) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n LogBox.ignoreLogs(['Require cycle:']);\n } else {\n // eslint-disable-next-line deprecation/deprecation\n YellowBox.ignoreWarnings(['Require cycle:']);\n }\n\n this._browserClient = new BrowserClient({\n dsn: options.dsn,\n transport: options.transport,\n transportOptions: options.transportOptions,\n stackParser: options.stackParser || defaultStackParser,\n integrations: [],\n _metadata: options._metadata,\n attachStacktrace: options.attachStacktrace,\n });\n\n void this._initNativeSdk();\n }\n\n\n /**\n * @inheritDoc\n */\n public eventFromException(_exception: unknown, _hint?: EventHint): PromiseLike<Event> {\n return this._browserClient.eventFromException(_exception, _hint);\n }\n\n /**\n * @inheritDoc\n */\n public eventFromMessage(_message: string, _level?: SeverityLevel, _hint?: EventHint): PromiseLike<Event> {\n return this._browserClient.eventFromMessage(_message, _level, _hint);\n }\n\n /**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\n public nativeCrash(): void {\n NATIVE.nativeCrash();\n }\n\n /**\n * @inheritDoc\n */\n public close(): PromiseLike<boolean> {\n // As super.close() flushes queued events, we wait for that to finish before closing the native SDK.\n return super.close().then((result: boolean) => {\n return NATIVE.closeNativeSdk().then(() => result) as PromiseLike<boolean>;\n });\n }\n\n /**\n * Sends user feedback to Sentry.\n */\n public captureUserFeedback(feedback: UserFeedback): void {\n const envelope = createUserFeedbackEnvelope(\n feedback,\n {\n metadata: this._options._metadata,\n dsn: this.getDsn(),\n tunnel: this._options.tunnel,\n },\n );\n this._sendEnvelope(envelope);\n }\n\n /**\n * @inheritdoc\n */\n protected _sendEnvelope(envelope: Envelope): void {\n const outcomes = this._clearOutcomes();\n this._outcomesBuffer = mergeOutcomes(this._outcomesBuffer, outcomes);\n\n if (this._options.sendClientReports) {\n this._attachClientReportTo(this._outcomesBuffer, envelope as ClientReportEnvelope);\n }\n\n let shouldClearOutcomesBuffer = true;\n if (this._transport && this._dsn) {\n this._transport.send(envelope)\n .then(null, reason => {\n if (reason instanceof SentryError) { // SentryError is thrown by SyncPromise\n shouldClearOutcomesBuffer = false;\n // If this is called asynchronously we want the _outcomesBuffer to be cleared\n logger.error('SentryError while sending event, keeping outcomes buffer:', reason);\n } else {\n logger.error('Error while sending event:', reason);\n }\n });\n } else {\n logger.error('Transport disabled');\n }\n\n if (shouldClearOutcomesBuffer) {\n this._outcomesBuffer = []; // if send fails synchronously the _outcomesBuffer will stay intact\n }\n }\n\n /**\n * Starts native client with dsn and options\n */\n private async _initNativeSdk(): Promise<void> {\n let didCallNativeInit = false;\n\n try {\n didCallNativeInit = await NATIVE.initNativeSdk(this._options);\n } catch (_) {\n this._showCannotConnectDialog();\n } finally {\n try {\n this._options.onReady?.({ didCallNativeInit });\n } catch (error) {\n logger.error('The OnReady callback threw an error: ', error);\n }\n }\n }\n\n /**\n * If the user is in development mode, and the native nagger is enabled then it will show an alert.\n */\n private _showCannotConnectDialog(): void {\n if (__DEV__ && this._options.enableNativeNagger) {\n Alert.alert(\n 'Sentry',\n 'Warning, could not connect to Sentry native SDK.\\nIf you do not want to use the native component please pass `enableNative: false` in the options.\\nVisit: https://docs.sentry.io/platforms/react-native/#linking for more details.'\n );\n }\n }\n\n /**\n * Attaches a client report from outcomes to the envelope.\n */\n private _attachClientReportTo(outcomes: Outcome[], envelope: ClientReportEnvelope): void {\n if (outcomes.length > 0) {\n const clientReportItem: ClientReportItem = [\n { type: 'client_report' },\n {\n timestamp: dateTimestampInSeconds(),\n discarded_events: outcomes,\n },\n ];\n\n envelope[items].push(clientReportItem);\n }\n }\n}\n"]}
@@ -1,4 +1,13 @@
1
1
  import { Integration } from '@sentry/types';
2
+ /**
3
+ * React Native Error
4
+ */
5
+ export declare type ReactNativeError = Error & {
6
+ framesToPop?: number;
7
+ jsEngine?: string;
8
+ preventSymbolication?: boolean;
9
+ componentStack?: string;
10
+ };
2
11
  /** Tries to symbolicate the JS stack trace on the device. */
3
12
  export declare class DebugSymbolicator implements Integration {
4
13
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"debugsymbolicator.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicator.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,WAAW,EAAc,MAAM,eAAe,CAAC;AAgC1E,6DAA6D;AAC7D,qBAAa,iBAAkB,YAAW,WAAW;IACnD;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAuB;IAC/C;;OAEG;IACI,IAAI,EAAE,MAAM,CAAwB;IAE3C;;OAEG;IACI,SAAS,IAAI,IAAI;IAoCxB;;;OAGG;YACW,YAAY;IAsC1B;;;OAGG;YACW,uCAAuC;IAqDrD;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAW7B;;;;;OAKG;YACW,iBAAiB;CAgChC"}
1
+ {"version":3,"file":"debugsymbolicator.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicator.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,WAAW,EAAc,MAAM,eAAe,CAAC;AAsB1E;;GAEG;AACH,oBAAY,gBAAgB,GAAG,KAAK,GAAG;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,6DAA6D;AAC7D,qBAAa,iBAAkB,YAAW,WAAW;IACnD;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAuB;IAC/C;;OAEG;IACI,IAAI,EAAE,MAAM,CAAwB;IAE3C;;OAEG;IACI,SAAS,IAAI,IAAI;IA6BxB;;;OAGG;YACW,YAAY;IAsC1B;;;OAGG;YACW,uCAAuC;IAqDrD;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAW7B;;;;;OAKG;YACW,iBAAiB;CAgChC"}
@@ -30,8 +30,6 @@ export class DebugSymbolicator {
30
30
  // In RN 0.64 `parseErrorStack` now only takes a string
31
31
  stack = parseErrorStack(reactError.stack);
32
32
  }
33
- // Ideally this should go into contexts but android sdk doesn't support it
34
- event.extra = Object.assign(Object.assign({}, event.extra), { componentStack: reactError.componentStack, jsEngine: reactError.jsEngine });
35
33
  yield self._symbolicate(event, stack);
36
34
  event.platform = 'node'; // Setting platform node makes sure we do not show source maps errors
37
35
  return event;
@@ -1 +1 @@
1
- {"version":3,"file":"debugsymbolicator.js","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicator.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,uBAAuB,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C;gBAElC,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;aACjC;;KACF;;AAxMD;;GAEG;AACW,oBAAE,GAAW,mBAAmB,CAAC","sourcesContent":["import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';\nimport { Event, EventHint, Integration, StackFrame } from '@sentry/types';\nimport { addContextToFrame, logger } from '@sentry/utils';\n\nconst INTERNAL_CALLSITES_REGEX = new RegExp(\n ['ReactNativeRenderer-dev\\\\.js$', 'MessageQueue\\\\.js$'].join('|')\n);\n\ninterface GetDevServer {\n (): { url: string };\n}\n\n/**\n * React Native Stack Frame\n */\ninterface ReactNativeFrame {\n // arguments: []\n column: number;\n file: string;\n lineNumber: number;\n methodName: string;\n}\n\n/**\n * React Native Error\n */\ntype ReactNativeError = Error & {\n framesToPop?: number;\n jsEngine?: string;\n preventSymbolication?: boolean;\n componentStack?: string;\n};\n\n/** Tries to symbolicate the JS stack trace on the device. */\nexport class DebugSymbolicator implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'DebugSymbolicator';\n /**\n * @inheritDoc\n */\n public name: string = DebugSymbolicator.id;\n\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n addGlobalEventProcessor(async (event: Event, hint?: EventHint) => {\n const self = getCurrentHub().getIntegration(DebugSymbolicator);\n\n if (!self || hint === undefined || hint.originalException === undefined) {\n return event;\n }\n\n const reactError = hint.originalException as ReactNativeError;\n\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const parseErrorStack = require('react-native/Libraries/Core/Devtools/parseErrorStack');\n\n let stack;\n try {\n stack = parseErrorStack(reactError);\n } catch (e) {\n // In RN 0.64 `parseErrorStack` now only takes a string\n stack = parseErrorStack(reactError.stack);\n }\n\n // Ideally this should go into contexts but android sdk doesn't support it\n event.extra = {\n ...event.extra,\n componentStack: reactError.componentStack,\n jsEngine: reactError.jsEngine,\n };\n\n await self._symbolicate(event, stack);\n\n event.platform = 'node'; // Setting platform node makes sure we do not show source maps errors\n\n return event;\n });\n }\n\n /**\n * Symbolicates the stack on the device talking to local dev server.\n * Mutates the passed event.\n */\n private async _symbolicate(\n event: Event,\n stack: string | undefined\n ): Promise<void> {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const symbolicateStackTrace = require('react-native/Libraries/Core/Devtools/symbolicateStackTrace');\n const prettyStack = await symbolicateStackTrace(stack);\n\n if (prettyStack) {\n let newStack = prettyStack;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (prettyStack.stack) {\n // This has been changed in an react-native version so stack is contained in here\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n newStack = prettyStack.stack;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const stackWithoutInternalCallsites = newStack.filter(\n (frame: { file?: string }) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n frame.file && frame.file.match(INTERNAL_CALLSITES_REGEX) === null\n );\n\n const symbolicatedFrames = await this._convertReactNativeFramesToSentryFrames(\n stackWithoutInternalCallsites\n );\n this._replaceFramesInEvent(event, symbolicatedFrames);\n } else {\n logger.error('The stack is null');\n }\n } catch (error) {\n if (error instanceof Error) {\n logger.warn(`Unable to symbolicate stack trace: ${error.message}`);\n }\n }\n }\n\n /**\n * Converts ReactNativeFrames to frames in the Sentry format\n * @param frames ReactNativeFrame[]\n */\n private async _convertReactNativeFramesToSentryFrames(\n frames: ReactNativeFrame[]\n ): Promise<StackFrame[]> {\n let getDevServer: GetDevServer;\n try {\n getDevServer = require('react-native/Libraries/Core/Devtools/getDevServer');\n } catch (_oO) {\n // We can't load devserver URL\n }\n // Below you will find lines marked with :HACK to prevent showing errors in the sentry ui\n // But since this is a debug only feature: This is Fine (TM)\n return Promise.all(\n frames.map(\n async (frame: ReactNativeFrame): Promise<StackFrame> => {\n let inApp = !!frame.column && !!frame.lineNumber;\n inApp =\n inApp &&\n frame.file !== undefined &&\n !frame.file.includes('node_modules') &&\n !frame.file.includes('native code');\n\n const newFrame: StackFrame = {\n colno: frame.column,\n filename: frame.file,\n function: frame.methodName,\n in_app: inApp,\n lineno: inApp ? frame.lineNumber : undefined, // :HACK\n platform: inApp ? 'javascript' : 'node', // :HACK\n };\n\n // The upstream `react-native@0.61` delegates parsing of stacks to `stacktrace-parser`, which is buggy and\n // leaves a trailing `(address at` in the function name.\n // `react-native@0.62` seems to have custom logic to parse hermes frames specially.\n // Anyway, all we do here is throw away the bogus suffix.\n if (newFrame.function) {\n const addressAtPos = newFrame.function.indexOf('(address at');\n if (addressAtPos >= 0) {\n newFrame.function = newFrame.function\n .substr(0, addressAtPos)\n .trim();\n }\n }\n\n if (inApp) {\n await this._addSourceContext(newFrame, getDevServer);\n }\n\n return newFrame;\n }\n )\n );\n }\n\n /**\n * Replaces the frames in the exception of a error.\n * @param event Event\n * @param frames StackFrame[]\n */\n private _replaceFramesInEvent(event: Event, frames: StackFrame[]): void {\n if (\n event.exception &&\n event.exception.values &&\n event.exception.values[0] &&\n event.exception.values[0].stacktrace\n ) {\n event.exception.values[0].stacktrace.frames = frames.reverse();\n }\n }\n\n /**\n * This tries to add source context for in_app Frames\n *\n * @param frame StackFrame\n * @param getDevServer function from RN to get DevServer URL\n */\n private async _addSourceContext(\n frame: StackFrame,\n getDevServer?: GetDevServer\n ): Promise<void> {\n let response;\n\n const segments = frame.filename?.split('/') ?? [];\n\n if (getDevServer) {\n for (const idx in segments) {\n if (Object.prototype.hasOwnProperty.call(segments, idx)) {\n response = await fetch(\n `${getDevServer().url}${segments.slice(-idx).join('/')}`,\n {\n method: 'GET',\n }\n );\n\n if (response.ok) {\n break;\n }\n }\n }\n }\n\n if (response && response.ok) {\n const content = await response.text();\n const lines = content.split('\\n');\n\n addContextToFrame(lines, frame);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"debugsymbolicator.js","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicator.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC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rame } from '@sentry/types';\nimport { addContextToFrame, logger } from '@sentry/utils';\n\nconst INTERNAL_CALLSITES_REGEX = new RegExp(\n ['ReactNativeRenderer-dev\\\\.js$', 'MessageQueue\\\\.js$'].join('|')\n);\n\ninterface GetDevServer {\n (): { url: string };\n}\n\n/**\n * React Native Stack Frame\n */\ninterface ReactNativeFrame {\n // arguments: []\n column: number;\n file: string;\n lineNumber: number;\n methodName: string;\n}\n\n/**\n * React Native Error\n */\nexport type ReactNativeError = Error & {\n framesToPop?: number;\n jsEngine?: string;\n preventSymbolication?: boolean;\n componentStack?: string;\n};\n\n/** Tries to symbolicate the JS stack trace on the device. */\nexport class DebugSymbolicator implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'DebugSymbolicator';\n /**\n * @inheritDoc\n */\n public name: string = DebugSymbolicator.id;\n\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n addGlobalEventProcessor(async (event: Event, hint?: EventHint) => {\n const self = getCurrentHub().getIntegration(DebugSymbolicator);\n\n if (!self || hint === undefined || hint.originalException === undefined) {\n return event;\n }\n\n const reactError = hint.originalException as ReactNativeError;\n\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const parseErrorStack = require('react-native/Libraries/Core/Devtools/parseErrorStack');\n\n let stack;\n try {\n stack = parseErrorStack(reactError);\n } catch (e) {\n // In RN 0.64 `parseErrorStack` now only takes a string\n stack = parseErrorStack(reactError.stack);\n }\n\n await self._symbolicate(event, stack);\n\n event.platform = 'node'; // Setting platform node makes sure we do not show source maps errors\n\n return event;\n });\n }\n\n /**\n * Symbolicates the stack on the device talking to local dev server.\n * Mutates the passed event.\n */\n private async _symbolicate(\n event: Event,\n stack: string | undefined\n ): Promise<void> {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const symbolicateStackTrace = require('react-native/Libraries/Core/Devtools/symbolicateStackTrace');\n const prettyStack = await symbolicateStackTrace(stack);\n\n if (prettyStack) {\n let newStack = prettyStack;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (prettyStack.stack) {\n // This has been changed in an react-native version so stack is contained in here\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n newStack = prettyStack.stack;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const stackWithoutInternalCallsites = newStack.filter(\n (frame: { file?: string }) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n frame.file && frame.file.match(INTERNAL_CALLSITES_REGEX) === null\n );\n\n const symbolicatedFrames = await this._convertReactNativeFramesToSentryFrames(\n stackWithoutInternalCallsites\n );\n this._replaceFramesInEvent(event, symbolicatedFrames);\n } else {\n logger.error('The stack is null');\n }\n } catch (error) {\n if (error instanceof Error) {\n logger.warn(`Unable to symbolicate stack trace: ${error.message}`);\n }\n }\n }\n\n /**\n * Converts ReactNativeFrames to frames in the Sentry format\n * @param frames ReactNativeFrame[]\n */\n private async _convertReactNativeFramesToSentryFrames(\n frames: ReactNativeFrame[]\n ): Promise<StackFrame[]> {\n let getDevServer: GetDevServer;\n try {\n getDevServer = require('react-native/Libraries/Core/Devtools/getDevServer');\n } catch (_oO) {\n // We can't load devserver URL\n }\n // Below you will find lines marked with :HACK to prevent showing errors in the sentry ui\n // But since this is a debug only feature: This is Fine (TM)\n return Promise.all(\n frames.map(\n async (frame: ReactNativeFrame): Promise<StackFrame> => {\n let inApp = !!frame.column && !!frame.lineNumber;\n inApp =\n inApp &&\n frame.file !== undefined &&\n !frame.file.includes('node_modules') &&\n !frame.file.includes('native code');\n\n const newFrame: StackFrame = {\n colno: frame.column,\n filename: frame.file,\n function: frame.methodName,\n in_app: inApp,\n lineno: inApp ? frame.lineNumber : undefined, // :HACK\n platform: inApp ? 'javascript' : 'node', // :HACK\n };\n\n // The upstream `react-native@0.61` delegates parsing of stacks to `stacktrace-parser`, which is buggy and\n // leaves a trailing `(address at` in the function name.\n // `react-native@0.62` seems to have custom logic to parse hermes frames specially.\n // Anyway, all we do here is throw away the bogus suffix.\n if (newFrame.function) {\n const addressAtPos = newFrame.function.indexOf('(address at');\n if (addressAtPos >= 0) {\n newFrame.function = newFrame.function\n .substr(0, addressAtPos)\n .trim();\n }\n }\n\n if (inApp) {\n await this._addSourceContext(newFrame, getDevServer);\n }\n\n return newFrame;\n }\n )\n );\n }\n\n /**\n * Replaces the frames in the exception of a error.\n * @param event Event\n * @param frames StackFrame[]\n */\n private _replaceFramesInEvent(event: Event, frames: StackFrame[]): void {\n if (\n event.exception &&\n event.exception.values &&\n event.exception.values[0] &&\n event.exception.values[0].stacktrace\n ) {\n event.exception.values[0].stacktrace.frames = frames.reverse();\n }\n }\n\n /**\n * This tries to add source context for in_app Frames\n *\n * @param frame StackFrame\n * @param getDevServer function from RN to get DevServer URL\n */\n private async _addSourceContext(\n frame: StackFrame,\n getDevServer?: GetDevServer\n ): Promise<void> {\n let response;\n\n const segments = frame.filename?.split('/') ?? [];\n\n if (getDevServer) {\n for (const idx in segments) {\n if (Object.prototype.hasOwnProperty.call(segments, idx)) {\n response = await fetch(\n `${getDevServer().url}${segments.slice(-idx).join('/')}`,\n {\n method: 'GET',\n }\n );\n\n if (response.ok) {\n break;\n }\n }\n }\n }\n\n if (response && response.ok) {\n const content = await response.text();\n const lines = content.split('\\n');\n\n addContextToFrame(lines, frame);\n }\n }\n}\n"]}
@@ -4,4 +4,5 @@ export { ReactNativeErrorHandlers } from './reactnativeerrorhandlers';
4
4
  export { Release } from './release';
5
5
  export { EventOrigin } from './eventorigin';
6
6
  export { SdkInfo } from './sdkinfo';
7
+ export { ReactNativeInfo } from './reactnativeinfo';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
@@ -4,4 +4,5 @@ export { ReactNativeErrorHandlers } from './reactnativeerrorhandlers';
4
4
  export { Release } from './release';
5
5
  export { EventOrigin } from './eventorigin';
6
6
  export { SdkInfo } from './sdkinfo';
7
+ export { ReactNativeInfo } from './reactnativeinfo';
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/js/integrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC","sourcesContent":["export { DebugSymbolicator } from './debugsymbolicator';\nexport { DeviceContext } from './devicecontext';\nexport { ReactNativeErrorHandlers } from './reactnativeerrorhandlers';\nexport { Release } from './release';\nexport { EventOrigin } from './eventorigin';\nexport { SdkInfo } from './sdkinfo';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/js/integrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export { DebugSymbolicator } from './debugsymbolicator';\nexport { DeviceContext } from './devicecontext';\nexport { ReactNativeErrorHandlers } from './reactnativeerrorhandlers';\nexport { Release } from './release';\nexport { EventOrigin } from './eventorigin';\nexport { SdkInfo } from './sdkinfo';\nexport { ReactNativeInfo } from './reactnativeinfo';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"reactnativeerrorhandlers.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/reactnativeerrorhandlers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAiB,MAAM,eAAe,CAAC;AAK3D,uCAAuC;AACvC,UAAU,+BAA+B;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAUD,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,OAAO,CAAC,+BAA+B,CAAC;IASrE;;OAEG;IACI,SAAS,IAAI,IAAI;IAKxB;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAUlC;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB;IAgBxB;;OAEG;IACH,OAAO,CAAC,gCAAgC;IAyCxC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAqB5B;;OAEG;IACH,OAAO,CAAC,cAAc;CAoEvB"}
1
+ {"version":3,"file":"reactnativeerrorhandlers.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/reactnativeerrorhandlers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAiB,MAAM,eAAe,CAAC;AAM3D,uCAAuC;AACvC,UAAU,+BAA+B;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAUD,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,OAAO,CAAC,+BAA+B,CAAC;IASrE;;OAEG;IACI,SAAS,IAAI,IAAI;IAKxB;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAUlC;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB;IAgBxB;;OAEG;IACH,OAAO,CAAC,gCAAgC;IAyCxC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAmB5B;;OAEG;IACH,OAAO,CAAC,cAAc;CAoEvB"}
@@ -1,6 +1,7 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { getCurrentHub } from '@sentry/core';
3
- import { addExceptionMechanism, getGlobalObject, logger } from '@sentry/utils';
3
+ import { addExceptionMechanism, logger } from '@sentry/utils';
4
+ import { RN_GLOBAL_OBJ } from '../utils/worldwide';
4
5
  /** ReactNativeErrorHandlers Integration */
5
6
  export class ReactNativeErrorHandlers {
6
7
  /** Constructor */
@@ -90,8 +91,7 @@ export class ReactNativeErrorHandlers {
90
91
  try {
91
92
  // eslint-disable-next-line @typescript-eslint/no-var-requires,import/no-extraneous-dependencies
92
93
  const Promise = require('promise/setimmediate/es6-extensions');
93
- const _global = getGlobalObject();
94
- if (Promise !== _global.Promise) {
94
+ if (Promise !== RN_GLOBAL_OBJ.Promise) {
95
95
  logger.warn('Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page.');
96
96
  }
97
97
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"reactnativeerrorhandlers.js","sourceRoot":"","sources":["../../../src/js/integrations/reactnativeerrorhandlers.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAmB/E,2CAA2C;AAC3C,MAAM,OAAO,wBAAwB;IAcnC,kBAAkB;IAClB,YAAmB,OAAkD;QATrE;;WAEG;QACI,SAAI,GAAW,wBAAwB,CAAC,EAAE,CAAC;QAOhD,IAAI,CAAC,QAAQ,mBACX,OAAO,EAAE,IAAI,EACb,oBAAoB,EAAE,IAAI,EAC1B,kBAAkB,EAAE,IAAI,IACrB,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,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,EAAE;gBACpC,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,GAAG,UAAU,CAAC,SAAS,EAAqB,CAAC;gBACzD,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;gBAEpC,IAAI,CAAC,MAAM,EAAE;oBACX,MAAM,CAAC,KAAK,CACV,0DAA0D,EAC1D,KAAK,CACN,CAAC;oBAEF,+EAA+E;oBAC/E,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;oBAE/B,OAAO;iBACR;gBAED,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;gBAEpC,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE;oBACnD,iBAAiB,EAAE,KAAK;oBACxB,WAAW,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,EAAE;iBACrC,CAAC,CAAC;gBAEH,IAAI,OAAO,EAAE;oBACX,KAAK,CAAC,KAAK,GAAG,OAAwB,CAAC;oBAEvC,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;;AA/MD;;GAEG;AACW,2BAAE,GAAW,0BAA0B,CAAC","sourcesContent":["import { getCurrentHub } from '@sentry/core';\nimport { Integration, SeverityLevel } 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 patchGlobalPromise: boolean;\n}\n\ninterface PromiseRejectionTrackingOptions {\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?: Partial<ReactNativeErrorHandlersOptions>) {\n this._options = {\n onerror: true,\n onunhandledrejection: true,\n patchGlobalPromise: 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 if (this._options.patchGlobalPromise) {\n this._polyfillPromise();\n }\n\n this._attachUnhandledRejectionHandler();\n this._checkPromiseAndWarn();\n }\n }\n /**\n * Polyfill the global promise instance with one we can be sure that we can attach the tracking to.\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.\n * Originally we tried a solution where we would have you put a package resolution to ensure the promise instances match. However,\n * - Using a package resolution requires the you to manually troubleshoot.\n * - The package resolution fix no longer works with 0.67 on iOS Hermes.\n */\n private _polyfillPromise(): void {\n /* eslint-disable import/no-extraneous-dependencies,@typescript-eslint/no-var-requires */\n const {\n polyfillGlobal,\n } = require('react-native/Libraries/Utilities/PolyfillFunctions');\n\n // Below, we follow the exact way React Native initializes its promise library, and we globally replace it.\n const Promise = require('promise/setimmediate/es6-extensions');\n\n // As of RN 0.67 only done and finally are used\n require('promise/setimmediate/done');\n require('promise/setimmediate/finally');\n\n polyfillGlobal('Promise', () => Promise);\n /* eslint-enable import/no-extraneous-dependencies,@typescript-eslint/no-var-requires */\n }\n /**\n * Attach the unhandled rejection handler\n */\n private _attachUnhandledRejectionHandler(): void {\n const tracking: {\n disable: () => void;\n enable: (arg: unknown) => void;\n // eslint-disable-next-line import/no-extraneous-dependencies,@typescript-eslint/no-var-requires\n } = require('promise/setimmediate/rejection-tracking');\n\n const promiseRejectionTrackingOptions: PromiseRejectionTrackingOptions = {\n onUnhandled: (id, rejection = {}) => {\n // eslint-disable-next-line no-console\n console.warn(\n `Possible Unhandled Promise Rejection (id: ${id}):\\n${rejection}`\n );\n },\n onHandled: (id) => {\n // eslint-disable-next-line no-console\n console.warn(\n `Promise Rejection Handled (id: ${id})\\n` +\n 'This means you can ignore any previous messages of the form ' +\n `\"Possible Unhandled Promise Rejection (id: ${id}):\"`\n );\n },\n };\n\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 * Checks if the promise is the same one or not, if not it will warn the user\n */\n private _checkPromiseAndWarn(): void {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires,import/no-extraneous-dependencies\n const Promise = require('promise/setimmediate/es6-extensions');\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 const scope = currentHub.getScope();\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 client.eventFromException(error, {\n originalException: error,\n attachments: scope?.getAttachments(),\n });\n\n if (isFatal) {\n event.level = 'fatal' as SeverityLevel;\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,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAiBnD,2CAA2C;AAC3C,MAAM,OAAO,wBAAwB;IAcnC,kBAAkB;IA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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;;AA7MD;;GAEG;AACW,2BAAE,GAAW,0BAA0B,CAAC","sourcesContent":["import { getCurrentHub } from '@sentry/core';\nimport { Integration, SeverityLevel } from '@sentry/types';\nimport { addExceptionMechanism, logger } from '@sentry/utils';\n\nimport { ReactNativeClient } from '../client';\nimport { RN_GLOBAL_OBJ } from '../utils/worldwide';\n\n/** ReactNativeErrorHandlers Options */\ninterface ReactNativeErrorHandlersOptions {\n onerror: boolean;\n onunhandledrejection: boolean;\n patchGlobalPromise: boolean;\n}\n\ninterface PromiseRejectionTrackingOptions {\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?: Partial<ReactNativeErrorHandlersOptions>) {\n this._options = {\n onerror: true,\n onunhandledrejection: true,\n patchGlobalPromise: 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 if (this._options.patchGlobalPromise) {\n this._polyfillPromise();\n }\n\n this._attachUnhandledRejectionHandler();\n this._checkPromiseAndWarn();\n }\n }\n /**\n * Polyfill the global promise instance with one we can be sure that we can attach the tracking to.\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.\n * Originally we tried a solution where we would have you put a package resolution to ensure the promise instances match. However,\n * - Using a package resolution requires the you to manually troubleshoot.\n * - The package resolution fix no longer works with 0.67 on iOS Hermes.\n */\n private _polyfillPromise(): void {\n /* eslint-disable import/no-extraneous-dependencies,@typescript-eslint/no-var-requires */\n const {\n polyfillGlobal,\n } = require('react-native/Libraries/Utilities/PolyfillFunctions');\n\n // Below, we follow the exact way React Native initializes its promise library, and we globally replace it.\n const Promise = require('promise/setimmediate/es6-extensions');\n\n // As of RN 0.67 only done and finally are used\n require('promise/setimmediate/done');\n require('promise/setimmediate/finally');\n\n polyfillGlobal('Promise', () => Promise);\n /* eslint-enable import/no-extraneous-dependencies,@typescript-eslint/no-var-requires */\n }\n /**\n * Attach the unhandled rejection handler\n */\n private _attachUnhandledRejectionHandler(): void {\n const tracking: {\n disable: () => void;\n enable: (arg: unknown) => void;\n // eslint-disable-next-line import/no-extraneous-dependencies,@typescript-eslint/no-var-requires\n } = require('promise/setimmediate/rejection-tracking');\n\n const promiseRejectionTrackingOptions: PromiseRejectionTrackingOptions = {\n onUnhandled: (id, rejection = {}) => {\n // eslint-disable-next-line no-console\n console.warn(\n `Possible Unhandled Promise Rejection (id: ${id}):\\n${rejection}`\n );\n },\n onHandled: (id) => {\n // eslint-disable-next-line no-console\n console.warn(\n `Promise Rejection Handled (id: ${id})\\n` +\n 'This means you can ignore any previous messages of the form ' +\n `\"Possible Unhandled Promise Rejection (id: ${id}):\"`\n );\n },\n };\n\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 * Checks if the promise is the same one or not, if not it will warn the user\n */\n private _checkPromiseAndWarn(): void {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires,import/no-extraneous-dependencies\n const Promise = require('promise/setimmediate/es6-extensions');\n\n if (Promise !== RN_GLOBAL_OBJ.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 const scope = currentHub.getScope();\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 client.eventFromException(error, {\n originalException: error,\n attachments: scope?.getAttachments(),\n });\n\n if (isFatal) {\n event.level = 'fatal' as SeverityLevel;\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"]}
@@ -0,0 +1,23 @@
1
+ import { Context, EventProcessor, Integration } from '@sentry/types';
2
+ export interface ReactNativeContext extends Context {
3
+ js_engine?: string;
4
+ turbo_module: boolean;
5
+ fabric: boolean;
6
+ component_stack?: string;
7
+ }
8
+ /** Loads React Native context at runtime */
9
+ export declare class ReactNativeInfo implements Integration {
10
+ /**
11
+ * @inheritDoc
12
+ */
13
+ static id: string;
14
+ /**
15
+ * @inheritDoc
16
+ */
17
+ name: string;
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void): void;
22
+ }
23
+ //# sourceMappingURL=reactnativeinfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactnativeinfo.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/reactnativeinfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAoB,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAKvF,MAAM,WAAW,kBAAmB,SAAQ,OAAO;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,4CAA4C;AAC5C,qBAAa,eAAgB,YAAW,WAAW;IACjD;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAqB;IAE7C;;OAEG;IACI,IAAI,EAAE,MAAM,CAAsB;IAEzC;;OAEG;IACI,SAAS,CAAC,uBAAuB,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,GAAG,IAAI;CAoCpF"}
@@ -0,0 +1,43 @@
1
+ import { __awaiter } from "tslib";
2
+ import { isFabricEnabled, isHermesEnabled, isTurboModuleEnabled } from '../utils/environment';
3
+ /** Loads React Native context at runtime */
4
+ export class ReactNativeInfo {
5
+ constructor() {
6
+ /**
7
+ * @inheritDoc
8
+ */
9
+ this.name = ReactNativeInfo.id;
10
+ }
11
+ /**
12
+ * @inheritDoc
13
+ */
14
+ setupOnce(addGlobalEventProcessor) {
15
+ addGlobalEventProcessor((event, hint) => __awaiter(this, void 0, void 0, function* () {
16
+ const reactNativeError = (hint === null || hint === void 0 ? void 0 : hint.originalException) ? hint === null || hint === void 0 ? void 0 : hint.originalException
17
+ : undefined;
18
+ const reactNativeContext = {
19
+ turbo_module: isTurboModuleEnabled(),
20
+ fabric: isFabricEnabled(),
21
+ };
22
+ if (isHermesEnabled()) {
23
+ reactNativeContext.js_engine = 'hermes';
24
+ }
25
+ else if (reactNativeError === null || reactNativeError === void 0 ? void 0 : reactNativeError.jsEngine) {
26
+ reactNativeContext.js_engine = reactNativeError.jsEngine;
27
+ }
28
+ if (reactNativeContext.js_engine === 'hermes') {
29
+ event.tags = Object.assign({ hermes: 'true' }, event.tags);
30
+ }
31
+ if (reactNativeError === null || reactNativeError === void 0 ? void 0 : reactNativeError.componentStack) {
32
+ reactNativeContext.component_stack = reactNativeError.componentStack;
33
+ }
34
+ event.contexts = Object.assign({ react_native_context: reactNativeContext }, event.contexts);
35
+ return event;
36
+ }));
37
+ }
38
+ }
39
+ /**
40
+ * @inheritDoc
41
+ */
42
+ ReactNativeInfo.id = 'ReactNativeInfo';
43
+ //# sourceMappingURL=reactnativeinfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactnativeinfo.js","sourceRoot":"","sources":["../../../src/js/integrations/reactnativeinfo.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAU9F,4CAA4C;AAC5C,MAAM,OAAO,eAAe;IAA5B;QAME;;WAEG;QACI,SAAI,GAAW,eAAe,CAAC,EAAE,CAAC;IAyC3C,CAAC;IAvCC;;OAEG;IACI,SAAS,CAAC,uBAA2D;QAC1E,uBAAuB,CAAC,CAAO,KAAY,EAAE,IAAgB,EAAE,EAAE;YAC/D,MAAM,gBAAgB,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,iBAAiB,EAC9C,CAAC,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,iBAAqC;gBAC7C,CAAC,CAAC,SAAS,CAAC;YAEd,MAAM,kBAAkB,GAAuB;gBAC7C,YAAY,EAAE,oBAAoB,EAAE;gBACpC,MAAM,EAAE,eAAe,EAAE;aAC1B,CAAC;YAEF,IAAI,eAAe,EAAE,EAAE;gBACrB,kBAAkB,CAAC,SAAS,GAAG,QAAQ,CAAC;aACzC;iBAAM,IAAI,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,QAAQ,EAAE;gBACrC,kBAAkB,CAAC,SAAS,GAAG,gBAAgB,CAAC,QAAQ,CAAC;aAC1D;YAED,IAAI,kBAAkB,CAAC,SAAS,KAAK,QAAQ,EAAE;gBAC7C,KAAK,CAAC,IAAI,mBACR,MAAM,EAAE,MAAM,IACX,KAAK,CAAC,IAAI,CACd,CAAC;aACH;YAED,IAAI,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,cAAc,EAAE;gBACpC,kBAAkB,CAAC,eAAe,GAAG,gBAAgB,CAAC,cAAc,CAAC;aACtE;YAED,KAAK,CAAC,QAAQ,mBACZ,oBAAoB,EAAE,kBAAkB,IACrC,KAAK,CAAC,QAAQ,CAClB,CAAC;YAEF,OAAO,KAAK,CAAC;QACf,CAAC,CAAA,CAAC,CAAC;IACL,CAAC;;AAhDD;;GAEG;AACW,kBAAE,GAAW,iBAAiB,CAAC","sourcesContent":["import { Context, Event, EventHint, EventProcessor, Integration } from '@sentry/types';\n\nimport { isFabricEnabled, isHermesEnabled, isTurboModuleEnabled } from '../utils/environment';\nimport { ReactNativeError } from './debugsymbolicator';\n\nexport interface ReactNativeContext extends Context {\n js_engine?: string;\n turbo_module: boolean;\n fabric: boolean;\n component_stack?: string;\n}\n\n/** Loads React Native context at runtime */\nexport class ReactNativeInfo implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'ReactNativeInfo';\n\n /**\n * @inheritDoc\n */\n public name: string = ReactNativeInfo.id;\n\n /**\n * @inheritDoc\n */\n public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void): void {\n addGlobalEventProcessor(async (event: Event, hint?: EventHint) => {\n const reactNativeError = hint?.originalException\n ? hint?.originalException as ReactNativeError\n : undefined;\n\n const reactNativeContext: ReactNativeContext = {\n turbo_module: isTurboModuleEnabled(),\n fabric: isFabricEnabled(),\n };\n\n if (isHermesEnabled()) {\n reactNativeContext.js_engine = 'hermes';\n } else if (reactNativeError?.jsEngine) {\n reactNativeContext.js_engine = reactNativeError.jsEngine;\n }\n\n if (reactNativeContext.js_engine === 'hermes') {\n event.tags = {\n hermes: 'true',\n ...event.tags,\n };\n }\n\n if (reactNativeError?.componentStack) {\n reactNativeContext.component_stack = reactNativeError.componentStack;\n }\n\n event.contexts = {\n react_native_context: reactNativeContext,\n ...event.contexts,\n };\n\n return event;\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sdkinfo.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/sdkinfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAW,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AAM7F,aAAK,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC,CAAC;AAEnF,eAAO,MAAM,cAAc,EAAE,cAS5B,CAAC;AAEF,sCAAsC;AACtC,qBAAa,OAAQ,YAAW,WAAW;IACzC;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAa;IAErC;;OAEG;IACI,IAAI,EAAE,MAAM,CAAc;IAEjC,OAAO,CAAC,cAAc,CAAwB;IAE9C;;OAEG;IACI,SAAS,CAAC,uBAAuB,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,GAAG,IAAI;CA8B7E"}
1
+ {"version":3,"file":"sdkinfo.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/sdkinfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAW,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AAM7F,aAAK,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC,CAAC;AAEnF,eAAO,MAAM,cAAc,EAAE,cAS5B,CAAC;AAEF,sCAAsC;AACtC,qBAAa,OAAQ,YAAW,WAAW;IACzC;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAa;IAErC;;OAEG;IACI,IAAI,EAAE,MAAM,CAAc;IAEjC,OAAO,CAAC,cAAc,CAAwB;IAE9C;;OAEG;IACI,SAAS,CAAC,uBAAuB,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,GAAG,IAAI;CA6B7E"}