Skip to content

Commit f34feb1

Browse files
committed
Merge remote-tracking branch 'origin/main' into antonis/cleanup-sentrysdkwrapper-deadcode
# Conflicts: # packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m # packages/core/ios/SentrySDKWrapper.h # packages/core/ios/SentrySDKWrapper.m
2 parents c8717ed + ddaa8a1 commit f34feb1

21 files changed

Lines changed: 589 additions & 233 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
### Fixes
1717

1818
- Stop the Hermes sampling profiler on React instance teardown to prevent `pthread_kill` SIGABRT when the JS thread is torn down with profiling active ([#6035](https://github.com/getsentry/sentry-react-native/pull/6035))
19+
- Restrict the Metro source-context middleware to files within the project root ([#6044](https://github.com/getsentry/sentry-react-native/pull/6044))
20+
- Escape `name` and `version` values when injecting release constants into the web bundle ([#6044](https://github.com/getsentry/sentry-react-native/pull/6044))
21+
- Mask the Sentry auth token in the `sentry.gradle` upload-task lifecycle log ([#6057](https://github.com/getsentry/sentry-react-native/pull/6057))
22+
- Discard invalid navigation/interaction transactions via an event processor instead of mutating the internal `_sampled` flag, removing misleading "dropped due to sampling" debug logs ([#6051](https://github.com/getsentry/sentry-react-native/pull/6051))
1923

2024
### Dependencies
2125

packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m

Lines changed: 0 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,126 +1006,4 @@ - (void)testStartBeforeSendFiltersOutJSErrorCppException
10061006
@"dropped");
10071007
}
10081008

1009-
#pragma mark - RNSentryStart enableSessionReplayInUnreliableEnvironment Tests
1010-
1011-
- (void)testStartCreateOptionsWithDictionaryEnableSessionReplayInUnreliableEnvironmentDefault
1012-
{
1013-
NSError *error = nil;
1014-
1015-
NSDictionary *_Nonnull mockedReactNativeDictionary = @{
1016-
@"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456",
1017-
};
1018-
SentryOptions *actualOptions =
1019-
[RNSentryStart createOptionsWithDictionary:mockedReactNativeDictionary error:&error];
1020-
1021-
XCTAssertNotNil(actualOptions, @"Did not create sentry options");
1022-
XCTAssertNil(error, @"Should not pass no error");
1023-
1024-
id experimentalOptions = [actualOptions valueForKey:@"experimental"];
1025-
XCTAssertNotNil(experimentalOptions, @"Experimental options should not be nil");
1026-
1027-
BOOL enableSessionReplayInUnreliableEnvironment =
1028-
[[experimentalOptions valueForKey:@"enableSessionReplayInUnreliableEnvironment"] boolValue];
1029-
XCTAssertFalse(enableSessionReplayInUnreliableEnvironment,
1030-
@"enableSessionReplayInUnreliableEnvironment should be disabled");
1031-
}
1032-
1033-
- (void)
1034-
testStartCreateOptionsWithDictionaryEnableSessionReplayInUnreliableEnvironmentWithErrorSampleRate
1035-
{
1036-
NSError *error = nil;
1037-
1038-
NSDictionary *_Nonnull mockedReactNativeDictionary = @{
1039-
@"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456",
1040-
@"replaysOnErrorSampleRate" : @1.0,
1041-
@"replaysSessionSampleRate" : @0
1042-
};
1043-
SentryOptions *actualOptions =
1044-
[RNSentryStart createOptionsWithDictionary:mockedReactNativeDictionary error:&error];
1045-
1046-
XCTAssertNotNil(actualOptions, @"Did not create sentry options");
1047-
XCTAssertNil(error, @"Should not pass no error");
1048-
1049-
id experimentalOptions = [actualOptions valueForKey:@"experimental"];
1050-
XCTAssertNotNil(experimentalOptions, @"Experimental options should not be nil");
1051-
1052-
BOOL enableSessionReplayInUnreliableEnvironment =
1053-
[[experimentalOptions valueForKey:@"enableSessionReplayInUnreliableEnvironment"] boolValue];
1054-
XCTAssertTrue(enableSessionReplayInUnreliableEnvironment,
1055-
@"enableSessionReplayInUnreliableEnvironment should be enabled");
1056-
}
1057-
1058-
- (void)
1059-
testStartCreateOptionsWithDictionaryEnableSessionReplayInUnreliableEnvironmentWithSessionSampleRate
1060-
{
1061-
NSError *error = nil;
1062-
1063-
NSDictionary *_Nonnull mockedReactNativeDictionary = @{
1064-
@"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456",
1065-
@"replaysOnErrorSampleRate" : @0.0,
1066-
@"replaysSessionSampleRate" : @0.1
1067-
};
1068-
SentryOptions *actualOptions =
1069-
[RNSentryStart createOptionsWithDictionary:mockedReactNativeDictionary error:&error];
1070-
XCTAssertNotNil(actualOptions, @"Did not create sentry options");
1071-
XCTAssertNil(error, @"Should not pass no error");
1072-
1073-
id experimentalOptions = [actualOptions valueForKey:@"experimental"];
1074-
XCTAssertNotNil(experimentalOptions, @"Experimental options should not be nil");
1075-
1076-
BOOL enableSessionReplayInUnreliableEnvironment =
1077-
[[experimentalOptions valueForKey:@"enableSessionReplayInUnreliableEnvironment"] boolValue];
1078-
XCTAssertTrue(enableSessionReplayInUnreliableEnvironment,
1079-
@"enableSessionReplayInUnreliableEnvironment should be enabled");
1080-
}
1081-
1082-
- (void)
1083-
testStartCreateOptionsWithDictionaryEnableSessionReplayInUnreliableEnvironmentWithSessionSampleRates
1084-
{
1085-
NSError *error = nil;
1086-
1087-
NSDictionary *_Nonnull mockedReactNativeDictionary = @{
1088-
@"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456",
1089-
@"replaysOnErrorSampleRate" : @1.0,
1090-
@"replaysSessionSampleRate" : @0.1
1091-
};
1092-
SentryOptions *actualOptions =
1093-
[RNSentryStart createOptionsWithDictionary:mockedReactNativeDictionary error:&error];
1094-
1095-
XCTAssertNotNil(actualOptions, @"Did not create sentry options");
1096-
XCTAssertNil(error, @"Should not pass no error");
1097-
1098-
id experimentalOptions = [actualOptions valueForKey:@"experimental"];
1099-
XCTAssertNotNil(experimentalOptions, @"Experimental options should not be nil");
1100-
1101-
BOOL enableSessionReplayInUnreliableEnvironment =
1102-
[[experimentalOptions valueForKey:@"enableSessionReplayInUnreliableEnvironment"] boolValue];
1103-
XCTAssertTrue(enableSessionReplayInUnreliableEnvironment,
1104-
@"enableSessionReplayInUnreliableEnvironment should be enabled");
1105-
}
1106-
1107-
- (void)testStartCreateOptionsWithDictionaryEnableSessionReplayInUnreliableEnvironmentDisabled
1108-
{
1109-
NSError *error = nil;
1110-
1111-
NSDictionary *_Nonnull mockedReactNativeDictionary = @{
1112-
@"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456",
1113-
@"replaysOnErrorSampleRate" : @0,
1114-
@"replaysSessionSampleRate" : @0
1115-
};
1116-
SentryOptions *actualOptions =
1117-
[RNSentryStart createOptionsWithDictionary:mockedReactNativeDictionary error:&error];
1118-
1119-
XCTAssertNotNil(actualOptions, @"Did not create sentry options");
1120-
XCTAssertNil(error, @"Should not pass no error");
1121-
1122-
id experimentalOptions = [actualOptions valueForKey:@"experimental"];
1123-
XCTAssertNotNil(experimentalOptions, @"Experimental options should not be nil");
1124-
1125-
BOOL enableSessionReplayInUnreliableEnvironment =
1126-
[[experimentalOptions valueForKey:@"enableSessionReplayInUnreliableEnvironment"] boolValue];
1127-
XCTAssertFalse(enableSessionReplayInUnreliableEnvironment,
1128-
@"enableSessionReplayInUnreliableEnvironment should be disabled");
1129-
}
1130-
11311009
@end

packages/core/ios/RNSentryExperimentalOptions.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ NS_ASSUME_NONNULL_BEGIN
2828
*/
2929
+ (void)setEnableLogs:(BOOL)enabled sentryOptions:(SentryOptions *)sentryOptions;
3030

31-
/**
32-
* Sets the enableSessionReplayInUnreliableEnvironment experimental option on SentryOptions
33-
* @param sentryOptions The SentryOptions instance to configure
34-
* @param enabled Whether enableSessionReplayInUnreliableEnvironment from sentry Cocoa should be
35-
* enabled
36-
*/
37-
+ (void)setEnableSessionReplayInUnreliableEnvironment:(BOOL)enabled
38-
sentryOptions:(SentryOptions *)sentryOptions;
39-
4031
/**
4132
* Configures iOS UI profiling options on SentryOptions
4233
* @param profilingOptions Dictionary containing profiling configuration

packages/core/ios/RNSentryExperimentalOptions.m

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ + (void)setEnableLogs:(BOOL)enabled sentryOptions:(SentryOptions *)sentryOptions
2828
sentryOptions.enableLogs = enabled;
2929
}
3030

31-
+ (void)setEnableSessionReplayInUnreliableEnvironment:(BOOL)enabled
32-
sentryOptions:(SentryOptions *)sentryOptions
33-
{
34-
if (sentryOptions == nil) {
35-
return;
36-
}
37-
sentryOptions.experimental.enableSessionReplayInUnreliableEnvironment = enabled;
38-
}
39-
4031
+ (void)configureProfilingWithOptions:(NSDictionary *)profilingOptions
4132
sentryOptions:(SentryOptions *)sentryOptions
4233
{

packages/core/ios/RNSentryReplay.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
/**
55
* Updates the session replay options
6-
* @return true when session replay is enabled
76
*/
8-
+ (BOOL)updateOptions:(NSMutableDictionary *)options;
7+
+ (void)updateOptions:(NSMutableDictionary *)options;
98

109
+ (void)postInit;
1110

packages/core/ios/RNSentryReplay.mm

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
@implementation RNSentryReplay {
1313
}
1414

15-
+ (BOOL)updateOptions:(NSMutableDictionary *)options
15+
+ (void)updateOptions:(NSMutableDictionary *)options
1616
{
1717
NSNumber *sessionSampleRate = options[@"replaysSessionSampleRate"];
1818
NSNumber *errorSampleRate = options[@"replaysOnErrorSampleRate"];
1919

2020
if (sessionSampleRate == nil && errorSampleRate == nil) {
2121
NSLog(@"Session replay disabled via configuration");
22-
return NO;
22+
return;
2323
}
2424

2525
NSLog(@"Setting up session replay");
@@ -45,8 +45,6 @@ + (BOOL)updateOptions:(NSMutableDictionary *)options
4545
@ { @"name" : REACT_NATIVE_SDK_NAME, @"version" : REACT_NATIVE_SDK_PACKAGE_VERSION }
4646
}
4747
forKey:@"sessionReplay"];
48-
return (errorSampleRate != nil && [errorSampleRate doubleValue] > 0)
49-
|| (sessionSampleRate != nil && [sessionSampleRate doubleValue] > 0);
5048
}
5149

5250
+ (NSArray *_Nonnull)getReplayRNRedactClasses:(NSDictionary *_Nullable)replayOptions

packages/core/ios/RNSentryStart.m

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ + (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull)
4444
NSMutableDictionary *mutableOptions = [options mutableCopy];
4545

4646
#if SENTRY_TARGET_REPLAY_SUPPORTED
47-
BOOL isSessionReplayEnabled = [RNSentryReplay updateOptions:mutableOptions];
48-
#else
49-
BOOL isSessionReplayEnabled = NO;
47+
[RNSentryReplay updateOptions:mutableOptions];
5048
#endif
5149

5250
SentryOptions *sentryOptions = [PrivateSentrySDKOnly optionsWithDictionary:mutableOptions
@@ -170,11 +168,6 @@ + (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull)
170168
}
171169
}
172170

173-
if (isSessionReplayEnabled) {
174-
[RNSentryExperimentalOptions setEnableSessionReplayInUnreliableEnvironment:YES
175-
sentryOptions:sentryOptions];
176-
}
177-
178171
return sentryOptions;
179172
}
180173

packages/core/sentry.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ plugins.withId('com.android.application') {
269269

270270
args.addAll(extraArgs)
271271

272-
project.logger.lifecycle("Sentry-CLI arguments: ${args}")
272+
// Mask sentryAuthToken in the logged args; do not pass loggedArgs to the CLI.
273+
def loggedArgs = sentryAuthToken ? args.collect { it == sentryAuthToken ? "***" : it } : args
274+
project.logger.lifecycle("Sentry-CLI arguments: ${loggedArgs}")
273275
def osCompatibility = Os.isFamily(Os.FAMILY_WINDOWS) ? ['cmd', '/c', 'node'] : []
274276
if (!System.getenv('SENTRY_DOTENV_PATH') && file("$reactRoot/.env.sentry-build-plugin").exists()) {
275277
environment('SENTRY_DOTENV_PATH', "$reactRoot/.env.sentry-build-plugin")

0 commit comments

Comments
 (0)