---
title: "Privacy"
description: "Learn about the privacy-oriented settings for Session Replay."
url: https://docs.sentry.io/platforms/dart/guides/flutter/session-replay/privacy/
---

# Privacy for Flutter

Before enabling Session Replay in production, verify your masking configuration to ensure no sensitive data is captured. Our default settings aggressively mask potentially sensitive data, but if you modify these settings or update UI frameworks or system SDKs, you must thoroughly test your application. If you find any masking issues or sensitive data that should be masked but isn't, please [create a GitHub issue](https://github.com/getsentry/sentry-dart/issues/new/choose) and avoid deploying to production with Session Replay enabled until the issue is resolved.

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. This approach allows the SDK to automatically mask widgets that are part of the Flutter SDK itself. However, for third-party widgets, you need to manually configure the privacy settings to mask their content. Read more about [Third Party Widgets](https://docs.sentry.io/platforms/dart/guides/flutter/session-replay/privacy.md#third-party-widgets) below.

## [Privacy Configuration](https://docs.sentry.io/platforms/dart/guides/flutter/session-replay/privacy.md#privacy-configuration)

The following options can be configured in the `options.privacy` field of your Sentry Flutter SDK, in `SentryFlutter.init((options) { ... })`:

| Key                               | Type   | Default | Description                                                                                                                                                                                                                              |
| --------------------------------- | ------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| maskAllText                       | `bool` | `true`  | Mask all text content. Draws a rectangle of text bounds with text color on top. Currently `Text`, `EditableText` and `RichText` widgets are masked.                                                                                      |
| maskAllImages                     | `bool` | `true`  | Mask content of all images. Draws a rectangle of image bounds with image's dominant color on top. Currently `Image` widgets are masked.                                                                                                  |
| maskAssetImages                   | `bool` | `false` | Mask asset images coming from the root asset bundle.                                                                                                                                                                                     |
| mask\<T extends Widget>()         | `void` | /       | Mask given widget type `T` (or subclasses of `T`). 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.                                                  |
| unmask\<T extends Widget>()       | `void` | /       | Unmask given widget type `T` (or subclasses of `T`). 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.                                                |
| maskCallback\<T extends Widget>() | `void` | /       | Provide a custom callback to decide whether to mask the widget of class `T` (or subclasses of `T`). 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. |

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);
```

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 the default text and image masking rules for screenshots and Session Replay, use the following options. This does not disable `SensitiveContent` masking, `SentryMask`, or custom rules. Only use these settings when the content is safe to capture:

```dart
options.privacy.maskAllText = false;
options.privacy.maskAllImages = false;
```

## [SensitiveContent Widgets](https://docs.sentry.io/platforms/dart/guides/flutter/session-replay/privacy.md#sensitivecontent-widgets)

The default rules mask Flutter `SensitiveContent` widgets marked `ContentSensitivity.sensitive` or `ContentSensitivity.autoSensitive`. Unrecognized sensitivity values are also masked. `ContentSensitivity.notSensitive` continues through other masking rules; it does not unmask the content by itself.

These rules apply to both screenshots and Session Replay. Custom rules and `SentryUnmask` take precedence over the default rules, so verify your configuration if you override masking.

## [Third Party Widgets](https://docs.sentry.io/platforms/dart/guides/flutter/session-replay/privacy.md#third-party-widgets)

The Sentry Flutter SDK cannot automatically mask widgets from third party packages. You need to manually configure the privacy configuration to mask the content of these widgets.

For example, if you are using the [FlutterMap](https://pub.dev/packages/flutter_map) package, you need to add the following privacy configuration:

```dart
options.privacy.mask<FlutterMap>();
```
