Skip to content
Merged
27 changes: 27 additions & 0 deletions docs/platforms/dart/common/feature-flags/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: Set Up Feature Flags
sidebar_order: 7000
description: With Feature Flags, Sentry tracks feature flag evaluations in your application, keeps an audit log feature flag changes, and reports any suspicious updates that may have caused an error.
---

<PlatformContent includePath="feature-flags/prerelease-alert" />

## Prerequisites

- [Sentry SDK](/platforms/dart/#configure) version `9.0.0` or higher is installed.

## Enable Evaluation Tracking

If you use a third-party SDK to evaluate feature flags, you can enable a Sentry SDK integration to track those evaluations. Integrations are provider specific. Documentation for supported SDKs is listed below.

- [Firebase Remote Config](/platforms/dart/configuration/integrations/firebase-remote-config/)

### Manual Usage

Call `Sentry.addFeatureFlag` to track feature flag evaluations.

```dart
Sentry.addFeatureFlag("feature_flag_a", true);
```

Calling this function multiple times with the same flag name will override the previous value.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Firebase Remote Config
description: "Learn more about the Sentry Firebase Remote Config integration for the Dart SDK."
sidebar_order: 50
redirect_from:
- /platforms/dart/guides/firebase-remote-config/
---

<Include name="dart-integrations/firebase-remote-config.mdx" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Firebase Remote Config
description: "Learn more about the Sentry Firebase Remote Config integration for the Flutter SDK."
sidebar_order: 60
redirect_from:
- /platforms/dart/guides/flutter/firebase-remote-config/
---

<Include name="dart-integrations/firebase-remote-config.mdx" />
59 changes: 59 additions & 0 deletions includes/dart-integrations/firebase-remote-config.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
title: Firebase Remote Config
description: "Learn more about the Sentry Firebase Remote Config integration for the Dart SDK."
sidebar_order: 6
platforms:
- flutter
---

The `sentry_firebase_remote_config` integration provides [Firebase Remote Config](https://firebase.google.com/docs/remote-config/get-started?platform=flutter) support for Sentry thus providing insight into feature flag evaluations.

## Behavior

- Adding the `SentryFirebaseRemoteConfig` integration will automatically track feature flag evaluations.
- Only boolean values are supported.

## Prerequisites

1. [Sentry SDK](/platforms/dart/#configure) version `9.0.0` or higher is installed.
2. Firebase Remote Config is set up.

## Install

To use the `SentryFirebaseRemoteConfig` integration, add the `sentry_firebase_remote_config` dependency.

```yml {filename:pubspec.yaml}
dependencies:
sentry: ^9.0.0
sentry_firebase_remote_config: ^9.0.0
```

## Configure

Add the `SentryFirebaseRemoteConfig` integration to the Sentry SDK initialization. The integration will automatically call `await remoteConfig.activate();` when the config is updated.
If you don't want this behavior, you can set `activateOnConfigUpdated` to `false`.

```dart
await SentryFlutter.init(
(options) {
options.addIntegration(
SentryFirebaseRemoteConfigIntegration(
firebaseRemoteConfig: firebaseRemoteConfig,
activateOnConfigUpdated: false,
),
);
},
);
```

## Verify & View

### 1. Update Firebase Remote Config value

Update a boolean [Firebase Remote Config](https://firebase.google.com/docs/remote-config/get-started?platform=flutter) value to true. Keep in mind that values will be evaluated as bool if there string values are `true`, `false`, `1`, or `0`. So keep in mind that numerical values of `1` or `0` will be evaluated as `true` or `false` boolean values.

### 2. View the Recorded Feature Flag Evaluation on Sentry.io

To view the recorded feature flag evaluation, log into [sentry.io](https://sentry.io) and open your project.

The recorded feature flag evaluations will be visible in the event context.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One note for the future: We don't support change tracking for Firebase yet.
But once we do, we'll add it to here: https://docs.sentry.io/product/issues/issue-details/feature-flags/#change-tracking

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bruno can you clarify - is the wording in the PR ok? because while change tracking is not there, this paragraph talks about evaluation tracking

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was just a note for the future. But that makes sense, thanks for pointing out.

It turns out it's not super easy to add Firebase support either and might require the customer to add some firebase lambda in order to call our tracking endpoint. @michellewzhang wrote about it here: https://www.notion.so/sentry/firebase-feature-flag-webhook-1e38b10e4b5d805fb057d2e990ea45e8

I wonder if this is something @aliu39 might be keen to tackle in the future though.

2 changes: 1 addition & 1 deletion includes/dart-integrations/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
| [`Slow and Frozen Frames`](/platforms/dart/guides/flutter/integrations/slow-and-frozen-frames-instrumentation) | ✓ * | | ✓ | |
| [`Sqflite`](/platforms/dart/guides/flutter/integrations/sqflite-instrumentation) | | | ✓ | |
| [`User Interaction`](/platforms/dart/guides/flutter/integrations/user-interaction-instrumentation) | | | ✓ | ✓ |

| [`Firebase Remote Config`](/platforms/dart/guides/flutter/integrations/firebase-remote-config) | | | | ✓ |
<Alert>

*Slow and Frozen Frames* should work automatically, however if `WidgetsFlutterBinding` is initialized before `SentryFlutter.init`, then this instrumentation will not work automatically.
Expand Down
4 changes: 4 additions & 0 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,10 @@ const USER_DOCS_REDIRECTS: Redirect[] = [
from: '/platforms/dart/configuration/integrations/dio/',
to: '/platforms/dart/integrations/dio/',
},
{
from: '/platforms/dart/configuration/integrations/firebase-remote-config/',
to: '/platforms/dart/integrations/firebase-remote-config/',
},
{
from: '/quickstart/',
to: '/platforms/',
Expand Down
Loading