Subchapter 52.1
references/sdk/observability-plugin.mdMarkdown11 KBView on GitHub
Load this file whenever the user mentions observability, session replay, error monitoring, logs, tracing, or “the observability plugin”, at any point. A typical request, appended to the onboarding prompt:
Also add the LaunchDarkly observability plugin for this stack to that client’s
pluginsoption, reusing its key. For a browser app, that’s @launchdarkly/observability and @launchdarkly/session-replay with privacySetting “strict”.
The request can arrive at any point:
plugins option, in the same init code the SDK install wrote (or the existing init, if LaunchDarkly was already integrated).plugins entry. Pass only the constructor arguments the plugin requires (such as the key on Android, per rule 2). Do not add custom spans, log forwarding, network recording, error boundaries, sampling, or service names the user did not ask for.privacySetting: 'strict' in the browser, all four mask options on React Native (see the table). On iOS and Android, keep the package defaults unless the user names a level.launchdarkly-js-client-sdk 2.x can’t load plugins; adding them means moving to @launchdarkly/js-client-sdk 4.x.”). See Apply code changes.plugins list on every platform that has both.sdk/@launchdarkly/<package>/) and the observability docs (opens in a new tab) are authoritative. Take the plugin wiring from them and the client initializer from the recipe for the project’s actual SDK. README examples can lag the SDKs, so do not copy a client initializer from a plugin README.Match the row to the SDK the project actually uses (from SDK recipes). The Wiring column shows only where the plugins go; keep the rest of the existing init unchanged.
Browser apps get two packages: @launchdarkly/observability (errors, logs, traces) and @launchdarkly/session-replay (session replay). Both are default exports. There is no separate React package.
npm install @launchdarkly/observability @launchdarkly/session-replayimport Observability from '@launchdarkly/observability';
import SessionReplay from '@launchdarkly/session-replay';
const plugins = [
new Observability(),
new SessionReplay({ privacySetting: 'strict' }),
];Add only the plugin(s) the user asked for. “Observability” alone means Observability; “session replay” means both, since replay builds on observability. Use privacySetting: 'strict' unless the user named another level (rule 5).
| SDK in the project | Where plugins goes |
|---|---|
React, launchdarkly-react-client-sdk (v3) | asyncWithLDProvider({ clientSideID, context, options: { plugins } }), same for withLDProvider |
React, @launchdarkly/react-sdk (v4) | createLDReactProvider(clientSideID, context, { ldOptions: { plugins } }). Under ldOptions, not at the top level of the third argument. |
JavaScript, @launchdarkly/js-client-sdk (v4) | createClient(clientSideID, context, { plugins }) |
Vue, launchdarkly-vue-client-sdk | app.use(LDPlugin, { clientSideID, context, options: { plugins } }) |
| Angular, Svelte, Preact, other browser frameworks | Same as JavaScript (@launchdarkly/js-client-sdk) |
If the project is on an older browser SDK that does not accept plugins (for example launchdarkly-js-client-sdk 2.x, TypeScript rejects the option, or the SDK’s changelog does not list plugin support), do not upgrade on your own. Ask first, per rule 6, and keep the existing SDK if the user declines. Then continue onboarding with feature flags.
Wire each client the onboarding installed:
@launchdarkly/observability-node (next section).@launchdarkly/observability-next is a separate standalone package that initializes from a key without a LaunchDarkly client. It does not attach to a client’s plugins option, so do not use it to satisfy a request to add the plugin to the client.
| Stack | Package | Install | Wiring | Minimum SDK |
|---|---|---|---|---|
| Node.js (server) | @launchdarkly/observability-node | npm install @launchdarkly/observability-node | import { Observability } from '@launchdarkly/observability-node', then init(sdkKey, { plugins: [new Observability()] }) | Current @launchdarkly/node-server-sdk |
| React Native | @launchdarkly/observability-react-native | npm install @launchdarkly/observability-react-native | import { Observability } from '@launchdarkly/observability-react-native', then new ReactNativeLDClient(mobileKey, AutoEnvAttributes.Enabled, { plugins: [new Observability()] }) | @launchdarkly/react-native-client-sdk v10 |
| React Native session replay | @launchdarkly/session-replay-react-native | npm install @launchdarkly/session-replay-react-native | import { createSessionReplayPlugin } from '@launchdarkly/session-replay-react-native', then add createSessionReplayPlugin() after Observability in plugins. With no privacy level named, or for “strict”, pass { maskTextInputs: true, maskLabels: true, maskImages: true, maskWebViews: true }. Native module: run npx pod-install on bare React Native. | React Native 0.75+ |
| Python | launchdarkly-observability | pip install launchdarkly-observability | from ldobserve import ObservabilityPlugin, then Config(sdk_key, plugins=[ObservabilityPlugin()]) | launchdarkly-server-sdk 9.12+ |
| Ruby | launchdarkly-observability | add gem 'launchdarkly-observability' to the Gemfile, then bundle install | require 'launchdarkly_observability', then LaunchDarkly::Config.new(plugins: [LaunchDarklyObservability::Plugin.new]) | launchdarkly-server-sdk 8.11+ |
| Go | github.com/launchdarkly/observability-sdk/go | go get github.com/launchdarkly/observability-sdk/go | ld.MakeCustomClient(sdkKey, ld.Config{Plugins: []ldplugins.Plugin{ldobserve.NewObservabilityPlugin()}}, timeout) with ldobserve as the import alias | go-server-sdk/v7 with ldplugins |
| .NET (server) | LaunchDarkly.Observability | dotnet add package LaunchDarkly.Observability | Configuration.Builder(sdkKey).Plugins(new PluginConfigurationBuilder().Add(ObservabilityPlugin.Builder(builder.Services).Build())). Build the LdClient before builder.Build(). | LaunchDarkly.ServerSdk 8.10+ |
| iOS | swift-launchdarkly-observability (SPM), or pods LaunchDarklyObservability / LaunchDarklySessionReplay | SPM: add https://github.com/launchdarkly/swift-launchdarkly-observability and the LaunchDarklyObservability product (plus LaunchDarklySessionReplay for replay) | import LaunchDarklyObservability, then config.plugins = [Observability(options: .init())]; for replay also import LaunchDarklySessionReplay and append SessionReplay(options: .init()) | iOS SDK 9.14+ |
| Android | com.launchdarkly:launchdarkly-observability-android | add implementation("com.launchdarkly:launchdarkly-observability-android:<latest>") next to the client SDK | .plugins(Components.plugins().setPlugins(listOf(Observability(application, mobileKey)))) on LDConfig.Builder; for replay append SessionReplay() (com.launchdarkly.observability.replay.plugin.SessionReplay) | Android client SDK 5.9+ |
Confirm the iOS and .NET constructor options against the package README before writing them. Both packages are pre-1.0 and their option shapes change between releases.
Java, PHP, Rust, Erlang/Elixir, Haskell, Lua, C/C++, Apex, Electron, Node.js (client), Roku, .NET (client), Flutter, and the edge SDKs have no observability plugin covered here. Check the observability docs (opens in a new tab) once. If nothing is listed for the stack, tell the user in one line that the observability plugin is not available for it yet, then continue onboarding with feature flags. Do not substitute OpenTelemetry setup or a different package.
The plugin is done when:
plugins entry is in the same init call the client uses, with no new credential.Mention it in the completion summary in one line (for example “Observability and session replay are on, with strict privacy.”). Do not offer observability again in the wrap-up choice.