Skip to content

Commit 2f5e5f7

Browse files
authored
Rename session replay redact options and APIs to mask (#4373)
Renaming SR redact to mask and ignoretounmask
1 parent 4314fa2 commit 2f5e5f7

File tree

17 files changed

+74
-74
lines changed

17 files changed

+74
-74
lines changed

.github/workflows/benchmarking.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ jobs:
134134
name: raw-build-output-build-xcframework
135135
path: |
136136
build-xcframework.log
137-
137+
138138
- name: Build test app with sentry
139139
run: bundle exec fastlane build_perf_test_app_sentry
140140
env:

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
- Speed up HTTP tracking for multiple requests in parallel (#4366)
1515
- Slightly speed up SentryInAppLogic (#4370)
16+
- Rename session replay `redact` options and APIs to `mask` (#4373)
1617
- Stop canceling timer for manual transactions (#4380)
1718

1819
### Fixes

Samples/iOS-ObjectiveC/iOS-ObjectiveC/AppDelegate.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ - (BOOL)application:(UIApplication *)application
2929
options.failedRequestStatusCodes = @[ httpStatusCodeRange ];
3030

3131
options.experimental.sessionReplay.quality = SentryReplayQualityMedium;
32-
options.experimental.sessionReplay.redactAllText = true;
33-
options.experimental.sessionReplay.redactAllImages = true;
32+
options.experimental.sessionReplay.maskAllText = true;
33+
options.experimental.sessionReplay.maskAllImages = true;
3434
options.experimental.sessionReplay.sessionSampleRate = 0;
3535
options.experimental.sessionReplay.onErrorSampleRate = 1;
3636

Samples/iOS-Swift/iOS-Swift/AppDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
4444
options.debug = true
4545

4646
if #available(iOS 16.0, *), !args.contains("--disable-session-replay") {
47-
options.experimental.sessionReplay = SentryReplayOptions(sessionSampleRate: 1, onErrorSampleRate: 1, redactAllText: true, redactAllImages: true)
47+
options.experimental.sessionReplay = SentryReplayOptions(sessionSampleRate: 1, onErrorSampleRate: 1, maskAllText: true, maskAllImages: true)
4848
options.experimental.sessionReplay.quality = .high
4949
}
5050

Samples/iOS-Swift/iOS-Swift/ViewControllers/SRRedactSampleViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ class SRRedactSampleViewController: UIViewController {
1212
notRedactedView.backgroundColor = .green
1313
notRedactedView.transform = CGAffineTransform(rotationAngle: 45 * .pi / 180.0)
1414

15-
SentrySDK.replay.ignoreView(notRedactedView)
15+
SentrySDK.replay.maskView(notRedactedView)
1616
}
1717
}

Samples/iOS-SwiftUI/iOS-SwiftUI/ContentView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ struct ContentView: View {
199199
Text("Form Screen")
200200
}
201201
}
202-
.sentryReplayRedact()
202+
.sentryReplayMask()
203203
}
204204
SecondView()
205205
}

Samples/iOS-SwiftUI/iOS-SwiftUI/SwiftUIApp.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ struct SwiftUIApp: App {
1111
options.tracesSampleRate = 1.0
1212
options.profilesSampleRate = 1.0
1313
options.experimental.sessionReplay.sessionSampleRate = 1.0
14-
options.experimental.sessionReplay.redactAllImages = false
15-
options.experimental.sessionReplay.redactAllText = false
14+
options.experimental.sessionReplay.maskAllImages = false
15+
options.experimental.sessionReplay.maskAllText = false
1616
options.initialScope = { scope in
1717
scope.injectGitInformation()
1818
return scope

Sources/Sentry/Public/SentryReplayApi.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,18 @@ NS_ASSUME_NONNULL_BEGIN
1515
@interface SentryReplayApi : NSObject
1616

1717
/**
18-
* Marks this view to be redacted during replays.
18+
* Marks this view to be masked during replays.
1919
*
2020
* @warning This is an experimental feature and may still have bugs.
2121
*/
22-
- (void)redactView:(UIView *)view NS_SWIFT_NAME(redactView(_:));
22+
- (void)maskView:(UIView *)view NS_SWIFT_NAME(maskView(_:));
2323

2424
/**
25-
* Marks this view to be ignored during redact step of session replay.
26-
* All its content will be visible in the replay.
25+
* Marks this view to not be masked during redact step of session replay.
2726
*
2827
* @warning This is an experimental feature and may still have bugs.
2928
*/
30-
- (void)ignoreView:(UIView *)view NS_SWIFT_NAME(ignoreView(_:));
29+
- (void)unmaskView:(UIView *)view NS_SWIFT_NAME(unmaskView(_:));
3130

3231
/**
3332
* Pauses the replay.

Sources/Sentry/SentryReplayApi.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
@implementation SentryReplayApi
1212

13-
- (void)redactView:(UIView *)view
13+
- (void)maskView:(UIView *)view
1414
{
15-
[SentryRedactViewHelper redactView:view];
15+
[SentryRedactViewHelper maskView:view];
1616
}
1717

18-
- (void)ignoreView:(UIView *)view
18+
- (void)unmaskView:(UIView *)view
1919
{
20-
[SentryRedactViewHelper ignoreView:view];
20+
[SentryRedactViewHelper unmaskView:view];
2121
}
2222

2323
- (void)pause

Sources/SentrySwiftUI/SentryReplayView.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct SentryReplayView: UIViewRepresentable {
1010

1111
func makeUIView(context: Context) -> UIView {
1212
let result = SentryRedactView()
13-
result.sentryReplayRedact()
13+
result.sentryReplayMask()
1414
return result
1515
}
1616

@@ -29,15 +29,15 @@ struct SentryReplayModifier: ViewModifier {
2929
@available(iOS 13, macOS 10.15, tvOS 13, *)
3030
public extension View {
3131

32-
/// Marks the view as containing sensitive information that should be redacted during replays.
32+
/// Marks the view as containing sensitive information that should be masked during replays.
3333
///
34-
/// When this modifier is applied, any sensitive content within the view will be hidden or masked
34+
/// When this modifier is applied, any sensitive content within the view will be masked
3535
/// during session replays to ensure user privacy. This is useful for views containing personal
3636
/// data or confidential information that shouldn't be visible when the replay is reviewed.
3737
///
3838
/// - Returns: A modifier that redacts sensitive information during session replays.
3939
/// - Experiment: This is an experimental feature and may still have bugs.
40-
func sentryReplayRedact() -> some View {
40+
func sentryReplayMask() -> some View {
4141
modifier(SentryReplayModifier())
4242
}
4343
}

Sources/Swift/Extensions/UIViewExtensions.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ public extension UIView {
99
* Marks this view to be redacted during replays.
1010
* - experiment: This is an experimental feature and may still have bugs.
1111
*/
12-
func sentryReplayRedact() {
13-
SentryRedactViewHelper.redactView(self)
12+
func sentryReplayMask() {
13+
SentryRedactViewHelper.maskView(self)
1414
}
1515

1616
/**
1717
* Marks this view to be ignored during redact step
1818
* of session replay. All its content will be visible in the replay.
1919
* - experiment: This is an experimental feature and may still have bugs.
2020
*/
21-
func sentryReplayIgnore() {
22-
SentryRedactViewHelper.ignoreView(self)
21+
func sentryReplayUnmask() {
22+
SentryRedactViewHelper.unmaskView(self)
2323
}
2424
}
2525

Sources/Swift/Integrations/SessionReplay/SentryReplayOptions.swift

+10-10
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ public class SentryReplayOptions: NSObject, SentryRedactOptions {
5151
*
5252
* - note: The default is true
5353
*/
54-
public var redactAllText = true
54+
public var maskAllText = true
5555

5656
/**
5757
* Indicates whether session replay should redact all non-bundled image
5858
* in the app by drawing a black rectangle over it.
5959
*
6060
* - note: The default is true
6161
*/
62-
public var redactAllImages = true
62+
public var maskAllImages = true
6363

6464
/**
6565
* Indicates the quality of the replay.
@@ -73,15 +73,15 @@ public class SentryReplayOptions: NSObject, SentryRedactOptions {
7373
* By default Sentry already mask text and image elements from UIKit
7474
* Every child of a view that is redacted will also be redacted.
7575
*/
76-
public var redactViewClasses = [AnyClass]()
76+
public var maskedViewClasses = [AnyClass]()
7777

7878
/**
7979
* A list of custom UIView subclasses to be ignored
8080
* during masking step of the session replay.
8181
* The views of given classes will not be redacted but their children may be.
8282
* This property has precedence over `redactViewTypes`.
8383
*/
84-
public var ignoreViewClasses = [AnyClass]()
84+
public var unmaskedViewClasses = [AnyClass]()
8585

8686
/**
8787
* Defines the quality of the session replay.
@@ -139,18 +139,18 @@ public class SentryReplayOptions: NSObject, SentryRedactOptions {
139139
* - errorSampleRate Indicates the percentage in which a 30 seconds replay will be send with
140140
* error events.
141141
*/
142-
public init(sessionSampleRate: Float = 0, onErrorSampleRate: Float = 0, redactAllText: Bool = true, redactAllImages: Bool = true) {
142+
public init(sessionSampleRate: Float = 0, onErrorSampleRate: Float = 0, maskAllText: Bool = true, maskAllImages: Bool = true) {
143143
self.sessionSampleRate = sessionSampleRate
144144
self.onErrorSampleRate = onErrorSampleRate
145-
self.redactAllText = redactAllText
146-
self.redactAllImages = redactAllImages
145+
self.maskAllText = maskAllText
146+
self.maskAllImages = maskAllImages
147147
}
148148

149149
convenience init(dictionary: [String: Any]) {
150150
let sessionSampleRate = (dictionary["sessionSampleRate"] as? NSNumber)?.floatValue ?? 0
151151
let onErrorSampleRate = (dictionary["errorSampleRate"] as? NSNumber)?.floatValue ?? 0
152-
let redactAllText = (dictionary["redactAllText"] as? NSNumber)?.boolValue ?? true
153-
let redactAllImages = (dictionary["redactAllImages"] as? NSNumber)?.boolValue ?? true
154-
self.init(sessionSampleRate: sessionSampleRate, onErrorSampleRate: onErrorSampleRate, redactAllText: redactAllText, redactAllImages: redactAllImages)
152+
let maskAllText = (dictionary["maskAllText"] as? NSNumber)?.boolValue ?? true
153+
let maskAllImages = (dictionary["maskAllImages"] as? NSNumber)?.boolValue ?? true
154+
self.init(sessionSampleRate: sessionSampleRate, onErrorSampleRate: onErrorSampleRate, maskAllText: maskAllText, maskAllImages: maskAllImages)
155155
}
156156
}

Sources/Swift/Protocol/SentryRedactOptions.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import Foundation
22

33
@objc
44
protocol SentryRedactOptions {
5-
var redactAllText: Bool { get }
6-
var redactAllImages: Bool { get }
7-
var redactViewClasses: [AnyClass] { get }
8-
var ignoreViewClasses: [AnyClass] { get }
5+
var maskAllText: Bool { get }
6+
var maskAllImages: Bool { get }
7+
var maskedViewClasses: [AnyClass] { get }
8+
var unmaskedViewClasses: [AnyClass] { get }
99
}

Sources/Swift/Tools/UIRedactBuilder.swift

+17-17
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,21 @@ class UIRedactBuilder {
5252

5353
- parameter options: A `SentryRedactOptions` object that specifies the configuration for the redaction process.
5454

55-
- If `options.redactAllText` is `true`, common text-related views such as `UILabel`, `UITextView`, and `UITextField` are redacted.
56-
- If `options.redactAllImages` is `true`, common image-related views such as `UIImageView` and various internal `SwiftUI` image views are redacted.
57-
- The `options.ignoreRedactViewTypes` allows specifying custom view types to be ignored during the redaction process.
58-
- The `options.redactViewTypes` allows specifying additional custom view types to be redacted.
55+
- If `options.maskAllText` is `true`, common text-related views such as `UILabel`, `UITextView`, and `UITextField` are redacted.
56+
- If `options.maskAllImages` is `true`, common image-related views such as `UIImageView` and various internal `SwiftUI` image views are redacted.
57+
- The `options.unmaskViewTypes` allows specifying custom view types to be ignored during the redaction process.
58+
- The `options.maskViewTypes` allows specifying additional custom view types to be redacted.
5959

6060
- note: On iOS, views such as `WKWebView` and `UIWebView` are automatically redacted, and controls like `UISlider` and `UISwitch` are ignored.
6161
*/
6262
init(options: SentryRedactOptions) {
6363
var redactClasses = [AnyClass]()
6464

65-
if options.redactAllText {
65+
if options.maskAllText {
6666
redactClasses += [ UILabel.self, UITextView.self, UITextField.self ]
6767
}
6868

69-
if options.redactAllImages {
69+
if options.maskAllImages {
7070
//this classes are used by SwiftUI to display images.
7171
redactClasses += ["_TtCOCV7SwiftUI11DisplayList11ViewUpdater8Platform13CGDrawingView",
7272
"_TtC7SwiftUIP33_A34643117F00277B93DEBAB70EC0697122_UIShapeHitTestingView",
@@ -89,11 +89,11 @@ class UIRedactBuilder {
8989

9090
redactClassesIdentifiers = Set(redactClasses.map({ ObjectIdentifier($0) }))
9191

92-
for type in options.ignoreViewClasses {
92+
for type in options.unmaskedViewClasses {
9393
self.ignoreClassesIdentifiers.insert(ObjectIdentifier(type))
9494
}
9595

96-
for type in options.redactViewClasses {
96+
for type in options.maskedViewClasses {
9797
self.redactClassesIdentifiers.insert(ObjectIdentifier(type))
9898
}
9999
}
@@ -133,15 +133,15 @@ class UIRedactBuilder {
133133
This function identifies and returns the regions within a given UIView that need to be redacted, based on the specified redaction options.
134134

135135
- Parameter view: The root UIView for which redaction regions are to be calculated.
136-
- Parameter options: A `SentryRedactOptions` object specifying whether to redact all text (`redactAllText`) or all images (`redactAllImages`). If `options` is nil, defaults are used (redacting all text and images).
136+
- Parameter options: A `SentryRedactOptions` object specifying whether to redact all text (`maskAllText`) or all images (`maskAllImages`). If `options` is nil, defaults are used (redacting all text and images).
137137

138138
- Returns: An array of `RedactRegion` objects representing areas of the view (and its subviews) that require redaction, based on the current visibility, opacity, and content (text or images).
139139

140140
The method recursively traverses the view hierarchy, collecting redaction areas from the view and all its subviews. Each redaction area is calculated based on the view’s presentation layer, size, transformation matrix, and other attributes.
141141

142142
The redaction process considers several key factors:
143-
1. **Text Redaction**: If `redactAllText` is set to true, regions containing text within the view or its subviews are marked for redaction.
144-
2. **Image Redaction**: If `redactAllImages` is set to true, image-containing regions are also marked for redaction.
143+
1. **Text Redaction**: If `maskAllText` is set to true, regions containing text within the view or its subviews are marked for redaction.
144+
2. **Image Redaction**: If `maskAllImages` is set to true, image-containing regions are also marked for redaction.
145145
3. **Opaque View Handling**: If an opaque view covers the entire area, obfuscating views beneath it, those hidden views are excluded from processing, and we can remove them from the result.
146146
4. **Clip Area Creation**: If a smaller opaque view blocks another view, we create a clip area to avoid drawing a redact mask on top of a view that does not require redaction.
147147

@@ -159,11 +159,11 @@ class UIRedactBuilder {
159159
}
160160

161161
private func shouldIgnore(view: UIView) -> Bool {
162-
return SentryRedactViewHelper.shouldIgnoreView(view) || containsIgnoreClass(type(of: view))
162+
return SentryRedactViewHelper.shouldUnmask(view) || containsIgnoreClass(type(of: view))
163163
}
164164

165165
private func shouldRedact(view: UIView) -> Bool {
166-
if SentryRedactViewHelper.shouldRedactView(view) {
166+
if SentryRedactViewHelper.shouldMaskView(view) {
167167
return true
168168
}
169169
if let imageView = view as? UIImageView, containsRedactClass(UIImageView.self) {
@@ -257,19 +257,19 @@ class SentryRedactViewHelper: NSObject {
257257
private static var associatedRedactObjectHandle: UInt8 = 0
258258
private static var associatedIgnoreObjectHandle: UInt8 = 0
259259

260-
static func shouldRedactView(_ view: UIView) -> Bool {
260+
static func shouldMaskView(_ view: UIView) -> Bool {
261261
(objc_getAssociatedObject(view, &associatedRedactObjectHandle) as? NSNumber)?.boolValue ?? false
262262
}
263263

264-
static func shouldIgnoreView(_ view: UIView) -> Bool {
264+
static func shouldUnmask(_ view: UIView) -> Bool {
265265
(objc_getAssociatedObject(view, &associatedIgnoreObjectHandle) as? NSNumber)?.boolValue ?? false
266266
}
267267

268-
static func redactView(_ view: UIView) {
268+
static func maskView(_ view: UIView) {
269269
objc_setAssociatedObject(view, &associatedRedactObjectHandle, true, .OBJC_ASSOCIATION_ASSIGN)
270270
}
271271

272-
static func ignoreView(_ view: UIView) {
272+
static func unmaskView(_ view: UIView) {
273273
objc_setAssociatedObject(view, &associatedIgnoreObjectHandle, true, .OBJC_ASSOCIATION_ASSIGN)
274274
}
275275
}

Tests/SentryTests/Integrations/SessionReplay/SentrySessionReplayIntegrationTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ class SentrySessionReplayIntegrationTests: XCTestCase {
288288
}
289289

290290
startSDK(sessionSampleRate: 1, errorSampleRate: 1) { options in
291-
options.experimental.sessionReplay.redactViewClasses = [AnotherLabel.self]
291+
options.experimental.sessionReplay.maskedViewClasses = [AnotherLabel.self]
292292
}
293293

294294
let sut = try getSut()
@@ -301,7 +301,7 @@ class SentrySessionReplayIntegrationTests: XCTestCase {
301301
}
302302

303303
startSDK(sessionSampleRate: 1, errorSampleRate: 1) { options in
304-
options.experimental.sessionReplay.ignoreViewClasses = [AnotherLabel.self]
304+
options.experimental.sessionReplay.unmaskedViewClasses = [AnotherLabel.self]
305305
}
306306

307307
let sut = try getSut()

Tests/SentryTests/SwiftUI/SentryRedactModifierTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class SentryRedactModifierTests: XCTestCase {
88

99
func testViewRedacted() throws {
1010
let text = Text("Hello, World!")
11-
let redactedText = text.sentryReplayRedact()
11+
let redactedText = text.sentryReplayMask()
1212

1313
XCTAssertTrue(redactedText is ModifiedContent<Text, SentryReplayModifier>)
1414
}

0 commit comments

Comments
 (0)