-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(flutter): update screenshots and session replay with masking options #11930
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
Merged
martinhaintz
merged 5 commits into
master
from
martinhaintz/redact-screenshots-via-view-hierarchy
Dec 9, 2024
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c212773
add masking options
mar-hai 8f7b00b
minor arrangement changes
mar-hai c301cee
add specific intro for screenshot and session replay
mar-hai a6383e4
Merge branch 'master' into martinhaintz/redact-screenshots-via-view-h…
mar-hai 589cb2c
Update docs/platforms/flutter/session-replay/index.mdx
martinhaintz 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 hidden or 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 hidden or 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
73 changes: 73 additions & 0 deletions
73
platform-includes/replay/privacy-configuration/flutter.mdx
This file contains hidden or 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,73 @@ | ||
| ## Privacy | ||
|
|
||
| <Alert level="warning"> | ||
| Setting these parameter will affect `masking` for{" "} | ||
| <PlatformLink to="/enriching-events/screenshots/">`Screenshots`</PlatformLink>{" "} | ||
| and <PlatformLink to="/session-replay/">`Session Replay`</PlatformLink>. | ||
| </Alert> | ||
| <Note> | ||
| By default, `masking` is disabled for{" "} | ||
| <PlatformLink to="/enriching-events/screenshots/">`Screenshots`</PlatformLink>{" "} | ||
| and enabled for{" "} | ||
| <PlatformLink to="/session-replay/">`Session Replay`</PlatformLink> | ||
| </Note> | ||
|
|
||
| By default, the SDK is recording and aggressively redacting (masking) all `Text`, `EditableText`, and `Image` widgets for <PlatformLink to="/session-replay/">`Session Replay`</PlatformLink>. | ||
| Masking in the Sentry Flutter SDK is based on Widget _types_, e.g. `Image`, not the string representation of the type (i.e. we check whether | ||
| a `widgetInstance` should be masked by checking `if (widgetInstance is Image)` instead of `if (widgetInstance.runtimeType == 'Image')`). | ||
| This means we can ensure masking works regardless of obfuscation in release builds and also works for subclasses. | ||
| However, it also means we can only automatically mask widgets that are part of the Flutter SDK itself. | ||
|
|
||
| <Alert level="warning"> | ||
| We cannot mask widgets defined in various 3rd-party packages (because the type is not known in the Sentry Flutter SDK), | ||
| even though many should be masked. | ||
|
|
||
| Therefore, you need to consider the widgets your application uses and ensure they're masked correctly with custom masking rules. | ||
| Examples of widgets that usually should be masked include (but are not limited to): VideoPlayer, WebView, Chart, etc. | ||
|
|
||
| </Alert> | ||
|
|
||
| You can tune this and add custom masking rules to fit your needs by adjusting the configuration in `options.experimental.privacy`. | ||
| For example, you can explicitly mask or unmask widgets by type, | ||
| or you can even have a callback to decide whether a specific widget instance should be masked: | ||
|
|
||
| ```dart | ||
| options.privacy.mask<IconButton>(); | ||
| options.privacy.unmask<Image>(); | ||
| options.privacy.maskCallback<Text>( | ||
| (Element element, Text widget) => | ||
| (widget.data?.contains('secret') ?? false) | ||
| ? SentryMaskingDecision.mask | ||
| : SentryMaskingDecision.continueProcessing); | ||
| ``` | ||
|
|
||
| ### `maskAllText` | ||
|
|
||
| Mask all text content. Draws a rectangle of text bounds with text color on top. Currently, only `Text` and `EditableText` Widgets are masked. | ||
|
|
||
| ### `maskAllImages` | ||
|
|
||
| Mask content of all images. Draws a rectangle of image bounds with image's dominant color on top. Currently, only `Image` widgets are masked. | ||
|
|
||
| ### `maskAssetImages` | ||
|
|
||
| Mask asset images coming from the root asset bundle. | ||
|
|
||
| ### `mask<T extends Widget>()` | ||
|
|
||
| Mask given widget type `T` (or subclasses of `T`) in the screenshot. Note: masking rules are called in the order they're added so if a previous rule already makes a decision, this rule won't be called. | ||
|
|
||
| You can find more details in the documentation for each method. | ||
|
|
||
| <Note> | ||
|
|
||
| If you find that data isn't being masked with the default settings, please let us know by creating a [GitHub issue](https://github.com/getsentry/sentry-dart/issues/new?template=BUG_REPORT.yml). | ||
|
|
||
| </Note> | ||
|
|
||
| To disable masking for <PlatformLink to="/enriching-events/screenshots/">`Screenshots`</PlatformLink> and <PlatformLink to="/session-replay/">`Session Replay`</PlatformLink> (not to be used on applications with sensitive data): | ||
|
|
||
| ```dart | ||
| options.experimental.privacy.maskAllText = false; | ||
| options.experimental.privacy.maskAllImages = false; | ||
| ``` |
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.
Uh oh!
There was an error while loading. Please reload this page.