@sentry/react-native 5.0.0-alpha.5 → 5.0.0-alpha.6
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.
- package/CHANGELOG.md +55 -0
- package/RNSentry.podspec +21 -3
- package/android/build.gradle +20 -2
- package/android/src/main/java/io/sentry/react/{RNSentryModule.java → RNSentryModuleImpl.java} +64 -84
- package/android/src/main/java/io/sentry/react/RNSentryPackage.java +35 -19
- package/android/src/newarch/java/io/sentry/react/RNSentryModule.java +109 -0
- package/android/src/oldarch/java/io/sentry/react/RNSentryModule.java +109 -0
- package/dist/js/NativeRNSentry.d.ts +45 -0
- package/dist/js/NativeRNSentry.d.ts.map +1 -0
- package/dist/js/NativeRNSentry.js +4 -0
- package/dist/js/NativeRNSentry.js.map +1 -0
- package/dist/js/measurements.js +1 -1
- package/dist/js/measurements.js.map +1 -1
- package/dist/js/scope.d.ts +1 -1
- package/dist/js/scope.d.ts.map +1 -1
- package/dist/js/scope.js +1 -1
- package/dist/js/scope.js.map +1 -1
- package/dist/js/sdk.d.ts +1 -1
- package/dist/js/sdk.d.ts.map +1 -1
- package/dist/js/sdk.js +1 -2
- package/dist/js/sdk.js.map +1 -1
- package/dist/js/touchevents.d.ts +4 -0
- package/dist/js/touchevents.d.ts.map +1 -1
- package/dist/js/touchevents.js.map +1 -1
- package/dist/js/tracing/nativeframes.js.map +1 -1
- package/dist/js/tracing/reactnativenavigation.d.ts +7 -0
- package/dist/js/tracing/reactnativenavigation.d.ts.map +1 -1
- package/dist/js/tracing/reactnativenavigation.js.map +1 -1
- package/dist/js/tracing/reactnativetracing.d.ts +1 -1
- package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
- package/dist/js/tracing/reactnativetracing.js +1 -0
- package/dist/js/tracing/reactnativetracing.js.map +1 -1
- package/dist/js/tracing/reactnavigation.d.ts +5 -1
- package/dist/js/tracing/reactnavigation.d.ts.map +1 -1
- package/dist/js/tracing/reactnavigation.js.map +1 -1
- package/dist/js/tracing/reactnavigationv4.d.ts +5 -1
- package/dist/js/tracing/reactnavigationv4.d.ts.map +1 -1
- package/dist/js/tracing/reactnavigationv4.js.map +1 -1
- package/dist/js/tracing/routingInstrumentation.d.ts +1 -1
- package/dist/js/tracing/routingInstrumentation.d.ts.map +1 -1
- package/dist/js/tracing/routingInstrumentation.js.map +1 -1
- package/dist/js/version.d.ts +1 -1
- package/dist/js/version.js +1 -1
- package/dist/js/version.js.map +1 -1
- package/dist/js/wrapper.d.ts +6 -2
- package/dist/js/wrapper.d.ts.map +1 -1
- package/dist/js/wrapper.js +17 -5
- package/dist/js/wrapper.js.map +1 -1
- package/ios/{RNSentry.m → RNSentry.mm} +22 -5
- package/package.json +25 -21
- package/sample-new-architecture/react-native.config.js +10 -0
- package/dist/js/definitions.d.ts +0 -50
- package/dist/js/definitions.d.ts.map +0 -1
- package/dist/js/definitions.js +0 -1
- package/dist/js/definitions.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
# Unreleased
|
|
4
|
+
|
|
5
|
+
- Latest changes from 4.6.1
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
- Add initial support for the RN New Architecture, backwards compatible RNSentry Turbo Module ([#2522](https://github.com/getsentry/sentry-react-native/pull/2522))
|
|
9
|
+
|
|
10
|
+
### Breaking changes
|
|
11
|
+
|
|
12
|
+
- New ReactNativeTracingOptions idleTimeoutMs and finalTimeoutMs replacing idleTimeout and maxTransactionDuration respectively ([#2481](https://github.com/getsentry/sentry-react-native/pull/2481))
|
|
13
|
+
- 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))
|
|
14
|
+
|
|
15
|
+
### Dependencies
|
|
16
|
+
|
|
17
|
+
- Bump Android SDK from v6.4.3 to v6.5.0 ([#2535](https://github.com/getsentry/sentry-react-native/pull/2535))
|
|
18
|
+
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#650)
|
|
19
|
+
- [diff](https://github.com/getsentry/sentry-java/compare/6.4.3...6.5.0)
|
|
20
|
+
- Bump JavaScript SDK from v7.14.2 to v7.15.0 ([#2536](https://github.com/getsentry/sentry-react-native/pull/2536))
|
|
21
|
+
- [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7150)
|
|
22
|
+
- [diff](https://github.com/getsentry/sentry-javascript/compare/7.14.2...7.15.0)
|
|
23
|
+
|
|
24
|
+
## 5.0.0-alpha.6
|
|
25
|
+
|
|
26
|
+
### Various fixes & improvements
|
|
27
|
+
|
|
28
|
+
- build(deps-dev): bump eslint-plugin-react from 7.20.6 to 7.31.10 (#2537) by @dependabot
|
|
29
|
+
- build(deps): bump async from 2.6.3 to 2.6.4 in /sample (#2491) by @dependabot
|
|
30
|
+
- build(deps): bump github/codeql-action from 2.1.26 to 2.1.27 (#2529) by @dependabot
|
|
31
|
+
- chore(deps): update JavaScript SDK to v7.15.0 (#2536) by @github-actions
|
|
32
|
+
- chore(deps): update Android SDK to v6.5.0 (#2535) by @github-actions
|
|
33
|
+
- release: 4.6.1 (3c8631d1) by @getsentry-bot
|
|
34
|
+
- chore(deps): update JavaScript SDK to v7.14.2 (#2526) by @github-actions
|
|
35
|
+
- Allows collecting app start and slow/frozen frames if Native SDK is inited manually (#2517) by @marandaneto
|
|
36
|
+
- Nested breadcrumb data on android was not treated correctly (#2519) by @marandaneto
|
|
37
|
+
|
|
38
|
+
## 4.6.1
|
|
39
|
+
|
|
40
|
+
### Fixes
|
|
41
|
+
|
|
42
|
+
- Make `configureScope` callback safe [#2510](https://github.com/getsentry/sentry-react-native/pull/2510)
|
|
43
|
+
- Allows collecting app start and slow/frozen frames if Native SDK is inited manually [#2517](https://github.com/getsentry/sentry-react-native/pull/2517)
|
|
44
|
+
- Nested breadcrumb data on android was not treated correctly [#2519](https://github.com/getsentry/sentry-react-native/pull/2519)
|
|
45
|
+
|
|
46
|
+
### Dependencies
|
|
47
|
+
|
|
48
|
+
- 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))
|
|
49
|
+
- [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7142)
|
|
50
|
+
- [diff](https://github.com/getsentry/sentry-javascript/compare/7.14.0...7.14.2)
|
|
51
|
+
- Bump Cocoa SDK from v7.27.0 to v7.27.1 ([#2521](https://github.com/getsentry/sentry-react-native/pull/2521))
|
|
52
|
+
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7271)
|
|
53
|
+
- [diff](https://github.com/getsentry/sentry-cocoa/compare/7.27.0...7.27.1)
|
|
54
|
+
- Bump Android SDK from v6.4.2 to v6.4.3 ([#2520](https://github.com/getsentry/sentry-react-native/pull/2520))
|
|
55
|
+
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#643)
|
|
56
|
+
- [diff](https://github.com/getsentry/sentry-java/compare/6.4.2...6.4.3)
|
|
57
|
+
|
|
3
58
|
## 5.0.0-alpha.5
|
|
4
59
|
|
|
5
60
|
### Fixes
|
package/RNSentry.podspec
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
require 'json'
|
|
2
2
|
version = JSON.parse(File.read('package.json'))["version"]
|
|
3
3
|
|
|
4
|
+
folly_version = '2021.07.22.00'
|
|
5
|
+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
6
|
+
|
|
4
7
|
Pod::Spec.new do |s|
|
|
5
8
|
s.name = 'RNSentry'
|
|
6
9
|
s.version = version
|
|
@@ -10,15 +13,30 @@ Pod::Spec.new do |s|
|
|
|
10
13
|
s.homepage = "https://github.com/getsentry/sentry-react-native"
|
|
11
14
|
s.source = { :git => 'https://github.com/getsentry/sentry-react-native.git', :tag => "#{s.version}"}
|
|
12
15
|
|
|
13
|
-
s.ios.deployment_target = "
|
|
16
|
+
s.ios.deployment_target = "12.4"
|
|
14
17
|
s.osx.deployment_target = "10.10"
|
|
15
|
-
s.tvos.deployment_target = "
|
|
18
|
+
s.tvos.deployment_target = "12.4"
|
|
16
19
|
|
|
17
20
|
s.preserve_paths = '*.js'
|
|
18
21
|
|
|
19
22
|
s.dependency 'React-Core'
|
|
20
23
|
s.dependency 'Sentry', '7.27.1'
|
|
21
24
|
|
|
22
|
-
s.source_files = 'ios/RNSentry.{h,
|
|
25
|
+
s.source_files = 'ios/RNSentry.{h,mm}'
|
|
23
26
|
s.public_header_files = 'ios/RNSentry.h'
|
|
27
|
+
|
|
28
|
+
# This guard prevent to install the dependencies when we run `pod install` in the old architecture.
|
|
29
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
30
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
31
|
+
s.pod_target_xcconfig = {
|
|
32
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
33
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
s.dependency "React-Codegen"
|
|
37
|
+
s.dependency "RCT-Folly", folly_version
|
|
38
|
+
s.dependency "RCTRequired"
|
|
39
|
+
s.dependency "RCTTypeSafety"
|
|
40
|
+
s.dependency "ReactCommon/turbomodule/core"
|
|
41
|
+
end
|
|
24
42
|
end
|
package/android/build.gradle
CHANGED
|
@@ -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',
|
|
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.
|
|
45
|
+
api 'io.sentry:sentry-android:6.5.0'
|
|
28
46
|
}
|
package/android/src/main/java/io/sentry/react/{RNSentryModule.java → RNSentryModuleImpl.java}
RENAMED
|
@@ -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
|
-
|
|
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
|
|
52
|
+
private final ReactApplicationContext reactApplicationContext;
|
|
53
|
+
private final PackageInfo packageInfo;
|
|
59
54
|
private FrameMetricsAggregator frameMetricsAggregator = null;
|
|
60
|
-
private boolean androidXAvailable
|
|
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
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
public RNSentryModuleImpl(ReactApplicationContext reactApplicationContext) {
|
|
65
|
+
packageInfo = getPackageInfo(reactApplicationContext);
|
|
66
|
+
this.reactApplicationContext = reactApplicationContext;
|
|
72
67
|
}
|
|
73
68
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return NAME;
|
|
69
|
+
private ReactApplicationContext getReactApplicationContext() {
|
|
70
|
+
return this.reactApplicationContext;
|
|
77
71
|
}
|
|
78
72
|
|
|
79
|
-
@
|
|
80
|
-
|
|
81
|
-
|
|
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
|
|
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()
|
|
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
|
|
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,7 +291,6 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
329
291
|
}
|
|
330
292
|
}
|
|
331
293
|
|
|
332
|
-
@ReactMethod
|
|
333
294
|
public void setUser(final ReadableMap user, final ReadableMap otherUserKeys) {
|
|
334
295
|
Sentry.configureScope(scope -> {
|
|
335
296
|
if (user == null && otherUserKeys == null) {
|
|
@@ -356,13 +317,16 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
356
317
|
}
|
|
357
318
|
|
|
358
319
|
if (otherUserKeys != null) {
|
|
359
|
-
HashMap<String, String> otherUserKeysMap = new HashMap
|
|
320
|
+
HashMap<String, String> otherUserKeysMap = new HashMap<>();
|
|
360
321
|
ReadableMapKeySetIterator it = otherUserKeys.keySetIterator();
|
|
361
322
|
while (it.hasNextKey()) {
|
|
362
323
|
String key = it.nextKey();
|
|
363
324
|
String value = otherUserKeys.getString(key);
|
|
364
325
|
|
|
365
|
-
|
|
326
|
+
// other is ConcurrentHashMap and can't have null values
|
|
327
|
+
if (value != null) {
|
|
328
|
+
otherUserKeysMap.put(key, value);
|
|
329
|
+
}
|
|
366
330
|
}
|
|
367
331
|
|
|
368
332
|
userInstance.setOthers(otherUserKeysMap);
|
|
@@ -373,7 +337,6 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
373
337
|
});
|
|
374
338
|
}
|
|
375
339
|
|
|
376
|
-
@ReactMethod
|
|
377
340
|
public void addBreadcrumb(final ReadableMap breadcrumb) {
|
|
378
341
|
Sentry.configureScope(scope -> {
|
|
379
342
|
Breadcrumb breadcrumbInstance = new Breadcrumb();
|
|
@@ -398,29 +361,27 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
398
361
|
case "warning":
|
|
399
362
|
breadcrumbInstance.setLevel(SentryLevel.WARNING);
|
|
400
363
|
break;
|
|
401
|
-
case "info":
|
|
402
|
-
breadcrumbInstance.setLevel(SentryLevel.INFO);
|
|
403
|
-
break;
|
|
404
364
|
case "debug":
|
|
405
365
|
breadcrumbInstance.setLevel(SentryLevel.DEBUG);
|
|
406
366
|
break;
|
|
407
367
|
case "error":
|
|
408
368
|
breadcrumbInstance.setLevel(SentryLevel.ERROR);
|
|
409
369
|
break;
|
|
370
|
+
case "info":
|
|
410
371
|
default:
|
|
411
|
-
breadcrumbInstance.setLevel(SentryLevel.
|
|
372
|
+
breadcrumbInstance.setLevel(SentryLevel.INFO);
|
|
412
373
|
break;
|
|
413
374
|
}
|
|
414
375
|
}
|
|
415
376
|
|
|
416
377
|
if (breadcrumb.hasKey("data")) {
|
|
417
|
-
ReadableMap data = breadcrumb.getMap("data");
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
378
|
+
final ReadableMap data = breadcrumb.getMap("data");
|
|
379
|
+
for (final Map.Entry<String, Object> entry : data.toHashMap().entrySet()) {
|
|
380
|
+
final Object value = entry.getValue();
|
|
381
|
+
// data is ConcurrentHashMap and can't have null values
|
|
382
|
+
if (value != null) {
|
|
383
|
+
breadcrumbInstance.setData(entry.getKey(), entry.getValue());
|
|
384
|
+
}
|
|
424
385
|
}
|
|
425
386
|
}
|
|
426
387
|
|
|
@@ -428,21 +389,18 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
428
389
|
});
|
|
429
390
|
}
|
|
430
391
|
|
|
431
|
-
@ReactMethod
|
|
432
392
|
public void clearBreadcrumbs() {
|
|
433
393
|
Sentry.configureScope(scope -> {
|
|
434
394
|
scope.clearBreadcrumbs();
|
|
435
395
|
});
|
|
436
396
|
}
|
|
437
397
|
|
|
438
|
-
@ReactMethod
|
|
439
398
|
public void setExtra(String key, String extra) {
|
|
440
399
|
Sentry.configureScope(scope -> {
|
|
441
400
|
scope.setExtra(key, extra);
|
|
442
401
|
});
|
|
443
402
|
}
|
|
444
403
|
|
|
445
|
-
@ReactMethod
|
|
446
404
|
public void setContext(final String key, final ReadableMap context) {
|
|
447
405
|
if (key == null || context == null) {
|
|
448
406
|
return;
|
|
@@ -454,14 +412,12 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
454
412
|
});
|
|
455
413
|
}
|
|
456
414
|
|
|
457
|
-
@ReactMethod
|
|
458
415
|
public void setTag(String key, String value) {
|
|
459
416
|
Sentry.configureScope(scope -> {
|
|
460
417
|
scope.setTag(key, value);
|
|
461
418
|
});
|
|
462
419
|
}
|
|
463
420
|
|
|
464
|
-
@ReactMethod
|
|
465
421
|
public void closeNativeSdk(Promise promise) {
|
|
466
422
|
Sentry.close();
|
|
467
423
|
|
|
@@ -470,7 +426,31 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
470
426
|
promise.resolve(true);
|
|
471
427
|
}
|
|
472
428
|
|
|
473
|
-
|
|
429
|
+
public void enableNativeFramesTracking() {
|
|
430
|
+
androidXAvailable = checkAndroidXAvailability();
|
|
431
|
+
|
|
432
|
+
if (androidXAvailable) {
|
|
433
|
+
frameMetricsAggregator = new FrameMetricsAggregator();
|
|
434
|
+
final Activity currentActivity = getCurrentActivity();
|
|
435
|
+
|
|
436
|
+
if (frameMetricsAggregator != null && currentActivity != null) {
|
|
437
|
+
try {
|
|
438
|
+
frameMetricsAggregator.add(currentActivity);
|
|
439
|
+
|
|
440
|
+
logger.info("FrameMetricsAggregator installed.");
|
|
441
|
+
} catch (Throwable ignored) {
|
|
442
|
+
// throws ConcurrentModification when calling addOnFrameMetricsAvailableListener
|
|
443
|
+
// this is a best effort since we can't reproduce it
|
|
444
|
+
logger.severe("Error adding Activity to frameMetricsAggregator.");
|
|
445
|
+
}
|
|
446
|
+
} else {
|
|
447
|
+
logger.info("currentActivity isn't available.");
|
|
448
|
+
}
|
|
449
|
+
} else {
|
|
450
|
+
logger.warning("androidx.core' isn't available as a dependency.");
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
474
454
|
public void disableNativeFramesTracking() {
|
|
475
455
|
if (isFrameMetricsAggregatorAvailable()) {
|
|
476
456
|
frameMetricsAggregator.stop();
|
|
@@ -485,10 +465,10 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
485
465
|
// If the event is from capacitor js, it gets set there and we do not handle it
|
|
486
466
|
// here.
|
|
487
467
|
case "sentry.native":
|
|
488
|
-
setEventEnvironmentTag(event, "
|
|
468
|
+
setEventEnvironmentTag(event, "native");
|
|
489
469
|
break;
|
|
490
470
|
case "sentry.java.android":
|
|
491
|
-
setEventEnvironmentTag(event, "
|
|
471
|
+
setEventEnvironmentTag(event, "java");
|
|
492
472
|
break;
|
|
493
473
|
default:
|
|
494
474
|
break;
|
|
@@ -496,8 +476,8 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
496
476
|
}
|
|
497
477
|
}
|
|
498
478
|
|
|
499
|
-
private void setEventEnvironmentTag(SentryEvent event, String
|
|
500
|
-
event.setTag("event.origin",
|
|
479
|
+
private void setEventEnvironmentTag(SentryEvent event, String environment) {
|
|
480
|
+
event.setTag("event.origin", "android");
|
|
501
481
|
event.setTag("event.environment", environment);
|
|
502
482
|
}
|
|
503
483
|
|
|
@@ -1,30 +1,46 @@
|
|
|
1
1
|
package io.sentry.react;
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import java.util.
|
|
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.
|
|
11
|
-
import com.facebook.react.
|
|
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
|
|
14
|
-
public RNSentryPackage() {
|
|
15
|
-
}
|
|
14
|
+
public class RNSentryPackage extends TurboReactPackage {
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
23
|
-
|
|
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
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
package io.sentry.react;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
6
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
7
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
8
|
+
import com.facebook.react.bridge.Promise;
|
|
9
|
+
|
|
10
|
+
public class RNSentryModule extends NativeRNSentrySpec {
|
|
11
|
+
|
|
12
|
+
private final RNSentryModuleImpl impl;
|
|
13
|
+
|
|
14
|
+
RNSentryModule(ReactApplicationContext reactContext) {
|
|
15
|
+
super(reactContext);
|
|
16
|
+
this.impl = new RNSentryModuleImpl(reactContext);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Override
|
|
20
|
+
@NonNull
|
|
21
|
+
public String getName() {
|
|
22
|
+
return RNSentryModuleImpl.NAME;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Override
|
|
26
|
+
public void initNativeSdk(final ReadableMap rnOptions, Promise promise) {
|
|
27
|
+
this.impl.initNativeSdk(rnOptions, promise);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Override
|
|
31
|
+
public void crash() {
|
|
32
|
+
this.impl.crash();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@Override
|
|
36
|
+
public void fetchNativeRelease(Promise promise) {
|
|
37
|
+
this.impl.fetchNativeRelease(promise);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@Override
|
|
41
|
+
public void fetchNativeAppStart(Promise promise) {
|
|
42
|
+
this.impl.fetchNativeAppStart(promise);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@Override
|
|
46
|
+
public void fetchNativeFrames(Promise promise) {
|
|
47
|
+
this.impl.fetchNativeFrames(promise);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@Override
|
|
51
|
+
public void captureEnvelope(ReadableArray rawBytes, ReadableMap options, Promise promise) {
|
|
52
|
+
this.impl.captureEnvelope(rawBytes, options, promise);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@Override
|
|
56
|
+
public void setUser(final ReadableMap user, final ReadableMap otherUserKeys) {
|
|
57
|
+
this.impl.setUser(user, otherUserKeys);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@Override
|
|
61
|
+
public void addBreadcrumb(final ReadableMap breadcrumb) {
|
|
62
|
+
this.impl.addBreadcrumb(breadcrumb);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@Override
|
|
66
|
+
public void clearBreadcrumbs() {
|
|
67
|
+
this.impl.clearBreadcrumbs();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@Override
|
|
71
|
+
public void setExtra(String key, String extra) {
|
|
72
|
+
this.impl.setExtra(key, extra);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@Override
|
|
76
|
+
public void setContext(final String key, final ReadableMap context) {
|
|
77
|
+
this.impl.setContext(key, context);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@Override
|
|
81
|
+
public void setTag(String key, String value) {
|
|
82
|
+
this.impl.setTag(key, value);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@Override
|
|
86
|
+
public void closeNativeSdk(Promise promise) {
|
|
87
|
+
this.impl.closeNativeSdk(promise);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@Override
|
|
91
|
+
public void enableNativeFramesTracking() {
|
|
92
|
+
this.impl.enableNativeFramesTracking();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@Override
|
|
96
|
+
public void disableNativeFramesTracking() {
|
|
97
|
+
this.impl.disableNativeFramesTracking();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@Override
|
|
101
|
+
public void fetchNativeDeviceContexts(Promise promise) {
|
|
102
|
+
// Not used on android
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@Override
|
|
106
|
+
public void fetchNativeSdkInfo(Promise promise) {
|
|
107
|
+
// Not used on android
|
|
108
|
+
}
|
|
109
|
+
}
|