@sentry/react-native 5.0.0-alpha.4 → 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 +97 -0
- package/RNSentry.podspec +22 -4
- package/android/build.gradle +20 -2
- package/android/src/main/java/io/sentry/react/{RNSentryModule.java → RNSentryModuleImpl.java} +67 -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/client.d.ts +12 -3
- package/dist/js/client.d.ts.map +1 -1
- package/dist/js/client.js +60 -7
- package/dist/js/client.js.map +1 -1
- package/dist/js/index.d.ts +2 -2
- package/dist/js/index.d.ts.map +1 -1
- package/dist/js/index.js +2 -2
- package/dist/js/index.js.map +1 -1
- 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 +21 -1
- package/dist/js/sdk.d.ts.map +1 -1
- package/dist/js/sdk.js +46 -4
- 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 +2 -2
- 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/utils/envelope.d.ts +2 -0
- package/dist/js/utils/envelope.d.ts.map +1 -1
- package/dist/js/utils/envelope.js +2 -1
- package/dist/js/utils/envelope.js.map +1 -1
- package/dist/js/utils/outcome.d.ts +6 -0
- package/dist/js/utils/outcome.d.ts.map +1 -0
- package/dist/js/utils/outcome.js +19 -0
- package/dist/js/utils/outcome.js.map +1 -0
- package/dist/js/utils/safe.d.ts +18 -0
- package/dist/js/utils/safe.d.ts.map +1 -0
- package/dist/js/utils/safe.js +46 -0
- package/dist/js/utils/safe.js.map +1 -0
- 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,102 @@
|
|
|
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
|
+
|
|
58
|
+
## 5.0.0-alpha.5
|
|
59
|
+
|
|
60
|
+
### Fixes
|
|
61
|
+
|
|
62
|
+
- Make `configureScope` callback safe [#2510](https://github.com/getsentry/sentry-react-native/pull/2510)
|
|
63
|
+
|
|
64
|
+
### Dependencies
|
|
65
|
+
|
|
66
|
+
- Bump JavaScript SDK from v7.14.0 to v7.14.1 ([#2511](https://github.com/getsentry/sentry-react-native/pull/2511))
|
|
67
|
+
- [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7141)
|
|
68
|
+
- [diff](https://github.com/getsentry/sentry-javascript/compare/7.14.0...7.14.1)
|
|
69
|
+
- Bump Cocoa SDK from v7.27.0 to v7.27.1 ([#2521](https://github.com/getsentry/sentry-react-native/pull/2521))
|
|
70
|
+
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7271)
|
|
71
|
+
- [diff](https://github.com/getsentry/sentry-cocoa/compare/7.27.0...7.27.1)
|
|
72
|
+
- Bump Android SDK from v6.4.2 to v6.4.3 ([#2520](https://github.com/getsentry/sentry-react-native/pull/2520))
|
|
73
|
+
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#643)
|
|
74
|
+
- [diff](https://github.com/getsentry/sentry-java/compare/6.4.2...6.4.3)
|
|
75
|
+
|
|
76
|
+
## 4.6.0
|
|
77
|
+
|
|
78
|
+
### Fixes
|
|
79
|
+
|
|
80
|
+
- SDK Gracefully downgrades when callback throws an error ([#2502](https://github.com/getsentry/sentry-react-native/pull/2502))
|
|
81
|
+
- React Navigation v5 ignores when current route is undefined after state changed. ([#2484](https://github.com/getsentry/sentry-react-native/pull/2484))
|
|
82
|
+
|
|
83
|
+
### Features
|
|
84
|
+
|
|
85
|
+
- Add ClientReports ([#2496](https://github.com/getsentry/sentry-react-native/pull/2496))
|
|
86
|
+
|
|
87
|
+
### Sentry Self-hosted Compatibility
|
|
88
|
+
|
|
89
|
+
- Starting with version `4.6.0` of the `@sentry/react-native` package, [Sentry's self hosted version >= v21.9.0](https://github.com/getsentry/self-hosted/releases) is required or you have to manually disable sending client reports via the `sendClientReports` option. This only applies to self-hosted Sentry. If you are using [sentry.io](https://sentry.io), no action is needed.
|
|
90
|
+
|
|
91
|
+
### Dependencies
|
|
92
|
+
|
|
93
|
+
- Bump Cocoa SDK from v7.25.1 to v7.27.0 ([#2500](https://github.com/getsentry/sentry-react-native/pull/2500), [#2506](https://github.com/getsentry/sentry-react-native/pull/2506))
|
|
94
|
+
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7270)
|
|
95
|
+
- [diff](https://github.com/getsentry/sentry-cocoa/compare/7.25.1...7.27.0)
|
|
96
|
+
- Bump JavaScript SDK from v7.13.0 to v7.14.0 ([#2504](https://github.com/getsentry/sentry-react-native/pull/2504))
|
|
97
|
+
- [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7140)
|
|
98
|
+
- [diff](https://github.com/getsentry/sentry-javascript/compare/7.13.0...7.14.0)
|
|
99
|
+
|
|
3
100
|
## 5.0.0-alpha.4
|
|
4
101
|
|
|
5
102
|
- Latest changes from 4.5.0
|
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
|
-
s.dependency 'Sentry', '7.
|
|
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")) {
|
|
@@ -99,6 +89,9 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
99
89
|
// SentryAndroid needs an empty string fallback for the dsn.
|
|
100
90
|
options.setDsn("");
|
|
101
91
|
}
|
|
92
|
+
if (rnOptions.hasKey("sendClientReports")) {
|
|
93
|
+
options.setSendClientReports(rnOptions.getBoolean("sendClientReports"));
|
|
94
|
+
}
|
|
102
95
|
if (rnOptions.hasKey("maxBreadcrumbs")) {
|
|
103
96
|
options.setMaxBreadcrumbs(rnOptions.getInt("maxBreadcrumbs"));
|
|
104
97
|
}
|
|
@@ -130,36 +123,13 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
130
123
|
options.setAttachStacktrace(rnOptions.getBoolean("attachStacktrace"));
|
|
131
124
|
}
|
|
132
125
|
if (rnOptions.hasKey("attachThreads")) {
|
|
133
|
-
// JS use top level
|
|
126
|
+
// JS use top level stacktrace and android attaches Threads which hides them so
|
|
134
127
|
// by default we hide.
|
|
135
128
|
options.setAttachThreads(rnOptions.getBoolean("attachThreads"));
|
|
136
129
|
}
|
|
137
130
|
if (rnOptions.hasKey("sendDefaultPii")) {
|
|
138
131
|
options.setSendDefaultPii(rnOptions.getBoolean("sendDefaultPii"));
|
|
139
132
|
}
|
|
140
|
-
if (rnOptions.hasKey("enableAutoPerformanceTracking")
|
|
141
|
-
&& rnOptions.getBoolean("enableAutoPerformanceTracking")) {
|
|
142
|
-
androidXAvailable = checkAndroidXAvailability();
|
|
143
|
-
|
|
144
|
-
if (androidXAvailable) {
|
|
145
|
-
frameMetricsAggregator = new FrameMetricsAggregator();
|
|
146
|
-
final Activity currentActivity = getCurrentActivity();
|
|
147
|
-
|
|
148
|
-
if (frameMetricsAggregator != null && currentActivity != null) {
|
|
149
|
-
try {
|
|
150
|
-
frameMetricsAggregator.add(currentActivity);
|
|
151
|
-
} catch (Throwable ignored) {
|
|
152
|
-
// throws ConcurrentModification when calling addOnFrameMetricsAvailableListener
|
|
153
|
-
// this is a best effort since we can't reproduce it
|
|
154
|
-
logger.warning("Error adding Activity to frameMetricsAggregator.");
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
} else {
|
|
158
|
-
logger.warning("androidx.core' isn't available as a dependency.");
|
|
159
|
-
}
|
|
160
|
-
} else {
|
|
161
|
-
this.disableNativeFramesTracking();
|
|
162
|
-
}
|
|
163
133
|
|
|
164
134
|
options.setBeforeSend((event, hint) -> {
|
|
165
135
|
// React native internally throws a JavascriptException
|
|
@@ -190,18 +160,16 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
190
160
|
}
|
|
191
161
|
}
|
|
192
162
|
|
|
193
|
-
logger.info(String.format("Native Integrations '%s'", options.getIntegrations()
|
|
163
|
+
logger.info(String.format("Native Integrations '%s'", options.getIntegrations()));
|
|
194
164
|
});
|
|
195
165
|
|
|
196
166
|
promise.resolve(true);
|
|
197
167
|
}
|
|
198
168
|
|
|
199
|
-
@ReactMethod
|
|
200
169
|
public void crash() {
|
|
201
170
|
throw new RuntimeException("TEST - Sentry Client Crash (only works in release mode)");
|
|
202
171
|
}
|
|
203
172
|
|
|
204
|
-
@ReactMethod
|
|
205
173
|
public void fetchNativeRelease(Promise promise) {
|
|
206
174
|
WritableMap release = Arguments.createMap();
|
|
207
175
|
release.putString("id", packageInfo.packageName);
|
|
@@ -210,7 +178,6 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
210
178
|
promise.resolve(release);
|
|
211
179
|
}
|
|
212
180
|
|
|
213
|
-
@ReactMethod
|
|
214
181
|
public void fetchNativeAppStart(Promise promise) {
|
|
215
182
|
final AppStartState appStartInstance = AppStartState.getInstance();
|
|
216
183
|
final Date appStartTime = appStartInstance.getAppStartTime();
|
|
@@ -242,7 +209,6 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
242
209
|
/**
|
|
243
210
|
* Returns frames metrics at the current point in time.
|
|
244
211
|
*/
|
|
245
|
-
@ReactMethod
|
|
246
212
|
public void fetchNativeFrames(Promise promise) {
|
|
247
213
|
if (!isFrameMetricsAggregatorAvailable()) {
|
|
248
214
|
promise.resolve(null);
|
|
@@ -292,9 +258,8 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
292
258
|
}
|
|
293
259
|
}
|
|
294
260
|
|
|
295
|
-
@ReactMethod
|
|
296
261
|
public void captureEnvelope(ReadableArray rawBytes, ReadableMap options, Promise promise) {
|
|
297
|
-
byte
|
|
262
|
+
byte[] bytes = new byte[rawBytes.size()];
|
|
298
263
|
for (int i = 0; i < rawBytes.size(); i++) {
|
|
299
264
|
bytes[i] = (byte) rawBytes.getInt(i);
|
|
300
265
|
}
|
|
@@ -326,7 +291,6 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
326
291
|
}
|
|
327
292
|
}
|
|
328
293
|
|
|
329
|
-
@ReactMethod
|
|
330
294
|
public void setUser(final ReadableMap user, final ReadableMap otherUserKeys) {
|
|
331
295
|
Sentry.configureScope(scope -> {
|
|
332
296
|
if (user == null && otherUserKeys == null) {
|
|
@@ -353,13 +317,16 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
353
317
|
}
|
|
354
318
|
|
|
355
319
|
if (otherUserKeys != null) {
|
|
356
|
-
HashMap<String, String> otherUserKeysMap = new HashMap
|
|
320
|
+
HashMap<String, String> otherUserKeysMap = new HashMap<>();
|
|
357
321
|
ReadableMapKeySetIterator it = otherUserKeys.keySetIterator();
|
|
358
322
|
while (it.hasNextKey()) {
|
|
359
323
|
String key = it.nextKey();
|
|
360
324
|
String value = otherUserKeys.getString(key);
|
|
361
325
|
|
|
362
|
-
|
|
326
|
+
// other is ConcurrentHashMap and can't have null values
|
|
327
|
+
if (value != null) {
|
|
328
|
+
otherUserKeysMap.put(key, value);
|
|
329
|
+
}
|
|
363
330
|
}
|
|
364
331
|
|
|
365
332
|
userInstance.setOthers(otherUserKeysMap);
|
|
@@ -370,7 +337,6 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
370
337
|
});
|
|
371
338
|
}
|
|
372
339
|
|
|
373
|
-
@ReactMethod
|
|
374
340
|
public void addBreadcrumb(final ReadableMap breadcrumb) {
|
|
375
341
|
Sentry.configureScope(scope -> {
|
|
376
342
|
Breadcrumb breadcrumbInstance = new Breadcrumb();
|
|
@@ -395,29 +361,27 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
395
361
|
case "warning":
|
|
396
362
|
breadcrumbInstance.setLevel(SentryLevel.WARNING);
|
|
397
363
|
break;
|
|
398
|
-
case "info":
|
|
399
|
-
breadcrumbInstance.setLevel(SentryLevel.INFO);
|
|
400
|
-
break;
|
|
401
364
|
case "debug":
|
|
402
365
|
breadcrumbInstance.setLevel(SentryLevel.DEBUG);
|
|
403
366
|
break;
|
|
404
367
|
case "error":
|
|
405
368
|
breadcrumbInstance.setLevel(SentryLevel.ERROR);
|
|
406
369
|
break;
|
|
370
|
+
case "info":
|
|
407
371
|
default:
|
|
408
|
-
breadcrumbInstance.setLevel(SentryLevel.
|
|
372
|
+
breadcrumbInstance.setLevel(SentryLevel.INFO);
|
|
409
373
|
break;
|
|
410
374
|
}
|
|
411
375
|
}
|
|
412
376
|
|
|
413
377
|
if (breadcrumb.hasKey("data")) {
|
|
414
|
-
ReadableMap data = breadcrumb.getMap("data");
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
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
|
+
}
|
|
421
385
|
}
|
|
422
386
|
}
|
|
423
387
|
|
|
@@ -425,21 +389,18 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
425
389
|
});
|
|
426
390
|
}
|
|
427
391
|
|
|
428
|
-
@ReactMethod
|
|
429
392
|
public void clearBreadcrumbs() {
|
|
430
393
|
Sentry.configureScope(scope -> {
|
|
431
394
|
scope.clearBreadcrumbs();
|
|
432
395
|
});
|
|
433
396
|
}
|
|
434
397
|
|
|
435
|
-
@ReactMethod
|
|
436
398
|
public void setExtra(String key, String extra) {
|
|
437
399
|
Sentry.configureScope(scope -> {
|
|
438
400
|
scope.setExtra(key, extra);
|
|
439
401
|
});
|
|
440
402
|
}
|
|
441
403
|
|
|
442
|
-
@ReactMethod
|
|
443
404
|
public void setContext(final String key, final ReadableMap context) {
|
|
444
405
|
if (key == null || context == null) {
|
|
445
406
|
return;
|
|
@@ -451,14 +412,12 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
451
412
|
});
|
|
452
413
|
}
|
|
453
414
|
|
|
454
|
-
@ReactMethod
|
|
455
415
|
public void setTag(String key, String value) {
|
|
456
416
|
Sentry.configureScope(scope -> {
|
|
457
417
|
scope.setTag(key, value);
|
|
458
418
|
});
|
|
459
419
|
}
|
|
460
420
|
|
|
461
|
-
@ReactMethod
|
|
462
421
|
public void closeNativeSdk(Promise promise) {
|
|
463
422
|
Sentry.close();
|
|
464
423
|
|
|
@@ -467,7 +426,31 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
467
426
|
promise.resolve(true);
|
|
468
427
|
}
|
|
469
428
|
|
|
470
|
-
|
|
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
|
+
|
|
471
454
|
public void disableNativeFramesTracking() {
|
|
472
455
|
if (isFrameMetricsAggregatorAvailable()) {
|
|
473
456
|
frameMetricsAggregator.stop();
|
|
@@ -482,10 +465,10 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
482
465
|
// If the event is from capacitor js, it gets set there and we do not handle it
|
|
483
466
|
// here.
|
|
484
467
|
case "sentry.native":
|
|
485
|
-
setEventEnvironmentTag(event, "
|
|
468
|
+
setEventEnvironmentTag(event, "native");
|
|
486
469
|
break;
|
|
487
470
|
case "sentry.java.android":
|
|
488
|
-
setEventEnvironmentTag(event, "
|
|
471
|
+
setEventEnvironmentTag(event, "java");
|
|
489
472
|
break;
|
|
490
473
|
default:
|
|
491
474
|
break;
|
|
@@ -493,8 +476,8 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
493
476
|
}
|
|
494
477
|
}
|
|
495
478
|
|
|
496
|
-
private void setEventEnvironmentTag(SentryEvent event, String
|
|
497
|
-
event.setTag("event.origin",
|
|
479
|
+
private void setEventEnvironmentTag(SentryEvent event, String environment) {
|
|
480
|
+
event.setTag("event.origin", "android");
|
|
498
481
|
event.setTag("event.environment", environment);
|
|
499
482
|
}
|
|
500
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
|
}
|