@sentry/react-native 6.7.0-alpha.0 → 6.8.0

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 (86) hide show
  1. package/RNSentry.podspec +2 -2
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +280 -2
  4. package/android/src/main/java/io/sentry/react/RNSentryVersion.java +1 -1
  5. package/dist/js/integrations/debugsymbolicator.js +9 -1
  6. package/dist/js/integrations/debugsymbolicator.js.map +1 -1
  7. package/dist/js/integrations/debugsymbolicatorutils.js +9 -1
  8. package/dist/js/integrations/debugsymbolicatorutils.js.map +1 -1
  9. package/dist/js/integrations/devicecontext.js +9 -1
  10. package/dist/js/integrations/devicecontext.js.map +1 -1
  11. package/dist/js/integrations/modulesloader.js +9 -1
  12. package/dist/js/integrations/modulesloader.js.map +1 -1
  13. package/dist/js/integrations/reactnativeerrorhandlers.js +9 -1
  14. package/dist/js/integrations/reactnativeerrorhandlers.js.map +1 -1
  15. package/dist/js/integrations/release.js +9 -1
  16. package/dist/js/integrations/release.js.map +1 -1
  17. package/dist/js/integrations/screenshot.js +9 -1
  18. package/dist/js/integrations/screenshot.js.map +1 -1
  19. package/dist/js/integrations/sdkinfo.js +9 -1
  20. package/dist/js/integrations/sdkinfo.js.map +1 -1
  21. package/dist/js/integrations/viewhierarchy.js +9 -1
  22. package/dist/js/integrations/viewhierarchy.js.map +1 -1
  23. package/dist/js/replay/mobilereplay.js +9 -1
  24. package/dist/js/replay/mobilereplay.js.map +1 -1
  25. package/dist/js/sdk.d.ts.map +1 -1
  26. package/dist/js/sdk.js +19 -22
  27. package/dist/js/sdk.js.map +1 -1
  28. package/dist/js/tools/metroMiddleware.js +11 -3
  29. package/dist/js/tools/metroMiddleware.js.map +1 -1
  30. package/dist/js/tools/metroconfig.d.ts +7 -11
  31. package/dist/js/tools/metroconfig.d.ts.map +1 -1
  32. package/dist/js/tools/metroconfig.js +25 -14
  33. package/dist/js/tools/metroconfig.js.map +1 -1
  34. package/dist/js/tools/sentryBabelTransformer.d.ts +1 -2
  35. package/dist/js/tools/sentryBabelTransformer.d.ts.map +1 -1
  36. package/dist/js/tools/sentryBabelTransformer.js +1 -23
  37. package/dist/js/tools/sentryBabelTransformer.js.map +1 -1
  38. package/dist/js/tools/sentryBabelTransformerUtils.d.ts +18 -0
  39. package/dist/js/tools/sentryBabelTransformerUtils.d.ts.map +1 -1
  40. package/dist/js/tools/sentryBabelTransformerUtils.js +71 -1
  41. package/dist/js/tools/sentryBabelTransformerUtils.js.map +1 -1
  42. package/dist/js/tools/sentryMetroSerializer.d.ts.map +1 -1
  43. package/dist/js/tools/sentryMetroSerializer.js +11 -4
  44. package/dist/js/tools/sentryMetroSerializer.js.map +1 -1
  45. package/dist/js/tools/utils.d.ts +1 -2
  46. package/dist/js/tools/utils.d.ts.map +1 -1
  47. package/dist/js/tools/utils.js.map +1 -1
  48. package/dist/js/tracing/integrations/appStart.js +9 -1
  49. package/dist/js/tracing/integrations/appStart.js.map +1 -1
  50. package/dist/js/tracing/integrations/nativeFrames.js +9 -1
  51. package/dist/js/tracing/integrations/nativeFrames.js.map +1 -1
  52. package/dist/js/utils/worldwide.d.ts +0 -2
  53. package/dist/js/utils/worldwide.d.ts.map +1 -1
  54. package/dist/js/utils/worldwide.js.map +1 -1
  55. package/dist/js/version.d.ts +1 -1
  56. package/dist/js/version.d.ts.map +1 -1
  57. package/dist/js/version.js +1 -1
  58. package/dist/js/version.js.map +1 -1
  59. package/dist/js/wrapper.js +20 -1
  60. package/dist/js/wrapper.js.map +1 -1
  61. package/ios/RNSentry.h +5 -3
  62. package/ios/RNSentry.mm +210 -19
  63. package/ios/RNSentryVersion.m +1 -1
  64. package/package.json +8 -8
  65. package/plugin/build/withSentry.d.ts +2 -0
  66. package/plugin/build/withSentry.js +10 -0
  67. package/plugin/build/withSentryAndroidGradlePlugin.d.ts +15 -0
  68. package/plugin/build/withSentryAndroidGradlePlugin.js +91 -0
  69. package/scripts/collect-modules.sh +5 -5
  70. package/scripts/sentry-xcode.sh +0 -19
  71. package/sentry.gradle +1 -52
  72. package/ts3.8/dist/js/utils/worldwide.d.ts +0 -2
  73. package/ts3.8/dist/js/version.d.ts +1 -1
  74. package/android/src/main/java/io/sentry/react/RNSentryCompositeOptionsConfiguration.java +0 -25
  75. package/android/src/main/java/io/sentry/react/RNSentryJsonConverter.java +0 -76
  76. package/android/src/main/java/io/sentry/react/RNSentryJsonUtils.java +0 -41
  77. package/android/src/main/java/io/sentry/react/RNSentrySDK.java +0 -68
  78. package/android/src/main/java/io/sentry/react/RNSentryStart.java +0 -365
  79. package/dist/js/tools/sentryOptionsSerializer.d.ts +0 -6
  80. package/dist/js/tools/sentryOptionsSerializer.d.ts.map +0 -1
  81. package/dist/js/tools/sentryOptionsSerializer.js +0 -91
  82. package/dist/js/tools/sentryOptionsSerializer.js.map +0 -1
  83. package/ios/RNSentrySDK.h +0 -31
  84. package/ios/RNSentrySDK.m +0 -71
  85. package/ios/RNSentryStart.h +0 -26
  86. package/ios/RNSentryStart.m +0 -222
package/RNSentry.podspec CHANGED
@@ -33,11 +33,11 @@ Pod::Spec.new do |s|
33
33
  s.preserve_paths = '*.js'
34
34
 
35
35
  s.source_files = 'ios/**/*.{h,m,mm}'
36
- s.public_header_files = 'ios/RNSentry.h', 'ios/RNSentrySDK.h'
36
+ s.public_header_files = 'ios/RNSentry.h'
37
37
 
38
38
  s.compiler_flags = other_cflags
39
39
 
40
- s.dependency 'Sentry/HybridSDK', '8.44.0'
40
+ s.dependency 'Sentry/HybridSDK', '8.45.0'
41
41
 
42
42
  if defined? install_modules_dependencies
43
43
  # Default React Native dependencies for 0.71 and above (new and legacy architecture)
@@ -54,5 +54,5 @@ android {
54
54
 
55
55
  dependencies {
56
56
  implementation 'com.facebook.react:react-native:+'
57
- api 'io.sentry:sentry-android:7.20.1'
57
+ api 'io.sentry:sentry-android:7.22.0'
58
58
  }
@@ -20,11 +20,13 @@ import com.facebook.react.bridge.Promise;
20
20
  import com.facebook.react.bridge.ReactApplicationContext;
21
21
  import com.facebook.react.bridge.ReadableMap;
22
22
  import com.facebook.react.bridge.ReadableMapKeySetIterator;
23
+ import com.facebook.react.bridge.ReadableType;
23
24
  import com.facebook.react.bridge.UiThreadUtil;
24
25
  import com.facebook.react.bridge.WritableArray;
25
26
  import com.facebook.react.bridge.WritableMap;
26
27
  import com.facebook.react.bridge.WritableNativeArray;
27
28
  import com.facebook.react.bridge.WritableNativeMap;
29
+ import com.facebook.react.common.JavascriptException;
28
30
  import com.facebook.react.modules.core.DeviceEventManagerModule;
29
31
  import io.sentry.Breadcrumb;
30
32
  import io.sentry.HubAdapter;
@@ -32,16 +34,25 @@ import io.sentry.ILogger;
32
34
  import io.sentry.IScope;
33
35
  import io.sentry.ISentryExecutorService;
34
36
  import io.sentry.ISerializer;
37
+ import io.sentry.Integration;
35
38
  import io.sentry.Sentry;
36
39
  import io.sentry.SentryDate;
37
40
  import io.sentry.SentryDateProvider;
41
+ import io.sentry.SentryEvent;
38
42
  import io.sentry.SentryExecutorService;
39
43
  import io.sentry.SentryLevel;
40
44
  import io.sentry.SentryOptions;
45
+ import io.sentry.SentryReplayOptions;
46
+ import io.sentry.UncaughtExceptionHandlerIntegration;
41
47
  import io.sentry.android.core.AndroidLogger;
42
48
  import io.sentry.android.core.AndroidProfiler;
49
+ import io.sentry.android.core.AnrIntegration;
50
+ import io.sentry.android.core.BuildConfig;
43
51
  import io.sentry.android.core.BuildInfoProvider;
52
+ import io.sentry.android.core.CurrentActivityHolder;
44
53
  import io.sentry.android.core.InternalSentrySdk;
54
+ import io.sentry.android.core.NdkIntegration;
55
+ import io.sentry.android.core.SentryAndroid;
45
56
  import io.sentry.android.core.SentryAndroidDateProvider;
46
57
  import io.sentry.android.core.SentryAndroidOptions;
47
58
  import io.sentry.android.core.ViewHierarchyEventProcessor;
@@ -50,8 +61,11 @@ import io.sentry.android.core.internal.util.SentryFrameMetricsCollector;
50
61
  import io.sentry.android.core.performance.AppStartMetrics;
51
62
  import io.sentry.protocol.SdkVersion;
52
63
  import io.sentry.protocol.SentryId;
64
+ import io.sentry.protocol.SentryPackage;
53
65
  import io.sentry.protocol.User;
54
66
  import io.sentry.protocol.ViewHierarchy;
67
+ import io.sentry.react.replay.RNSentryReplayMask;
68
+ import io.sentry.react.replay.RNSentryReplayUnmask;
55
69
  import io.sentry.util.DebugMetaPropertiesApplier;
56
70
  import io.sentry.util.FileUtils;
57
71
  import io.sentry.util.JsonSerializationUtils;
@@ -63,6 +77,8 @@ import java.io.FileNotFoundException;
63
77
  import java.io.FileReader;
64
78
  import java.io.IOException;
65
79
  import java.io.InputStream;
80
+ import java.net.URI;
81
+ import java.net.URISyntaxException;
66
82
  import java.nio.charset.Charset;
67
83
  import java.util.HashMap;
68
84
  import java.util.Iterator;
@@ -162,12 +178,216 @@ public class RNSentryModuleImpl {
162
178
  }
163
179
 
164
180
  public void initNativeSdk(final ReadableMap rnOptions, Promise promise) {
165
- RNSentryStart.startWithOptions(
166
- this.getReactApplicationContext(), rnOptions, getCurrentActivity(), logger);
181
+ SentryAndroid.init(
182
+ this.getReactApplicationContext(),
183
+ options -> getSentryAndroidOptions(options, rnOptions, logger));
167
184
 
168
185
  promise.resolve(true);
169
186
  }
170
187
 
188
+ protected void getSentryAndroidOptions(
189
+ @NotNull SentryAndroidOptions options, @NotNull ReadableMap rnOptions, ILogger logger) {
190
+ @Nullable SdkVersion sdkVersion = options.getSdkVersion();
191
+ if (sdkVersion == null) {
192
+ sdkVersion = new SdkVersion(RNSentryVersion.ANDROID_SDK_NAME, BuildConfig.VERSION_NAME);
193
+ } else {
194
+ sdkVersion.setName(RNSentryVersion.ANDROID_SDK_NAME);
195
+ }
196
+ sdkVersion.addPackage(
197
+ RNSentryVersion.REACT_NATIVE_SDK_PACKAGE_NAME,
198
+ RNSentryVersion.REACT_NATIVE_SDK_PACKAGE_VERSION);
199
+
200
+ options.setSentryClientName(sdkVersion.getName() + "/" + sdkVersion.getVersion());
201
+ options.setNativeSdkName(RNSentryVersion.NATIVE_SDK_NAME);
202
+ options.setSdkVersion(sdkVersion);
203
+
204
+ if (rnOptions.hasKey("debug") && rnOptions.getBoolean("debug")) {
205
+ options.setDebug(true);
206
+ }
207
+ if (rnOptions.hasKey("dsn") && rnOptions.getString("dsn") != null) {
208
+ String dsn = rnOptions.getString("dsn");
209
+ logger.log(SentryLevel.INFO, String.format("Starting with DSN: '%s'", dsn));
210
+ options.setDsn(dsn);
211
+ } else {
212
+ // SentryAndroid needs an empty string fallback for the dsn.
213
+ options.setDsn("");
214
+ }
215
+ if (rnOptions.hasKey("sampleRate")) {
216
+ options.setSampleRate(rnOptions.getDouble("sampleRate"));
217
+ }
218
+ if (rnOptions.hasKey("sendClientReports")) {
219
+ options.setSendClientReports(rnOptions.getBoolean("sendClientReports"));
220
+ }
221
+ if (rnOptions.hasKey("maxBreadcrumbs")) {
222
+ options.setMaxBreadcrumbs(rnOptions.getInt("maxBreadcrumbs"));
223
+ }
224
+ if (rnOptions.hasKey("maxCacheItems")) {
225
+ options.setMaxCacheItems(rnOptions.getInt("maxCacheItems"));
226
+ }
227
+ if (rnOptions.hasKey("environment") && rnOptions.getString("environment") != null) {
228
+ options.setEnvironment(rnOptions.getString("environment"));
229
+ }
230
+ if (rnOptions.hasKey("release") && rnOptions.getString("release") != null) {
231
+ options.setRelease(rnOptions.getString("release"));
232
+ }
233
+ if (rnOptions.hasKey("dist") && rnOptions.getString("dist") != null) {
234
+ options.setDist(rnOptions.getString("dist"));
235
+ }
236
+ if (rnOptions.hasKey("enableAutoSessionTracking")) {
237
+ options.setEnableAutoSessionTracking(rnOptions.getBoolean("enableAutoSessionTracking"));
238
+ }
239
+ if (rnOptions.hasKey("sessionTrackingIntervalMillis")) {
240
+ options.setSessionTrackingIntervalMillis(rnOptions.getInt("sessionTrackingIntervalMillis"));
241
+ }
242
+ if (rnOptions.hasKey("shutdownTimeout")) {
243
+ options.setShutdownTimeoutMillis(rnOptions.getInt("shutdownTimeout"));
244
+ }
245
+ if (rnOptions.hasKey("enableNdkScopeSync")) {
246
+ options.setEnableScopeSync(rnOptions.getBoolean("enableNdkScopeSync"));
247
+ }
248
+ if (rnOptions.hasKey("attachStacktrace")) {
249
+ options.setAttachStacktrace(rnOptions.getBoolean("attachStacktrace"));
250
+ }
251
+ if (rnOptions.hasKey("attachThreads")) {
252
+ // JS use top level stacktrace and android attaches Threads which hides them so
253
+ // by default we hide.
254
+ options.setAttachThreads(rnOptions.getBoolean("attachThreads"));
255
+ }
256
+ if (rnOptions.hasKey("attachScreenshot")) {
257
+ options.setAttachScreenshot(rnOptions.getBoolean("attachScreenshot"));
258
+ }
259
+ if (rnOptions.hasKey("attachViewHierarchy")) {
260
+ options.setAttachViewHierarchy(rnOptions.getBoolean("attachViewHierarchy"));
261
+ }
262
+ if (rnOptions.hasKey("sendDefaultPii")) {
263
+ options.setSendDefaultPii(rnOptions.getBoolean("sendDefaultPii"));
264
+ }
265
+ if (rnOptions.hasKey("maxQueueSize")) {
266
+ options.setMaxQueueSize(rnOptions.getInt("maxQueueSize"));
267
+ }
268
+ if (rnOptions.hasKey("enableNdk")) {
269
+ options.setEnableNdk(rnOptions.getBoolean("enableNdk"));
270
+ }
271
+ if (rnOptions.hasKey("spotlight")) {
272
+ if (rnOptions.getType("spotlight") == ReadableType.Boolean) {
273
+ options.setEnableSpotlight(rnOptions.getBoolean("spotlight"));
274
+ options.setSpotlightConnectionUrl(rnOptions.getString("defaultSidecarUrl"));
275
+ } else if (rnOptions.getType("spotlight") == ReadableType.String) {
276
+ options.setEnableSpotlight(true);
277
+ options.setSpotlightConnectionUrl(rnOptions.getString("spotlight"));
278
+ }
279
+ }
280
+
281
+ SentryReplayOptions replayOptions = getReplayOptions(rnOptions);
282
+ options.setSessionReplay(replayOptions);
283
+ if (isReplayEnabled(replayOptions)) {
284
+ options.getReplayController().setBreadcrumbConverter(new RNSentryReplayBreadcrumbConverter());
285
+ }
286
+
287
+ // Exclude Dev Server and Sentry Dsn request from Breadcrumbs
288
+ String dsn = getURLFromDSN(rnOptions.getString("dsn"));
289
+ String devServerUrl = rnOptions.getString("devServerUrl");
290
+ options.setBeforeBreadcrumb(
291
+ (breadcrumb, hint) -> {
292
+ Object urlObject = breadcrumb.getData("url");
293
+ String url = urlObject instanceof String ? (String) urlObject : "";
294
+ if ("http".equals(breadcrumb.getType())
295
+ && ((dsn != null && url.startsWith(dsn))
296
+ || (devServerUrl != null && url.startsWith(devServerUrl)))) {
297
+ return null;
298
+ }
299
+ return breadcrumb;
300
+ });
301
+
302
+ // React native internally throws a JavascriptException.
303
+ // we want to ignore it on the native side to avoid sending it twice.
304
+ options.addIgnoredExceptionForType(JavascriptException.class);
305
+
306
+ options.setBeforeSend(
307
+ (event, hint) -> {
308
+ setEventOriginTag(event);
309
+ addPackages(event, options.getSdkVersion());
310
+
311
+ return event;
312
+ });
313
+
314
+ if (rnOptions.hasKey("enableNativeCrashHandling")
315
+ && !rnOptions.getBoolean("enableNativeCrashHandling")) {
316
+ final List<Integration> integrations = options.getIntegrations();
317
+ for (final Integration integration : integrations) {
318
+ if (integration instanceof UncaughtExceptionHandlerIntegration
319
+ || integration instanceof AnrIntegration
320
+ || integration instanceof NdkIntegration) {
321
+ integrations.remove(integration);
322
+ }
323
+ }
324
+ }
325
+ logger.log(
326
+ SentryLevel.INFO, String.format("Native Integrations '%s'", options.getIntegrations()));
327
+
328
+ final CurrentActivityHolder currentActivityHolder = CurrentActivityHolder.getInstance();
329
+ final Activity currentActivity = getCurrentActivity();
330
+ if (currentActivity != null) {
331
+ currentActivityHolder.setActivity(currentActivity);
332
+ }
333
+ }
334
+
335
+ private boolean isReplayEnabled(SentryReplayOptions replayOptions) {
336
+ return replayOptions.getSessionSampleRate() != null
337
+ || replayOptions.getOnErrorSampleRate() != null;
338
+ }
339
+
340
+ private SentryReplayOptions getReplayOptions(@NotNull ReadableMap rnOptions) {
341
+ final SdkVersion replaySdkVersion =
342
+ new SdkVersion(
343
+ RNSentryVersion.REACT_NATIVE_SDK_NAME,
344
+ RNSentryVersion.REACT_NATIVE_SDK_PACKAGE_VERSION);
345
+ @NotNull
346
+ final SentryReplayOptions androidReplayOptions =
347
+ new SentryReplayOptions(false, replaySdkVersion);
348
+
349
+ if (!(rnOptions.hasKey("replaysSessionSampleRate")
350
+ || rnOptions.hasKey("replaysOnErrorSampleRate"))) {
351
+ return androidReplayOptions;
352
+ }
353
+
354
+ androidReplayOptions.setSessionSampleRate(
355
+ rnOptions.hasKey("replaysSessionSampleRate")
356
+ ? rnOptions.getDouble("replaysSessionSampleRate")
357
+ : null);
358
+ androidReplayOptions.setOnErrorSampleRate(
359
+ rnOptions.hasKey("replaysOnErrorSampleRate")
360
+ ? rnOptions.getDouble("replaysOnErrorSampleRate")
361
+ : null);
362
+
363
+ if (!rnOptions.hasKey("mobileReplayOptions")) {
364
+ return androidReplayOptions;
365
+ }
366
+ @Nullable final ReadableMap rnMobileReplayOptions = rnOptions.getMap("mobileReplayOptions");
367
+ if (rnMobileReplayOptions == null) {
368
+ return androidReplayOptions;
369
+ }
370
+
371
+ androidReplayOptions.setMaskAllText(
372
+ !rnMobileReplayOptions.hasKey("maskAllText")
373
+ || rnMobileReplayOptions.getBoolean("maskAllText"));
374
+ androidReplayOptions.setMaskAllImages(
375
+ !rnMobileReplayOptions.hasKey("maskAllImages")
376
+ || rnMobileReplayOptions.getBoolean("maskAllImages"));
377
+
378
+ final boolean redactVectors =
379
+ !rnMobileReplayOptions.hasKey("maskAllVectors")
380
+ || rnMobileReplayOptions.getBoolean("maskAllVectors");
381
+ if (redactVectors) {
382
+ androidReplayOptions.addMaskViewClass("com.horcrux.svg.SvgView"); // react-native-svg
383
+ }
384
+
385
+ androidReplayOptions.setMaskViewContainerClass(RNSentryReplayMask.class.getName());
386
+ androidReplayOptions.setUnmaskViewContainerClass(RNSentryReplayUnmask.class.getName());
387
+
388
+ return androidReplayOptions;
389
+ }
390
+
171
391
  public void crash() {
172
392
  throw new RuntimeException("TEST - Sentry Client Crash (only works in release mode)");
173
393
  }
@@ -754,6 +974,51 @@ public class RNSentryModuleImpl {
754
974
  promise.resolve(Sentry.isCrashedLastRun());
755
975
  }
756
976
 
977
+ private void setEventOriginTag(SentryEvent event) {
978
+ // We hardcode native-java as only java events are processed by the Android SDK.
979
+ SdkVersion sdk = event.getSdk();
980
+ if (sdk != null) {
981
+ switch (sdk.getName()) {
982
+ case RNSentryVersion.NATIVE_SDK_NAME:
983
+ setEventEnvironmentTag(event, "native");
984
+ break;
985
+ case RNSentryVersion.ANDROID_SDK_NAME:
986
+ setEventEnvironmentTag(event, "java");
987
+ break;
988
+ default:
989
+ break;
990
+ }
991
+ }
992
+ }
993
+
994
+ private void setEventEnvironmentTag(SentryEvent event, String environment) {
995
+ event.setTag("event.origin", "android");
996
+ event.setTag("event.environment", environment);
997
+ }
998
+
999
+ private void addPackages(SentryEvent event, SdkVersion sdk) {
1000
+ SdkVersion eventSdk = event.getSdk();
1001
+ if (eventSdk != null
1002
+ && "sentry.javascript.react-native".equals(eventSdk.getName())
1003
+ && sdk != null) {
1004
+ List<SentryPackage> sentryPackages = sdk.getPackages();
1005
+ if (sentryPackages != null) {
1006
+ for (SentryPackage sentryPackage : sentryPackages) {
1007
+ eventSdk.addPackage(sentryPackage.getName(), sentryPackage.getVersion());
1008
+ }
1009
+ }
1010
+
1011
+ List<String> integrations = sdk.getIntegrations();
1012
+ if (integrations != null) {
1013
+ for (String integration : integrations) {
1014
+ eventSdk.addIntegration(integration);
1015
+ }
1016
+ }
1017
+
1018
+ event.setSdk(eventSdk);
1019
+ }
1020
+ }
1021
+
757
1022
  private boolean checkAndroidXAvailability() {
758
1023
  try {
759
1024
  Class.forName("androidx.core.app.FrameMetricsAggregator");
@@ -767,4 +1032,17 @@ public class RNSentryModuleImpl {
767
1032
  private boolean isFrameMetricsAggregatorAvailable() {
768
1033
  return androidXAvailable && frameMetricsAggregator != null;
769
1034
  }
1035
+
1036
+ public static @Nullable String getURLFromDSN(@Nullable String dsn) {
1037
+ if (dsn == null) {
1038
+ return null;
1039
+ }
1040
+ URI uri = null;
1041
+ try {
1042
+ uri = new URI(dsn);
1043
+ } catch (URISyntaxException e) {
1044
+ return null;
1045
+ }
1046
+ return uri.getScheme() + "://" + uri.getHost();
1047
+ }
770
1048
  }
@@ -2,7 +2,7 @@ package io.sentry.react;
2
2
 
3
3
  class RNSentryVersion {
4
4
  static final String REACT_NATIVE_SDK_PACKAGE_NAME = "npm:@sentry/react-native";
5
- static final String REACT_NATIVE_SDK_PACKAGE_VERSION = "6.7.0-alpha.0";
5
+ static final String REACT_NATIVE_SDK_PACKAGE_VERSION = "6.8.0";
6
6
  static final String NATIVE_SDK_NAME = "sentry.native.android.react-native";
7
7
  static final String ANDROID_SDK_NAME = "sentry.java.android.react-native";
8
8
  static final String REACT_NATIVE_SDK_NAME = "sentry.javascript.react-native";
@@ -1,4 +1,12 @@
1
- import { __awaiter } from "tslib";
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
2
10
  import { logger } from '@sentry/core';
3
11
  import { getFramesToPop, isErrorLike } from '../utils/error';
4
12
  import { fetchSourceContext, parseErrorStack, symbolicateStackTrace } from './debugsymbolicatorutils';
@@ -1 +1 @@
1
- {"version":3,"file":"debugsymbolicator.js","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicator.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,cAAc,EAA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,CAAC,OAAO,EAAE,CAAC;KAChD;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,0BAA0B,CAAC,KAAY,EAAE,MAA0B;IAC1E,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE;QAC1G,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;KAC9D;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,iBAA0B;IACnD,MAAM,GAAG,GAAG,iBAAkC,CAAC;IAC/C,MAAM,UAAU,GAAkC,EAAE,CAAC;IACrD,KAAK,IAAI,KAAK,GAA8B,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE;QACxF,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACxB;IACD,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import type { Event, EventHint, Exception, Integration, StackFrame as SentryStackFrame } from '@sentry/core';\nimport { logger } from '@sentry/core';\n\nimport type { ExtendedError } from '../utils/error';\nimport { getFramesToPop, isErrorLike } from '../utils/error';\nimport type * as ReactNative from '../vendor/react-native';\nimport { fetchSourceContext, parseErrorStack, symbolicateStackTrace } from './debugsymbolicatorutils';\n\nconst INTEGRATION_NAME = 'DebugSymbolicator';\n\n// eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor\nconst INTERNAL_CALLSITES_REGEX = new RegExp(['ReactNativeRenderer-dev\\\\.js$', 'MessageQueue\\\\.js$'].join('|'));\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 const debugSymbolicatorIntegration = (): Integration => {\n return {\n name: INTEGRATION_NAME,\n setupOnce: () => {\n /* noop */\n },\n processEvent,\n };\n};\n\nasync function processEvent(event: Event, hint: EventHint): Promise<Event> {\n if (event.exception?.values && isErrorLike(hint.originalException)) {\n // originalException is ErrorLike object\n const errorGroup = getExceptionGroup(hint.originalException);\n for (const [index, error] of errorGroup.entries()) {\n const symbolicatedFrames = await symbolicate(error.stack, getFramesToPop(error));\n\n symbolicatedFrames && replaceExceptionFramesInException(event.exception.values[index], symbolicatedFrames);\n }\n } else if (hint.syntheticException && isErrorLike(hint.syntheticException)) {\n // syntheticException is Error object\n const symbolicatedFrames = await symbolicate(\n hint.syntheticException.stack,\n getFramesToPop(hint.syntheticException),\n );\n\n if (event.exception) {\n symbolicatedFrames &&\n event.exception.values &&\n replaceExceptionFramesInException(event.exception.values[0], symbolicatedFrames);\n } else if (event.threads) {\n // RN JS doesn't have threads\n symbolicatedFrames && replaceThreadFramesInEvent(event, symbolicatedFrames);\n }\n }\n\n return event;\n}\n\n/**\n * Symbolicates the stack on the device talking to local dev server.\n * Mutates the passed event.\n */\nasync function symbolicate(rawStack: string, skipFirstFrames: number = 0): Promise<SentryStackFrame[] | null> {\n try {\n const parsedStack = parseErrorStack(rawStack);\n\n const prettyStack = await symbolicateStackTrace(parsedStack);\n if (!prettyStack) {\n logger.error('React Native DevServer could not symbolicate the stack trace.');\n return null;\n }\n\n // This has been changed in an react-native version so stack is contained in here\n const newStack = 'stack' in prettyStack ? prettyStack.stack : prettyStack;\n\n // https://github.com/getsentry/sentry-javascript/blob/739d904342aaf9327312f409952f14ceff4ae1ab/packages/utils/src/stacktrace.ts#L23\n // Match SentryParser which counts lines of stack (-1 for first line with the Error message)\n const skipFirstAdjustedToSentryStackParser = Math.max(skipFirstFrames - 1, 0);\n const stackWithoutPoppedFrames = skipFirstAdjustedToSentryStackParser\n ? newStack.slice(skipFirstAdjustedToSentryStackParser)\n : newStack;\n\n const stackWithoutInternalCallsites = stackWithoutPoppedFrames.filter(\n (frame: { file?: string }) => frame.file && frame.file.match(INTERNAL_CALLSITES_REGEX) === null,\n );\n\n const sentryFrames = await convertReactNativeFramesToSentryFrames(stackWithoutInternalCallsites);\n return await fetchSourceContext(sentryFrames);\n } catch (error) {\n if (error instanceof Error) {\n logger.warn(`Unable to symbolicate stack trace: ${error.message}`);\n }\n return null;\n }\n}\n\n/**\n * Converts ReactNativeFrames to frames in the Sentry format\n * @param frames ReactNativeFrame[]\n */\nasync function convertReactNativeFramesToSentryFrames(frames: ReactNative.StackFrame[]): Promise<SentryStackFrame[]> {\n return Promise.all(\n frames.map(async (frame: ReactNative.StackFrame): Promise<SentryStackFrame> => {\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: SentryStackFrame = {\n lineno: frame.lineNumber,\n colno: frame.column,\n filename: frame.file,\n function: frame.methodName,\n in_app: inApp,\n };\n\n return newFrame;\n }),\n );\n}\n\n/**\n * Replaces the frames in the exception of a error.\n * @param event Event\n * @param frames StackFrame[]\n */\nfunction replaceExceptionFramesInException(exception: Exception, frames: SentryStackFrame[]): void {\n if (exception?.stacktrace) {\n exception.stacktrace.frames = frames.reverse();\n }\n}\n\n/**\n * Replaces the frames in the thread of a message.\n * @param event Event\n * @param frames StackFrame[]\n */\nfunction replaceThreadFramesInEvent(event: Event, frames: SentryStackFrame[]): void {\n if (event.threads && event.threads.values && event.threads.values[0] && event.threads.values[0].stacktrace) {\n event.threads.values[0].stacktrace.frames = frames.reverse();\n }\n}\n\n/**\n * Return a list containing the original exception and also the cause if found.\n *\n * @param originalException The original exception.\n */\nfunction getExceptionGroup(originalException: unknown): (Error & { stack: string })[] {\n const err = originalException as ExtendedError;\n const errorGroup: (Error & { stack: string })[] = [];\n for (let cause: ExtendedError | undefined = err; isErrorLike(cause); cause = cause.cause) {\n errorGroup.push(cause);\n }\n return errorGroup;\n}\n"]}
1
+ {"version":3,"file":"debugsymbolicator.js","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicator.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtG,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAE7C,sEAAsE;AACtE,MAAM,wBAAwB,GAAG,IAAI,MAAM,CAAC,CAAC,+BAA+B,EAAE,oBAAoB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAY/G,6DAA6D;AAC7D,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAgB,EAAE;IAC5D,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,SAAS,EAAE,GAAG,EAAE;YACd,UAAU;QACZ,CAAC;QACD,YAAY;KACb,CAAC;AACJ,CAAC,CAAC;AAEF,SAAe,YAAY,CAAC,KAAY,EAAE,IAAe;;;QACvD,IAAI,CAAA,MAAA,KAAK,CAAC,SAAS,0CAAE,MAAM,KAAI,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE;YAClE,wCAAwC;YACxC,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAC7D,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE;gBACjD,MAAM,kBAAkB,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;gBAEjF,kBAAkB,IAAI,iCAAiC,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK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AQ,CAAC;QAClB,CAAC,CAAA,CAAC,CACH,CAAC;IACJ,CAAC;CAAA;AAED;;;;GAIG;AACH,SAAS,iCAAiC,CAAC,SAAoB,EAAE,MAA0B;IACzF,IAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,UAAU,EAAE;QACzB,SAAS,CAAC,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;KAChD;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,0BAA0B,CAAC,KAAY,EAAE,MAA0B;IAC1E,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE;QAC1G,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;KAC9D;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,iBAA0B;IACnD,MAAM,GAAG,GAAG,iBAAkC,CAAC;IAC/C,MAAM,UAAU,GAAkC,EAAE,CAAC;IACrD,KAAK,IAAI,KAAK,GAA8B,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE;QACxF,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACxB;IACD,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import type { Event, EventHint, Exception, Integration, StackFrame as SentryStackFrame } from '@sentry/core';\nimport { logger } from '@sentry/core';\n\nimport type { ExtendedError } from '../utils/error';\nimport { getFramesToPop, isErrorLike } from '../utils/error';\nimport type * as ReactNative from '../vendor/react-native';\nimport { fetchSourceContext, parseErrorStack, symbolicateStackTrace } from './debugsymbolicatorutils';\n\nconst INTEGRATION_NAME = 'DebugSymbolicator';\n\n// eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor\nconst INTERNAL_CALLSITES_REGEX = new RegExp(['ReactNativeRenderer-dev\\\\.js$', 'MessageQueue\\\\.js$'].join('|'));\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 const debugSymbolicatorIntegration = (): Integration => {\n return {\n name: INTEGRATION_NAME,\n setupOnce: () => {\n /* noop */\n },\n processEvent,\n };\n};\n\nasync function processEvent(event: Event, hint: EventHint): Promise<Event> {\n if (event.exception?.values && isErrorLike(hint.originalException)) {\n // originalException is ErrorLike object\n const errorGroup = getExceptionGroup(hint.originalException);\n for (const [index, error] of errorGroup.entries()) {\n const symbolicatedFrames = await symbolicate(error.stack, getFramesToPop(error));\n\n symbolicatedFrames && replaceExceptionFramesInException(event.exception.values[index], symbolicatedFrames);\n }\n } else if (hint.syntheticException && isErrorLike(hint.syntheticException)) {\n // syntheticException is Error object\n const symbolicatedFrames = await symbolicate(\n hint.syntheticException.stack,\n getFramesToPop(hint.syntheticException),\n );\n\n if (event.exception) {\n symbolicatedFrames &&\n event.exception.values &&\n replaceExceptionFramesInException(event.exception.values[0], symbolicatedFrames);\n } else if (event.threads) {\n // RN JS doesn't have threads\n symbolicatedFrames && replaceThreadFramesInEvent(event, symbolicatedFrames);\n }\n }\n\n return event;\n}\n\n/**\n * Symbolicates the stack on the device talking to local dev server.\n * Mutates the passed event.\n */\nasync function symbolicate(rawStack: string, skipFirstFrames: number = 0): Promise<SentryStackFrame[] | null> {\n try {\n const parsedStack = parseErrorStack(rawStack);\n\n const prettyStack = await symbolicateStackTrace(parsedStack);\n if (!prettyStack) {\n logger.error('React Native DevServer could not symbolicate the stack trace.');\n return null;\n }\n\n // This has been changed in an react-native version so stack is contained in here\n const newStack = 'stack' in prettyStack ? prettyStack.stack : prettyStack;\n\n // https://github.com/getsentry/sentry-javascript/blob/739d904342aaf9327312f409952f14ceff4ae1ab/packages/utils/src/stacktrace.ts#L23\n // Match SentryParser which counts lines of stack (-1 for first line with the Error message)\n const skipFirstAdjustedToSentryStackParser = Math.max(skipFirstFrames - 1, 0);\n const stackWithoutPoppedFrames = skipFirstAdjustedToSentryStackParser\n ? newStack.slice(skipFirstAdjustedToSentryStackParser)\n : newStack;\n\n const stackWithoutInternalCallsites = stackWithoutPoppedFrames.filter(\n (frame: { file?: string }) => frame.file && frame.file.match(INTERNAL_CALLSITES_REGEX) === null,\n );\n\n const sentryFrames = await convertReactNativeFramesToSentryFrames(stackWithoutInternalCallsites);\n return await fetchSourceContext(sentryFrames);\n } catch (error) {\n if (error instanceof Error) {\n logger.warn(`Unable to symbolicate stack trace: ${error.message}`);\n }\n return null;\n }\n}\n\n/**\n * Converts ReactNativeFrames to frames in the Sentry format\n * @param frames ReactNativeFrame[]\n */\nasync function convertReactNativeFramesToSentryFrames(frames: ReactNative.StackFrame[]): Promise<SentryStackFrame[]> {\n return Promise.all(\n frames.map(async (frame: ReactNative.StackFrame): Promise<SentryStackFrame> => {\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: SentryStackFrame = {\n lineno: frame.lineNumber,\n colno: frame.column,\n filename: frame.file,\n function: frame.methodName,\n in_app: inApp,\n };\n\n return newFrame;\n }),\n );\n}\n\n/**\n * Replaces the frames in the exception of a error.\n * @param event Event\n * @param frames StackFrame[]\n */\nfunction replaceExceptionFramesInException(exception: Exception, frames: SentryStackFrame[]): void {\n if (exception?.stacktrace) {\n exception.stacktrace.frames = frames.reverse();\n }\n}\n\n/**\n * Replaces the frames in the thread of a message.\n * @param event Event\n * @param frames StackFrame[]\n */\nfunction replaceThreadFramesInEvent(event: Event, frames: SentryStackFrame[]): void {\n if (event.threads && event.threads.values && event.threads.values[0] && event.threads.values[0].stacktrace) {\n event.threads.values[0].stacktrace.frames = frames.reverse();\n }\n}\n\n/**\n * Return a list containing the original exception and also the cause if found.\n *\n * @param originalException The original exception.\n */\nfunction getExceptionGroup(originalException: unknown): (Error & { stack: string })[] {\n const err = originalException as ExtendedError;\n const errorGroup: (Error & { stack: string })[] = [];\n for (let cause: ExtendedError | undefined = err; isErrorLike(cause); cause = cause.cause) {\n errorGroup.push(cause);\n }\n return errorGroup;\n}\n"]}
@@ -1,4 +1,12 @@
1
- import { __awaiter } from "tslib";
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
2
10
  import { logger } from '@sentry/core';
3
11
  import { ReactNativeLibraries } from '../utils/rnlibraries';
4
12
  import { createStealthXhr, XHR_READYSTATE_DONE } from '../utils/xhr';
@@ -1 +1 @@
1
- {"version":3,"file":"debugsymbolicatorutils.js","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicatorutils.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGrE;;;;;GAKG;AACH,MAAM,UAAgB,kBAAkB,CAAC,MAA0B;;QACjE,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;YAC3B,IAAI;gBACF,MAAM,GAAG,GAAG,gBAAgB,EAAE,CAAC;gBAC/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AAkB,CAAC;AACjD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;KACzD;IACD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;AACnE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAoC,EACpC,SAAmC;IAEnC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;KACzD;IACD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AAC/E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY;;IAC1B,IAAI;QACF,OAAO,MAAA,oBAAoB,CAAC,QAAQ,0CAAE,YAAY,EAAE,CAAC;KACtD;IAAC,OAAO,GAAG,EAAE;QACZ,8BAA8B;KAC/B;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { StackFrame as SentryStackFrame } from '@sentry/core';\nimport { logger } from '@sentry/core';\n\nimport { ReactNativeLibraries } from '../utils/rnlibraries';\nimport { createStealthXhr, XHR_READYSTATE_DONE } from '../utils/xhr';\nimport type * as ReactNative from '../vendor/react-native';\n\n/**\n * Fetches source context for the Sentry Middleware (/__sentry/context)\n *\n * @param frame StackFrame\n * @param getDevServer function from RN to get DevServer URL\n */\nexport async function fetchSourceContext(frames: SentryStackFrame[]): Promise<SentryStackFrame[]> {\n return new Promise(resolve => {\n try {\n const xhr = createStealthXhr();\n if (!xhr) {\n resolve(frames);\n return;\n }\n\n xhr.open('POST', getSentryMetroSourceContextUrl(), true);\n xhr.setRequestHeader('Content-Type', 'application/json');\n xhr.send(JSON.stringify({ stack: frames }));\n\n xhr.onreadystatechange = (): void => {\n if (xhr.readyState === XHR_READYSTATE_DONE) {\n if (xhr.status !== 200) {\n resolve(frames);\n }\n\n try {\n const response: { stack?: SentryStackFrame[] } = JSON.parse(xhr.responseText);\n if (Array.isArray(response.stack)) {\n resolve(response.stack);\n } else {\n resolve(frames);\n }\n } catch (error) {\n resolve(frames);\n }\n }\n };\n xhr.onerror = (): void => {\n resolve(frames);\n };\n } catch (error) {\n logger.error('Could not fetch source context.', error);\n resolve(frames);\n }\n });\n}\n\nfunction getSentryMetroSourceContextUrl(): string {\n return `${getDevServer().url}__sentry/context`;\n}\n\n/**\n * Loads and calls RN Core Devtools parseErrorStack function.\n */\nexport function parseErrorStack(errorStack: string): Array<ReactNative.StackFrame> {\n if (!ReactNativeLibraries.Devtools) {\n throw new Error('React Native Devtools not available.');\n }\n return ReactNativeLibraries.Devtools.parseErrorStack(errorStack);\n}\n\n/**\n * Loads and calls RN Core Devtools symbolicateStackTrace function.\n */\nexport function symbolicateStackTrace(\n stack: Array<ReactNative.StackFrame>,\n extraData?: Record<string, unknown>,\n): Promise<ReactNative.SymbolicatedStackTrace> {\n if (!ReactNativeLibraries.Devtools) {\n throw new Error('React Native Devtools not available.');\n }\n return ReactNativeLibraries.Devtools.symbolicateStackTrace(stack, extraData);\n}\n\n/**\n * Loads and returns the RN DevServer URL.\n */\nexport function getDevServer(): ReactNative.DevServerInfo | undefined {\n try {\n return ReactNativeLibraries.Devtools?.getDevServer();\n } catch (_oO) {\n // We can't load devserver URL\n }\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"debugsymbolicatorutils.js","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicatorutils.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGrE;;;;;GAKG;AACH,MAAM,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D,OAAO,CAAC,MAAM,CAAC,CAAC;aACjB;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CAAA;AAED,SAAS,8BAA8B;IACrC,OAAO,GAAG,YAAY,EAAE,CAAC,GAAG,kBAAkB,CAAC;AACjD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;KACzD;IACD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;AACnE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAoC,EACpC,SAAmC;IAEnC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;KACzD;IACD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AAC/E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY;;IAC1B,IAAI;QACF,OAAO,MAAA,oBAAoB,CAAC,QAAQ,0CAAE,YAAY,EAAE,CAAC;KACtD;IAAC,OAAO,GAAG,EAAE;QACZ,8BAA8B;KAC/B;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { StackFrame as SentryStackFrame } from '@sentry/core';\nimport { logger } from '@sentry/core';\n\nimport { ReactNativeLibraries } from '../utils/rnlibraries';\nimport { createStealthXhr, XHR_READYSTATE_DONE } from '../utils/xhr';\nimport type * as ReactNative from '../vendor/react-native';\n\n/**\n * Fetches source context for the Sentry Middleware (/__sentry/context)\n *\n * @param frame StackFrame\n * @param getDevServer function from RN to get DevServer URL\n */\nexport async function fetchSourceContext(frames: SentryStackFrame[]): Promise<SentryStackFrame[]> {\n return new Promise(resolve => {\n try {\n const xhr = createStealthXhr();\n if (!xhr) {\n resolve(frames);\n return;\n }\n\n xhr.open('POST', getSentryMetroSourceContextUrl(), true);\n xhr.setRequestHeader('Content-Type', 'application/json');\n xhr.send(JSON.stringify({ stack: frames }));\n\n xhr.onreadystatechange = (): void => {\n if (xhr.readyState === XHR_READYSTATE_DONE) {\n if (xhr.status !== 200) {\n resolve(frames);\n }\n\n try {\n const response: { stack?: SentryStackFrame[] } = JSON.parse(xhr.responseText);\n if (Array.isArray(response.stack)) {\n resolve(response.stack);\n } else {\n resolve(frames);\n }\n } catch (error) {\n resolve(frames);\n }\n }\n };\n xhr.onerror = (): void => {\n resolve(frames);\n };\n } catch (error) {\n logger.error('Could not fetch source context.', error);\n resolve(frames);\n }\n });\n}\n\nfunction getSentryMetroSourceContextUrl(): string {\n return `${getDevServer().url}__sentry/context`;\n}\n\n/**\n * Loads and calls RN Core Devtools parseErrorStack function.\n */\nexport function parseErrorStack(errorStack: string): Array<ReactNative.StackFrame> {\n if (!ReactNativeLibraries.Devtools) {\n throw new Error('React Native Devtools not available.');\n }\n return ReactNativeLibraries.Devtools.parseErrorStack(errorStack);\n}\n\n/**\n * Loads and calls RN Core Devtools symbolicateStackTrace function.\n */\nexport function symbolicateStackTrace(\n stack: Array<ReactNative.StackFrame>,\n extraData?: Record<string, unknown>,\n): Promise<ReactNative.SymbolicatedStackTrace> {\n if (!ReactNativeLibraries.Devtools) {\n throw new Error('React Native Devtools not available.');\n }\n return ReactNativeLibraries.Devtools.symbolicateStackTrace(stack, extraData);\n}\n\n/**\n * Loads and returns the RN DevServer URL.\n */\nexport function getDevServer(): ReactNative.DevServerInfo | undefined {\n try {\n return ReactNativeLibraries.Devtools?.getDevServer();\n } catch (_oO) {\n // We can't load devserver URL\n }\n return undefined;\n}\n"]}
@@ -1,4 +1,12 @@
1
- import { __awaiter } from "tslib";
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
2
10
  import { logger, severityLevelFromString } from '@sentry/core';
3
11
  import { AppState } from 'react-native';
4
12
  import { breadcrumbFromObject } from '../breadcrumb';
@@ -1 +1 @@
1
- {"version":3,"file":"devicecontext.js","sourceRoot":"","sources":["../../../src/js/integrations/devicecontext.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAEzC,uCAAuC;AACvC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAgB,EAAE;IACxD,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,SAAS,EAAE,GAAG,EAAE;YACd,UAAU;QACZ,CAAC;QACD,YAAY;KACb,CAAC;AACJ,CAAC,CAAC;AAEF,SAAe,YAAY,CAAC,KAAY,EAAE,KAAgB,EAAE,MAAc;;;QACxE,IAAI,MAAM,GAAwC,IAAI,CAAC;QACvD,IAAI;YACF,MAAM,GAAG,MAAM,MAAM,CAAC,yBAAyB,EAAE,CAAC;SACnD;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,GAAG,CAAC,6CAA6C,CAAC,EAAE,CAAC,CAAC;SAC9D;QAED,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,KAAK,CAAC;SACd;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC;QAC/B,I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ity */\nimport type { Client, Event, EventHint, Integration } from '@sentry/core';\nimport { logger, severityLevelFromString } from '@sentry/core';\nimport { AppState } from 'react-native';\n\nimport { breadcrumbFromObject } from '../breadcrumb';\nimport type { NativeDeviceContextsResponse } from '../NativeRNSentry';\nimport { NATIVE } from '../wrapper';\n\nconst INTEGRATION_NAME = 'DeviceContext';\n\n/** Load device context from native. */\nexport const deviceContextIntegration = (): Integration => {\n return {\n name: INTEGRATION_NAME,\n setupOnce: () => {\n /* noop */\n },\n processEvent,\n };\n};\n\nasync function processEvent(event: Event, _hint: EventHint, client: Client): Promise<Event> {\n let native: NativeDeviceContextsResponse | null = null;\n try {\n native = await NATIVE.fetchNativeDeviceContexts();\n } catch (e) {\n logger.log(`Failed to get device context from native: ${e}`);\n }\n\n if (!native) {\n return event;\n }\n\n const nativeUser = native.user;\n if (!event.user && nativeUser) {\n event.user = nativeUser;\n }\n\n let nativeContexts = native.contexts;\n if (AppState.currentState !== 'unknown') {\n nativeContexts = nativeContexts || {};\n nativeContexts.app = {\n ...nativeContexts.app,\n in_foreground: AppState.currentState === 'active',\n };\n }\n if (nativeContexts) {\n event.contexts = { ...nativeContexts, ...event.contexts };\n if (nativeContexts.app) {\n event.contexts.app = { ...nativeContexts.app, ...event.contexts.app };\n }\n }\n\n const nativeTags = native.tags;\n if (nativeTags) {\n event.tags = { ...nativeTags, ...event.tags };\n }\n\n const nativeExtra = native.extra;\n if (nativeExtra) {\n event.extra = { ...nativeExtra, ...event.extra };\n }\n\n const nativeFingerprint = native.fingerprint;\n if (nativeFingerprint) {\n event.fingerprint = (event.fingerprint ?? []).concat(\n nativeFingerprint.filter(item => (event.fingerprint ?? []).indexOf(item) < 0),\n );\n }\n\n const nativeLevel = typeof native['level'] === 'string' ? severityLevelFromString(native['level']) : undefined;\n if (!event.level && nativeLevel) {\n event.level = nativeLevel;\n }\n\n const nativeEnvironment = native['environment'];\n if (!event.environment && nativeEnvironment) {\n event.environment = nativeEnvironment;\n }\n\n const nativeBreadcrumbs = Array.isArray(native['breadcrumbs'])\n ? native['breadcrumbs'].map(breadcrumbFromObject)\n : undefined;\n if (nativeBreadcrumbs) {\n const maxBreadcrumbs = client?.getOptions().maxBreadcrumbs ?? 100; // Default is 100.\n event.breadcrumbs = nativeBreadcrumbs\n .concat(event.breadcrumbs || []) // concatenate the native and js breadcrumbs\n .sort((a, b) => (a.timestamp ?? 0) - (b.timestamp ?? 0)) // sort by timestamp\n .slice(-maxBreadcrumbs); // keep the last maxBreadcrumbs\n }\n\n return event;\n}\n"]}
1
+ {"version":3,"file":"devicecontext.js","sourceRoot":"","sources":["../../../src/js/integrations/devicecontext.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAEzC,uCAAuC;AACvC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAgB,EAAE;IACxD,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,SAAS,EAAE,GAAG,EAAE;YACd,UAAU;QACZ,CAAC;QACD,YAAY;KACb,CAAC;AACJ,CAAC,CAAC;AAEF,SAAe,YAAY,CAAC,KAAY,EAAE,KAAgB,EAAE,MAAc;;;QACxE,IAAI,MAAM,GAAwC,IAAI,CAAC;QACvD,IAAI;YACF,MAAM,GAAG,MAAM,MAAM,CAAC,yBAAyB,EAAE,CAAC;SACnD;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,GAAG,CAAC,6CAA6C,CAAC,EAAE,CAAC,CAAC;SAC9D;QAED,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,KAAK,CAAC;SACd;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,C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["/* eslint-disable complexity */\nimport type { Client, Event, EventHint, Integration } from '@sentry/core';\nimport { logger, severityLevelFromString } from '@sentry/core';\nimport { AppState } from 'react-native';\n\nimport { breadcrumbFromObject } from '../breadcrumb';\nimport type { NativeDeviceContextsResponse } from '../NativeRNSentry';\nimport { NATIVE } from '../wrapper';\n\nconst INTEGRATION_NAME = 'DeviceContext';\n\n/** Load device context from native. */\nexport const deviceContextIntegration = (): Integration => {\n return {\n name: INTEGRATION_NAME,\n setupOnce: () => {\n /* noop */\n },\n processEvent,\n };\n};\n\nasync function processEvent(event: Event, _hint: EventHint, client: Client): Promise<Event> {\n let native: NativeDeviceContextsResponse | null = null;\n try {\n native = await NATIVE.fetchNativeDeviceContexts();\n } catch (e) {\n logger.log(`Failed to get device context from native: ${e}`);\n }\n\n if (!native) {\n return event;\n }\n\n const nativeUser = native.user;\n if (!event.user && nativeUser) {\n event.user = nativeUser;\n }\n\n let nativeContexts = native.contexts;\n if (AppState.currentState !== 'unknown') {\n nativeContexts = nativeContexts || {};\n nativeContexts.app = {\n ...nativeContexts.app,\n in_foreground: AppState.currentState === 'active',\n };\n }\n if (nativeContexts) {\n event.contexts = { ...nativeContexts, ...event.contexts };\n if (nativeContexts.app) {\n event.contexts.app = { ...nativeContexts.app, ...event.contexts.app };\n }\n }\n\n const nativeTags = native.tags;\n if (nativeTags) {\n event.tags = { ...nativeTags, ...event.tags };\n }\n\n const nativeExtra = native.extra;\n if (nativeExtra) {\n event.extra = { ...nativeExtra, ...event.extra };\n }\n\n const nativeFingerprint = native.fingerprint;\n if (nativeFingerprint) {\n event.fingerprint = (event.fingerprint ?? []).concat(\n nativeFingerprint.filter(item => (event.fingerprint ?? []).indexOf(item) < 0),\n );\n }\n\n const nativeLevel = typeof native['level'] === 'string' ? severityLevelFromString(native['level']) : undefined;\n if (!event.level && nativeLevel) {\n event.level = nativeLevel;\n }\n\n const nativeEnvironment = native['environment'];\n if (!event.environment && nativeEnvironment) {\n event.environment = nativeEnvironment;\n }\n\n const nativeBreadcrumbs = Array.isArray(native['breadcrumbs'])\n ? native['breadcrumbs'].map(breadcrumbFromObject)\n : undefined;\n if (nativeBreadcrumbs) {\n const maxBreadcrumbs = client?.getOptions().maxBreadcrumbs ?? 100; // Default is 100.\n event.breadcrumbs = nativeBreadcrumbs\n .concat(event.breadcrumbs || []) // concatenate the native and js breadcrumbs\n .sort((a, b) => (a.timestamp ?? 0) - (b.timestamp ?? 0)) // sort by timestamp\n .slice(-maxBreadcrumbs); // keep the last maxBreadcrumbs\n }\n\n return event;\n}\n"]}
@@ -1,4 +1,12 @@
1
- import { __awaiter } from "tslib";
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
2
10
  import { logger } from '@sentry/core';
3
11
  import { NATIVE } from '../wrapper';
4
12
  const INTEGRATION_NAME = 'ModulesLoader';
@@ -1 +1 @@
1
- {"version":3,"file":"modulesloader.js","sourceRoot":"","sources":["../../../src/js/integrations/modulesloader.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAEzC,mDAAmD;AACnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAgB,EAAE;IACxD,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,SAAS,EAAE,GAAG,EAAE;YACd,OAAO;QACT,CAAC;QACD,YAAY,EAAE,kBAAkB,EAAE;KACnC,CAAC;AACJ,CAAC,CAAC;AAEF,SAAS,kBAAkB;IACzB,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,OAAO,GAAkC,IAAI,CAAC;IAElD,OAAO,CAAO,KAAY,EAAE,EAAE;QAC5B,IAAI,CAAC,OAAO,EAAE;YACZ,IAAI;gBACF,OAAO,GAAG,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;aACvC;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,CAAC,GAAG,CAAC,sCAAsC,CAAC,EAAE,CAAC,CAAC;aACvD;YACD,OAAO,GAAG,IAAI,CAAC;SAChB;QACD,IAAI,OAAO,EAAE;YACX,KAAK,CAAC,OAAO,mCACR,OAAO,GACP,KAAK,CAAC,OAAO,CACjB,CAAC;SACH;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAA,CAAC;AACJ,CAAC","sourcesContent":["import type { Event, Integration } from '@sentry/core';\nimport { logger } from '@sentry/core';\n\nimport { NATIVE } from '../wrapper';\n\nconst INTEGRATION_NAME = 'ModulesLoader';\n\n/** Loads runtime JS modules from prepared file. */\nexport const modulesLoaderIntegration = (): Integration => {\n return {\n name: INTEGRATION_NAME,\n setupOnce: () => {\n // noop\n },\n processEvent: createProcessEvent(),\n };\n};\n\nfunction createProcessEvent(): (event: Event) => Promise<Event> {\n let isSetup = false;\n let modules: Record<string, string> | null = null;\n\n return async (event: Event) => {\n if (!isSetup) {\n try {\n modules = await NATIVE.fetchModules();\n } catch (e) {\n logger.log(`Failed to get modules from native: ${e}`);\n }\n isSetup = true;\n }\n if (modules) {\n event.modules = {\n ...modules,\n ...event.modules,\n };\n }\n return event;\n };\n}\n"]}
1
+ {"version":3,"file":"modulesloader.js","sourceRoot":"","sources":["../../../src/js/integrations/modulesloader.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAEzC,mDAAmD;AACnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAgB,EAAE;IACxD,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,SAAS,EAAE,GAAG,EAAE;YACd,OAAO;QACT,CAAC;QACD,YAAY,EAAE,kBAAkB,EAAE;KACnC,CAAC;AACJ,CAAC,CAAC;AAEF,SAAS,kBAAkB;IACzB,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,OAAO,GAAkC,IAAI,CAAC;IAElD,OAAO,CAAO,KAAY,EAAE,EAAE;QAC5B,IAAI,CAAC,OAAO,EAAE;YACZ,IAAI;gBACF,OAAO,GAAG,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;aACvC;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,CAAC,GAAG,CAAC,sCAAsC,CAAC,EAAE,CAAC,CAAC;aACvD;YACD,OAAO,GAAG,IAAI,CAAC;SAChB;QACD,IAAI,OAAO,EAAE;YACX,KAAK,CAAC,OAAO,mCACR,OAAO,GACP,KAAK,CAAC,OAAO,CACjB,CAAC;SACH;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAA,CAAC;AACJ,CAAC","sourcesContent":["import type { Event, Integration } from '@sentry/core';\nimport { logger } from '@sentry/core';\n\nimport { NATIVE } from '../wrapper';\n\nconst INTEGRATION_NAME = 'ModulesLoader';\n\n/** Loads runtime JS modules from prepared file. */\nexport const modulesLoaderIntegration = (): Integration => {\n return {\n name: INTEGRATION_NAME,\n setupOnce: () => {\n // noop\n },\n processEvent: createProcessEvent(),\n };\n};\n\nfunction createProcessEvent(): (event: Event) => Promise<Event> {\n let isSetup = false;\n let modules: Record<string, string> | null = null;\n\n return async (event: Event) => {\n if (!isSetup) {\n try {\n modules = await NATIVE.fetchModules();\n } catch (e) {\n logger.log(`Failed to get modules from native: ${e}`);\n }\n isSetup = true;\n }\n if (modules) {\n event.modules = {\n ...modules,\n ...event.modules,\n };\n }\n return event;\n };\n}\n"]}
@@ -1,4 +1,12 @@
1
- import { __awaiter } from "tslib";
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
2
10
  import { addExceptionMechanism, captureException, getClient, getCurrentScope, logger } from '@sentry/core';
3
11
  import { createSyntheticError, isErrorLike } from '../utils/error';
4
12
  import { RN_GLOBAL_OBJ } from '../utils/worldwide';
@@ -1 +1 @@
1
- {"version":3,"file":"reactnativeerrorhandlers.js","sourceRoot":"","sources":["../../../src/js/integrations/reactnativeerrorhandlers.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3G,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAEjH,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAcpD,2CAA2C;AAC3C,MAAM,CAAC,MAAM,mCAAmC,GAAG,CACjD,UAAoD,EAAE,EACzC,EAAE;IACf,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,SAAS,EAAE,GAAG,EAAE,CACd,KAAK,iBACH,OAAO,EAAE,IAAI,EACb,oBAAoB,EAAE,IAAI,EAC1B,kBAAkB,EAAE,IAA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,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAE3D,IAAI,OAAO,EAAE;YACX,KAAK,CAAC,KAAK,GAAG,OAAwB,CAAC;YAEvC,qBAAqB,CAAC,KAAK,EAAE;gBAC3B,OAAO,EAAE,KAAK;gBACd,IAAI,EAAE,SAAS;aAChB,CAAC,CAAC;SACJ;aAAM;YACL,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC;YAEtB,qBAAqB,CAAC,KAAK,EAAE;gBAC3B,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,SAAS;aAChB,CAAC,CAAC;SACJ;QAED,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAEjC,IAAI,OAAO,EAAE;YACX,gFAAgF;YAChF,mCAAmC;YACnC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC/B,OAAO;SACR;QAED,KAAK,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,eAAe,IAAI,IAAI,CAAC,CAAC,IAAI,CACjE,GAAG,EAAE;YACH,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACjC,CAAC,EACD,CAAC,MAAe,EAAE,EAAE;YAClB,MAAM,CAAC,KAAK,CAAC,uFAAuF,EAAE,MAAM,CAAC,CAAC;QAChH,CAAC,CACF,CAAC;IACJ,CAAC,CAAA,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { EventHint, Integration, SeverityLevel } from '@sentry/core';\nimport { addExceptionMechanism, captureException, getClient, getCurrentScope, logger } from '@sentry/core';\n\nimport { createSyntheticError, isErrorLike } from '../utils/error';\nimport { RN_GLOBAL_OBJ } from '../utils/worldwide';\nimport { checkPromiseAndWarn, polyfillPromise, requireRejectionTracking } from './reactnativeerrorhandlersutils';\n\nconst INTEGRATION_NAME = 'ReactNativeErrorHandlers';\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/** ReactNativeErrorHandlers Integration */\nexport const reactNativeErrorHandlersIntegration = (\n options: Partial<ReactNativeErrorHandlersOptions> = {},\n): Integration => {\n return {\n name: INTEGRATION_NAME,\n setupOnce: () =>\n setup({\n onerror: true,\n onunhandledrejection: true,\n patchGlobalPromise: true,\n ...options,\n }),\n };\n};\n\nfunction setup(options: ReactNativeErrorHandlersOptions): void {\n options.onunhandledrejection && setupUnhandledRejectionsTracking(options.patchGlobalPromise);\n options.onerror && setupErrorUtilsGlobalHandler();\n}\n\n/**\n * Setup unhandled promise rejection tracking\n */\nfunction setupUnhandledRejectionsTracking(patchGlobalPromise: boolean): void {\n if (patchGlobalPromise) {\n polyfillPromise();\n }\n\n attachUnhandledRejectionHandler();\n checkPromiseAndWarn();\n}\n\nfunction attachUnhandledRejectionHandler(): void {\n const tracking = requireRejectionTracking();\n\n const promiseRejectionTrackingOptions: PromiseRejectionTrackingOptions = {\n onUnhandled: (id, rejection = {}) => {\n // eslint-disable-next-line no-console\n console.warn(`Possible Unhandled Promise Rejection (id: ${id}):\\n${rejection}`);\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: unknown) => {\n if (__DEV__) {\n promiseRejectionTrackingOptions.onUnhandled(id, error);\n }\n\n captureException(error, {\n data: { id },\n originalException: error,\n syntheticException: isErrorLike(error) ? undefined : createSyntheticError(),\n mechanism: { handled: true, type: 'onunhandledrejection' },\n });\n },\n onHandled: (id: string) => {\n promiseRejectionTrackingOptions.onHandled(id);\n },\n });\n}\n\nfunction setupErrorUtilsGlobalHandler(): void {\n let handlingFatal = false;\n\n const errorUtils = RN_GLOBAL_OBJ.ErrorUtils;\n if (!errorUtils) {\n logger.warn('ErrorUtils not found. Can be caused by different environment for example react-native-web.');\n return;\n }\n\n const defaultHandler = 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('Encountered multiple fatals in a row. The latest:', error);\n return;\n }\n handlingFatal = true;\n }\n\n const client = getClient();\n\n if (!client) {\n logger.error('Sentry client is missing, the error event might be lost.', error);\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 hint: EventHint = {\n originalException: error,\n attachments: getCurrentScope().getScopeData().attachments,\n };\n const event = await client.eventFromException(error, hint);\n\n if (isFatal) {\n event.level = 'fatal' as SeverityLevel;\n\n addExceptionMechanism(event, {\n handled: false,\n type: 'onerror',\n });\n } else {\n event.level = 'error';\n\n addExceptionMechanism(event, {\n handled: true,\n type: 'generic',\n });\n }\n\n client.captureEvent(event, hint);\n\n if (__DEV__) {\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 return;\n }\n\n void client.flush(client.getOptions().shutdownTimeout || 2000).then(\n () => {\n defaultHandler(error, isFatal);\n },\n (reason: unknown) => {\n logger.error('[ReactNativeErrorHandlers] Error while flushing the event cache after uncaught error.', reason);\n },\n );\n });\n}\n"]}
1
+ {"version":3,"file":"reactnativeerrorhandlers.js","sourceRoot":"","sources":["../../../src/js/integrations/reactnativeerrorhandlers.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3G,OAAO,EAAE,oBAAoB,E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FAAuF,EAAE,MAAM,CAAC,CAAC;QAChH,CAAC,CACF,CAAC;IACJ,CAAC,CAAA,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { EventHint, Integration, SeverityLevel } from '@sentry/core';\nimport { addExceptionMechanism, captureException, getClient, getCurrentScope, logger } from '@sentry/core';\n\nimport { createSyntheticError, isErrorLike } from '../utils/error';\nimport { RN_GLOBAL_OBJ } from '../utils/worldwide';\nimport { checkPromiseAndWarn, polyfillPromise, requireRejectionTracking } from './reactnativeerrorhandlersutils';\n\nconst INTEGRATION_NAME = 'ReactNativeErrorHandlers';\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/** ReactNativeErrorHandlers Integration */\nexport const reactNativeErrorHandlersIntegration = (\n options: Partial<ReactNativeErrorHandlersOptions> = {},\n): Integration => {\n return {\n name: INTEGRATION_NAME,\n setupOnce: () =>\n setup({\n onerror: true,\n onunhandledrejection: true,\n patchGlobalPromise: true,\n ...options,\n }),\n };\n};\n\nfunction setup(options: ReactNativeErrorHandlersOptions): void {\n options.onunhandledrejection && setupUnhandledRejectionsTracking(options.patchGlobalPromise);\n options.onerror && setupErrorUtilsGlobalHandler();\n}\n\n/**\n * Setup unhandled promise rejection tracking\n */\nfunction setupUnhandledRejectionsTracking(patchGlobalPromise: boolean): void {\n if (patchGlobalPromise) {\n polyfillPromise();\n }\n\n attachUnhandledRejectionHandler();\n checkPromiseAndWarn();\n}\n\nfunction attachUnhandledRejectionHandler(): void {\n const tracking = requireRejectionTracking();\n\n const promiseRejectionTrackingOptions: PromiseRejectionTrackingOptions = {\n onUnhandled: (id, rejection = {}) => {\n // eslint-disable-next-line no-console\n console.warn(`Possible Unhandled Promise Rejection (id: ${id}):\\n${rejection}`);\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: unknown) => {\n if (__DEV__) {\n promiseRejectionTrackingOptions.onUnhandled(id, error);\n }\n\n captureException(error, {\n data: { id },\n originalException: error,\n syntheticException: isErrorLike(error) ? undefined : createSyntheticError(),\n mechanism: { handled: true, type: 'onunhandledrejection' },\n });\n },\n onHandled: (id: string) => {\n promiseRejectionTrackingOptions.onHandled(id);\n },\n });\n}\n\nfunction setupErrorUtilsGlobalHandler(): void {\n let handlingFatal = false;\n\n const errorUtils = RN_GLOBAL_OBJ.ErrorUtils;\n if (!errorUtils) {\n logger.warn('ErrorUtils not found. Can be caused by different environment for example react-native-web.');\n return;\n }\n\n const defaultHandler = 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('Encountered multiple fatals in a row. The latest:', error);\n return;\n }\n handlingFatal = true;\n }\n\n const client = getClient();\n\n if (!client) {\n logger.error('Sentry client is missing, the error event might be lost.', error);\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 hint: EventHint = {\n originalException: error,\n attachments: getCurrentScope().getScopeData().attachments,\n };\n const event = await client.eventFromException(error, hint);\n\n if (isFatal) {\n event.level = 'fatal' as SeverityLevel;\n\n addExceptionMechanism(event, {\n handled: false,\n type: 'onerror',\n });\n } else {\n event.level = 'error';\n\n addExceptionMechanism(event, {\n handled: true,\n type: 'generic',\n });\n }\n\n client.captureEvent(event, hint);\n\n if (__DEV__) {\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 return;\n }\n\n void client.flush(client.getOptions().shutdownTimeout || 2000).then(\n () => {\n defaultHandler(error, isFatal);\n },\n (reason: unknown) => {\n logger.error('[ReactNativeErrorHandlers] Error while flushing the event cache after uncaught error.', reason);\n },\n );\n });\n}\n"]}
@@ -1,4 +1,12 @@
1
- import { __awaiter } from "tslib";
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
2
10
  import { NATIVE } from '../wrapper';
3
11
  const INTEGRATION_NAME = 'Release';
4
12
  /** Release integration responsible to load release from file. */