@sentry/react-native 5.0.0-alpha.5 → 5.0.0-alpha.7

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 (90) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/RNSentry.podspec +21 -4
  3. package/android/build.gradle +20 -2
  4. package/android/src/main/java/io/sentry/react/{RNSentryModule.java → RNSentryModuleImpl.java} +83 -99
  5. package/android/src/main/java/io/sentry/react/RNSentryPackage.java +35 -19
  6. package/android/src/newarch/java/io/sentry/react/RNSentryModule.java +109 -0
  7. package/android/src/oldarch/java/io/sentry/react/RNSentryModule.java +109 -0
  8. package/dist/js/NativeRNSentry.d.ts +45 -0
  9. package/dist/js/NativeRNSentry.d.ts.map +1 -0
  10. package/dist/js/NativeRNSentry.js +4 -0
  11. package/dist/js/NativeRNSentry.js.map +1 -0
  12. package/dist/js/integrations/debugsymbolicator.d.ts +9 -0
  13. package/dist/js/integrations/debugsymbolicator.d.ts.map +1 -1
  14. package/dist/js/integrations/debugsymbolicator.js +0 -2
  15. package/dist/js/integrations/debugsymbolicator.js.map +1 -1
  16. package/dist/js/integrations/index.d.ts +1 -0
  17. package/dist/js/integrations/index.d.ts.map +1 -1
  18. package/dist/js/integrations/index.js +1 -0
  19. package/dist/js/integrations/index.js.map +1 -1
  20. package/dist/js/integrations/reactnativeerrorhandlers.d.ts.map +1 -1
  21. package/dist/js/integrations/reactnativeerrorhandlers.js +3 -3
  22. package/dist/js/integrations/reactnativeerrorhandlers.js.map +1 -1
  23. package/dist/js/integrations/reactnativeinfo.d.ts +23 -0
  24. package/dist/js/integrations/reactnativeinfo.d.ts.map +1 -0
  25. package/dist/js/integrations/reactnativeinfo.js +43 -0
  26. package/dist/js/integrations/reactnativeinfo.js.map +1 -0
  27. package/dist/js/integrations/sdkinfo.d.ts.map +1 -1
  28. package/dist/js/integrations/sdkinfo.js +0 -1
  29. package/dist/js/integrations/sdkinfo.js.map +1 -1
  30. package/dist/js/measurements.js +1 -1
  31. package/dist/js/measurements.js.map +1 -1
  32. package/dist/js/options.d.ts +1 -1
  33. package/dist/js/options.d.ts.map +1 -1
  34. package/dist/js/options.js.map +1 -1
  35. package/dist/js/scope.d.ts +1 -1
  36. package/dist/js/scope.d.ts.map +1 -1
  37. package/dist/js/scope.js +1 -1
  38. package/dist/js/scope.js.map +1 -1
  39. package/dist/js/sdk.d.ts +1 -1
  40. package/dist/js/sdk.d.ts.map +1 -1
  41. package/dist/js/sdk.js +4 -8
  42. package/dist/js/sdk.js.map +1 -1
  43. package/dist/js/touchevents.d.ts +4 -0
  44. package/dist/js/touchevents.d.ts.map +1 -1
  45. package/dist/js/touchevents.js.map +1 -1
  46. package/dist/js/tracing/nativeframes.js.map +1 -1
  47. package/dist/js/tracing/reactnativenavigation.d.ts +7 -0
  48. package/dist/js/tracing/reactnativenavigation.d.ts.map +1 -1
  49. package/dist/js/tracing/reactnativenavigation.js.map +1 -1
  50. package/dist/js/tracing/reactnativetracing.d.ts +1 -1
  51. package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
  52. package/dist/js/tracing/reactnativetracing.js +1 -0
  53. package/dist/js/tracing/reactnativetracing.js.map +1 -1
  54. package/dist/js/tracing/reactnavigation.d.ts +5 -1
  55. package/dist/js/tracing/reactnavigation.d.ts.map +1 -1
  56. package/dist/js/tracing/reactnavigation.js +4 -4
  57. package/dist/js/tracing/reactnavigation.js.map +1 -1
  58. package/dist/js/tracing/reactnavigationv4.d.ts +5 -1
  59. package/dist/js/tracing/reactnavigationv4.d.ts.map +1 -1
  60. package/dist/js/tracing/reactnavigationv4.js +4 -4
  61. package/dist/js/tracing/reactnavigationv4.js.map +1 -1
  62. package/dist/js/tracing/routingInstrumentation.d.ts +1 -1
  63. package/dist/js/tracing/routingInstrumentation.d.ts.map +1 -1
  64. package/dist/js/tracing/routingInstrumentation.js.map +1 -1
  65. package/dist/js/user.d.ts +6 -0
  66. package/dist/js/user.d.ts.map +1 -0
  67. package/dist/js/user.js +1 -0
  68. package/dist/js/user.js.map +1 -0
  69. package/dist/js/utils/environment.d.ts +7 -0
  70. package/dist/js/utils/environment.d.ts.map +1 -0
  71. package/dist/js/utils/environment.js +14 -0
  72. package/dist/js/utils/environment.js.map +1 -0
  73. package/dist/js/utils/worldwide.d.ts +13 -0
  74. package/dist/js/utils/worldwide.d.ts.map +1 -0
  75. package/dist/js/utils/worldwide.js +4 -0
  76. package/dist/js/utils/worldwide.js.map +1 -0
  77. package/dist/js/version.d.ts +1 -1
  78. package/dist/js/version.js +1 -1
  79. package/dist/js/version.js.map +1 -1
  80. package/dist/js/wrapper.d.ts +3 -2
  81. package/dist/js/wrapper.d.ts.map +1 -1
  82. package/dist/js/wrapper.js +28 -14
  83. package/dist/js/wrapper.js.map +1 -1
  84. package/ios/{RNSentry.m → RNSentry.mm} +33 -14
  85. package/package.json +26 -22
  86. package/sample-new-architecture/react-native.config.js +10 -0
  87. package/dist/js/definitions.d.ts +0 -50
  88. package/dist/js/definitions.d.ts.map +0 -1
  89. package/dist/js/definitions.js +0 -1
  90. package/dist/js/definitions.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,92 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.0.0-alpha.7
4
+
5
+ - Latest changes from 4.7.1
6
+
7
+ ### Fixes
8
+
9
+ - Remove hardcoded Folly version ([#2558](https://github.com/getsentry/sentry-react-native/pull/2558))
10
+
11
+ ### Features
12
+
13
+ - Send react native js engine, turbo module, fabric flags and component stack in Event contexts ([#2552](https://github.com/getsentry/sentry-react-native/pull/2552))
14
+
15
+ ### Dependencies
16
+
17
+ - Bump CLI from v1.74.4 to v2.7.0 ([#2457](https://github.com/getsentry/sentry-react-native/pull/2457))
18
+ - [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#270)
19
+ - [diff](https://github.com/getsentry/sentry-cli/compare/1.74.4...2.7.0)
20
+ - Bump Android SDK from v6.5.0 to v6.6.0 ([#2572](https://github.com/getsentry/sentry-react-native/pull/2572))
21
+ - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#660)
22
+ - [diff](https://github.com/getsentry/sentry-java/compare/6.5.0...6.6.0)
23
+ - Bump Cocoa SDK from v7.28.0 to v7.29.0 ([#2571](https://github.com/getsentry/sentry-react-native/pull/2571))
24
+ - [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7290)
25
+ - [diff](https://github.com/getsentry/sentry-cocoa/compare/7.28.0...7.29.0)
26
+
27
+ ## 4.7.1
28
+
29
+ ### Fixes
30
+
31
+ - Remove duplicate sdk package record from envelope ([#2570](https://github.com/getsentry/sentry-react-native/pull/2570))
32
+ - Fix `appHangsTimeoutInterval` -> `appHangTimeoutInterval` option name ([#2574](https://github.com/getsentry/sentry-react-native/pull/2574))
33
+
34
+ ## 4.7.0
35
+
36
+ ### Dependencies
37
+
38
+ - Bump Android SDK from v6.4.3 to v6.5.0 ([#2535](https://github.com/getsentry/sentry-react-native/pull/2535))
39
+ - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#650)
40
+ - [diff](https://github.com/getsentry/sentry-java/compare/6.4.3...6.5.0)
41
+ - Bump JavaScript SDK from v7.14.2 to v7.16.0 ([#2536](https://github.com/getsentry/sentry-react-native/pull/2536), [#2561](https://github.com/getsentry/sentry-react-native/pull/2561))
42
+ - [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7160)
43
+ - [diff](https://github.com/getsentry/sentry-javascript/compare/7.14.2...7.16.0)
44
+ - Bump Cocoa SDK from v7.27.1 to v7.28.0 ([#2548](https://github.com/getsentry/sentry-react-native/pull/2548))
45
+ - [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7280)
46
+ - [diff](https://github.com/getsentry/sentry-cocoa/compare/7.27.1...7.28.0)
47
+
48
+ ## 5.0.0-alpha.6
49
+
50
+ - Latest changes from 4.6.1
51
+
52
+ ### Features
53
+
54
+ - Add initial support for the RN New Architecture, backwards compatible RNSentry Turbo Module ([#2522](https://github.com/getsentry/sentry-react-native/pull/2522))
55
+
56
+ ### Breaking changes
57
+
58
+ - New ReactNativeTracingOptions idleTimeoutMs and finalTimeoutMs replacing idleTimeout and maxTransactionDuration respectively ([#2481](https://github.com/getsentry/sentry-react-native/pull/2481))
59
+ - iOS min target 12.4, Android API min 21, min React Native version 0.70 ([#2522](https://github.com/getsentry/sentry-react-native/pull/2522))
60
+
61
+ ### Dependencies
62
+
63
+ - Bump Android SDK from v6.4.3 to v6.5.0 ([#2535](https://github.com/getsentry/sentry-react-native/pull/2535))
64
+ - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#650)
65
+ - [diff](https://github.com/getsentry/sentry-java/compare/6.4.3...6.5.0)
66
+ - Bump JavaScript SDK from v7.14.2 to v7.15.0 ([#2536](https://github.com/getsentry/sentry-react-native/pull/2536))
67
+ - [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7150)
68
+ - [diff](https://github.com/getsentry/sentry-javascript/compare/7.14.2...7.15.0)
69
+
70
+ ## 4.6.1
71
+
72
+ ### Fixes
73
+
74
+ - Make `configureScope` callback safe [#2510](https://github.com/getsentry/sentry-react-native/pull/2510)
75
+ - Allows collecting app start and slow/frozen frames if Native SDK is inited manually [#2517](https://github.com/getsentry/sentry-react-native/pull/2517)
76
+ - Nested breadcrumb data on android was not treated correctly [#2519](https://github.com/getsentry/sentry-react-native/pull/2519)
77
+
78
+ ### Dependencies
79
+
80
+ - Bump JavaScript SDK from v7.14.0 to v7.14.2 ([#2511](https://github.com/getsentry/sentry-react-native/pull/2511), [#2526](https://github.com/getsentry/sentry-react-native/pull/2526))
81
+ - [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7142)
82
+ - [diff](https://github.com/getsentry/sentry-javascript/compare/7.14.0...7.14.2)
83
+ - Bump Cocoa SDK from v7.27.0 to v7.27.1 ([#2521](https://github.com/getsentry/sentry-react-native/pull/2521))
84
+ - [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7271)
85
+ - [diff](https://github.com/getsentry/sentry-cocoa/compare/7.27.0...7.27.1)
86
+ - Bump Android SDK from v6.4.2 to v6.4.3 ([#2520](https://github.com/getsentry/sentry-react-native/pull/2520))
87
+ - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#643)
88
+ - [diff](https://github.com/getsentry/sentry-java/compare/6.4.2...6.4.3)
89
+
3
90
  ## 5.0.0-alpha.5
4
91
 
5
92
  ### Fixes
package/RNSentry.podspec CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'json'
2
2
  version = JSON.parse(File.read('package.json'))["version"]
3
3
 
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
4
6
  Pod::Spec.new do |s|
5
7
  s.name = 'RNSentry'
6
8
  s.version = version
@@ -10,15 +12,30 @@ Pod::Spec.new do |s|
10
12
  s.homepage = "https://github.com/getsentry/sentry-react-native"
11
13
  s.source = { :git => 'https://github.com/getsentry/sentry-react-native.git', :tag => "#{s.version}"}
12
14
 
13
- s.ios.deployment_target = "8.0"
15
+ s.ios.deployment_target = "12.4"
14
16
  s.osx.deployment_target = "10.10"
15
- s.tvos.deployment_target = "9.0"
17
+ s.tvos.deployment_target = "12.4"
16
18
 
17
19
  s.preserve_paths = '*.js'
18
20
 
19
21
  s.dependency 'React-Core'
20
- s.dependency 'Sentry', '7.27.1'
22
+ s.dependency 'Sentry', '7.29.0'
21
23
 
22
- s.source_files = 'ios/RNSentry.{h,m}'
24
+ s.source_files = 'ios/RNSentry.{h,mm}'
23
25
  s.public_header_files = 'ios/RNSentry.h'
26
+
27
+ # This guard prevent to install the dependencies when we run `pod install` in the old architecture.
28
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
29
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
30
+ s.pod_target_xcconfig = {
31
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
32
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
33
+ }
34
+
35
+ s.dependency "React-Codegen"
36
+ s.dependency "RCT-Folly"
37
+ s.dependency "RCTRequired"
38
+ s.dependency "RCTTypeSafety"
39
+ s.dependency "ReactCommon/turbomodule/core"
40
+ end
24
41
  end
@@ -2,13 +2,20 @@ def safeExtGet(prop, fallback) {
2
2
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
3
3
  }
4
4
 
5
+ def isNewArchitectureEnabled() {
6
+ return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
7
+ }
8
+
5
9
  apply plugin: 'com.android.library'
10
+ if (isNewArchitectureEnabled()) {
11
+ apply plugin: 'com.facebook.react'
12
+ }
6
13
 
7
14
  android {
8
15
  compileSdkVersion safeExtGet('compileSdkVersion', 31)
9
16
 
10
17
  defaultConfig {
11
- minSdkVersion safeExtGet('minSdkVersion', 16)
18
+ minSdkVersion safeExtGet('minSdkVersion', 21)
12
19
  targetSdkVersion safeExtGet('targetSdkVersion', 31)
13
20
  versionCode 1
14
21
  versionName "1.0"
@@ -19,10 +26,21 @@ android {
19
26
  sourceCompatibility JavaVersion.VERSION_1_8
20
27
  targetCompatibility JavaVersion.VERSION_1_8
21
28
  }
29
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
30
+ }
31
+
32
+ sourceSets {
33
+ main {
34
+ if (isNewArchitectureEnabled()) {
35
+ java.srcDirs += ['src/newarch']
36
+ } else {
37
+ java.srcDirs += ['src/oldarch']
38
+ }
39
+ }
22
40
  }
23
41
  }
24
42
 
25
43
  dependencies {
26
44
  implementation 'com.facebook.react:react-native:+'
27
- api 'io.sentry:sentry-android:6.4.3'
45
+ api 'io.sentry:sentry-android:6.6.0'
28
46
  }
@@ -6,24 +6,19 @@ import android.content.pm.PackageInfo;
6
6
  import android.content.pm.PackageManager;
7
7
  import android.util.SparseIntArray;
8
8
 
9
+ import androidx.annotation.Nullable;
9
10
  import androidx.core.app.FrameMetricsAggregator;
10
11
 
11
12
  import com.facebook.react.bridge.Arguments;
12
- import com.facebook.react.bridge.LifecycleEventListener;
13
13
  import com.facebook.react.bridge.Promise;
14
14
  import com.facebook.react.bridge.ReactApplicationContext;
15
- import com.facebook.react.bridge.ReactContextBaseJavaModule;
16
- import com.facebook.react.bridge.ReactMethod;
17
15
  import com.facebook.react.bridge.ReadableArray;
18
16
  import com.facebook.react.bridge.ReadableMap;
19
17
  import com.facebook.react.bridge.ReadableMapKeySetIterator;
20
18
  import com.facebook.react.bridge.WritableMap;
21
- import com.facebook.react.module.annotations.ReactModule;
22
19
 
23
20
  import java.io.File;
24
21
  import java.io.FileOutputStream;
25
- import java.io.UnsupportedEncodingException;
26
- import java.nio.charset.Charset;
27
22
  import java.util.Date;
28
23
  import java.util.HashMap;
29
24
  import java.util.List;
@@ -32,32 +27,32 @@ import java.util.UUID;
32
27
  import java.util.logging.Level;
33
28
  import java.util.logging.Logger;
34
29
 
35
- import io.sentry.SentryEvent;
36
- import io.sentry.android.core.AnrIntegration;
37
- import io.sentry.android.core.AppStartState;
38
- import io.sentry.android.core.NdkIntegration;
39
- import io.sentry.android.core.SentryAndroid;
40
30
  import io.sentry.Breadcrumb;
41
31
  import io.sentry.HubAdapter;
42
32
  import io.sentry.Integration;
43
33
  import io.sentry.Sentry;
34
+ import io.sentry.SentryEvent;
44
35
  import io.sentry.SentryLevel;
45
36
  import io.sentry.UncaughtExceptionHandlerIntegration;
37
+ import io.sentry.android.core.AnrIntegration;
38
+ import io.sentry.android.core.AppStartState;
39
+ import io.sentry.android.core.NdkIntegration;
40
+ import io.sentry.android.core.SentryAndroid;
46
41
  import io.sentry.protocol.SdkVersion;
47
42
  import io.sentry.protocol.SentryException;
48
43
  import io.sentry.protocol.SentryPackage;
49
44
  import io.sentry.protocol.User;
50
45
 
51
- @ReactModule(name = RNSentryModule.NAME)
52
- public class RNSentryModule extends ReactContextBaseJavaModule {
46
+ public class RNSentryModuleImpl {
53
47
 
54
48
  public static final String NAME = "RNSentry";
55
49
 
56
50
  private static final Logger logger = Logger.getLogger("react-native-sentry");
57
51
 
58
- private PackageInfo packageInfo = null;
52
+ private final ReactApplicationContext reactApplicationContext;
53
+ private final PackageInfo packageInfo;
59
54
  private FrameMetricsAggregator frameMetricsAggregator = null;
60
- private boolean androidXAvailable = true;
55
+ private boolean androidXAvailable;
61
56
 
62
57
  private static boolean didFetchAppStart;
63
58
 
@@ -66,25 +61,20 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
66
61
  // 16ms (slower than 60fps) to constitute slow frames.
67
62
  private static final int SLOW_FRAME_THRESHOLD = 16;
68
63
 
69
- public RNSentryModule(ReactApplicationContext reactContext) {
70
- super(reactContext);
71
- packageInfo = getPackageInfo(reactContext);
64
+ public RNSentryModuleImpl(ReactApplicationContext reactApplicationContext) {
65
+ packageInfo = getPackageInfo(reactApplicationContext);
66
+ this.reactApplicationContext = reactApplicationContext;
72
67
  }
73
68
 
74
- @Override
75
- public String getName() {
76
- return NAME;
69
+ private ReactApplicationContext getReactApplicationContext() {
70
+ return this.reactApplicationContext;
77
71
  }
78
72
 
79
- @Override
80
- public Map<String, Object> getConstants() {
81
- final Map<String, Object> constants = new HashMap<>();
82
- constants.put("nativeClientAvailable", true);
83
- constants.put("nativeTransport", true);
84
- return constants;
73
+ private @Nullable
74
+ Activity getCurrentActivity() {
75
+ return this.reactApplicationContext.getCurrentActivity();
85
76
  }
86
77
 
87
- @ReactMethod
88
78
  public void initNativeSdk(final ReadableMap rnOptions, Promise promise) {
89
79
  SentryAndroid.init(this.getReactApplicationContext(), options -> {
90
80
  if (rnOptions.hasKey("debug") && rnOptions.getBoolean("debug")) {
@@ -133,36 +123,13 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
133
123
  options.setAttachStacktrace(rnOptions.getBoolean("attachStacktrace"));
134
124
  }
135
125
  if (rnOptions.hasKey("attachThreads")) {
136
- // JS use top level stacktraces and android attaches Threads which hides them so
126
+ // JS use top level stacktrace and android attaches Threads which hides them so
137
127
  // by default we hide.
138
128
  options.setAttachThreads(rnOptions.getBoolean("attachThreads"));
139
129
  }
140
130
  if (rnOptions.hasKey("sendDefaultPii")) {
141
131
  options.setSendDefaultPii(rnOptions.getBoolean("sendDefaultPii"));
142
132
  }
143
- if (rnOptions.hasKey("enableAutoPerformanceTracking")
144
- && rnOptions.getBoolean("enableAutoPerformanceTracking")) {
145
- androidXAvailable = checkAndroidXAvailability();
146
-
147
- if (androidXAvailable) {
148
- frameMetricsAggregator = new FrameMetricsAggregator();
149
- final Activity currentActivity = getCurrentActivity();
150
-
151
- if (frameMetricsAggregator != null && currentActivity != null) {
152
- try {
153
- frameMetricsAggregator.add(currentActivity);
154
- } catch (Throwable ignored) {
155
- // throws ConcurrentModification when calling addOnFrameMetricsAvailableListener
156
- // this is a best effort since we can't reproduce it
157
- logger.warning("Error adding Activity to frameMetricsAggregator.");
158
- }
159
- }
160
- } else {
161
- logger.warning("androidx.core' isn't available as a dependency.");
162
- }
163
- } else {
164
- this.disableNativeFramesTracking();
165
- }
166
133
 
167
134
  options.setBeforeSend((event, hint) -> {
168
135
  // React native internally throws a JavascriptException
@@ -193,18 +160,16 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
193
160
  }
194
161
  }
195
162
 
196
- logger.info(String.format("Native Integrations '%s'", options.getIntegrations().toString()));
163
+ logger.info(String.format("Native Integrations '%s'", options.getIntegrations()));
197
164
  });
198
165
 
199
166
  promise.resolve(true);
200
167
  }
201
168
 
202
- @ReactMethod
203
169
  public void crash() {
204
170
  throw new RuntimeException("TEST - Sentry Client Crash (only works in release mode)");
205
171
  }
206
172
 
207
- @ReactMethod
208
173
  public void fetchNativeRelease(Promise promise) {
209
174
  WritableMap release = Arguments.createMap();
210
175
  release.putString("id", packageInfo.packageName);
@@ -213,7 +178,6 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
213
178
  promise.resolve(release);
214
179
  }
215
180
 
216
- @ReactMethod
217
181
  public void fetchNativeAppStart(Promise promise) {
218
182
  final AppStartState appStartInstance = AppStartState.getInstance();
219
183
  final Date appStartTime = appStartInstance.getAppStartTime();
@@ -245,7 +209,6 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
245
209
  /**
246
210
  * Returns frames metrics at the current point in time.
247
211
  */
248
- @ReactMethod
249
212
  public void fetchNativeFrames(Promise promise) {
250
213
  if (!isFrameMetricsAggregatorAvailable()) {
251
214
  promise.resolve(null);
@@ -295,9 +258,8 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
295
258
  }
296
259
  }
297
260
 
298
- @ReactMethod
299
261
  public void captureEnvelope(ReadableArray rawBytes, ReadableMap options, Promise promise) {
300
- byte bytes[] = new byte[rawBytes.size()];
262
+ byte[] bytes = new byte[rawBytes.size()];
301
263
  for (int i = 0; i < rawBytes.size(); i++) {
302
264
  bytes[i] = (byte) rawBytes.getInt(i);
303
265
  }
@@ -329,43 +291,49 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
329
291
  }
330
292
  }
331
293
 
332
- @ReactMethod
333
- public void setUser(final ReadableMap user, final ReadableMap otherUserKeys) {
294
+ public void setUser(final ReadableMap userKeys, final ReadableMap userDataKeys) {
334
295
  Sentry.configureScope(scope -> {
335
- if (user == null && otherUserKeys == null) {
296
+ if (userKeys == null && userDataKeys == null) {
336
297
  scope.setUser(null);
337
298
  } else {
338
299
  User userInstance = new User();
339
300
 
340
- if (user != null) {
341
- if (user.hasKey("email")) {
342
- userInstance.setEmail(user.getString("email"));
301
+ if (userKeys != null) {
302
+ if (userKeys.hasKey("email")) {
303
+ userInstance.setEmail(userKeys.getString("email"));
343
304
  }
344
305
 
345
- if (user.hasKey("id")) {
346
- userInstance.setId(user.getString("id"));
306
+ if (userKeys.hasKey("id")) {
307
+ userInstance.setId(userKeys.getString("id"));
347
308
  }
348
309
 
349
- if (user.hasKey("username")) {
350
- userInstance.setUsername(user.getString("username"));
310
+ if (userKeys.hasKey("username")) {
311
+ userInstance.setUsername(userKeys.getString("username"));
351
312
  }
352
313
 
353
- if (user.hasKey("ip_address")) {
354
- userInstance.setIpAddress(user.getString("ip_address"));
314
+ if (userKeys.hasKey("ip_address")) {
315
+ userInstance.setIpAddress(userKeys.getString("ip_address"));
316
+ }
317
+
318
+ if (userKeys.hasKey("segment")) {
319
+ userInstance.setSegment(userKeys.getString("segment"));
355
320
  }
356
321
  }
357
322
 
358
- if (otherUserKeys != null) {
359
- HashMap<String, String> otherUserKeysMap = new HashMap<String, String>();
360
- ReadableMapKeySetIterator it = otherUserKeys.keySetIterator();
323
+ if (userDataKeys != null) {
324
+ HashMap<String, String> userDataMap = new HashMap<>();
325
+ ReadableMapKeySetIterator it = userDataKeys.keySetIterator();
361
326
  while (it.hasNextKey()) {
362
327
  String key = it.nextKey();
363
- String value = otherUserKeys.getString(key);
328
+ String value = userDataKeys.getString(key);
364
329
 
365
- otherUserKeysMap.put(key, value);
330
+ // other is ConcurrentHashMap and can't have null values
331
+ if (value != null) {
332
+ userDataMap.put(key, value);
333
+ }
366
334
  }
367
335
 
368
- userInstance.setOthers(otherUserKeysMap);
336
+ userInstance.setData(userDataMap);
369
337
  }
370
338
 
371
339
  scope.setUser(userInstance);
@@ -373,7 +341,6 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
373
341
  });
374
342
  }
375
343
 
376
- @ReactMethod
377
344
  public void addBreadcrumb(final ReadableMap breadcrumb) {
378
345
  Sentry.configureScope(scope -> {
379
346
  Breadcrumb breadcrumbInstance = new Breadcrumb();
@@ -398,29 +365,27 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
398
365
  case "warning":
399
366
  breadcrumbInstance.setLevel(SentryLevel.WARNING);
400
367
  break;
401
- case "info":
402
- breadcrumbInstance.setLevel(SentryLevel.INFO);
403
- break;
404
368
  case "debug":
405
369
  breadcrumbInstance.setLevel(SentryLevel.DEBUG);
406
370
  break;
407
371
  case "error":
408
372
  breadcrumbInstance.setLevel(SentryLevel.ERROR);
409
373
  break;
374
+ case "info":
410
375
  default:
411
- breadcrumbInstance.setLevel(SentryLevel.ERROR);
376
+ breadcrumbInstance.setLevel(SentryLevel.INFO);
412
377
  break;
413
378
  }
414
379
  }
415
380
 
416
381
  if (breadcrumb.hasKey("data")) {
417
- ReadableMap data = breadcrumb.getMap("data");
418
- ReadableMapKeySetIterator it = data.keySetIterator();
419
- while (it.hasNextKey()) {
420
- String key = it.nextKey();
421
- String value = data.getString(key);
422
-
423
- breadcrumbInstance.setData(key, value);
382
+ final ReadableMap data = breadcrumb.getMap("data");
383
+ for (final Map.Entry<String, Object> entry : data.toHashMap().entrySet()) {
384
+ final Object value = entry.getValue();
385
+ // data is ConcurrentHashMap and can't have null values
386
+ if (value != null) {
387
+ breadcrumbInstance.setData(entry.getKey(), entry.getValue());
388
+ }
424
389
  }
425
390
  }
426
391
 
@@ -428,21 +393,18 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
428
393
  });
429
394
  }
430
395
 
431
- @ReactMethod
432
396
  public void clearBreadcrumbs() {
433
397
  Sentry.configureScope(scope -> {
434
398
  scope.clearBreadcrumbs();
435
399
  });
436
400
  }
437
401
 
438
- @ReactMethod
439
402
  public void setExtra(String key, String extra) {
440
403
  Sentry.configureScope(scope -> {
441
404
  scope.setExtra(key, extra);
442
405
  });
443
406
  }
444
407
 
445
- @ReactMethod
446
408
  public void setContext(final String key, final ReadableMap context) {
447
409
  if (key == null || context == null) {
448
410
  return;
@@ -454,14 +416,12 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
454
416
  });
455
417
  }
456
418
 
457
- @ReactMethod
458
419
  public void setTag(String key, String value) {
459
420
  Sentry.configureScope(scope -> {
460
421
  scope.setTag(key, value);
461
422
  });
462
423
  }
463
424
 
464
- @ReactMethod
465
425
  public void closeNativeSdk(Promise promise) {
466
426
  Sentry.close();
467
427
 
@@ -470,7 +430,31 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
470
430
  promise.resolve(true);
471
431
  }
472
432
 
473
- @ReactMethod
433
+ public void enableNativeFramesTracking() {
434
+ androidXAvailable = checkAndroidXAvailability();
435
+
436
+ if (androidXAvailable) {
437
+ frameMetricsAggregator = new FrameMetricsAggregator();
438
+ final Activity currentActivity = getCurrentActivity();
439
+
440
+ if (frameMetricsAggregator != null && currentActivity != null) {
441
+ try {
442
+ frameMetricsAggregator.add(currentActivity);
443
+
444
+ logger.info("FrameMetricsAggregator installed.");
445
+ } catch (Throwable ignored) {
446
+ // throws ConcurrentModification when calling addOnFrameMetricsAvailableListener
447
+ // this is a best effort since we can't reproduce it
448
+ logger.severe("Error adding Activity to frameMetricsAggregator.");
449
+ }
450
+ } else {
451
+ logger.info("currentActivity isn't available.");
452
+ }
453
+ } else {
454
+ logger.warning("androidx.core' isn't available as a dependency.");
455
+ }
456
+ }
457
+
474
458
  public void disableNativeFramesTracking() {
475
459
  if (isFrameMetricsAggregatorAvailable()) {
476
460
  frameMetricsAggregator.stop();
@@ -485,10 +469,10 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
485
469
  // If the event is from capacitor js, it gets set there and we do not handle it
486
470
  // here.
487
471
  case "sentry.native":
488
- setEventEnvironmentTag(event, "android", "native");
472
+ setEventEnvironmentTag(event, "native");
489
473
  break;
490
474
  case "sentry.java.android":
491
- setEventEnvironmentTag(event, "android", "java");
475
+ setEventEnvironmentTag(event, "java");
492
476
  break;
493
477
  default:
494
478
  break;
@@ -496,8 +480,8 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
496
480
  }
497
481
  }
498
482
 
499
- private void setEventEnvironmentTag(SentryEvent event, String origin, String environment) {
500
- event.setTag("event.origin", origin);
483
+ private void setEventEnvironmentTag(SentryEvent event, String environment) {
484
+ event.setTag("event.origin", "android");
501
485
  event.setTag("event.environment", environment);
502
486
  }
503
487
 
@@ -1,30 +1,46 @@
1
1
  package io.sentry.react;
2
2
 
3
- import java.util.Arrays;
4
- import java.util.Collections;
5
- import java.util.List;
3
+ import androidx.annotation.Nullable;
4
+
5
+ import java.util.HashMap;
6
+ import java.util.Map;
6
7
 
7
- import com.facebook.react.ReactPackage;
8
8
  import com.facebook.react.bridge.NativeModule;
9
9
  import com.facebook.react.bridge.ReactApplicationContext;
10
- import com.facebook.react.uimanager.ViewManager;
11
- import com.facebook.react.bridge.JavaScriptModule;
10
+ import com.facebook.react.module.model.ReactModuleInfo;
11
+ import com.facebook.react.module.model.ReactModuleInfoProvider;
12
+ import com.facebook.react.TurboReactPackage;
12
13
 
13
- public class RNSentryPackage implements ReactPackage {
14
- public RNSentryPackage() {
15
- }
14
+ public class RNSentryPackage extends TurboReactPackage {
16
15
 
17
- @Override
18
- public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
19
- return Arrays.<NativeModule>asList(new RNSentryModule(reactContext));
16
+ @Nullable
17
+ @Override
18
+ public NativeModule getModule(String name, ReactApplicationContext reactContext) {
19
+ if (name.equals(RNSentryModuleImpl.NAME)) {
20
+ return new RNSentryModule(reactContext);
21
+ } else {
22
+ return null;
20
23
  }
24
+ }
21
25
 
22
- public List<Class<? extends JavaScriptModule>> createJSModules() {
23
- return Collections.emptyList();
24
- }
26
+ @Override
27
+ public ReactModuleInfoProvider getReactModuleInfoProvider() {
28
+ return () -> {
29
+ final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
30
+ boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
31
+ moduleInfos.put(
32
+ RNSentryModuleImpl.NAME,
33
+ new ReactModuleInfo(
34
+ RNSentryModuleImpl.NAME,
35
+ RNSentryModuleImpl.NAME,
36
+ false, // canOverrideExistingModule
37
+ false, // needsEagerInit
38
+ true, // hasConstants
39
+ false, // isCxxModule
40
+ isTurboModule // isTurboModule
41
+ ));
42
+ return moduleInfos;
43
+ };
44
+ }
25
45
 
26
- @Override
27
- public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
28
- return Collections.emptyList();
29
- }
30
46
  }