Skip to content

Commit

Permalink
fix(replay): MaskAll* set to false should unmask all on iOS (#4257)
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich authored Nov 11, 2024
1 parent 2c42e02 commit a5d86e1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- Enhanced accuracy of time-to-display spans. ([#4189](https://github.com/getsentry/sentry-react-native/pull/4189))
- Fix Replay redacting of RN Classes on iOS ([#4243](https://github.com/getsentry/sentry-react-native/pull/4243))
- Speed up getBinaryImages for finishing transactions and capturing events ([#4194](https://github.com/getsentry/sentry-react-native/pull/4194))
- Replay `maskAll*` set to `false` on iOS kept all masked ([#4257](https://github.com/getsentry/sentry-react-native/pull/4257))
- Add missing `getRootSpan`, `withActiveSpan` and `suppressTracing` exports from `@sentry/core` ([#4254](https://github.com/getsentry/sentry-react-native/pull/4254))

### Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ final class RNSentryReplayOptions: XCTestCase {
XCTAssertEqual(replayOptions.count, 5)
XCTAssertNotNil(replayOptions["sessionSampleRate"])
XCTAssertNotNil(replayOptions["errorSampleRate"])
XCTAssertNotNil(replayOptions["redactAllImages"])
XCTAssertNotNil(replayOptions["redactAllText"])
XCTAssertNotNil(replayOptions["maskAllImages"])
XCTAssertNotNil(replayOptions["maskAllText"])
XCTAssertNotNil(replayOptions["maskedViewClasses"])
}

Expand Down Expand Up @@ -133,6 +133,21 @@ final class RNSentryReplayOptions: XCTestCase {
XCTAssertEqual(ObjectIdentifier(actualOptions.experimental.sessionReplay.maskedViewClasses[0]), ObjectIdentifier(NSClassFromString("RCTImageView")!))
}

func testMaskAllImagesFalse() {
let optionsDict = ([
"dsn": "https://[email protected]/1234567",
"_experiments": [ "replaysOnErrorSampleRate": 0.75 ],
"mobileReplayOptions": [ "maskAllImages": false ]
] as NSDictionary).mutableCopy() as! NSMutableDictionary

RNSentryReplay.updateOptions(optionsDict)

let actualOptions = try! Options(dict: optionsDict as! [String: Any])

XCTAssertEqual(actualOptions.experimental.sessionReplay.maskAllImages, false)
XCTAssertEqual(actualOptions.experimental.sessionReplay.maskedViewClasses.count, 0)
}

func testMaskAllText() {
let optionsDict = ([
"dsn": "https://[email protected]/1234567",
Expand All @@ -152,4 +167,19 @@ final class RNSentryReplayOptions: XCTestCase {
XCTAssertEqual(ObjectIdentifier(actualOptions.experimental.sessionReplay.maskedViewClasses[1]), ObjectIdentifier(NSClassFromString("RCTParagraphComponentView")!))
}

func testMaskAllTextFalse() {
let optionsDict = ([
"dsn": "https://[email protected]/1234567",
"_experiments": [ "replaysOnErrorSampleRate": 0.75 ],
"mobileReplayOptions": [ "maskAllText": false ]
] as NSDictionary).mutableCopy() as! NSMutableDictionary

RNSentryReplay.updateOptions(optionsDict)

let actualOptions = try! Options(dict: optionsDict as! [String: Any])

XCTAssertEqual(actualOptions.experimental.sessionReplay.maskAllText, false)
XCTAssertEqual(actualOptions.experimental.sessionReplay.maskedViewClasses.count, 0)
}

}
4 changes: 2 additions & 2 deletions packages/core/ios/RNSentryReplay.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ + (void)updateOptions:(NSMutableDictionary *)options
@"sessionReplay" : @ {
@"sessionSampleRate" : experiments[@"replaysSessionSampleRate"] ?: [NSNull null],
@"errorSampleRate" : experiments[@"replaysOnErrorSampleRate"] ?: [NSNull null],
@"redactAllImages" : replayOptions[@"maskAllImages"] ?: [NSNull null],
@"redactAllText" : replayOptions[@"maskAllText"] ?: [NSNull null],
@"maskAllImages" : replayOptions[@"maskAllImages"] ?: [NSNull null],
@"maskAllText" : replayOptions[@"maskAllText"] ?: [NSNull null],
@"maskedViewClasses" : [RNSentryReplay getReplayRNRedactClasses:replayOptions],
}
}
Expand Down

0 comments on commit a5d86e1

Please sign in to comment.