![]() |
VOOZH | about |
dotnet add package LaunchDarkly.SessionReplay --version 0.10.2
NuGet\Install-Package LaunchDarkly.SessionReplay -Version 0.10.2
<PackageReference Include="LaunchDarkly.SessionReplay" Version="0.10.2" />
<PackageVersion Include="LaunchDarkly.SessionReplay" Version="0.10.2" />Directory.Packages.props
<PackageReference Include="LaunchDarkly.SessionReplay" />Project file
paket add LaunchDarkly.SessionReplay --version 0.10.2
#r "nuget: LaunchDarkly.SessionReplay, 0.10.2"
#:package LaunchDarkly.SessionReplay@0.10.2
#addin nuget:?package=LaunchDarkly.SessionReplay&version=0.10.2Install as a Cake Addin
#tool nuget:?package=LaunchDarkly.SessionReplay&version=0.10.2Install as a Cake Tool
The LaunchDarkly Observability SDK for .NET MAUI provides automatic and manual instrumentation for your mobile application, including metrics, logs, error reporting, and session replay.
NB: APIs are subject to change until a 1.x version is released.
The .NET MAUI observability plugin automatically instruments:
A complete example application is available in the directory.
In your MauiProgram.cs (or wherever you initialize your application), register the ObservabilityPlugin via LdClient:
using LaunchDarkly.Observability;
using LaunchDarkly.Sdk;
using LaunchDarkly.Sdk.Client;
using LaunchDarkly.Sdk.Client.Integrations;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
// ... other configuration ...
var mobileKey = "your-mobile-key";
var ldConfig = Configuration.Builder(mobileKey, ConfigurationBuilder.AutoEnvAttributes.Enabled)
.Plugins(new PluginConfigurationBuilder()
.Add(new ObservabilityPlugin(new ObservabilityOptions(
isEnabled: true,
serviceName: "maui-sample-app"
)))
).Build();
var context = Context.New("maui-user-key");
var client = LdClient.Init(ldConfig, context, TimeSpan.FromSeconds(10));
return builder.Build();
}
}
After initialization of the LaunchDarkly client, use LDObserve to record metrics, logs, and errors:
using LaunchDarkly.Observability;
// Record metrics
LDObserve.RecordMetric("user_actions", 1.0);
LDObserve.RecordCount("api_calls", 1.0);
LDObserve.RecordIncr("page_views", 1.0);
LDObserve.RecordHistogram("response_time", 150.0);
LDObserve.RecordUpDownCounter("active_connections", 1.0);
// Record logs with severity and optional attributes
LDObserve.RecordLog(
"User performed action",
Severity.Info,
new Dictionary<string, object?>
{
{ "user_id", "12345" },
{ "action", "button_click" }
}
);
// Record errors from an exception
var exception = new Exception("Something went wrong", new InvalidOperationException("root cause"));
LDObserve.RecordError(exception);
// Or record errors from a message string
LDObserve.RecordError("Something went wrong", "The underlying cause of the error.");
| Method | Description |
|---|---|
RecordMetric(name, value) |
Record a gauge metric |
RecordCount(name, value) |
Record a count metric |
RecordIncr(name, value) |
Record an incremental counter metric |
RecordHistogram(name, value) |
Record a histogram metric |
RecordUpDownCounter(name, value) |
Record an up-down counter metric |
Use RecordLog to emit structured log records with a severity level and optional attributes:
LDObserve.RecordLog(
"Checkout completed",
Severity.Info,
new Dictionary<string, object?>
{
{ "order_id", "ORD-9876" },
{ "total", 42.99 }
}
);
Supported severity levels: Trace, Debug, Info, Warn, Error, Fatal.
You can correlate logs with a specific span for distributed tracing by capturing and passing a SpanContext:
var span = LDObserve.StartActiveSpan("checkout-flow");
var capturedContext = span.Context;
span.End();
await Task.Run(() =>
{
LDObserve.RecordLog(
"Checkout processed on background thread",
Severity.Warn,
new Dictionary<string, object?> { { "source", "background-task" } },
spanContext: capturedContext);
});
This is useful when a log is emitted on a different thread or after the span has ended, but you still want it associated with the original trace.
Use RecordError to capture error events. You can pass an Exception object directly, or a message string with an optional cause:
// From an exception (inner exceptions are captured automatically)
var exception = new Exception("Payment failed", new TimeoutException("Connection timed out"));
LDObserve.RecordError(exception);
// From a message string with optional cause
LDObserve.RecordError("Payment failed", "Timeout connecting to payment gateway.");
For in-depth examples covering nested spans, error handling, manual context propagation, and more, see the .
Use LDObserve to create spans for tracing operations in your application. Spans are backed by OpenTelemetry and should be disposed when the operation completes.
Create spans to trace operations. The returned TelemetrySpan is disposable — wrap it in a using statement so it ends automatically:
using var span = LDObserve.StartActiveSpan("api_request");
span.SetAttribute("endpoint", "/api/users");
span.SetAttribute("method", "GET");
span.AddEvent("cache.miss");
StartActiveSpan automatically creates parent-child relationships. Each new active span becomes a child of the currently active span:
using var parent = LDObserve.StartActiveSpan("ProcessOrder");
using var child = LDObserve.StartActiveSpan("ValidatePayment");
using var grandchild = LDObserve.StartActiveSpan("ChargeCard");
await httpClient.PostAsync("https://api.example.com/charge", content);
Use StartRootSpan to create spans that are independent of the current trace context. This is useful for sequential operations that should not be nested:
using (var span1 = LDObserve.StartRootSpan("SequentialOperation1"))
{
span1.SetAttribute("sequence", "1");
}
using (var span2 = LDObserve.StartRootSpan("SequentialOperation2"))
{
span2.SetAttribute("sequence", "2");
}
You can also manage a span's lifecycle manually using End() and capture its Context for distributed tracing:
var span = LDObserve.StartActiveSpan("my-operation");
span.SetAttribute("key", "value");
var capturedContext = span.Context;
span.End();
| Method | Description |
|---|---|
LDObserve.StartActiveSpan(name) |
Start a new active span that automatically nests under the current parent. Returns a disposable TelemetrySpan. |
LDObserve.StartActiveSpan(name, parentContext) |
Start a new active span with an explicit parent SpanContext (defaults to SpanKind.Internal). Use when Activity.Current is not propagated. |
LDObserve.StartActiveSpan(name, kind, parentContext) |
Same as above but with an explicit SpanKind. |
LDObserve.StartRootSpan(name) |
Start a new root span with no parent. Returns a disposable TelemetrySpan. |
span.SetAttribute(key, value) |
Set a key-value attribute on a span. |
span.AddEvent(name) |
Record a named event on a span. |
span.Context |
Capture the span's context for correlating logs or other operations across async boundaries. |
span.End() |
Manually end a span (alternatively, use a using statement). |
System.Diagnostics.ActivityIf you prefer the native .NET Activity API over OpenTelemetry's TelemetrySpan, equivalent methods are available. Activities are nullable — StartActivity returns null before SDK initialization or when no listener is registered:
using System.Diagnostics;
using var activity = LDObserve.StartActivity("api_request");
activity?.SetTag("endpoint", "/api/users");
activity?.SetTag("method", "GET");
activity?.AddEvent(new ActivityEvent("cache.miss"));
// Root activity (no parent), equivalent to StartRootSpan
using var root = LDObserve.StartRootActivity("independent-operation");
root?.SetTag("sequence", "1");
// Or get the ActivitySource directly for full control
var source = LDObserve.GetActivitySource();
using var custom = source.StartActivity("custom", ActivityKind.Client);
Use the LaunchDarkly client to identify or switch user contexts. This ties observability data to the correct user:
using LaunchDarkly.Sdk;
using LaunchDarkly.Sdk.Client;
// Single context
var userContext = Context.Builder("user-key")
.Name("Bob Bobberson")
.Build();
await LdClient.Instance.IdentifyAsync(userContext);
// Multi-context
var userContext = Context.Builder("user-key")
.Name("Bob Bobberson")
.Build();
var deviceContext = Context.Builder(ContextKind.Of("device"), "iphone")
.Name("iphone")
.Build();
var multiContext = Context.MultiBuilder()
.Add(userContext)
.Add(deviceContext)
.Build();
LdClient.Instance.Identify(multiContext, TimeSpan.FromSeconds(5));
// Anonymous context
var anonContext = Context.Builder("anonymous-key")
.Anonymous(true)
.Build();
LdClient.Instance.Identify(anonContext, TimeSpan.FromSeconds(5));
Session Replay captures user interactions and screen recordings to help you understand how users interact with your application. To enable Session Replay, add the SessionReplayPlugin alongside the ObservabilityPlugin:
using LaunchDarkly.SessionReplay;
using LaunchDarkly.Observability;
using LaunchDarkly.Sdk;
using LaunchDarkly.Sdk.Client;
using LaunchDarkly.Sdk.Client.Integrations;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
// ... other configuration ...
var mobileKey = "your-mobile-key";
var ldConfig = Configuration.Builder(mobileKey, ConfigurationBuilder.AutoEnvAttributes.Enabled)
.Plugins(new PluginConfigurationBuilder()
.Add(new ObservabilityPlugin(new ObservabilityOptions(
isEnabled: true,
serviceName: "maui-sample-app"
)))
.Add(new SessionReplayPlugin(new SessionReplayOptions(
isEnabled: true,
privacy: new SessionReplayOptions.PrivacyOptions(
maskTextInputs: true,
maskWebViews: false,
maskLabels: false
)
)))
).Build();
var context = Context.New("maui-user-key");
var client = LdClient.Init(ldConfig, context, TimeSpan.FromSeconds(10));
return builder.Build();
}
}
You can control what information is captured during a session using PrivacyOptions:
MaskTextInputs: (Default: true) Masks all text input fields.MaskWebViews: (Default: false) Masks all web view content.MaskLabels: (Default: false) Masks all text labels.MaskImages: (Default: false) Masks all images.You can manually mask or unmask specific UI components using the provided extension methods on any MAUI View.
using LaunchDarkly.SessionReplay;
// Mask a specific view
mySensitiveView.LDMask();
// Unmask a specific view
myPublicView.LDUnmask();
We encourage pull requests and other contributions from the community. Check out our for instructions on how to contribute to this SDK.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0-android35.0 net9.0-android35.0 is compatible. net9.0-ios18.0 net9.0-ios18.0 is compatible. net10.0-android net10.0-android was computed. net10.0-ios net10.0-ios was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.10.2 | 123 | 5/8/2026 |
| 0.10.0 | 95 | 5/5/2026 |
| 0.9.17 | 112 | 5/1/2026 |
| 0.9.16 | 96 | 5/1/2026 |
| 0.9.15 | 99 | 5/1/2026 |
| 0.9.14 | 108 | 4/28/2026 |
| 0.9.12 | 103 | 4/28/2026 |
| 0.9.11 | 115 | 4/28/2026 |
| 0.9.10 | 112 | 4/28/2026 |
| 0.9.9 | 114 | 4/28/2026 |
| 0.9.8 | 108 | 4/28/2026 |
| 0.9.7 | 105 | 4/28/2026 |
| 0.9.6 | 106 | 4/27/2026 |
| 0.9.4 | 106 | 4/27/2026 |
| 0.9.2 | 126 | 4/15/2026 |
| 0.9.1 | 109 | 4/15/2026 |
| 0.9.0 | 113 | 4/14/2026 |
| 0.8.3 | 111 | 4/13/2026 |
| 0.8.2 | 115 | 4/10/2026 |
| 0.8.0 | 113 | 4/9/2026 |