Skip to content

Commit e6ad883

Browse files
buenaflorjas-kas
authored andcommitted
replay(flutter): Update setup configuration and privacy configuration (#13982)
Makes it clearer how to set up to get additional data such as network details and how to use it with third party widgets --------- Co-authored-by: Jasmin <77064737+jas-kas@users.noreply.github.com>
1 parent 6d6bd67 commit e6ad883

File tree

4 files changed

+74
-36
lines changed

4 files changed

+74
-36
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: Configuration
3+
sidebar_order: 4100
4+
notSupported:
5+
description: "Learn about the general Session Replay configuration fields."
6+
---
7+
8+
## General Integration Configuration
9+
10+
The following options can be configured in the `options.replay` field of your Sentry Flutter SDK, in `SentryFlutter.init((options) { ... })`:
11+
12+
13+
| Key | Type | Default | Description |
14+
| ------------------------ | -------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
15+
| sessionSampleRate | `double` | `0` | The sample rate for replays that begin recording immediately and last the entirety of the user's session. `1.0` collects all replays, and `0` collects none. |
16+
| onErrorSampleRate | `double` | `0` | The sample rate for replays that are recorded when an error happens. This type of replay will record up to a minute of events prior to the error and continue recording until the session ends. `1.0` captures all sessions with an error, and `0` captures none. |
17+
| quality | [SentryReplayQuality](https://pub.dev/documentation/sentry_flutter/latest/sentry_flutter/SentryReplayQuality.html) | `SentryReplayQuality.medium` | Defines the image quality of the session replay. The higher the quality, the more accurate the replay will be, but also more data to transfer and more CPU load. |
18+
19+
## Configure Network Details
20+
21+
In order to capture basic information about network requests, you need to use our Sentry integrations for the HTTP client you are using.
22+
This allows the Sentry instrumented HTTP client to capture network details during your replay.
23+
24+
- [Dio](/platforms/dart/integrations/dio/)
25+
- [HTTP](/platforms/dart/integrations/http-integration/)
26+
27+
## Configure Screen Names and Navigation Details
28+
29+
In order to capture screen names and navigation breadcrumbs, you need to add our `SentryNavigatorObserver` to your application's `navigatorObservers` and define route names when you navigate to a new screen.
30+
31+
Read more about how to configure the `SentryNavigatorObserver` in our [Routing Instrumentation](/platforms/dart/guides/flutter/integrations/routing-instrumentation/#configure) guide.
32+
33+
## Configure User Interactions
34+
35+
In order to capture user interaction breadcrumbs such as button taps, you need to wrap your root widget with `SentryWidget` and define unique keys for your buttons.
36+
37+
Read more about how to set up user interactions in our [User Interaction Instrumentation](/platforms/dart/guides/flutter/integrations/user-interaction-instrumentation/) guide.

docs/platforms/dart/guides/flutter/session-replay/index.mdx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ By default, our Session Replay SDK masks all text content, images, and user inpu
1818

1919
## Pre-requisites
2020

21-
Make sure your Sentry Flutter SDK version is at least 9.0.0, which is required for Session Replay.
21+
Make sure your Sentry Flutter SDK version is at least `9.0.0`, which is required for Session Replay.
2222
You can update your `pubspec.yaml` to the matching version:
2323

2424
```yaml
@@ -33,6 +33,7 @@ To set up replay, enable it by setting a non-zero sample rate and wrapping your
3333
```dart
3434
await SentryFlutter.init(
3535
(options) {
36+
options.dsn = '__DSN__';
3637
options.replay.sessionSampleRate = 1.0;
3738
options.replay.onErrorSampleRate = 1.0;
3839
},
@@ -60,17 +61,13 @@ Sampling allows you to control how much of your website's traffic will result in
6061

6162
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.
6263

63-
## Redact Session Replay via `masking`
64+
## PII & Privacy Considerations
6465

65-
By default, the SDK is recording and aggressively redacting (masking) all `Text`, `EditableText`, and `Image` widgets for <PlatformLink to="/session-replay/">`Session Replay`</PlatformLink>. To modify or disable this behavior, use the `options.privacy` parameter.
66+
Personally identifiable information (PII), and privacy are important considerations when enabling Session Replay. The Sentry Flutter SDK aggressively masks all `Text`, `EditableText`, `RichText` and `Image` widgets by default.
6667

67-
<Alert level="warning">
68-
Modifying this parameter will also affect `masking` for
69-
<PlatformLink to="/enriching-events/screenshots/">`Screenshots`</PlatformLink>
70-
.
71-
</Alert>
72-
73-
<PlatformContent includePath="replay/privacy-configuration" />
68+
While we have default privacy considerations in place, there are additional settings you might need to configure to fully mask your app's content.
69+
We cannot detect the usage of third party widgets such as [FlutterMap](https://pub.dev/packages/flutter_map) so you need to manually configure the privacy configuration to mask the content of these widgets.
70+
To learn more about session replay privacy, [read our docs.](/platforms/dart/guides/flutter/session-replay/privacy/)
7471

7572
## Error Linking
7673

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: Privacy
3+
sidebar_order: 4200
4+
notSupported:
5+
description: "Learn about the privacy-oriented settings for Session Replay."
6+
---
7+
8+
<PlatformContent includePath="replay/privacy-configuration" />
Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
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
22
a `widgetInstance` should be masked by checking `if (widgetInstance is Image)` instead of `if (widgetInstance.runtimeType == 'Image')`).
33
This means we can ensure masking works regardless of obfuscation in release builds and also works for subclasses.
4-
However, it also means we can only automatically mask widgets that are part of the Flutter SDK itself.
4+
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](#third-party-widgets) below.
55

6-
<Alert level="warning">
7-
We cannot mask widgets defined in various 3rd-party packages (because the type is not known in the Sentry Flutter SDK),
8-
even though many should be masked.
6+
## Privacy Configuration
97

10-
Therefore, you need to consider the widgets your application uses and ensure they're masked correctly with custom masking rules.
11-
Examples of widgets that usually should be masked include (but are not limited to): VideoPlayer, WebView, Chart, etc.
8+
The following options can be configured in the `options.privacy` field of your Sentry Flutter SDK, in `SentryFlutter.init((options) { ... })`:
129

13-
</Alert>
10+
| Key | Type | Default | Description |
11+
| ------------------------ | -------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
12+
| 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. |
13+
| 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. |
14+
| maskAssetImages | `bool` | `true` | Mask asset images coming from the root asset bundle. |
15+
| mask&lt;T extends Widget&gt;() | `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. |
16+
| unmask&lt;T extends Widget&gt;() | `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. |
17+
| maskCallback&lt;T extends Widget&gt;() | `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. |
1418

15-
You can tune this and add custom masking rules to fit your needs by adjusting the configuration in `options.privacy`.
1619
For example, you can explicitly mask or unmask widgets by type,
1720
or you can even have a callback to decide whether a specific widget instance should be masked:
1821

@@ -26,24 +29,6 @@ options.privacy.maskCallback<Text>(
2629
: SentryMaskingDecision.continueProcessing);
2730
```
2831

29-
### `maskAllText`
30-
31-
Mask all text content. Draws a rectangle of text bounds with text color on top. Currently, only `Text` and `EditableText` Widgets are masked.
32-
33-
### `maskAllImages`
34-
35-
Mask content of all images. Draws a rectangle of image bounds with image's dominant color on top. Currently, only `Image` widgets are masked.
36-
37-
### `maskAssetImages`
38-
39-
Mask asset images coming from the root asset bundle.
40-
41-
### `mask<T extends Widget>()`
42-
43-
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.
44-
45-
You can find more details in the documentation for each method.
46-
4732
<Alert>
4833

4934
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).
@@ -56,3 +41,14 @@ To disable masking for <PlatformLink to="/enriching-events/screenshots/">`Screen
5641
options.privacy.maskAllText = false;
5742
options.privacy.maskAllImages = false;
5843
```
44+
45+
## Third Party Widgets
46+
47+
The Sentry Flutter SDK cannot automatically mask widgets from third party packages.
48+
You need to manually configure the privacy configuration to mask the content of these widgets.
49+
50+
For example, if you are using the [FlutterMap](https://pub.dev/packages/flutter_map) package, you need to add the following privacy configuration:
51+
52+
```dart
53+
options.privacy.mask<FlutterMap>();
54+
```

0 commit comments

Comments
 (0)