This LaunchDarkly observability plugin is currently available in Early Access, and APIs are subject to change until a 1.x version is released.
This topic documents how to get started with the LaunchDarkly observability plugin for the Flutter SDK.
The launchdarkly_flutter_observability package provides error monitoring, logging, tracing, and session replay through a single public facade named LDObserve.
LaunchDarkly SDKs are open source. In addition to this reference guide, we provide source, API reference documentation, and a sample application:
This reference guide assumes you are familiar with the LaunchDarkly Flutter SDK.
The observability plugin requires the LaunchDarkly Flutter SDK version 4.17.0 or later.
The Flutter observability plugin is compatible with iOS, Android, and web platforms. Session replay is supported only on iOS and Android. Web session replay is not yet available.
Follow these steps to get started:
Add both the LaunchDarkly Flutter SDK and the observability package to your pubspec.yaml:
Then run:
For iOS, install the native pod dependencies from your app’s ios/ directory:
No extra setup is required for Android. Gradle resolves the plugin automatically.
After you install the dependencies, import the packages into your code:
To initialize, you need your LaunchDarkly environment’s mobile key. This authorizes your application to connect to a particular environment within LaunchDarkly. To learn more, read Initialize the client in the Flutter SDK reference guide.
The Flutter observability SDK uses a mobile key for iOS and Android builds. For web builds, use a client-side ID instead. Keys are specific to each project and environment. They are available on the SDK keys page under Settings. To learn more about key types, read Keys.
Mobile keys are not secret and you can expose them in your client-side code without risk. However, never embed a server-side SDK key into a client-side application.
There are two initialization variants. Use LDObserve.init if you are using the LaunchDarkly client, or LDObserve.initStandalone to initialize without a client.
Pass your LDClient to LDObserve.init. This registers the observability plugin on the client so feature flag evaluations are correlated with your telemetry:
To initialize without creating a LaunchDarkly client, pass your mobile key directly to LDObserve.initStandalone:
Pass an ObservabilityOptions object to LDObserve.init or LDObserve.initStandalone to configure observability behavior:
These ObservabilityOptions configuration options are available on all platforms:
true."observability-flutter"."0.1.0".InstrumentationOptions object that controls automatic instrumentation. To learn more, read Instrumentation options.https://otel.observability.app.launchdarkly.com:4318. You do not need to change this for most configurations.https://pub.observability.app.launchdarkly.com. You do not need to change this for most configurations.The following ObservabilityOptions configuration options are available only on Android and iOS:
{}.ObservabilityLogLevel.none to disable logs. Defaults to ObservabilityLogLevel.info.TracesOptions object that controls automatic trace generation. Toggles includeErrors and includeSpans. Both default to true.true.ProductAnalyticsOptions object that controls telemetry for product analytics events:
false.true.track(). Defaults to true.
To learn more, read Product analytics events.For more information on plugin options, read Configuration for client-side observability.
The InstrumentationOptions class controls which automatic instrumentation features are active. Pass it to the instrumentation parameter of ObservabilityOptions.
These instrumentation options are available on all platforms:
true, automatically instruments HTTP network requests. Defaults to true.true, measures and reports application launch time. Defaults to true.debugPrint calls are automatically captured as log events:
DebugPrintSetting.releaseOnly() (the default) captures debugPrint calls only in release builds.DebugPrintSetting.always() captures debugPrint calls in all build configurations. When enabled, debugPrint output does not appear in the Flutter console.DebugPrintSetting.disabled() does not instrument debugPrint.The following InstrumentationOptions configuration option is available only on Android and iOS:
true, reports uncaught exceptions as errors. Defaults to true.To capture the output from print statements, pass LDObserve.zoneSpecification() to runZonedGuarded:
Use contextFriendlyName to set a human-readable display name for the user’s session when displayed in the observability User Interface (UI):
Session replay for Flutter is available in Early Access. APIs are subject to change until a 1.x version is released.
Session replay captures screen recordings of user actions to help you understand how users interact with your application. It is included in the launchdarkly_flutter_observability package and uses native iOS and Android libraries to capture and upload recordings.
Session replay for Flutter is supported only on iOS and Android. Web session replay is not yet available.
To enable session replay, pass a SessionReplayOptions object to the replay parameter of LDObserve.init or LDObserve.initStandalone, and wrap your app in SessionReplayCapture:
Wrap your top-level widget in SessionReplayCapture to allow the native session replay library to capture screen content. On web, SessionReplayCapture is a no-op pass-through, so it is safe to use on every platform:
Pass a SessionReplayOptions object to LDObserve.init or LDObserve.initStandalone to control session replay behavior:
These SessionReplayOptions configuration options are available on all platforms:
true.PrivacyOptions object that controls which UI elements are masked. To learn more, read Privacy options.The following SessionReplayOptions configuration option is available only on Android and iOS:
1.0.Use PrivacyOptions to control which elements are masked in session replay recordings. By default, text inputs are masked to protect user data.
The available privacy options are:
true.false.false.false.0.02.In addition to screen-wide PrivacyOptions, you can redact individual widgets using LDMask and LDUnmask.
Use LDMask to redact a widget’s subtree in all captured frames:
Use LDUnmask to exempt a subtree from global masking rules such as maskTextInputs. For example, to reveal one non-sensitive field on a page where every input is masked:
LDUnmask only overrides global masking. It does not override an explicit LDMask. An LDUnmask nested inside an LDMask stays masked.
LDMask and LDUnmask are active on iOS and Android. On web they render their child unchanged.
To learn more about session replay configuration, read Configuration for session replay.
The observability plugin supports the following features. After the SDK and plugins are initialized, you can access these from within your application:
After you initialize the SDK and observability plugin, your application automatically starts sending observability data back to LaunchDarkly, including errors and logs. You can review this information in the LaunchDarkly user interface. To learn how, read Observability.