-
-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Add custom redact modifier for SwiftUI (#4362)
Added a SwiftUI modifier that allows the dev to choose with part of the View they want redacted during replay
- Loading branch information
Showing
8 changed files
with
126 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#if canImport(SwiftUI) && canImport(UIKit) && os(iOS) || os(tvOS) | ||
import Sentry | ||
import SwiftUI | ||
import UIKit | ||
|
||
@available(iOS 13, macOS 10.15, tvOS 13, *) | ||
struct SentryReplayView: UIViewRepresentable { | ||
class SentryRedactView: UIView { | ||
} | ||
|
||
func makeUIView(context: Context) -> UIView { | ||
let result = SentryRedactView() | ||
result.sentryReplayRedact() | ||
return result | ||
} | ||
|
||
func updateUIView(_ uiView: UIView, context: Context) { | ||
// This is blank on purpose. UIViewRepresentable requires this function. | ||
} | ||
} | ||
|
||
@available(iOS 13, macOS 10.15, tvOS 13, *) | ||
struct SentryReplayModifier: ViewModifier { | ||
func body(content: Content) -> some View { | ||
content.background(SentryReplayView()) | ||
} | ||
} | ||
|
||
@available(iOS 13, macOS 10.15, tvOS 13, *) | ||
public extension View { | ||
|
||
/// Marks the view as containing sensitive information that should be redacted during replays. | ||
/// | ||
/// When this modifier is applied, any sensitive content within the view will be hidden or masked | ||
/// during session replays to ensure user privacy. This is useful for views containing personal | ||
/// data or confidential information that shouldn't be visible when the replay is reviewed. | ||
/// | ||
/// - Returns: A modifier that redacts sensitive information during session replays. | ||
/// - Experiment: This is an experimental feature and may still have bugs. | ||
func sentryReplayRedact() -> some View { | ||
modifier(SentryReplayModifier()) | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.