@sentry/react-native 6.7.0-alpha.0 → 6.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RNSentry.podspec +1 -1
- package/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +280 -2
- package/android/src/main/java/io/sentry/react/RNSentryVersion.java +1 -1
- package/dist/js/sdk.d.ts.map +1 -1
- package/dist/js/sdk.js +10 -21
- package/dist/js/sdk.js.map +1 -1
- package/dist/js/tools/metroconfig.d.ts +7 -11
- package/dist/js/tools/metroconfig.d.ts.map +1 -1
- package/dist/js/tools/metroconfig.js +10 -12
- package/dist/js/tools/metroconfig.js.map +1 -1
- package/dist/js/tools/sentryBabelTransformer.d.ts +1 -2
- package/dist/js/tools/sentryBabelTransformer.d.ts.map +1 -1
- package/dist/js/tools/sentryBabelTransformer.js +1 -23
- package/dist/js/tools/sentryBabelTransformer.js.map +1 -1
- package/dist/js/tools/sentryBabelTransformerUtils.d.ts +18 -0
- package/dist/js/tools/sentryBabelTransformerUtils.d.ts.map +1 -1
- package/dist/js/tools/sentryBabelTransformerUtils.js +71 -1
- package/dist/js/tools/sentryBabelTransformerUtils.js.map +1 -1
- package/dist/js/tools/sentryMetroSerializer.d.ts.map +1 -1
- package/dist/js/tools/sentryMetroSerializer.js +0 -1
- package/dist/js/tools/sentryMetroSerializer.js.map +1 -1
- package/dist/js/tools/utils.d.ts +1 -2
- package/dist/js/tools/utils.d.ts.map +1 -1
- package/dist/js/tools/utils.js.map +1 -1
- package/dist/js/utils/worldwide.d.ts +0 -2
- package/dist/js/utils/worldwide.d.ts.map +1 -1
- package/dist/js/utils/worldwide.js.map +1 -1
- package/dist/js/version.d.ts +1 -1
- package/dist/js/version.d.ts.map +1 -1
- package/dist/js/version.js +1 -1
- package/dist/js/version.js.map +1 -1
- package/ios/RNSentry.h +5 -3
- package/ios/RNSentry.mm +169 -2
- package/ios/RNSentryVersion.m +1 -1
- package/package.json +6 -6
- package/scripts/sentry-xcode.sh +0 -19
- package/sentry.gradle +1 -52
- package/ts3.8/dist/js/utils/worldwide.d.ts +0 -2
- package/ts3.8/dist/js/version.d.ts +1 -1
- package/android/src/main/java/io/sentry/react/RNSentryCompositeOptionsConfiguration.java +0 -25
- package/android/src/main/java/io/sentry/react/RNSentryJsonConverter.java +0 -76
- package/android/src/main/java/io/sentry/react/RNSentryJsonUtils.java +0 -41
- package/android/src/main/java/io/sentry/react/RNSentrySDK.java +0 -68
- package/android/src/main/java/io/sentry/react/RNSentryStart.java +0 -365
- package/dist/js/tools/sentryOptionsSerializer.d.ts +0 -6
- package/dist/js/tools/sentryOptionsSerializer.d.ts.map +0 -1
- package/dist/js/tools/sentryOptionsSerializer.js +0 -91
- package/dist/js/tools/sentryOptionsSerializer.js.map +0 -1
- package/ios/RNSentrySDK.h +0 -31
- package/ios/RNSentrySDK.m +0 -71
- package/ios/RNSentryStart.h +0 -26
- package/ios/RNSentryStart.m +0 -222
package/ios/RNSentry.mm
CHANGED
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
# import "RNSentryRNSScreen.h"
|
|
50
50
|
#endif
|
|
51
51
|
|
|
52
|
-
#import "RNSentryStart.h"
|
|
53
52
|
#import "RNSentryVersion.h"
|
|
54
53
|
|
|
55
54
|
@interface
|
|
@@ -64,6 +63,7 @@ SentrySDK (RNSentry)
|
|
|
64
63
|
static bool hasFetchedAppStart;
|
|
65
64
|
|
|
66
65
|
@implementation RNSentry {
|
|
66
|
+
bool sentHybridSdkDidBecomeActive;
|
|
67
67
|
bool hasListeners;
|
|
68
68
|
RNSentryTimeToDisplay *_timeToDisplay;
|
|
69
69
|
}
|
|
@@ -94,14 +94,181 @@ RCT_EXPORT_METHOD(initNativeSdk
|
|
|
94
94
|
: (RCTPromiseRejectBlock)reject)
|
|
95
95
|
{
|
|
96
96
|
NSError *error = nil;
|
|
97
|
-
[
|
|
97
|
+
SentryOptions *sentryOptions = [self createOptionsWithDictionary:options error:&error];
|
|
98
98
|
if (error != nil) {
|
|
99
99
|
reject(@"SentryReactNative", error.localizedDescription, error);
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
|
+
|
|
103
|
+
NSString *sdkVersion = [PrivateSentrySDKOnly getSdkVersionString];
|
|
104
|
+
[PrivateSentrySDKOnly setSdkName:NATIVE_SDK_NAME andVersionString:sdkVersion];
|
|
105
|
+
[PrivateSentrySDKOnly addSdkPackage:REACT_NATIVE_SDK_PACKAGE_NAME
|
|
106
|
+
version:REACT_NATIVE_SDK_PACKAGE_VERSION];
|
|
107
|
+
|
|
108
|
+
[SentrySDK startWithOptions:sentryOptions];
|
|
109
|
+
|
|
110
|
+
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
|
|
111
|
+
BOOL appIsActive =
|
|
112
|
+
[[UIApplication sharedApplication] applicationState] == UIApplicationStateActive;
|
|
113
|
+
#else
|
|
114
|
+
BOOL appIsActive = [[NSApplication sharedApplication] isActive];
|
|
115
|
+
#endif
|
|
116
|
+
|
|
117
|
+
// If the app is active/in foreground, and we have not sent the SentryHybridSdkDidBecomeActive
|
|
118
|
+
// notification, send it.
|
|
119
|
+
if (appIsActive && !sentHybridSdkDidBecomeActive
|
|
120
|
+
&& (PrivateSentrySDKOnly.options.enableAutoSessionTracking
|
|
121
|
+
|| PrivateSentrySDKOnly.options.enableWatchdogTerminationTracking)) {
|
|
122
|
+
[[NSNotificationCenter defaultCenter] postNotificationName:@"SentryHybridSdkDidBecomeActive"
|
|
123
|
+
object:nil];
|
|
124
|
+
|
|
125
|
+
sentHybridSdkDidBecomeActive = true;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
#if SENTRY_TARGET_REPLAY_SUPPORTED
|
|
129
|
+
[RNSentryReplay postInit];
|
|
130
|
+
#endif
|
|
131
|
+
|
|
102
132
|
resolve(@YES);
|
|
103
133
|
}
|
|
104
134
|
|
|
135
|
+
- (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull)options
|
|
136
|
+
error:(NSError *_Nonnull *_Nonnull)errorPointer
|
|
137
|
+
{
|
|
138
|
+
SentryBeforeSendEventCallback beforeSend = ^SentryEvent *(SentryEvent *event)
|
|
139
|
+
{
|
|
140
|
+
// We don't want to send an event after startup that came from a Unhandled JS Exception of
|
|
141
|
+
// react native Because we sent it already before the app crashed.
|
|
142
|
+
if (nil != event.exceptions.firstObject.type &&
|
|
143
|
+
[event.exceptions.firstObject.type rangeOfString:@"Unhandled JS Exception"].location
|
|
144
|
+
!= NSNotFound) {
|
|
145
|
+
return nil;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
[self setEventOriginTag:event];
|
|
149
|
+
|
|
150
|
+
return event;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
NSMutableDictionary *mutableOptions = [options mutableCopy];
|
|
154
|
+
[mutableOptions setValue:beforeSend forKey:@"beforeSend"];
|
|
155
|
+
|
|
156
|
+
// remove performance traces sample rate and traces sampler since we don't want to synchronize
|
|
157
|
+
// these configurations to the Native SDKs. The user could tho initialize the SDK manually and
|
|
158
|
+
// set themselves.
|
|
159
|
+
[mutableOptions removeObjectForKey:@"tracesSampleRate"];
|
|
160
|
+
[mutableOptions removeObjectForKey:@"tracesSampler"];
|
|
161
|
+
[mutableOptions removeObjectForKey:@"enableTracing"];
|
|
162
|
+
|
|
163
|
+
#if SENTRY_TARGET_REPLAY_SUPPORTED
|
|
164
|
+
[RNSentryReplay updateOptions:mutableOptions];
|
|
165
|
+
#endif
|
|
166
|
+
|
|
167
|
+
SentryOptions *sentryOptions = [[SentryOptions alloc] initWithDict:mutableOptions
|
|
168
|
+
didFailWithError:errorPointer];
|
|
169
|
+
if (*errorPointer != nil) {
|
|
170
|
+
return nil;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Exclude Dev Server and Sentry Dsn request from Breadcrumbs
|
|
174
|
+
NSString *dsn = [self getURLFromDSN:[mutableOptions valueForKey:@"dsn"]];
|
|
175
|
+
NSString *devServerUrl = [mutableOptions valueForKey:@"devServerUrl"];
|
|
176
|
+
sentryOptions.beforeBreadcrumb
|
|
177
|
+
= ^SentryBreadcrumb *_Nullable(SentryBreadcrumb *_Nonnull breadcrumb)
|
|
178
|
+
{
|
|
179
|
+
NSString *url = breadcrumb.data[@"url"] ?: @"";
|
|
180
|
+
|
|
181
|
+
if ([@"http" isEqualToString:breadcrumb.type]
|
|
182
|
+
&& ((dsn != nil && [url hasPrefix:dsn])
|
|
183
|
+
|| (devServerUrl != nil && [url hasPrefix:devServerUrl]))) {
|
|
184
|
+
return nil;
|
|
185
|
+
}
|
|
186
|
+
return breadcrumb;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
if ([mutableOptions valueForKey:@"enableNativeCrashHandling"] != nil) {
|
|
190
|
+
BOOL enableNativeCrashHandling = [mutableOptions[@"enableNativeCrashHandling"] boolValue];
|
|
191
|
+
|
|
192
|
+
if (!enableNativeCrashHandling) {
|
|
193
|
+
NSMutableArray *integrations = sentryOptions.integrations.mutableCopy;
|
|
194
|
+
[integrations removeObject:@"SentryCrashIntegration"];
|
|
195
|
+
sentryOptions.integrations = integrations;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Set spotlight option
|
|
200
|
+
if ([mutableOptions valueForKey:@"spotlight"] != nil) {
|
|
201
|
+
id spotlightValue = [mutableOptions valueForKey:@"spotlight"];
|
|
202
|
+
if ([spotlightValue isKindOfClass:[NSString class]]) {
|
|
203
|
+
NSLog(@"Using Spotlight on address: %@", spotlightValue);
|
|
204
|
+
sentryOptions.enableSpotlight = true;
|
|
205
|
+
sentryOptions.spotlightUrl = spotlightValue;
|
|
206
|
+
} else if ([spotlightValue isKindOfClass:[NSNumber class]]) {
|
|
207
|
+
sentryOptions.enableSpotlight = [spotlightValue boolValue];
|
|
208
|
+
id defaultSpotlightUrl = [mutableOptions valueForKey:@"defaultSidecarUrl"];
|
|
209
|
+
if (defaultSpotlightUrl != nil) {
|
|
210
|
+
sentryOptions.spotlightUrl = defaultSpotlightUrl;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Enable the App start and Frames tracking measurements
|
|
216
|
+
if ([mutableOptions valueForKey:@"enableAutoPerformanceTracing"] != nil) {
|
|
217
|
+
BOOL enableAutoPerformanceTracing =
|
|
218
|
+
[mutableOptions[@"enableAutoPerformanceTracing"] boolValue];
|
|
219
|
+
PrivateSentrySDKOnly.appStartMeasurementHybridSDKMode = enableAutoPerformanceTracing;
|
|
220
|
+
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
|
|
221
|
+
PrivateSentrySDKOnly.framesTrackingMeasurementHybridSDKMode = enableAutoPerformanceTracing;
|
|
222
|
+
#endif
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Failed requests can only be enabled in one SDK to avoid duplicates
|
|
226
|
+
sentryOptions.enableCaptureFailedRequests = NO;
|
|
227
|
+
|
|
228
|
+
return sentryOptions;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
- (NSString *_Nullable)getURLFromDSN:(NSString *)dsn
|
|
232
|
+
{
|
|
233
|
+
NSURL *url = [NSURL URLWithString:dsn];
|
|
234
|
+
if (!url) {
|
|
235
|
+
return nil;
|
|
236
|
+
}
|
|
237
|
+
return [NSString stringWithFormat:@"%@://%@", url.scheme, url.host];
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
- (void)setEventOriginTag:(SentryEvent *)event
|
|
241
|
+
{
|
|
242
|
+
if (event.sdk != nil) {
|
|
243
|
+
NSString *sdkName = event.sdk[@"name"];
|
|
244
|
+
|
|
245
|
+
// If the event is from react native, it gets set
|
|
246
|
+
// there and we do not handle it here.
|
|
247
|
+
if ([sdkName isEqual:NATIVE_SDK_NAME]) {
|
|
248
|
+
[self setEventEnvironmentTag:event origin:@"ios" environment:@"native"];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
- (void)setEventEnvironmentTag:(SentryEvent *)event
|
|
254
|
+
origin:(NSString *)origin
|
|
255
|
+
environment:(NSString *)environment
|
|
256
|
+
{
|
|
257
|
+
NSMutableDictionary *newTags = [NSMutableDictionary new];
|
|
258
|
+
|
|
259
|
+
if (nil != event.tags && [event.tags count] > 0) {
|
|
260
|
+
[newTags addEntriesFromDictionary:event.tags];
|
|
261
|
+
}
|
|
262
|
+
if (nil != origin) {
|
|
263
|
+
[newTags setValue:origin forKey:@"event.origin"];
|
|
264
|
+
}
|
|
265
|
+
if (nil != environment) {
|
|
266
|
+
[newTags setValue:environment forKey:@"event.environment"];
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
event.tags = newTags;
|
|
270
|
+
}
|
|
271
|
+
|
|
105
272
|
RCT_EXPORT_METHOD(initNativeReactNavigationNewFrameTracking
|
|
106
273
|
: (RCTPromiseResolveBlock)resolve rejecter
|
|
107
274
|
: (RCTPromiseRejectBlock)reject)
|
package/ios/RNSentryVersion.m
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
NSString *const NATIVE_SDK_NAME = @"sentry.cocoa.react-native";
|
|
4
4
|
NSString *const REACT_NATIVE_SDK_NAME = @"sentry.javascript.react-native";
|
|
5
5
|
NSString *const REACT_NATIVE_SDK_PACKAGE_NAME = @"npm:@sentry/react-native";
|
|
6
|
-
NSString *const REACT_NATIVE_SDK_PACKAGE_VERSION = @"6.7.0
|
|
6
|
+
NSString *const REACT_NATIVE_SDK_PACKAGE_VERSION = @"6.7.0";
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@sentry/react-native",
|
|
3
3
|
"homepage": "https://github.com/getsentry/sentry-react-native",
|
|
4
4
|
"repository": "https://github.com/getsentry/sentry-react-native",
|
|
5
|
-
"version": "6.7.0
|
|
5
|
+
"version": "6.7.0",
|
|
6
6
|
"description": "Official Sentry SDK for react-native",
|
|
7
7
|
"typings": "dist/js/index.d.ts",
|
|
8
8
|
"types": "dist/js/index.d.ts",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"react-native": ">=0.65.0"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@sentry/babel-plugin-component-annotate": "
|
|
68
|
+
"@sentry/babel-plugin-component-annotate": "3.1.2",
|
|
69
69
|
"@sentry/browser": "8.54.0",
|
|
70
70
|
"@sentry/cli": "2.41.1",
|
|
71
71
|
"@sentry/core": "8.54.0",
|
|
@@ -77,13 +77,13 @@
|
|
|
77
77
|
"@babel/core": "^7.25.2",
|
|
78
78
|
"@expo/metro-config": "0.19.5",
|
|
79
79
|
"@mswjs/interceptors": "^0.25.15",
|
|
80
|
-
"@react-native/babel-preset": "0.
|
|
80
|
+
"@react-native/babel-preset": "0.77.0",
|
|
81
81
|
"@sentry-internal/eslint-config-sdk": "8.54.0",
|
|
82
82
|
"@sentry-internal/eslint-plugin-sdk": "8.54.0",
|
|
83
83
|
"@sentry-internal/typescript": "8.54.0",
|
|
84
84
|
"@sentry/wizard": "3.40.0",
|
|
85
85
|
"@testing-library/react-native": "^12.7.2",
|
|
86
|
-
"@types/jest": "^29.5.
|
|
86
|
+
"@types/jest": "^29.5.13",
|
|
87
87
|
"@types/node": "^20.9.3",
|
|
88
88
|
"@types/react": "^18.2.64",
|
|
89
89
|
"@types/uglify-js": "^3.17.2",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"@types/xmlhttprequest": "^1.8.2",
|
|
92
92
|
"@typescript-eslint/eslint-plugin": "^5.48.0",
|
|
93
93
|
"@typescript-eslint/parser": "^5.48.0",
|
|
94
|
-
"babel-jest": "^29.6.
|
|
94
|
+
"babel-jest": "^29.6.3",
|
|
95
95
|
"babel-plugin-module-resolver": "^5.0.0",
|
|
96
96
|
"babel-preset-fbjs": "^3.4.0",
|
|
97
97
|
"downlevel-dts": "^0.11.0",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"metro": "0.81.0",
|
|
108
108
|
"prettier": "^2.0.5",
|
|
109
109
|
"react": "18.3.1",
|
|
110
|
-
"react-native": "0.
|
|
110
|
+
"react-native": "0.77.0",
|
|
111
111
|
"react-test-renderer": "^18.3.1",
|
|
112
112
|
"rimraf": "^4.1.1",
|
|
113
113
|
"ts-jest": "^29.1.1",
|
package/scripts/sentry-xcode.sh
CHANGED
|
@@ -51,22 +51,3 @@ fi
|
|
|
51
51
|
if [ -f "$SENTRY_COLLECT_MODULES" ]; then
|
|
52
52
|
/bin/sh "$SENTRY_COLLECT_MODULES"
|
|
53
53
|
fi
|
|
54
|
-
|
|
55
|
-
SENTRY_OPTIONS_FILE_ERROR_MESSAGE_POSTFIX="Skipping options file copy. To disable this behavior, set SENTRY_COPY_OPTIONS_FILE=false in your environment variables."
|
|
56
|
-
SENTRY_OPTIONS_FILE_NAME="sentry.options.json"
|
|
57
|
-
SENTRY_OPTIONS_FILE_DESTINATION_PATH="$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/$SENTRY_OPTIONS_FILE_NAME"
|
|
58
|
-
[ -z "$SENTRY_OPTIONS_FILE_PATH" ] && SENTRY_OPTIONS_FILE_PATH="$RN_PROJECT_ROOT/$SENTRY_OPTIONS_FILE_NAME"
|
|
59
|
-
[ -z "$SENTRY_COPY_OPTIONS_FILE" ] && SENTRY_COPY_OPTIONS_FILE=true
|
|
60
|
-
|
|
61
|
-
if [ "$SENTRY_COPY_OPTIONS_FILE" = true ]; then
|
|
62
|
-
if [[ -z "$CONFIGURATION_BUILD_DIR" ]]; then
|
|
63
|
-
echo "[Sentry] CONFIGURATION_BUILD_DIR is not set. $SENTRY_OPTIONS_FILE_ERROR_MESSAGE_POSTFIX" 1>&2
|
|
64
|
-
elif [[ -z "$UNLOCALIZED_RESOURCES_FOLDER_PATH" ]]; then
|
|
65
|
-
echo "[Sentry] UNLOCALIZED_RESOURCES_FOLDER_PATH is not set. $SENTRY_OPTIONS_FILE_ERROR_MESSAGE_POSTFIX" 1>&2
|
|
66
|
-
elif [ ! -f "$SENTRY_OPTIONS_FILE_PATH" ]; then
|
|
67
|
-
echo "[Sentry] $SENTRY_OPTIONS_FILE_PATH not found. $SENTRY_OPTIONS_FILE_ERROR_MESSAGE_POSTFIX" 1>&2
|
|
68
|
-
else
|
|
69
|
-
cp "$SENTRY_OPTIONS_FILE_PATH" "$SENTRY_OPTIONS_FILE_DESTINATION_PATH"
|
|
70
|
-
echo "[Sentry] Copied $SENTRY_OPTIONS_FILE_PATH to $SENTRY_OPTIONS_FILE_DESTINATION_PATH"
|
|
71
|
-
fi
|
|
72
|
-
fi
|
package/sentry.gradle
CHANGED
|
@@ -3,7 +3,7 @@ import org.apache.tools.ant.taskdefs.condition.Os
|
|
|
3
3
|
import java.util.regex.Matcher
|
|
4
4
|
import java.util.regex.Pattern
|
|
5
5
|
|
|
6
|
-
project.ext.shouldSentryAutoUploadNative = { ->
|
|
6
|
+
project.ext.shouldSentryAutoUploadNative = { ->
|
|
7
7
|
return System.getenv('SENTRY_DISABLE_NATIVE_DEBUG_UPLOAD') != 'true'
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -15,60 +15,9 @@ project.ext.shouldSentryAutoUpload = { ->
|
|
|
15
15
|
return shouldSentryAutoUploadGeneral() && shouldSentryAutoUploadNative()
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
project.ext.shouldCopySentryOptionsFile = { -> // If not set, default to true
|
|
19
|
-
return System.getenv('SENTRY_COPY_OPTIONS_FILE') != 'false'
|
|
20
|
-
}
|
|
21
|
-
|
|
22
18
|
def config = project.hasProperty("sentryCli") ? project.sentryCli : [];
|
|
23
19
|
|
|
24
|
-
def configFile = "sentry.options.json" // Sentry condiguration file
|
|
25
|
-
def androidAssetsDir = new File("$rootDir/app/src/main/assets") // Path to Android assets folder
|
|
26
|
-
|
|
27
|
-
tasks.register("copySentryJsonConfiguration") {
|
|
28
|
-
onlyIf { shouldCopySentryOptionsFile() }
|
|
29
|
-
doLast {
|
|
30
|
-
def appRoot = project.rootDir.parentFile ?: project.rootDir
|
|
31
|
-
def sentryOptionsFile = new File(appRoot, configFile)
|
|
32
|
-
if (sentryOptionsFile.exists()) {
|
|
33
|
-
if (!androidAssetsDir.exists()) {
|
|
34
|
-
androidAssetsDir.mkdirs()
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
copy {
|
|
38
|
-
from sentryOptionsFile
|
|
39
|
-
into androidAssetsDir
|
|
40
|
-
rename { String fileName -> configFile }
|
|
41
|
-
}
|
|
42
|
-
logger.lifecycle("Copied ${configFile} to Android assets")
|
|
43
|
-
} else {
|
|
44
|
-
logger.warn("${configFile} not found in app root (${appRoot})")
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
tasks.register("cleanupTemporarySentryJsonConfiguration") {
|
|
50
|
-
onlyIf { shouldCopySentryOptionsFile() }
|
|
51
|
-
doLast {
|
|
52
|
-
def sentryOptionsFile = new File(androidAssetsDir, configFile)
|
|
53
|
-
if (sentryOptionsFile.exists()) {
|
|
54
|
-
logger.lifecycle("Deleting temporary file: ${sentryOptionsFile.path}")
|
|
55
|
-
sentryOptionsFile.delete()
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
20
|
gradle.projectsEvaluated {
|
|
61
|
-
// Add a task that copies the sentry.options.json file before the build starts
|
|
62
|
-
tasks.named("preBuild").configure {
|
|
63
|
-
dependsOn("copySentryJsonConfiguration")
|
|
64
|
-
}
|
|
65
|
-
// Cleanup sentry.options.json from assets after the build
|
|
66
|
-
tasks.matching { task ->
|
|
67
|
-
task.name == "build" || task.name.startsWith("assemble") || task.name.startsWith("install")
|
|
68
|
-
}.configureEach {
|
|
69
|
-
finalizedBy("cleanupTemporarySentryJsonConfiguration")
|
|
70
|
-
}
|
|
71
|
-
|
|
72
21
|
def releases = extractReleasesInfo()
|
|
73
22
|
|
|
74
23
|
if (config.flavorAware && config.sentryProperties) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="react-native" />
|
|
2
2
|
import type { InternalGlobal } from '@sentry/core';
|
|
3
3
|
import type { ErrorUtils } from 'react-native/types';
|
|
4
|
-
import type { ReactNativeOptions } from '../options';
|
|
5
4
|
import type { ExpoGlobalObject } from './expoglobalobject';
|
|
6
5
|
/** Internal Global object interface with common and Sentry specific properties */
|
|
7
6
|
export interface ReactNativeInternalGlobal extends InternalGlobal {
|
|
@@ -24,7 +23,6 @@ export interface ReactNativeInternalGlobal extends InternalGlobal {
|
|
|
24
23
|
__BUNDLE_START_TIME__?: number;
|
|
25
24
|
nativePerformanceNow?: () => number;
|
|
26
25
|
TextEncoder?: TextEncoder;
|
|
27
|
-
__SENTRY_OPTIONS__?: ReactNativeOptions;
|
|
28
26
|
}
|
|
29
27
|
type TextEncoder = {
|
|
30
28
|
new (): TextEncoder;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const SDK_PACKAGE_NAME = "npm:@sentry/react-native";
|
|
2
2
|
export declare const SDK_NAME = "sentry.javascript.react-native";
|
|
3
|
-
export declare const SDK_VERSION = "6.7.0
|
|
3
|
+
export declare const SDK_VERSION = "6.7.0";
|
|
4
4
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
package io.sentry.react;
|
|
2
|
-
|
|
3
|
-
import io.sentry.Sentry.OptionsConfiguration;
|
|
4
|
-
import io.sentry.android.core.SentryAndroidOptions;
|
|
5
|
-
import java.util.List;
|
|
6
|
-
import org.jetbrains.annotations.NotNull;
|
|
7
|
-
|
|
8
|
-
class RNSentryCompositeOptionsConfiguration implements OptionsConfiguration<SentryAndroidOptions> {
|
|
9
|
-
private final @NotNull List<OptionsConfiguration<SentryAndroidOptions>> configurations;
|
|
10
|
-
|
|
11
|
-
@SafeVarargs
|
|
12
|
-
protected RNSentryCompositeOptionsConfiguration(
|
|
13
|
-
@NotNull OptionsConfiguration<SentryAndroidOptions>... configurations) {
|
|
14
|
-
this.configurations = List.of(configurations);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
@Override
|
|
18
|
-
public void configure(@NotNull SentryAndroidOptions options) {
|
|
19
|
-
for (OptionsConfiguration<SentryAndroidOptions> configuration : configurations) {
|
|
20
|
-
if (configuration != null) {
|
|
21
|
-
configuration.configure(options);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
package io.sentry.react;
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.JavaOnlyArray;
|
|
4
|
-
import com.facebook.react.bridge.JavaOnlyMap;
|
|
5
|
-
import com.facebook.react.bridge.WritableArray;
|
|
6
|
-
import com.facebook.react.bridge.WritableMap;
|
|
7
|
-
import io.sentry.ILogger;
|
|
8
|
-
import io.sentry.SentryLevel;
|
|
9
|
-
import io.sentry.android.core.AndroidLogger;
|
|
10
|
-
import java.util.Iterator;
|
|
11
|
-
import org.jetbrains.annotations.NotNull;
|
|
12
|
-
import org.jetbrains.annotations.Nullable;
|
|
13
|
-
import org.json.JSONArray;
|
|
14
|
-
import org.json.JSONException;
|
|
15
|
-
import org.json.JSONObject;
|
|
16
|
-
|
|
17
|
-
final class RNSentryJsonConverter {
|
|
18
|
-
public static final String NAME = "RNSentry.RNSentryJsonConverter";
|
|
19
|
-
|
|
20
|
-
private static final ILogger logger = new AndroidLogger(NAME);
|
|
21
|
-
|
|
22
|
-
private RNSentryJsonConverter() {
|
|
23
|
-
throw new AssertionError("Utility class should not be instantiated");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@Nullable
|
|
27
|
-
static WritableMap convertToWritable(@NotNull JSONObject jsonObject) {
|
|
28
|
-
try {
|
|
29
|
-
WritableMap writableMap = new JavaOnlyMap();
|
|
30
|
-
Iterator<String> iterator = jsonObject.keys();
|
|
31
|
-
while (iterator.hasNext()) {
|
|
32
|
-
String key = iterator.next();
|
|
33
|
-
Object value = jsonObject.get(key);
|
|
34
|
-
if (value instanceof Float || value instanceof Double) {
|
|
35
|
-
writableMap.putDouble(key, jsonObject.getDouble(key));
|
|
36
|
-
} else if (value instanceof Number) {
|
|
37
|
-
writableMap.putInt(key, jsonObject.getInt(key));
|
|
38
|
-
} else if (value instanceof String) {
|
|
39
|
-
writableMap.putString(key, jsonObject.getString(key));
|
|
40
|
-
} else if (value instanceof JSONObject) {
|
|
41
|
-
writableMap.putMap(key, convertToWritable(jsonObject.getJSONObject(key)));
|
|
42
|
-
} else if (value instanceof JSONArray) {
|
|
43
|
-
writableMap.putArray(key, convertToWritable(jsonObject.getJSONArray(key)));
|
|
44
|
-
} else if (value == JSONObject.NULL) {
|
|
45
|
-
writableMap.putNull(key);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return writableMap;
|
|
49
|
-
} catch (JSONException e) {
|
|
50
|
-
logger.log(SentryLevel.ERROR, "Error parsing json object:" + e.getMessage());
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@NotNull
|
|
56
|
-
static WritableArray convertToWritable(@NotNull JSONArray jsonArray) throws JSONException {
|
|
57
|
-
WritableArray writableArray = new JavaOnlyArray();
|
|
58
|
-
for (int i = 0; i < jsonArray.length(); i++) {
|
|
59
|
-
Object value = jsonArray.get(i);
|
|
60
|
-
if (value instanceof Float || value instanceof Double) {
|
|
61
|
-
writableArray.pushDouble(jsonArray.getDouble(i));
|
|
62
|
-
} else if (value instanceof Number) {
|
|
63
|
-
writableArray.pushInt(jsonArray.getInt(i));
|
|
64
|
-
} else if (value instanceof String) {
|
|
65
|
-
writableArray.pushString(jsonArray.getString(i));
|
|
66
|
-
} else if (value instanceof JSONObject) {
|
|
67
|
-
writableArray.pushMap(convertToWritable(jsonArray.getJSONObject(i)));
|
|
68
|
-
} else if (value instanceof JSONArray) {
|
|
69
|
-
writableArray.pushArray(convertToWritable(jsonArray.getJSONArray(i)));
|
|
70
|
-
} else if (value == JSONObject.NULL) {
|
|
71
|
-
writableArray.pushNull();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return writableArray;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
package io.sentry.react;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import io.sentry.ILogger;
|
|
5
|
-
import io.sentry.SentryLevel;
|
|
6
|
-
import java.io.BufferedReader;
|
|
7
|
-
import java.io.InputStream;
|
|
8
|
-
import java.io.InputStreamReader;
|
|
9
|
-
import org.jetbrains.annotations.NotNull;
|
|
10
|
-
import org.jetbrains.annotations.Nullable;
|
|
11
|
-
import org.json.JSONObject;
|
|
12
|
-
|
|
13
|
-
final class RNSentryJsonUtils {
|
|
14
|
-
private RNSentryJsonUtils() {
|
|
15
|
-
throw new AssertionError("Utility class should not be instantiated");
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static @Nullable JSONObject getOptionsFromConfigurationFile(
|
|
19
|
-
@NotNull Context context, @NotNull String fileName, @NotNull ILogger logger) {
|
|
20
|
-
try (InputStream inputStream = context.getAssets().open(fileName);
|
|
21
|
-
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
|
|
22
|
-
|
|
23
|
-
StringBuilder stringBuilder = new StringBuilder();
|
|
24
|
-
String line;
|
|
25
|
-
while ((line = reader.readLine()) != null) {
|
|
26
|
-
stringBuilder.append(line);
|
|
27
|
-
}
|
|
28
|
-
String configFileContent = stringBuilder.toString();
|
|
29
|
-
return new JSONObject(configFileContent);
|
|
30
|
-
|
|
31
|
-
} catch (Exception e) {
|
|
32
|
-
logger.log(
|
|
33
|
-
SentryLevel.ERROR,
|
|
34
|
-
"Failed to read configuration file. Please make sure "
|
|
35
|
-
+ fileName
|
|
36
|
-
+ " exists in the root of your project.",
|
|
37
|
-
e);
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
package io.sentry.react;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
5
|
-
import io.sentry.ILogger;
|
|
6
|
-
import io.sentry.Sentry;
|
|
7
|
-
import io.sentry.SentryLevel;
|
|
8
|
-
import io.sentry.android.core.AndroidLogger;
|
|
9
|
-
import io.sentry.android.core.SentryAndroidOptions;
|
|
10
|
-
import org.jetbrains.annotations.NotNull;
|
|
11
|
-
import org.json.JSONObject;
|
|
12
|
-
|
|
13
|
-
public final class RNSentrySDK {
|
|
14
|
-
private static final String CONFIGURATION_FILE = "sentry.options.json";
|
|
15
|
-
private static final String NAME = "RNSentrySDK";
|
|
16
|
-
|
|
17
|
-
private static final ILogger logger = new AndroidLogger(NAME);
|
|
18
|
-
|
|
19
|
-
private RNSentrySDK() {
|
|
20
|
-
throw new AssertionError("Utility class should not be instantiated");
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static void init(
|
|
24
|
-
@NotNull final Context context,
|
|
25
|
-
@NotNull Sentry.OptionsConfiguration<SentryAndroidOptions> configuration,
|
|
26
|
-
@NotNull String configurationFile,
|
|
27
|
-
@NotNull ILogger logger) {
|
|
28
|
-
try {
|
|
29
|
-
JSONObject jsonObject =
|
|
30
|
-
RNSentryJsonUtils.getOptionsFromConfigurationFile(context, configurationFile, logger);
|
|
31
|
-
if (jsonObject == null) {
|
|
32
|
-
RNSentryStart.startWithConfiguration(context, configuration);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
ReadableMap rnOptions = RNSentryJsonConverter.convertToWritable(jsonObject);
|
|
36
|
-
if (rnOptions == null) {
|
|
37
|
-
RNSentryStart.startWithConfiguration(context, configuration);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
RNSentryStart.startWithOptions(context, rnOptions, configuration, logger);
|
|
41
|
-
} catch (Exception e) {
|
|
42
|
-
logger.log(
|
|
43
|
-
SentryLevel.ERROR, "Failed to start Sentry with options from configuration file.", e);
|
|
44
|
-
throw new RuntimeException("Failed to initialize Sentry's React Native SDK", e);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @experimental Start the Native Android SDK with the provided configuration options. Uses as a
|
|
50
|
-
* base configurations the `sentry.options.json` configuration file if it exists.
|
|
51
|
-
* @param context Android Context
|
|
52
|
-
* @param configuration configuration options
|
|
53
|
-
*/
|
|
54
|
-
public static void init(
|
|
55
|
-
@NotNull final Context context,
|
|
56
|
-
@NotNull Sentry.OptionsConfiguration<SentryAndroidOptions> configuration) {
|
|
57
|
-
init(context, configuration, CONFIGURATION_FILE, logger);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @experimental Start the Native Android SDK with options from `sentry.options.json`
|
|
62
|
-
* configuration file.
|
|
63
|
-
* @param context Android Context
|
|
64
|
-
*/
|
|
65
|
-
public static void init(@NotNull final Context context) {
|
|
66
|
-
init(context, options -> {}, CONFIGURATION_FILE, logger);
|
|
67
|
-
}
|
|
68
|
-
}
|