From c2127734c580fda69f58b82673c00383d4fd5c34 Mon Sep 17 00:00:00 2001 From: Martin Haintz Date: Mon, 25 Nov 2024 12:18:20 +0100 Subject: [PATCH 1/4] add masking options --- .../flutter/session-replay/index.mdx | 45 +----------- .../attach-screenshots/flutter.mdx | 2 + .../replay/privacy-configuration/flutter.mdx | 69 +++++++++++++++++++ 3 files changed, 72 insertions(+), 44 deletions(-) create mode 100644 platform-includes/replay/privacy-configuration/flutter.mdx diff --git a/docs/platforms/flutter/session-replay/index.mdx b/docs/platforms/flutter/session-replay/index.mdx index 8287abce67a78..a4cf68fd333f4 100644 --- a/docs/platforms/flutter/session-replay/index.mdx +++ b/docs/platforms/flutter/session-replay/index.mdx @@ -60,50 +60,7 @@ Sampling allows you to control how much of your website's traffic will result in Sampling starts as soon as a session begins. The `sessionSampleRate` is then evaluated. If the session is sampled, replay recording will start immediately. If not, `onErrorSampleRate` will be evaluated. If the session is sampled at this point, the replay will be buffered and will only be uploaded to Sentry if an error occurs. -## Privacy - -The SDK is recording and aggressively redacting (masking) all `Text`, `EditableText`, and `Image` widgets. -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. - - -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. - - -You can tune this and add custom masking rules to fit your needs by adjusting the configuration in `options.experimental.replay`. -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.experimental.replay.mask(); - options.experimental.replay.unmask(); - options.experimental.replay.maskCallback( - (Element element, Text widget) => - (widget.data?.contains('secret') ?? false) - ? SentryMaskingDecision.mask - : SentryMaskingDecision.continueProcessing); -``` - -You can find more details in the documentation for each method. - - - -If you find that data isn't being redacted 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). - - - -To disable redaction altogether (not to be used on applications with sensitive data): - -```dart - options.experimental.replay.maskAllText = false; - options.experimental.replay.maskAllImages = false; -``` + ## Error Linking diff --git a/platform-includes/enriching-events/attach-screenshots/flutter.mdx b/platform-includes/enriching-events/attach-screenshots/flutter.mdx index c17ce7d836ddf..97649f43037ab 100644 --- a/platform-includes/enriching-events/attach-screenshots/flutter.mdx +++ b/platform-includes/enriching-events/attach-screenshots/flutter.mdx @@ -13,6 +13,8 @@ await SentryFlutter.init( ); ``` + + ## Filtering Screenshots You can filter your screenshots by using the `beforeScreenshot` callback, which is called before attaching a screenshot to an event. By default, the callback returns `true` which means that all screenshots are attached. diff --git a/platform-includes/replay/privacy-configuration/flutter.mdx b/platform-includes/replay/privacy-configuration/flutter.mdx new file mode 100644 index 0000000000000..2932c3517022c --- /dev/null +++ b/platform-includes/replay/privacy-configuration/flutter.mdx @@ -0,0 +1,69 @@ +## Privacy + + + +Setting these parameter will affect `masking` for `screenshot` and `session replay`. + + + +###### By default, `masking` is disabled for `screenshot` and enabled for `session replay`. + +By default, for `session replay` the SDK is recording and aggressively redacting (masking) all `Text`, `EditableText`, and `Image` widgets. +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. + + +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. + + + +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(); + options.privacy.unmask(); + options.privacy.maskCallback( + (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()` + +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. + + + +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). + + + +To disable masking for `screenshot` and `session replay` (not to be used on applications with sensitive data): + +```dart + options.experimental.privacy.maskAllText = false; + options.experimental.privacy.maskAllImages = false; +``` From 8f7b00b1c21de5fac239ec5fc6b8afc56d47b0bf Mon Sep 17 00:00:00 2001 From: Martin Haintz Date: Mon, 25 Nov 2024 12:33:35 +0100 Subject: [PATCH 2/4] minor arrangement changes --- .../replay/privacy-configuration/flutter.mdx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/platform-includes/replay/privacy-configuration/flutter.mdx b/platform-includes/replay/privacy-configuration/flutter.mdx index 2932c3517022c..2ac2088765a39 100644 --- a/platform-includes/replay/privacy-configuration/flutter.mdx +++ b/platform-includes/replay/privacy-configuration/flutter.mdx @@ -1,14 +1,18 @@ ## Privacy + + Setting these parameter will affect `masking` for{" "} + `Screenshots`{" "} + and `Session Replay`. + - -Setting these parameter will affect `masking` for `screenshot` and `session replay`. - + By default, `masking` is disabled for{" "} + `Screenshots`{" "} + and enabled for{" "} + `Session Replay` -###### By default, `masking` is disabled for `screenshot` and enabled for `session replay`. - -By default, for `session replay` the SDK is recording and aggressively redacting (masking) all `Text`, `EditableText`, and `Image` widgets. +By default, the SDK is recording and aggressively redacting (masking) all `Text`, `EditableText`, and `Image` widgets for `Session Replay`. 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. @@ -61,7 +65,7 @@ If you find that data isn't being masked with the default settings, please let u -To disable masking for `screenshot` and `session replay` (not to be used on applications with sensitive data): +To disable masking for `Screenshots` and `Session Replay` (not to be used on applications with sensitive data): ```dart options.experimental.privacy.maskAllText = false; From c301cee169020cdc18c4438602b6aa755e9d836d Mon Sep 17 00:00:00 2001 From: Martin Haintz Date: Wed, 27 Nov 2024 14:10:51 +0100 Subject: [PATCH 3/4] add specific intro for screenshot and session replay --- docs/platforms/flutter/session-replay/index.mdx | 10 ++++++++++ .../attach-screenshots/flutter.mdx | 9 +++++++++ .../replay/privacy-configuration/flutter.mdx | 15 --------------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/docs/platforms/flutter/session-replay/index.mdx b/docs/platforms/flutter/session-replay/index.mdx index a4cf68fd333f4..f6fd8f9c55d26 100644 --- a/docs/platforms/flutter/session-replay/index.mdx +++ b/docs/platforms/flutter/session-replay/index.mdx @@ -60,6 +60,16 @@ Sampling allows you to control how much of your website's traffic will result in Sampling starts as soon as a session begins. The `sessionSampleRate` is then evaluated. If the session is sampled, replay recording will start immediately. If not, `onErrorSampleRate` will be evaluated. If the session is sampled at this point, the replay will be buffered and will only be uploaded to Sentry if an error occurs. +## Redact Session Replay via `masking` + +By default, the SDK is recording and aggressively redacting (masking) all `Text`, `EditableText`, and `Image` widgets for `Session Replay`. To modify or disable this beahvior, use the `options.experimental.privacy` parameter. + + + Modifying this parameter will also affect `masking` for + `Screenshots` + . + + ## Error Linking diff --git a/platform-includes/enriching-events/attach-screenshots/flutter.mdx b/platform-includes/enriching-events/attach-screenshots/flutter.mdx index 97649f43037ab..33d9c37ccd1b0 100644 --- a/platform-includes/enriching-events/attach-screenshots/flutter.mdx +++ b/platform-includes/enriching-events/attach-screenshots/flutter.mdx @@ -13,6 +13,15 @@ await SentryFlutter.init( ); ``` +## Redact Screenshots via `masking` + +The masking feature is by default disabled for Screenshots. To enable masking, use the `options.experimental.privacy` parameter. + + + Modifying this parameter will also affect `masking` for{" "} + `Session Replay`. + + ## Filtering Screenshots diff --git a/platform-includes/replay/privacy-configuration/flutter.mdx b/platform-includes/replay/privacy-configuration/flutter.mdx index 2ac2088765a39..472a97f2ca825 100644 --- a/platform-includes/replay/privacy-configuration/flutter.mdx +++ b/platform-includes/replay/privacy-configuration/flutter.mdx @@ -1,18 +1,3 @@ -## Privacy - - - Setting these parameter will affect `masking` for{" "} - `Screenshots`{" "} - and `Session Replay`. - - - By default, `masking` is disabled for{" "} - `Screenshots`{" "} - and enabled for{" "} - `Session Replay` - - -By default, the SDK is recording and aggressively redacting (masking) all `Text`, `EditableText`, and `Image` widgets for `Session Replay`. 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. From 589cb2ce32e7ae52bc735f073a523fc04469933c Mon Sep 17 00:00:00 2001 From: Martin Haintz Date: Mon, 9 Dec 2024 10:12:02 +0100 Subject: [PATCH 4/4] Update docs/platforms/flutter/session-replay/index.mdx Co-authored-by: Ivan Dlugos <6349682+vaind@users.noreply.github.com> --- docs/platforms/flutter/session-replay/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/flutter/session-replay/index.mdx b/docs/platforms/flutter/session-replay/index.mdx index 2baf55c4f9b6f..d7a2594414f74 100644 --- a/docs/platforms/flutter/session-replay/index.mdx +++ b/docs/platforms/flutter/session-replay/index.mdx @@ -59,7 +59,7 @@ Sampling starts as soon as a session begins. The `sessionSampleRate` is then eva ## Redact Session Replay via `masking` -By default, the SDK is recording and aggressively redacting (masking) all `Text`, `EditableText`, and `Image` widgets for `Session Replay`. To modify or disable this beahvior, use the `options.experimental.privacy` parameter. +By default, the SDK is recording and aggressively redacting (masking) all `Text`, `EditableText`, and `Image` widgets for `Session Replay`. To modify or disable this behavior, use the `options.experimental.privacy` parameter. Modifying this parameter will also affect `masking` for