@sentry/react-native 5.0.0-alpha.1 → 5.0.0-alpha.10

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 (161) hide show
  1. package/CHANGELOG.md +346 -1
  2. package/README.md +6 -0
  3. package/RNSentry.podspec +21 -4
  4. package/android/build.gradle +20 -2
  5. package/android/src/main/java/io/sentry/react/{RNSentryModule.java → RNSentryModuleImpl.java} +174 -114
  6. package/android/src/main/java/io/sentry/react/RNSentryPackage.java +35 -19
  7. package/android/src/newarch/java/io/sentry/react/RNSentryModule.java +119 -0
  8. package/android/src/oldarch/java/io/sentry/react/RNSentryModule.java +119 -0
  9. package/dist/js/NativeRNSentry.d.ts +52 -0
  10. package/dist/js/NativeRNSentry.d.ts.map +1 -0
  11. package/dist/js/NativeRNSentry.js +4 -0
  12. package/dist/js/NativeRNSentry.js.map +1 -0
  13. package/dist/js/client.d.ts +17 -4
  14. package/dist/js/client.d.ts.map +1 -1
  15. package/dist/js/client.js +90 -16
  16. package/dist/js/client.js.map +1 -1
  17. package/dist/js/index.d.ts +3 -3
  18. package/dist/js/index.d.ts.map +1 -1
  19. package/dist/js/index.js +2 -2
  20. package/dist/js/index.js.map +1 -1
  21. package/dist/js/integrations/debugsymbolicator.d.ts +9 -0
  22. package/dist/js/integrations/debugsymbolicator.d.ts.map +1 -1
  23. package/dist/js/integrations/debugsymbolicator.js +0 -2
  24. package/dist/js/integrations/debugsymbolicator.js.map +1 -1
  25. package/dist/js/integrations/index.d.ts +2 -0
  26. package/dist/js/integrations/index.d.ts.map +1 -1
  27. package/dist/js/integrations/index.js +2 -0
  28. package/dist/js/integrations/index.js.map +1 -1
  29. package/dist/js/integrations/modulesloader.d.ts +17 -0
  30. package/dist/js/integrations/modulesloader.d.ts.map +1 -0
  31. package/dist/js/integrations/modulesloader.js +33 -0
  32. package/dist/js/integrations/modulesloader.js.map +1 -0
  33. package/dist/js/integrations/reactnativeerrorhandlers.d.ts.map +1 -1
  34. package/dist/js/integrations/reactnativeerrorhandlers.js +6 -4
  35. package/dist/js/integrations/reactnativeerrorhandlers.js.map +1 -1
  36. package/dist/js/integrations/reactnativeinfo.d.ts +23 -0
  37. package/dist/js/integrations/reactnativeinfo.d.ts.map +1 -0
  38. package/dist/js/integrations/reactnativeinfo.js +43 -0
  39. package/dist/js/integrations/reactnativeinfo.js.map +1 -0
  40. package/dist/js/integrations/screenshot.d.ts +23 -0
  41. package/dist/js/integrations/screenshot.d.ts.map +1 -0
  42. package/dist/js/integrations/screenshot.js +39 -0
  43. package/dist/js/integrations/screenshot.js.map +1 -0
  44. package/dist/js/integrations/sdkinfo.d.ts +4 -1
  45. package/dist/js/integrations/sdkinfo.d.ts.map +1 -1
  46. package/dist/js/integrations/sdkinfo.js +13 -7
  47. package/dist/js/integrations/sdkinfo.js.map +1 -1
  48. package/dist/js/measurements.js +1 -1
  49. package/dist/js/measurements.js.map +1 -1
  50. package/dist/js/misc.d.ts +9 -0
  51. package/dist/js/misc.d.ts.map +1 -0
  52. package/dist/js/misc.js +17 -0
  53. package/dist/js/misc.js.map +1 -0
  54. package/dist/js/options.d.ts +45 -8
  55. package/dist/js/options.d.ts.map +1 -1
  56. package/dist/js/options.js.map +1 -1
  57. package/dist/js/scope.d.ts +10 -2
  58. package/dist/js/scope.d.ts.map +1 -1
  59. package/dist/js/scope.js +13 -1
  60. package/dist/js/scope.js.map +1 -1
  61. package/dist/js/sdk.d.ts +25 -0
  62. package/dist/js/sdk.d.ts.map +1 -1
  63. package/dist/js/sdk.js +85 -27
  64. package/dist/js/sdk.js.map +1 -1
  65. package/dist/js/tools/ModulesCollector.d.ts +17 -0
  66. package/dist/js/tools/ModulesCollector.d.ts.map +1 -0
  67. package/dist/js/tools/ModulesCollector.js +109 -0
  68. package/dist/js/tools/ModulesCollector.js.map +1 -0
  69. package/dist/js/tools/collectModules.d.ts +2 -0
  70. package/dist/js/tools/collectModules.d.ts.map +1 -0
  71. package/dist/js/tools/collectModules.js +11 -0
  72. package/dist/js/tools/collectModules.js.map +1 -0
  73. package/dist/js/touchevents.d.ts +4 -0
  74. package/dist/js/touchevents.d.ts.map +1 -1
  75. package/dist/js/touchevents.js.map +1 -1
  76. package/dist/js/tracing/nativeframes.js.map +1 -1
  77. package/dist/js/tracing/reactnativenavigation.d.ts +9 -0
  78. package/dist/js/tracing/reactnativenavigation.d.ts.map +1 -1
  79. package/dist/js/tracing/reactnativenavigation.js +20 -12
  80. package/dist/js/tracing/reactnativenavigation.js.map +1 -1
  81. package/dist/js/tracing/reactnativetracing.d.ts +15 -6
  82. package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
  83. package/dist/js/tracing/reactnativetracing.js +16 -9
  84. package/dist/js/tracing/reactnativetracing.js.map +1 -1
  85. package/dist/js/tracing/reactnavigation.d.ts +7 -1
  86. package/dist/js/tracing/reactnavigation.d.ts.map +1 -1
  87. package/dist/js/tracing/reactnavigation.js +31 -23
  88. package/dist/js/tracing/reactnavigation.js.map +1 -1
  89. package/dist/js/tracing/reactnavigationv4.d.ts +9 -9
  90. package/dist/js/tracing/reactnavigationv4.d.ts.map +1 -1
  91. package/dist/js/tracing/reactnavigationv4.js +27 -15
  92. package/dist/js/tracing/reactnavigationv4.js.map +1 -1
  93. package/dist/js/tracing/routingInstrumentation.d.ts +1 -1
  94. package/dist/js/tracing/routingInstrumentation.d.ts.map +1 -1
  95. package/dist/js/tracing/routingInstrumentation.js.map +1 -1
  96. package/dist/js/tracing/utils.d.ts +4 -3
  97. package/dist/js/tracing/utils.d.ts.map +1 -1
  98. package/dist/js/tracing/utils.js +7 -10
  99. package/dist/js/tracing/utils.js.map +1 -1
  100. package/dist/js/transports/TextEncoder.d.ts +3 -0
  101. package/dist/js/transports/TextEncoder.d.ts.map +1 -0
  102. package/dist/js/transports/TextEncoder.js +12 -0
  103. package/dist/js/transports/TextEncoder.js.map +1 -0
  104. package/dist/js/transports/native.d.ts +6 -1
  105. package/dist/js/transports/native.d.ts.map +1 -1
  106. package/dist/js/transports/native.js +6 -4
  107. package/dist/js/transports/native.js.map +1 -1
  108. package/dist/js/user.d.ts +6 -0
  109. package/dist/js/user.d.ts.map +1 -0
  110. package/dist/js/user.js +1 -0
  111. package/dist/js/user.js.map +1 -0
  112. package/dist/js/utils/envelope.d.ts +12 -0
  113. package/dist/js/utils/envelope.d.ts.map +1 -0
  114. package/dist/js/utils/envelope.js +21 -0
  115. package/dist/js/utils/envelope.js.map +1 -0
  116. package/dist/js/utils/environment.d.ts +7 -0
  117. package/dist/js/utils/environment.d.ts.map +1 -0
  118. package/dist/js/utils/environment.js +14 -0
  119. package/dist/js/utils/environment.js.map +1 -0
  120. package/dist/js/utils/outcome.d.ts +6 -0
  121. package/dist/js/utils/outcome.d.ts.map +1 -0
  122. package/dist/js/utils/outcome.js +19 -0
  123. package/dist/js/utils/outcome.js.map +1 -0
  124. package/dist/js/utils/safe.d.ts +18 -0
  125. package/dist/js/utils/safe.d.ts.map +1 -0
  126. package/dist/js/utils/safe.js +46 -0
  127. package/dist/js/utils/safe.js.map +1 -0
  128. package/dist/js/utils/worldwide.d.ts +13 -0
  129. package/dist/js/utils/worldwide.d.ts.map +1 -0
  130. package/dist/js/utils/worldwide.js +4 -0
  131. package/dist/js/utils/worldwide.js.map +1 -0
  132. package/dist/js/vendor/buffer/index.d.ts +2 -0
  133. package/dist/js/vendor/buffer/index.d.ts.map +1 -0
  134. package/dist/js/vendor/buffer/index.js +2 -0
  135. package/dist/js/vendor/buffer/index.js.map +1 -0
  136. package/dist/js/vendor/buffer/utf8ToBytes.d.ts +10 -0
  137. package/dist/js/vendor/buffer/utf8ToBytes.d.ts.map +1 -0
  138. package/dist/js/vendor/buffer/utf8ToBytes.js +82 -0
  139. package/dist/js/vendor/buffer/utf8ToBytes.js.map +1 -0
  140. package/dist/js/vendor/index.d.ts +2 -0
  141. package/dist/js/vendor/index.d.ts.map +1 -0
  142. package/dist/js/vendor/index.js +2 -0
  143. package/dist/js/vendor/index.js.map +1 -0
  144. package/dist/js/version.d.ts +2 -1
  145. package/dist/js/version.d.ts.map +1 -1
  146. package/dist/js/version.js +2 -1
  147. package/dist/js/version.js.map +1 -1
  148. package/dist/js/wrapper.d.ts +13 -4
  149. package/dist/js/wrapper.d.ts.map +1 -1
  150. package/dist/js/wrapper.js +126 -71
  151. package/dist/js/wrapper.js.map +1 -1
  152. package/ios/{RNSentry.m → RNSentry.mm} +98 -57
  153. package/package.json +31 -25
  154. package/sample-new-architecture/react-native.config.js +10 -0
  155. package/scripts/collect-modules.sh +43 -0
  156. package/sentry.gradle +57 -6
  157. package/src/js/NativeRNSentry.ts +66 -0
  158. package/dist/js/definitions.d.ts +0 -52
  159. package/dist/js/definitions.d.ts.map +0 -1
  160. package/dist/js/definitions.js +0 -1
  161. package/dist/js/definitions.js.map +0 -1
@@ -1,17 +1,33 @@
1
1
  import { __awaiter, __rest } from "tslib";
2
- import { logger, SentryError } from '@sentry/utils';
3
- import { NativeModules, Platform } from 'react-native';
4
- const RNSentry = NativeModules.RNSentry;
2
+ import { logger, normalize, SentryError } from '@sentry/utils';
3
+ import { NativeModules, Platform, TurboModuleRegistry } from 'react-native';
4
+ import { isHardCrash } from './misc';
5
+ import { isTurboModuleEnabled } from './utils/environment';
6
+ import { utf8ToBytes } from './vendor';
7
+ const RNSentry = isTurboModuleEnabled()
8
+ ? TurboModuleRegistry.getEnforcing('RNSentry')
9
+ : NativeModules.RNSentry;
5
10
  /**
6
11
  * Our internal interface for calling native functions
7
12
  */
8
13
  export const NATIVE = {
14
+ fetchModules() {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ if (!this._isModuleLoaded(RNSentry)) {
17
+ throw this._NativeClientError;
18
+ }
19
+ const raw = yield RNSentry.fetchModules();
20
+ if (raw) {
21
+ return JSON.parse(raw);
22
+ }
23
+ return null;
24
+ });
25
+ },
9
26
  /**
10
27
  * Sending the envelope over the bridge to native
11
28
  * @param envelope Envelope
12
29
  */
13
30
  sendEnvelope(envelope) {
14
- var _a, _b, _c, _d;
15
31
  return __awaiter(this, void 0, void 0, function* () {
16
32
  if (!this.enableNative) {
17
33
  logger.warn('Event was skipped as native SDK is not enabled.');
@@ -20,62 +36,43 @@ export const NATIVE = {
20
36
  if (!this._isModuleLoaded(RNSentry)) {
21
37
  throw this._NativeClientError;
22
38
  }
23
- const header = envelope[0];
24
- if (NATIVE.platform === 'android') {
25
- // Android
26
- const headerString = JSON.stringify(header);
27
- let envelopeItemsBuilder = `${headerString}`;
28
- for (const envelopeItems of envelope[1]) {
29
- const event = this._getEvent(envelopeItems);
30
- if (event != undefined) {
31
- // @ts-ignore Android still uses the old message object, without this the serialization of events will break.
32
- event.message = { message: event.message };
33
- /*
34
- We do this to avoid duplicate breadcrumbs on Android as sentry-android applies the breadcrumbs
35
- from the native scope onto every envelope sent through it. This scope will contain the breadcrumbs
36
- sent through the scope sync feature. This causes duplicate breadcrumbs.
37
- We then remove the breadcrumbs in all cases but if it is handled == false,
38
- this is a signal that the app would crash and android would lose the breadcrumbs by the time the app is restarted to read
39
- the envelope.
40
- */
41
- if (((_d = (_c = (_b = (_a = event.exception) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.mechanism) === null || _d === void 0 ? void 0 : _d.handled) != false && event.breadcrumbs) {
42
- event.breadcrumbs = [];
43
- }
44
- envelopeItems[1] = event;
45
- }
46
- // Content type is not inside BaseEnvelopeItemHeaders.
47
- envelopeItems[0].content_type = 'application/json';
48
- const itemPayload = JSON.stringify(envelopeItems[1]);
49
- let length = itemPayload.length;
50
- try {
51
- length = yield RNSentry.getStringBytesLength(itemPayload);
52
- }
53
- catch (_e) {
54
- // The native call failed, we do nothing, we have payload.length as a fallback
55
- }
56
- envelopeItems[0].length = length;
57
- const itemHeader = JSON.stringify(envelopeItems[0]);
58
- envelopeItemsBuilder += `\n${itemHeader}\n${itemPayload}`;
39
+ const [EOL] = utf8ToBytes('\n');
40
+ const [envelopeHeader, envelopeItems] = envelope;
41
+ const headerString = JSON.stringify(envelopeHeader);
42
+ let envelopeBytes = utf8ToBytes(headerString);
43
+ envelopeBytes.push(EOL);
44
+ let hardCrashed = false;
45
+ for (const rawItem of envelopeItems) {
46
+ const [itemHeader, itemPayload] = this._processItem(rawItem);
47
+ let bytesContentType;
48
+ let bytesPayload = [];
49
+ if (typeof itemPayload === 'string') {
50
+ bytesContentType = 'text/plain';
51
+ bytesPayload = utf8ToBytes(itemPayload);
59
52
  }
60
- yield RNSentry.captureEnvelope(envelopeItemsBuilder);
61
- }
62
- else {
63
- // iOS/Mac
64
- for (const envelopeItems of envelope[1]) {
65
- const event = this._getEvent(envelopeItems);
66
- if (event != undefined) {
67
- envelopeItems[1] = event;
53
+ else if (itemPayload instanceof Uint8Array) {
54
+ bytesContentType = typeof itemHeader.content_type === 'string'
55
+ ? itemHeader.content_type
56
+ : 'application/octet-stream';
57
+ bytesPayload = [...itemPayload];
58
+ }
59
+ else {
60
+ bytesContentType = 'application/json';
61
+ bytesPayload = utf8ToBytes(JSON.stringify(itemPayload));
62
+ if (!hardCrashed) {
63
+ hardCrashed = isHardCrash(itemPayload);
68
64
  }
69
- const itemPayload = JSON.parse(JSON.stringify(envelopeItems[1]));
70
- // The envelope item is created (and its length determined) on the iOS side of the native bridge.
71
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
72
- yield RNSentry.captureEnvelope({
73
- header,
74
- payload: itemPayload,
75
- });
76
65
  }
66
+ // Content type is not inside BaseEnvelopeItemHeaders.
67
+ itemHeader.content_type = bytesContentType;
68
+ itemHeader.length = bytesPayload.length;
69
+ const serializedItemHeader = JSON.stringify(itemHeader);
70
+ envelopeBytes.push(...utf8ToBytes(serializedItemHeader));
71
+ envelopeBytes.push(EOL);
72
+ envelopeBytes = envelopeBytes.concat(bytesPayload);
73
+ envelopeBytes.push(EOL);
77
74
  }
78
- ;
75
+ yield RNSentry.captureEnvelope(envelopeBytes, { store: hardCrashed });
79
76
  });
80
77
  },
81
78
  /**
@@ -210,20 +207,22 @@ export const NATIVE = {
210
207
  if (!this._isModuleLoaded(RNSentry)) {
211
208
  throw this._NativeClientError;
212
209
  }
213
- // separate and serialze all non-default user keys.
214
- let defaultUserKeys = null;
215
- let otherUserKeys = null;
210
+ // separate and serialize all non-default user keys.
211
+ let userKeys = null;
212
+ let userDataKeys = null;
216
213
  if (user) {
217
- const { id, ip_address, email, username } = user, otherKeys = __rest(user, ["id", "ip_address", "email", "username"]);
218
- defaultUserKeys = this._serializeObject({
219
- email,
214
+ const { id, ip_address, email, username, segment } = user, otherKeys = __rest(user, ["id", "ip_address", "email", "username", "segment"]);
215
+ const requiredUser = {
220
216
  id,
221
217
  ip_address,
218
+ email,
222
219
  username,
223
- });
224
- otherUserKeys = this._serializeObject(otherKeys);
220
+ segment,
221
+ };
222
+ userKeys = this._serializeObject(requiredUser);
223
+ userDataKeys = this._serializeObject(otherKeys);
225
224
  }
226
- RNSentry.setUser(defaultUserKeys, otherUserKeys);
225
+ RNSentry.setUser(userKeys, userDataKeys);
227
226
  },
228
227
  /**
229
228
  * Sets a tag in the native module.
@@ -273,7 +272,7 @@ export const NATIVE = {
273
272
  level: breadcrumb.level
274
273
  ? this._processLevel(breadcrumb.level)
275
274
  : undefined, data: breadcrumb.data
276
- ? this._serializeObject(breadcrumb.data)
275
+ ? normalize(breadcrumb.data)
277
276
  : undefined }));
278
277
  },
279
278
  /**
@@ -300,7 +299,7 @@ export const NATIVE = {
300
299
  if (!this._isModuleLoaded(RNSentry)) {
301
300
  throw this._NativeClientError;
302
301
  }
303
- RNSentry.setContext(key, context !== null ? this._serializeObject(context) : null);
302
+ RNSentry.setContext(key, context !== null ? normalize(context) : null);
304
303
  },
305
304
  /**
306
305
  * Closes the Native Layer SDK
@@ -327,19 +326,55 @@ export const NATIVE = {
327
326
  }
328
327
  RNSentry.disableNativeFramesTracking();
329
328
  },
329
+ enableNativeFramesTracking() {
330
+ if (!this.enableNative) {
331
+ return;
332
+ }
333
+ if (!this._isModuleLoaded(RNSentry)) {
334
+ return;
335
+ }
336
+ RNSentry.enableNativeFramesTracking();
337
+ },
330
338
  isNativeTransportAvailable() {
331
339
  return this.enableNative && this._isModuleLoaded(RNSentry);
332
340
  },
341
+ captureScreenshot() {
342
+ return __awaiter(this, void 0, void 0, function* () {
343
+ if (!this.enableNative) {
344
+ throw this._DisabledNativeError;
345
+ }
346
+ if (!this._isModuleLoaded(RNSentry)) {
347
+ throw this._NativeClientError;
348
+ }
349
+ try {
350
+ const raw = yield RNSentry.captureScreenshot();
351
+ return raw.map((item) => (Object.assign(Object.assign({}, item), { data: new Uint8Array(item.data) })));
352
+ }
353
+ catch (e) {
354
+ logger.warn('Failed to capture screenshot', e);
355
+ return null;
356
+ }
357
+ });
358
+ },
333
359
  /**
334
360
  * Gets the event from envelopeItem and applies the level filter to the selected event.
335
361
  * @param data An envelope item containing the event.
336
362
  * @returns The event from envelopeItem or undefined.
337
363
  */
338
- _getEvent(envelopeItem) {
339
- if (envelopeItem[0].type == 'event' || envelopeItem[0].type == 'transaction') {
340
- return this._processLevels(envelopeItem[1]);
364
+ _processItem(item) {
365
+ const [itemHeader, itemPayload] = item;
366
+ if (itemHeader.type == 'event' || itemHeader.type == 'transaction') {
367
+ const event = this._processLevels(itemPayload);
368
+ if (NATIVE.platform === 'android') {
369
+ if ('message' in event) {
370
+ // @ts-ignore Android still uses the old message object, without this the serialization of events will break.
371
+ event.message = { message: event.message };
372
+ }
373
+ event.breadcrumbs = this._getBreadcrumbs(event);
374
+ }
375
+ return [itemHeader, event];
341
376
  }
342
- return undefined;
377
+ return item;
343
378
  },
344
379
  /**
345
380
  * Serializes all values of root-level keys into strings.
@@ -389,6 +424,26 @@ export const NATIVE = {
389
424
  },
390
425
  _DisabledNativeError: new SentryError('Native is disabled'),
391
426
  _NativeClientError: new SentryError("Native Client is not available, can't start on native."),
427
+ /**
428
+ * Get breadcrumbs (removes breadcrumbs from handled exceptions on Android)
429
+ *
430
+ * We do this to avoid duplicate breadcrumbs on Android as sentry-android applies the breadcrumbs
431
+ * from the native scope onto every envelope sent through it. This scope will contain the breadcrumbs
432
+ * sent through the scope sync feature. This causes duplicate breadcrumbs.
433
+ * We then remove the breadcrumbs in all cases but if it is handled == false,
434
+ * this is a signal that the app would crash and android would lose the breadcrumbs by the time the app is restarted to read
435
+ * the envelope.
436
+ */
437
+ _getBreadcrumbs(event) {
438
+ let breadcrumbs = event.breadcrumbs;
439
+ const hardCrashed = isHardCrash(event);
440
+ if (NATIVE.platform === 'android'
441
+ && event.breadcrumbs
442
+ && !hardCrashed) {
443
+ breadcrumbs = [];
444
+ }
445
+ return breadcrumbs;
446
+ },
392
447
  enableNative: true,
393
448
  nativeIsReady: false,
394
449
  platform: Platform.OS,
@@ -1 +1 @@
1
- {"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../src/js/wrapper.ts"],"names":[],"mappings":";AAeA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAYvD,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAgD,CAAC;AA2ChF;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAwB;IACzC;;;OAGG;IACG,YAAY,CAAC,QAAkB;;;YACnC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;gBACtB,MAAM,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;gBAC/D,OAAO;aACR;YAED,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE;gBACnC,MAAM,IAAI,CAAC,kBAAkB,CAAC;aAC/B;YAED,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YAE3B,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE;gBACjC,UAAU;gBAEV,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;gBAE5C,IAAI,oBAAoB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AK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAChE,WAAW,QAAE,KAAK,CAAC,WAAW,0CAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,iCAC/C,UAAU,KACb,KAAK,EAAE,UAAU,CAAC,KAAK;oBACrB,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC;oBACtC,CAAC,CAAC,SAAS,IACb,IACH,CAAC;QAEF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;OAIG;IAEH,aAAa,CAAC,KAAoB;QAChC,IAAI,KAAK,IAAI,KAAsB,EAAE;YACnC,OAAO,OAAwB,CAAC;SACjC;aACI,IAAI,KAAK,IAAI,UAA2B,EAAE;YAC7C,OAAO,OAAwB,CAAC;SACjC;QAGD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,eAAe,CACb,MAA4C;QAE5C,OAAO,CAAC,CAAC,MAAM,CAAC;IAClB,CAAC;IAED,oBAAoB,EAAE,IAAI,WAAW,CAAC,oBAAoB,CAAC;IAE3D,kBAAkB,EAAE,IAAI,WAAW,CACjC,wDAAwD,CACzD;IAED,YAAY,EAAE,IAAI;IAClB,aAAa,EAAE,KAAK;IACpB,QAAQ,EAAE,QAAQ,CAAC,EAAE;CACtB,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport {\n AttachmentItem,\n BaseEnvelopeItemHeaders,\n Breadcrumb,\n ClientReportItem,\n Envelope,\n Event,\n EventItem,\n Package,\n SessionItem,\n SeverityLevel,\n User,\n UserFeedbackItem,\n} from '@sentry/types';\nimport { logger, SentryError } from '@sentry/utils';\nimport { NativeModules, Platform } from 'react-native';\n\nimport {\n NativeAppStartResponse,\n NativeDeviceContextsResponse,\n NativeFramesResponse,\n NativeReleaseResponse,\n SentryNativeBridgeModule,\n} from './definitions';\nimport { ReactNativeOptions } from './options';\n\n\nconst RNSentry = NativeModules.RNSentry as SentryNativeBridgeModule | undefined;\n\ninterface SentryNativeWrapper {\n enableNative: boolean;\n nativeIsReady: boolean;\n platform: typeof Platform.OS;\n\n _NativeClientError: Error;\n _DisabledNativeError: Error;\n\n _getEvent(envelopeItem: EventItem | AttachmentItem | UserFeedbackItem | SessionItem | ClientReportItem): Event | undefined;\n _processLevels(event: Event): Event;\n _processLevel(level: SeverityLevel): SeverityLevel;\n _serializeObject(data: { [key: string]: unknown }): { [key: string]: string };\n _isModuleLoaded(\n module: SentryNativeBridgeModule | undefined\n ): module is SentryNativeBridgeModule;\n\n isNativeTransportAvailable(): boolean;\n\n initNativeSdk(options: ReactNativeOptions): PromiseLike<boolean>;\n closeNativeSdk(): PromiseLike<void>;\n\n sendEnvelope(envelope: Envelope): Promise<void>;\n\n fetchNativeRelease(): PromiseLike<NativeReleaseResponse>;\n fetchNativeDeviceContexts(): PromiseLike<NativeDeviceContextsResponse>;\n fetchNativeAppStart(): PromiseLike<NativeAppStartResponse | null>;\n fetchNativeFrames(): PromiseLike<NativeFramesResponse | null>;\n fetchNativeSdkInfo(): PromiseLike<Package | null>;\n\n disableNativeFramesTracking(): void;\n\n addBreadcrumb(breadcrumb: Breadcrumb): void;\n setContext(key: string, context: { [key: string]: unknown } | null): void;\n clearBreadcrumbs(): void;\n setExtra(key: string, extra: unknown): void;\n setUser(user: User | null): void;\n setTag(key: string, value: string): void;\n\n nativeCrash(): void;\n}\n\n/**\n * Our internal interface for calling native functions\n */\nexport const NATIVE: SentryNativeWrapper = {\n /**\n * Sending the envelope over the bridge to native\n * @param envelope Envelope\n */\n async sendEnvelope(envelope: Envelope): Promise<void> {\n if (!this.enableNative) {\n logger.warn('Event was skipped as native SDK is not enabled.');\n return;\n }\n\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const header = envelope[0];\n\n if (NATIVE.platform === 'android') {\n // Android\n\n const headerString = JSON.stringify(header);\n\n let envelopeItemsBuilder = `${headerString}`;\n\n for (const envelopeItems of envelope[1]) {\n\n const event = this._getEvent(envelopeItems);\n if (event != undefined) {\n\n // @ts-ignore Android still uses the old message object, without this the serialization of events will break.\n event.message = { message: event.message };\n\n /*\n We do this to avoid duplicate breadcrumbs on Android as sentry-android applies the breadcrumbs\n from the native scope onto every envelope sent through it. This scope will contain the breadcrumbs\n sent through the scope sync feature. This causes duplicate breadcrumbs.\n We then remove the breadcrumbs in all cases but if it is handled == false,\n this is a signal that the app would crash and android would lose the breadcrumbs by the time the app is restarted to read\n the envelope.\n */\n if (event.exception?.values?.[0]?.mechanism?.handled != false && event.breadcrumbs) {\n event.breadcrumbs = [];\n }\n envelopeItems[1] = event;\n }\n\n // Content type is not inside BaseEnvelopeItemHeaders.\n (envelopeItems[0] as BaseEnvelopeItemHeaders).content_type = 'application/json';\n\n const itemPayload = JSON.stringify(envelopeItems[1]);\n\n let length = itemPayload.length;\n try {\n length = await RNSentry.getStringBytesLength(itemPayload);\n } catch {\n // The native call failed, we do nothing, we have payload.length as a fallback\n }\n\n (envelopeItems[0] as BaseEnvelopeItemHeaders).length = length;\n const itemHeader = JSON.stringify(envelopeItems[0]);\n\n envelopeItemsBuilder += `\\n${itemHeader}\\n${itemPayload}`;\n }\n\n await RNSentry.captureEnvelope(envelopeItemsBuilder);\n } else {\n // iOS/Mac\n\n for (const envelopeItems of envelope[1]) {\n const event = this._getEvent(envelopeItems);\n if (event != undefined) {\n envelopeItems[1] = event;\n }\n\n const itemPayload = JSON.parse(JSON.stringify(envelopeItems[1]));\n\n // The envelope item is created (and its length determined) on the iOS side of the native bridge.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\n await RNSentry.captureEnvelope({\n header,\n payload: itemPayload,\n });\n }\n };\n\n },\n\n /**\n * Starts native with the provided options.\n * @param options ReactNativeOptions\n */\n async initNativeSdk(originalOptions: ReactNativeOptions): Promise<boolean> {\n const options = {\n enableNative: true,\n autoInitializeNativeSdk: true,\n ...originalOptions,\n };\n\n if (!options.enableNative) {\n if (options.enableNativeNagger) {\n logger.warn('Note: Native Sentry SDK is disabled.');\n }\n this.enableNative = false;\n return false;\n }\n if (!options.autoInitializeNativeSdk) {\n if (options.enableNativeNagger) {\n logger.warn(\n 'Note: Native Sentry SDK was not initialized automatically, you will need to initialize it manually. If you wish to disable the native SDK and get rid of this warning, pass enableNative: false'\n );\n }\n return false;\n }\n\n if (!options.dsn) {\n logger.warn(\n 'Warning: No DSN was provided. The Sentry SDK will be disabled. Native SDK will also not be initalized.'\n );\n return false;\n }\n\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n // filter out all the options that would crash native.\n /* eslint-disable @typescript-eslint/unbound-method,@typescript-eslint/no-unused-vars */\n const {\n beforeSend,\n beforeBreadcrumb,\n integrations,\n ...filteredOptions\n } = options;\n /* eslint-enable @typescript-eslint/unbound-method,@typescript-eslint/no-unused-vars */\n const nativeIsReady = await RNSentry.initNativeSdk(filteredOptions);\n\n this.nativeIsReady = nativeIsReady;\n\n return nativeIsReady;\n },\n\n /**\n * Fetches the release from native\n */\n async fetchNativeRelease(): Promise<NativeReleaseResponse> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeRelease();\n },\n\n /**\n * Fetches the Sdk info for the native sdk.\n * NOTE: Only available on iOS.\n */\n async fetchNativeSdkInfo(): Promise<Package | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n if (this.platform !== 'ios') {\n return null;\n }\n\n return RNSentry.fetchNativeSdkInfo();\n },\n\n /**\n * Fetches the device contexts. Not used on Android.\n */\n async fetchNativeDeviceContexts(): Promise<NativeDeviceContextsResponse> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n if (this.platform !== 'ios') {\n // Only ios uses deviceContexts, return an empty object.\n return {};\n }\n\n return RNSentry.fetchNativeDeviceContexts();\n },\n\n async fetchNativeAppStart(): Promise<NativeAppStartResponse | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeAppStart();\n },\n\n async fetchNativeFrames(): Promise<NativeFramesResponse | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeFrames();\n },\n\n /**\n * Triggers a native crash.\n * Use this only for testing purposes.\n */\n nativeCrash(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.crash();\n },\n\n /**\n * Sets the user in the native scope.\n * Passing null clears the user.\n */\n setUser(user: User | null): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n // separate and serialze all non-default user keys.\n let defaultUserKeys = null;\n let otherUserKeys = null;\n if (user) {\n const { id, ip_address, email, username, ...otherKeys } = user;\n defaultUserKeys = this._serializeObject({\n email,\n id,\n ip_address,\n username,\n });\n otherUserKeys = this._serializeObject(otherKeys);\n }\n\n RNSentry.setUser(defaultUserKeys, otherUserKeys);\n },\n\n /**\n * Sets a tag in the native module.\n * @param key string\n * @param value string\n */\n setTag(key: string, value: string): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const stringifiedValue =\n typeof value === 'string' ? value : JSON.stringify(value);\n\n RNSentry.setTag(key, stringifiedValue);\n },\n\n /**\n * Sets an extra in the native scope, will stringify\n * extra value if it isn't already a string.\n * @param key string\n * @param extra any\n */\n setExtra(key: string, extra: unknown): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n // we stringify the extra as native only takes in strings.\n const stringifiedExtra =\n typeof extra === 'string' ? extra : JSON.stringify(extra);\n\n RNSentry.setExtra(key, stringifiedExtra);\n },\n\n /**\n * Adds breadcrumb to the native scope.\n * @param breadcrumb Breadcrumb\n */\n addBreadcrumb(breadcrumb: Breadcrumb): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.addBreadcrumb({\n ...breadcrumb,\n // Process and convert deprecated levels\n level: breadcrumb.level\n ? this._processLevel(breadcrumb.level)\n : undefined,\n data: breadcrumb.data\n ? this._serializeObject(breadcrumb.data)\n : undefined,\n });\n },\n\n /**\n * Clears breadcrumbs on the native scope.\n */\n clearBreadcrumbs(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.clearBreadcrumbs();\n },\n\n /**\n * Sets context on the native scope. Not implemented in Android yet.\n * @param key string\n * @param context key-value map\n */\n setContext(key: string, context: { [key: string]: unknown } | null): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.setContext(\n key,\n context !== null ? this._serializeObject(context) : null\n );\n },\n\n /**\n * Closes the Native Layer SDK\n */\n async closeNativeSdk(): Promise<void> {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n return RNSentry.closeNativeSdk().then(() => {\n this.enableNative = false;\n });\n },\n\n disableNativeFramesTracking(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n RNSentry.disableNativeFramesTracking();\n },\n\n isNativeTransportAvailable(): boolean {\n return this.enableNative && this._isModuleLoaded(RNSentry);\n },\n\n /**\n * Gets the event from envelopeItem and applies the level filter to the selected event.\n * @param data An envelope item containing the event.\n * @returns The event from envelopeItem or undefined.\n */\n _getEvent(envelopeItem: EventItem | AttachmentItem | UserFeedbackItem | SessionItem | ClientReportItem): Event | undefined {\n if (envelopeItem[0].type == 'event' || envelopeItem[0].type == 'transaction') {\n return this._processLevels(envelopeItem[1] as Event);\n }\n return undefined;\n },\n\n /**\n * Serializes all values of root-level keys into strings.\n * @param data key-value map.\n * @returns An object where all root-level values are strings.\n */\n _serializeObject(data: {\n [key: string]: unknown;\n }): { [key: string]: string } {\n const serialized: { [key: string]: string } = {};\n\n Object.keys(data).forEach((dataKey) => {\n const value = data[dataKey];\n serialized[dataKey] =\n typeof value === 'string' ? value : JSON.stringify(value);\n });\n\n return serialized;\n },\n\n /**\n * Convert js severity level in event.level and event.breadcrumbs to more widely supported levels.\n * @param event\n * @returns Event with more widely supported Severity level strings\n */\n\n _processLevels(event: Event): Event {\n const processed: Event = {\n ...event,\n level: event.level ? this._processLevel(event.level) : undefined,\n breadcrumbs: event.breadcrumbs?.map((breadcrumb) => ({\n ...breadcrumb,\n level: breadcrumb.level\n ? this._processLevel(breadcrumb.level)\n : undefined,\n })),\n };\n\n return processed;\n },\n\n /**\n * Convert js severity level which has critical and log to more widely supported levels.\n * @param level\n * @returns More widely supported Severity level strings\n */\n\n _processLevel(level: SeverityLevel): SeverityLevel {\n if (level == 'log' as SeverityLevel) {\n return 'debug' as SeverityLevel;\n }\n else if (level == 'critical' as SeverityLevel) {\n return 'fatal' as SeverityLevel;\n }\n\n\n return level;\n },\n\n /**\n * Checks whether the RNSentry module is loaded.\n */\n _isModuleLoaded(\n module: SentryNativeBridgeModule | undefined\n ): module is SentryNativeBridgeModule {\n return !!module;\n },\n\n _DisabledNativeError: new SentryError('Native is disabled'),\n\n _NativeClientError: new SentryError(\n \"Native Client is not available, can't start on native.\"\n ),\n\n enableNative: true,\n nativeIsReady: false,\n platform: Platform.OS,\n};\n"]}
1
+ {"version":3,"file":"wrapper.js","sourceRoot":"","sources":["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CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC;oBACtC,CAAC,CAAC,SAAS,IACb,IACH,CAAC;QAEF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;OAIG;IAEH,aAAa,CAAC,KAAoB;QAChC,IAAI,KAAK,IAAI,KAAsB,EAAE;YACnC,OAAO,OAAwB,CAAC;SACjC;aACI,IAAI,KAAK,IAAI,UAA2B,EAAE;YAC7C,OAAO,OAAwB,CAAC;SACjC;QAGD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,eAAe,CACb,MAAwB;QAExB,OAAO,CAAC,CAAC,MAAM,CAAC;IAClB,CAAC;IAED,oBAAoB,EAAE,IAAI,WAAW,CAAC,oBAAoB,CAAC;IAE3D,kBAAkB,EAAE,IAAI,WAAW,CACjC,wDAAwD,CACzD;IAED;;;;;;;;;OASG;IACH,eAAe,CAAC,KAAY;QAC1B,IAAI,WAAW,GAA6B,KAAK,CAAC,WAAW,CAAC;QAE9D,MAAM,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS;eAC5B,KAAK,CAAC,WAAW;eACjB,CAAC,WAAW,EAAE;YACjB,WAAW,GAAG,EAAE,CAAC;SAClB;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,YAAY,EAAE,IAAI;IAClB,aAAa,EAAE,KAAK;IACpB,QAAQ,EAAE,QAAQ,CAAC,EAAE;CACtB,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport {\n BaseEnvelopeItemHeaders,\n Breadcrumb,\n Envelope,\n EnvelopeItem,\n Event,\n Package,\n SeverityLevel,\n User,\n} from '@sentry/types';\nimport { logger, normalize, SentryError } from '@sentry/utils';\nimport { NativeModules, Platform , TurboModuleRegistry } from 'react-native';\n\nimport { isHardCrash } from './misc';\nimport {\n NativeAppStartResponse,\n NativeDeviceContextsResponse,\n NativeFramesResponse,\n NativeReleaseResponse,\n NativeScreenshot,\n Spec,\n} from './NativeRNSentry';\nimport { ReactNativeOptions } from './options';\nimport { RequiredKeysUser } from './user';\nimport { isTurboModuleEnabled } from './utils/environment'\nimport { utf8ToBytes } from './vendor';\n\nconst RNSentry: Spec | undefined = isTurboModuleEnabled()\n ? TurboModuleRegistry.getEnforcing<Spec>('RNSentry')\n : NativeModules.RNSentry;\n\nexport interface Screenshot {\n data: Uint8Array;\n contentType: string;\n filename: string;\n}\n\ninterface SentryNativeWrapper {\n enableNative: boolean;\n nativeIsReady: boolean;\n platform: typeof Platform.OS;\n\n _NativeClientError: Error;\n _DisabledNativeError: Error;\n\n _processItem(envelopeItem: EnvelopeItem): EnvelopeItem;\n _processLevels(event: Event): Event;\n _processLevel(level: SeverityLevel): SeverityLevel;\n _serializeObject(data: { [key: string]: unknown }): { [key: string]: string };\n _isModuleLoaded(\n module: Spec | undefined\n ): module is Spec;\n _getBreadcrumbs(event: Event): Breadcrumb[] | undefined;\n\n isNativeTransportAvailable(): boolean;\n\n initNativeSdk(options: ReactNativeOptions): PromiseLike<boolean>;\n closeNativeSdk(): PromiseLike<void>;\n\n sendEnvelope(envelope: Envelope): Promise<void>;\n captureScreenshot(): Promise<Screenshot[] | null>;\n\n fetchNativeRelease(): PromiseLike<NativeReleaseResponse>;\n fetchNativeDeviceContexts(): PromiseLike<NativeDeviceContextsResponse>;\n fetchNativeAppStart(): PromiseLike<NativeAppStartResponse | null>;\n fetchNativeFrames(): PromiseLike<NativeFramesResponse | null>;\n fetchNativeSdkInfo(): PromiseLike<Package | null>;\n\n disableNativeFramesTracking(): void;\n enableNativeFramesTracking(): void;\n\n addBreadcrumb(breadcrumb: Breadcrumb): void;\n setContext(key: string, context: { [key: string]: unknown } | null): void;\n clearBreadcrumbs(): void;\n setExtra(key: string, extra: unknown): void;\n setUser(user: User | null): void;\n setTag(key: string, value: string): void;\n\n nativeCrash(): void;\n\n fetchModules(): Promise<Record<string, string> | null>;\n}\n\n/**\n * Our internal interface for calling native functions\n */\nexport const NATIVE: SentryNativeWrapper = {\n async fetchModules(): Promise<Record<string, string> | null> {\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const raw = await RNSentry.fetchModules();\n if (raw) {\n return JSON.parse(raw);\n }\n return null;\n },\n /**\n * Sending the envelope over the bridge to native\n * @param envelope Envelope\n */\n async sendEnvelope(envelope: Envelope): Promise<void> {\n if (!this.enableNative) {\n logger.warn('Event was skipped as native SDK is not enabled.');\n return;\n }\n\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const [EOL] = utf8ToBytes('\\n');\n\n const [envelopeHeader, envelopeItems] = envelope;\n\n const headerString = JSON.stringify(envelopeHeader);\n let envelopeBytes: number[] = utf8ToBytes(headerString);\n envelopeBytes.push(EOL);\n\n let hardCrashed: boolean = false;\n for (const rawItem of envelopeItems) {\n const [itemHeader, itemPayload] = this._processItem(rawItem);\n\n let bytesContentType: string;\n let bytesPayload: number[] = [];\n if (typeof itemPayload === 'string') {\n bytesContentType = 'text/plain';\n bytesPayload = utf8ToBytes(itemPayload);\n } else if (itemPayload instanceof Uint8Array) {\n bytesContentType = typeof itemHeader.content_type === 'string'\n ? itemHeader.content_type\n : 'application/octet-stream';\n bytesPayload = [...itemPayload];\n } else {\n bytesContentType = 'application/json';\n bytesPayload = utf8ToBytes(JSON.stringify(itemPayload));\n if (!hardCrashed) {\n hardCrashed = isHardCrash(itemPayload);\n }\n }\n\n // Content type is not inside BaseEnvelopeItemHeaders.\n (itemHeader as BaseEnvelopeItemHeaders).content_type = bytesContentType;\n (itemHeader as BaseEnvelopeItemHeaders).length = bytesPayload.length;\n const serializedItemHeader = JSON.stringify(itemHeader);\n\n envelopeBytes.push(...utf8ToBytes(serializedItemHeader));\n envelopeBytes.push(EOL);\n envelopeBytes = envelopeBytes.concat(bytesPayload);\n envelopeBytes.push(EOL);\n }\n\n await RNSentry.captureEnvelope(envelopeBytes, { store: hardCrashed });\n },\n\n /**\n * Starts native with the provided options.\n * @param options ReactNativeOptions\n */\n async initNativeSdk(originalOptions: ReactNativeOptions): Promise<boolean> {\n const options = {\n enableNative: true,\n autoInitializeNativeSdk: true,\n ...originalOptions,\n };\n\n if (!options.enableNative) {\n if (options.enableNativeNagger) {\n logger.warn('Note: Native Sentry SDK is disabled.');\n }\n this.enableNative = false;\n return false;\n }\n if (!options.autoInitializeNativeSdk) {\n if (options.enableNativeNagger) {\n logger.warn(\n 'Note: Native Sentry SDK was not initialized automatically, you will need to initialize it manually. If you wish to disable the native SDK and get rid of this warning, pass enableNative: false'\n );\n }\n return false;\n }\n\n if (!options.dsn) {\n logger.warn(\n 'Warning: No DSN was provided. The Sentry SDK will be disabled. Native SDK will also not be initalized.'\n );\n return false;\n }\n\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n // filter out all the options that would crash native.\n /* eslint-disable @typescript-eslint/unbound-method,@typescript-eslint/no-unused-vars */\n const {\n beforeSend,\n beforeBreadcrumb,\n integrations,\n ...filteredOptions\n } = options;\n /* eslint-enable @typescript-eslint/unbound-method,@typescript-eslint/no-unused-vars */\n const nativeIsReady = await RNSentry.initNativeSdk(filteredOptions);\n\n this.nativeIsReady = nativeIsReady;\n\n return nativeIsReady;\n },\n\n /**\n * Fetches the release from native\n */\n async fetchNativeRelease(): Promise<NativeReleaseResponse> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeRelease();\n },\n\n /**\n * Fetches the Sdk info for the native sdk.\n * NOTE: Only available on iOS.\n */\n async fetchNativeSdkInfo(): Promise<Package | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n if (this.platform !== 'ios') {\n return null;\n }\n\n return RNSentry.fetchNativeSdkInfo();\n },\n\n /**\n * Fetches the device contexts. Not used on Android.\n */\n async fetchNativeDeviceContexts(): Promise<NativeDeviceContextsResponse> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n if (this.platform !== 'ios') {\n // Only ios uses deviceContexts, return an empty object.\n return {};\n }\n\n return RNSentry.fetchNativeDeviceContexts();\n },\n\n async fetchNativeAppStart(): Promise<NativeAppStartResponse | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeAppStart();\n },\n\n async fetchNativeFrames(): Promise<NativeFramesResponse | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeFrames();\n },\n\n /**\n * Triggers a native crash.\n * Use this only for testing purposes.\n */\n nativeCrash(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.crash();\n },\n\n /**\n * Sets the user in the native scope.\n * Passing null clears the user.\n */\n setUser(user: User | null): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n // separate and serialize all non-default user keys.\n let userKeys = null;\n let userDataKeys = null;\n if (user) {\n const { id, ip_address, email, username, segment, ...otherKeys } = user;\n const requiredUser: RequiredKeysUser = {\n id,\n ip_address,\n email,\n username,\n segment,\n };\n userKeys = this._serializeObject(requiredUser);\n userDataKeys = this._serializeObject(otherKeys);\n }\n\n RNSentry.setUser(userKeys, userDataKeys);\n },\n\n /**\n * Sets a tag in the native module.\n * @param key string\n * @param value string\n */\n setTag(key: string, value: string): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const stringifiedValue =\n typeof value === 'string' ? value : JSON.stringify(value);\n\n RNSentry.setTag(key, stringifiedValue);\n },\n\n /**\n * Sets an extra in the native scope, will stringify\n * extra value if it isn't already a string.\n * @param key string\n * @param extra any\n */\n setExtra(key: string, extra: unknown): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n // we stringify the extra as native only takes in strings.\n const stringifiedExtra =\n typeof extra === 'string' ? extra : JSON.stringify(extra);\n\n RNSentry.setExtra(key, stringifiedExtra);\n },\n\n /**\n * Adds breadcrumb to the native scope.\n * @param breadcrumb Breadcrumb\n */\n addBreadcrumb(breadcrumb: Breadcrumb): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.addBreadcrumb({\n ...breadcrumb,\n // Process and convert deprecated levels\n level: breadcrumb.level\n ? this._processLevel(breadcrumb.level)\n : undefined,\n data: breadcrumb.data\n ? normalize(breadcrumb.data)\n : undefined,\n });\n },\n\n /**\n * Clears breadcrumbs on the native scope.\n */\n clearBreadcrumbs(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.clearBreadcrumbs();\n },\n\n /**\n * Sets context on the native scope. Not implemented in Android yet.\n * @param key string\n * @param context key-value map\n */\n setContext(key: string, context: { [key: string]: unknown } | null): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.setContext(\n key,\n context !== null ? normalize(context) : null\n );\n },\n\n /**\n * Closes the Native Layer SDK\n */\n async closeNativeSdk(): Promise<void> {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n return RNSentry.closeNativeSdk().then(() => {\n this.enableNative = false;\n });\n },\n\n disableNativeFramesTracking(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n RNSentry.disableNativeFramesTracking();\n },\n\n enableNativeFramesTracking(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n RNSentry.enableNativeFramesTracking();\n },\n\n isNativeTransportAvailable(): boolean {\n return this.enableNative && this._isModuleLoaded(RNSentry);\n },\n\n async captureScreenshot(): Promise<Screenshot[] | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n try {\n const raw = await RNSentry.captureScreenshot();\n return raw.map((item: NativeScreenshot) => ({\n ...item,\n data: new Uint8Array(item.data),\n }));\n } catch (e) {\n logger.warn('Failed to capture screenshot', e);\n return null;\n }\n },\n\n /**\n * Gets the event from envelopeItem and applies the level filter to the selected event.\n * @param data An envelope item containing the event.\n * @returns The event from envelopeItem or undefined.\n */\n _processItem(item: EnvelopeItem): EnvelopeItem {\n const [itemHeader, itemPayload] = item;\n\n if (itemHeader.type == 'event' || itemHeader.type == 'transaction') {\n const event = this._processLevels(itemPayload as Event);\n\n if (NATIVE.platform === 'android') {\n if ('message' in event) {\n // @ts-ignore Android still uses the old message object, without this the serialization of events will break.\n event.message = { message: event.message };\n }\n event.breadcrumbs = this._getBreadcrumbs(event);\n }\n\n return [itemHeader, event];\n }\n\n return item;\n },\n\n /**\n * Serializes all values of root-level keys into strings.\n * @param data key-value map.\n * @returns An object where all root-level values are strings.\n */\n _serializeObject(data: {\n [key: string]: unknown;\n }): { [key: string]: string } {\n const serialized: { [key: string]: string } = {};\n\n Object.keys(data).forEach((dataKey) => {\n const value = data[dataKey];\n serialized[dataKey] =\n typeof value === 'string' ? value : JSON.stringify(value);\n });\n\n return serialized;\n },\n\n /**\n * Convert js severity level in event.level and event.breadcrumbs to more widely supported levels.\n * @param event\n * @returns Event with more widely supported Severity level strings\n */\n\n _processLevels(event: Event): Event {\n const processed: Event = {\n ...event,\n level: event.level ? this._processLevel(event.level) : undefined,\n breadcrumbs: event.breadcrumbs?.map((breadcrumb) => ({\n ...breadcrumb,\n level: breadcrumb.level\n ? this._processLevel(breadcrumb.level)\n : undefined,\n })),\n };\n\n return processed;\n },\n\n /**\n * Convert js severity level which has critical and log to more widely supported levels.\n * @param level\n * @returns More widely supported Severity level strings\n */\n\n _processLevel(level: SeverityLevel): SeverityLevel {\n if (level == 'log' as SeverityLevel) {\n return 'debug' as SeverityLevel;\n }\n else if (level == 'critical' as SeverityLevel) {\n return 'fatal' as SeverityLevel;\n }\n\n\n return level;\n },\n\n /**\n * Checks whether the RNSentry module is loaded.\n */\n _isModuleLoaded(\n module: Spec | undefined\n ): module is Spec {\n return !!module;\n },\n\n _DisabledNativeError: new SentryError('Native is disabled'),\n\n _NativeClientError: new SentryError(\n \"Native Client is not available, can't start on native.\"\n ),\n\n /**\n * Get breadcrumbs (removes breadcrumbs from handled exceptions on Android)\n *\n * We do this to avoid duplicate breadcrumbs on Android as sentry-android applies the breadcrumbs\n * from the native scope onto every envelope sent through it. This scope will contain the breadcrumbs\n * sent through the scope sync feature. This causes duplicate breadcrumbs.\n * We then remove the breadcrumbs in all cases but if it is handled == false,\n * this is a signal that the app would crash and android would lose the breadcrumbs by the time the app is restarted to read\n * the envelope.\n */\n _getBreadcrumbs(event: Event): Breadcrumb[] | undefined {\n let breadcrumbs: Breadcrumb[] | undefined = event.breadcrumbs;\n\n const hardCrashed = isHardCrash(event);\n if (NATIVE.platform === 'android'\n && event.breadcrumbs\n && !hardCrashed) {\n breadcrumbs = [];\n }\n\n return breadcrumbs;\n },\n\n enableNative: true,\n nativeIsReady: false,\n platform: Platform.OS,\n};\n"]}
@@ -7,8 +7,14 @@
7
7
  #endif
8
8
 
9
9
  #import <Sentry/Sentry.h>
10
+ #import <Sentry/PrivateSentrySDKOnly.h>
10
11
  #import <Sentry/SentryScreenFrames.h>
11
12
 
13
+ // Thanks to this guard, we won't import this header when we build for the old architecture.
14
+ #ifdef RCT_NEW_ARCH_ENABLED
15
+ #import "RNSentrySpec.h"
16
+ #endif
17
+
12
18
  @interface SentryTraceContext : NSObject
13
19
  - (nullable instancetype)initWithDict:(NSDictionary<NSString *, id> *)dictionary;
14
20
  @end
@@ -25,7 +31,6 @@ static bool didFetchAppStart;
25
31
 
26
32
  @implementation RNSentry {
27
33
  bool sentHybridSdkDidBecomeActive;
28
- SentryOptions *sentryOptions;
29
34
  }
30
35
 
31
36
  - (dispatch_queue_t)methodQueue
@@ -39,11 +44,6 @@ static bool didFetchAppStart;
39
44
 
40
45
  RCT_EXPORT_MODULE()
41
46
 
42
- - (NSDictionary<NSString *, id> *)constantsToExport
43
- {
44
- return @{@"nativeClientAvailable": @YES, @"nativeTransport": @YES};
45
- }
46
-
47
47
  RCT_EXPORT_METHOD(initNativeSdk:(NSDictionary *_Nonnull)options
48
48
  resolve:(RCTPromiseResolveBlock)resolve
49
49
  rejecter:(RCTPromiseRejectBlock)reject)
@@ -73,7 +73,7 @@ RCT_EXPORT_METHOD(initNativeSdk:(NSDictionary *_Nonnull)options
73
73
  [mutableOptions removeObjectForKey:@"tracesSampleRate"];
74
74
  [mutableOptions removeObjectForKey:@"tracesSampler"];
75
75
 
76
- sentryOptions = [[SentryOptions alloc] initWithDict:mutableOptions didFailWithError:&error];
76
+ SentryOptions *sentryOptions = [[SentryOptions alloc] initWithDict:mutableOptions didFailWithError:&error];
77
77
  if (error) {
78
78
  reject(@"SentryReactNative", error.localizedDescription, error);
79
79
  return;
@@ -108,7 +108,7 @@ RCT_EXPORT_METHOD(initNativeSdk:(NSDictionary *_Nonnull)options
108
108
  #endif
109
109
 
110
110
  // If the app is active/in foreground, and we have not sent the SentryHybridSdkDidBecomeActive notification, send it.
111
- if (appIsActive && !sentHybridSdkDidBecomeActive && (sentryOptions.enableAutoSessionTracking || sentryOptions.enableOutOfMemoryTracking)) {
111
+ if (appIsActive && !sentHybridSdkDidBecomeActive && (PrivateSentrySDKOnly.options.enableAutoSessionTracking || PrivateSentrySDKOnly.options.enableOutOfMemoryTracking)) {
112
112
  [[NSNotificationCenter defaultCenter]
113
113
  postNotificationName:@"SentryHybridSdkDidBecomeActive"
114
114
  object:nil];
@@ -155,16 +155,22 @@ RCT_EXPORT_METHOD(initNativeSdk:(NSDictionary *_Nonnull)options
155
155
  RCT_EXPORT_METHOD(fetchNativeSdkInfo:(RCTPromiseResolveBlock)resolve
156
156
  rejecter:(RCTPromiseRejectBlock)reject)
157
157
  {
158
- if (sentryOptions == nil) {
159
- return reject(@"SentryReactNative",@"Called fetchNativeSdkInfo without initializing the SDK first.", nil);
160
- }
161
-
162
158
  resolve(@{
163
- @"name": sentryOptions.sdkInfo.name,
164
- @"version": sentryOptions.sdkInfo.version
159
+ @"name": PrivateSentrySDKOnly.getSdkName,
160
+ @"version": PrivateSentrySDKOnly.getSdkVersionString
165
161
  });
166
162
  }
167
163
 
164
+ RCT_EXPORT_METHOD(fetchModules:(RCTPromiseResolveBlock)resolve
165
+ rejecter:(RCTPromiseRejectBlock)reject)
166
+ {
167
+ NSString *filePath = [[NSBundle mainBundle] pathForResource:@"modules" ofType:@"json"];
168
+ NSString* modulesString = [NSString stringWithContentsOfFile:filePath
169
+ encoding:NSUTF8StringEncoding
170
+ error:nil];
171
+ resolve(modulesString);
172
+ }
173
+
168
174
  RCT_EXPORT_METHOD(fetchNativeDeviceContexts:(RCTPromiseResolveBlock)resolve
169
175
  rejecter:(RCTPromiseRejectBlock)reject)
170
176
  {
@@ -190,7 +196,7 @@ RCT_EXPORT_METHOD(fetchNativeDeviceContexts:(RCTPromiseResolveBlock)resolve
190
196
  if (tempContexts != nil) {
191
197
  [contexts setValue:tempContexts forKey:@"context"];
192
198
  }
193
- if (sentryOptions != nil && sentryOptions.debug) {
199
+ if (PrivateSentrySDKOnly.options.debug) {
194
200
  NSData *data = [NSJSONSerialization dataWithJSONObject:contexts options:0 error:nil];
195
201
  NSString *debugContext = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
196
202
  NSLog(@"Contexts: %@", debugContext);
@@ -270,67 +276,85 @@ RCT_EXPORT_METHOD(fetchNativeRelease:(RCTPromiseResolveBlock)resolve
270
276
  });
271
277
  }
272
278
 
273
- RCT_EXPORT_METHOD(captureEnvelope:(NSDictionary * _Nonnull)envelopeDict
279
+ RCT_EXPORT_METHOD(captureEnvelope:(NSArray * _Nonnull)bytes
280
+ options: (NSDictionary * _Nonnull)options
274
281
  resolve:(RCTPromiseResolveBlock)resolve
275
282
  rejecter:(RCTPromiseRejectBlock)reject)
276
283
  {
277
- if ([NSJSONSerialization isValidJSONObject:envelopeDict]) {
278
- SentrySdkInfo *sdkInfo = [[SentrySdkInfo alloc] initWithDict:envelopeDict[@"header"]];
279
- SentryId *eventId = [[SentryId alloc] initWithUUIDString:envelopeDict[@"header"][@"event_id"]];
280
- SentryTraceContext *traceContext = [[SentryTraceContext alloc] initWithDict:envelopeDict[@"header"][@"trace"]];
281
- SentryEnvelopeHeader *envelopeHeader = [[SentryEnvelopeHeader alloc] initWithId:eventId sdkInfo:sdkInfo traceContext:traceContext];
282
-
283
- NSError *error;
284
- NSData *envelopeItemData = [NSJSONSerialization dataWithJSONObject:envelopeDict[@"payload"] options:0 error:&error];
285
- if (nil != error) {
286
- reject(@"SentryReactNative", @"Cannot serialize event", error);
287
- }
284
+ NSMutableData *data = [[NSMutableData alloc] initWithCapacity: [bytes count]];
285
+ for(NSNumber *number in bytes) {
286
+ char byte = [number charValue];
287
+ [data appendBytes: &byte length: 1];
288
+ }
288
289
 
289
- NSString *itemType = envelopeDict[@"payload"][@"type"];
290
- if (itemType == nil) {
291
- // Default to event type.
292
- itemType = @"event";
293
- }
290
+ SentryEnvelope *envelope = [PrivateSentrySDKOnly envelopeWithData:data];
291
+ if (envelope == nil) {
292
+ reject(@"SentryReactNative",@"Failed to parse envelope from byte array.", nil);
293
+ return;
294
+ }
294
295
 
295
- SentryEnvelopeItemHeader *envelopeItemHeader = [[SentryEnvelopeItemHeader alloc] initWithType:itemType length:envelopeItemData.length];
296
- SentryEnvelopeItem *envelopeItem = [[SentryEnvelopeItem alloc] initWithHeader:envelopeItemHeader data:envelopeItemData];
296
+ #if DEBUG
297
+ [PrivateSentrySDKOnly captureEnvelope:envelope];
298
+ #else
299
+ if (options[@'store']) {
300
+ // Storing to disk happens asynchronously with captureEnvelope
301
+ [PrivateSentrySDKOnly storeEnvelope:envelope];
302
+ } else {
303
+ [PrivateSentrySDKOnly captureEnvelope:envelope];
304
+ }
305
+ #endif
306
+ resolve(@YES);
307
+ }
297
308
 
298
- SentryEnvelope *envelope = [[SentryEnvelope alloc] initWithHeader:envelopeHeader singleItem:envelopeItem];
309
+ RCT_EXPORT_METHOD(captureScreenshot: (RCTPromiseResolveBlock)resolve
310
+ rejecter: (RCTPromiseRejectBlock)reject)
311
+ {
312
+ NSArray<NSData *>* rawScreenshots = [PrivateSentrySDKOnly captureScreenshots];
313
+ NSMutableArray *screenshotsArray = [NSMutableArray arrayWithCapacity:[rawScreenshots count]];
314
+
315
+ int counter = 1;
316
+ for (NSData* raw in rawScreenshots) {
317
+ NSMutableArray *screenshot = [NSMutableArray arrayWithCapacity:raw.length];
318
+ const char *bytes = (char*) [raw bytes];
319
+ for (int i = 0; i < [raw length]; i++) {
320
+ [screenshot addObject:[[NSNumber alloc] initWithChar:bytes[i]]];
321
+ }
299
322
 
300
- #if DEBUG
301
- [PrivateSentrySDKOnly captureEnvelope:envelope];
302
- #else
303
- if ([envelopeDict[@"payload"][@"level"] isEqualToString:@"fatal"]) {
304
- // Storing to disk happens asynchronously with captureEnvelope
305
- [PrivateSentrySDKOnly storeEnvelope:envelope];
306
- } else {
307
- [PrivateSentrySDKOnly captureEnvelope:envelope];
308
- }
309
- #endif
310
- resolve(@YES);
311
- } else {
312
- reject(@"SentryReactNative", @"Cannot serialize event", nil);
323
+ NSString* filename = @"screenshot.png";
324
+ if (counter > 1) {
325
+ filename = [NSString stringWithFormat:@"screenshot-%d.png", counter];
326
+ }
327
+ [screenshotsArray addObject:@{
328
+ @"data": screenshot,
329
+ @"contentType": @"image/png",
330
+ @"filename": filename,
331
+ }];
332
+ counter++;
313
333
  }
334
+
335
+ resolve(screenshotsArray);
314
336
  }
315
337
 
316
- RCT_EXPORT_METHOD(setUser:(NSDictionary *)user
317
- otherUserKeys:(NSDictionary *)otherUserKeys
338
+ RCT_EXPORT_METHOD(setUser:(NSDictionary *)userKeys
339
+ otherUserKeys:(NSDictionary *)userDataKeys
318
340
  )
319
341
  {
320
342
  [SentrySDK configureScope:^(SentryScope * _Nonnull scope) {
321
- if (nil == user && nil == otherUserKeys) {
343
+ if (nil == userKeys && nil == userDataKeys) {
322
344
  [scope setUser:nil];
323
345
  } else {
324
346
  SentryUser* userInstance = [[SentryUser alloc] init];
325
347
 
326
- if (nil != user) {
327
- [userInstance setUserId:user[@"id"]];
328
- [userInstance setEmail:user[@"email"]];
329
- [userInstance setUsername:user[@"username"]];
348
+ if (nil != userKeys) {
349
+ [userInstance setUserId:userKeys[@"id"]];
350
+ [userInstance setIpAddress:userKeys[@"ip_address"]];
351
+ [userInstance setEmail:userKeys[@"email"]];
352
+ [userInstance setUsername:userKeys[@"username"]];
353
+ [userInstance setSegment:userKeys[@"segment"]];
330
354
  }
331
355
 
332
- if (nil != otherUserKeys) {
333
- [userInstance setData:otherUserKeys];
356
+ if (nil != userDataKeys) {
357
+ [userInstance setData:userDataKeys];
334
358
  }
335
359
 
336
360
  [scope setUser:userInstance];
@@ -420,4 +444,21 @@ RCT_EXPORT_METHOD(disableNativeFramesTracking)
420
444
  // Do nothing on iOS, this bridge method only has an effect on android.
421
445
  }
422
446
 
447
+ RCT_EXPORT_METHOD(enableNativeFramesTracking)
448
+ {
449
+ // Do nothing on iOS, this bridge method only has an effect on android.
450
+ // If you're starting the Cocoa SDK manually,
451
+ // you can set the 'enableAutoPerformanceTracking: true' option and
452
+ // the 'tracesSampleRate' or 'tracesSampler' option.
453
+ }
454
+
455
+ // Thanks to this guard, we won't compile this code when we build for the old architecture.
456
+ #ifdef RCT_NEW_ARCH_ENABLED
457
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
458
+ (const facebook::react::ObjCTurboModule::InitParams &)params
459
+ {
460
+ return std::make_shared<facebook::react::NativeRNSentrySpecJSI>(params);
461
+ }
462
+ #endif
463
+
423
464
  @end