-
-
Notifications
You must be signed in to change notification settings - Fork 445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR] Add custom redaction options #3689
Merged
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2107b0c
Correctly infer text color for RN views
romtsn bee9697
Fix
romtsn a76e223
Add tests
romtsn 91e86ba
Formatting
romtsn c46fcc0
Changelog
romtsn 6e23fe5
wip
romtsn 3d5e837
Add custom redaction logic
romtsn 5727f28
Merge branch 'main' into rz/feat/session-replay-custom-redaction
romtsn fe15f79
revert
romtsn a660793
Add tests
romtsn e4ec640
Changelog
romtsn f434c56
redactClasses -> redactViewClasses
romtsn 504e855
Merge branch 'main' into rz/feat/session-replay-custom-redaction
romtsn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
31 changes: 31 additions & 0 deletions
31
sentry-android-replay/src/main/java/io/sentry/android/replay/SessionReplayOptions.kt
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,31 @@ | ||
package io.sentry.android.replay | ||
|
||
import io.sentry.SentryReplayOptions | ||
|
||
// since we don't have getters for redactAllText and redactAllImages, they won't be accessible as | ||
// properties in Kotlin, therefore we create these extensions where a getter is dummy, but a setter | ||
// delegates to the corresponding method in SentryReplayOptions | ||
|
||
/** | ||
* Redact all text content. Draws a rectangle of text bounds with text color on top. By default | ||
* only views extending TextView are redacted. | ||
* | ||
* <p>Default is enabled. | ||
*/ | ||
var SentryReplayOptions.redactAllText: Boolean | ||
@Deprecated("Getter is unsupported.", level = DeprecationLevel.ERROR) | ||
get() = error("Getter not supported") | ||
set(value) = setRedactAllText(value) | ||
|
||
/** | ||
* Redact all image content. Draws a rectangle of image bounds with image's dominant color on top. | ||
* By default only views extending ImageView with BitmapDrawable or custom Drawable type are | ||
* redacted. ColorDrawable, InsetDrawable, VectorDrawable are all considered non-PII, as they come | ||
* from the apk. | ||
* | ||
* <p>Default is enabled. | ||
*/ | ||
var SentryReplayOptions.redactAllImages: Boolean | ||
@Deprecated("Getter is unsupported.", level = DeprecationLevel.ERROR) | ||
get() = error("Getter not supported") | ||
set(value) = setRedactAllImages(value) |
18 changes: 18 additions & 0 deletions
18
sentry-android-replay/src/main/java/io/sentry/android/replay/ViewExtensions.kt
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,18 @@ | ||
package io.sentry.android.replay | ||
|
||
import android.view.View | ||
|
||
/** | ||
* Marks this view to be redacted in session replay. | ||
*/ | ||
fun View.sentryReplayRedact() { | ||
setTag(R.id.sentry_privacy, "redact") | ||
} | ||
|
||
/** | ||
* Marks this view to be ignored from redaction in session. | ||
* All its content will be visible in the replay, use with caution. | ||
*/ | ||
fun View.sentryReplayIgnore() { | ||
setTag(R.id.sentry_privacy, "ignore") | ||
} |
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 was deleted.
Oops, something went wrong.
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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<public name="sentry_privacy" type="id"/> | ||
<item name="sentry_privacy" type="id" format="string"/> | ||
</resources> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: Why is this deprecated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I explained in a comment on top of the file, but basically we scream to the dev that this should not be used to get the value. This extension only exists to set the value conveniently in Kotlin (
redactAllText = true
instead ofsetRedactAllText(true)
), so only the setter matters hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!! I didn't get the comment.
Can you just remove
get()
as in C# where you can have a property with just a setter?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, unfortunately not possible in Kotlin. It's possible to only have a getter without a setter, but not the other way around