Skip to content

feat: MAUI integration hooks and refactor#425

Open
abelonogov-ld wants to merge 46 commits intomainfrom
andrey/recordlog-android
Open

feat: MAUI integration hooks and refactor#425
abelonogov-ld wants to merge 46 commits intomainfrom
andrey/recordlog-android

Conversation

@abelonogov-ld
Copy link
Contributor

@abelonogov-ld abelonogov-ld commented Mar 19, 2026

Summary

Refactors the Android Observability SDK architecture to align with the iOS/Swift and MAUI integration patterns, decoupling the Observability plugin from SessionReplay so each can function independently.

Architectural Changes

  • Decoupled plugin dependency direction: SessionReplayService can depend on Observability, but Observability no longer depends on SessionReplay. Removed InstrumentationContributor, InstrumentationContributorManager, and the LDExtendedInstrumentation-based registration flow.
  • Renamed for parity with Swift: ReplayInstrumentationSessionReplayService, ReplayControlSessionReplayServicing.
  • Simplified log processing pipeline: Removed RoutingLogRecordProcessor and the per-instrumentation log routing mechanism from InstrumentationManager, since it was only used by session replay and no longer needed.
  • SessionManager exposed via context: InstrumentationManager now captures the OTel SessionManager via a lightweight bridge AndroidInstrumentation and exposes it through ObservabilityClientObservabilityContext.sessionManager, matching the Swift pattern.

Session Replay Changes

  • Plugin lifecycle: SessionReplay.register() directly creates SessionReplayService using LDObserve.context, wires it to LDReplay, and sets the hook delegate. SessionReplay.onPluginsReady() calls sessionReplayService.initialize() after SessionManager is available.
  • Hook refactoring: SessionReplayHook no longer holds a reference to the SessionReplay plugin. Instead, it uses a @Volatile delegate of type SessionReplayServicing and extracts context keys from SDK types before delegating.
  • afterIdentify moved to service layer: Context key extraction and LDContext building now happen in SessionReplayService.afterIdentify() and SessionReplayHook.afterIdentify() respectively, using a Map<String, String> interface for cross-platform compatibility.
  • New SessionReplayHookProxy: JVM adapter for the C#/MAUI bridge that accepts simple JVM types and delegates to SessionReplayServicing.
  • Wake-up events: Added RRWebEventGenerator.generateWakeUpEvents() and SessionReplayExporter.wakeUpEvents() to re-trigger player playback after session resumption with a reload event and synthetic mouse interactions.
  • Title propagation: RRWebEventGenerator now accepts a title parameter used in reload custom events, derived from the application name.

New Utilities

  • AttributeConverter: Converts untyped Map<String, Any?> dictionaries (from bridge layers like .NET MAUI) into OTel Attributes, with support for nested map flattening via dot-separated keys and typed list handling.

Note

Medium Risk
Moderate risk due to refactoring plugin wiring and telemetry/session replay initialization order, plus new replay export behavior (wake-up payloads) that changes network/event flow.

Overview
Refactors Android Observability + Session Replay integration to remove the LDExtendedInstrumentation/InstrumentationContributor* registration path and instead expose the OTel SessionManager from InstrumentationManager through ObservabilityClient into ObservabilityContext, which Session Replay consumes.

Session Replay is reworked into a standalone SessionReplayService that is initialized on onPluginsReady, receives identify events via a delegate-based SessionReplayHook (and new SessionReplayHookProxy for MAUI), and updates LDReplay to use a new SessionReplayServicing interface.

Replay export behavior changes by adding a title-aware RRWebEventGenerator and emitting an extra “wake up” payload (reload + synthetic interactions) after the first push to improve player resumption; also sets client_id for replay session init and adjusts identify event session selection when sessionId is missing.

Adds MAUI-friendly observability APIs: LDObserve.recordLog/recordError overloads plus AttributeConverter to turn Map<String, Any?> into OTel Attributes. Minor demo app UI tweaks (session replay header/toggle, label updates) and test updates/removals to match the new architecture.

Written by Cursor Bugbot for commit 27d2002. This will update automatically on new commits. Configure here.

* main:
  feat: Optional Jet Compose (#402)
  feat: Android Incremental Image Diff compression (#390)
  chore: add CLAUDE.md (#398)
  chore: release main (#400)
  fix: correct react native session replay build step (#399)
  chore: release main (#396)
  fix: Android span e2e tests (#397)
  fix: improve network response capture (#379)

# Conflicts:
#	sdk/@launchdarkly/mobile-dotnet/.vscode/tasks.json
(cherry picked from commit f883e975ca79da891b4178d8a12e27868f0931eb)
* main:
  chore: release main (#401)
(cherry picked from commit 9901600)
* main:
  chore: release main (#406)
  feat: Make Android SDK35 compilable (#405)
* andrey/hooks:
  comment identify stuff
  fat working
  working
  can launch
* main:
  fix: ldclient dependencies (#407)
* main:
  chore: release main (#419)
  feat: Use C and NEON for hashing (Optimization) 100x on Pixel 8 (#415)
  chore: release main (#418)
  feat: Android SR use Jpeg 0.3 quality (#417)
  chore: release main (#411)
  feat: CPU utilization optimization in image diff calculations (#414)
  fix: reset nodeIds during fullsnapshot (#412)
  chore: Android benchmark screen of SR data pipelines on iOS Raw Frames (#410)
  feat: Android Observability hook  proxy for MAUI (#409)
  feat: ruby observability plugin (#360)

# Conflicts:
#	sdk/@launchdarkly/mobile-dotnet/android/native/LDObserve/src/main/java/com/example/LDObserve/ObservabilityBridge.kt
#	sdk/@launchdarkly/mobile-dotnet/macios/native/LDObserve/Sources/ObservabilityBridge.swift
#	sdk/@launchdarkly/mobile-dotnet/observability/LDAPI/LDObserve.cs
#	sdk/@launchdarkly/mobile-dotnet/observability/LDObservability.Fat.csproj
#	sdk/@launchdarkly/mobile-dotnet/observability/LDObservability.csproj
#	sdk/@launchdarkly/mobile-dotnet/observability/bridge/LDObserve.cs
#	sdk/@launchdarkly/mobile-dotnet/observability/bridge/NativeHookProxy.cs
#	sdk/@launchdarkly/mobile-dotnet/observability/observe/api/LDObserve.cs
#	sdk/@launchdarkly/mobile-dotnet/observability/observe/plugin/ObservabilityHook.cs
#	sdk/@launchdarkly/mobile-dotnet/observability/observe/plugin/ObservabilityPlugin.cs
#	sdk/@launchdarkly/mobile-dotnet/observability/replay/plugin/SessionReplayHook.cs
#	sdk/@launchdarkly/mobile-dotnet/observability/replay/plugin/SessionReplayPlugin.cs
#	sdk/@launchdarkly/mobile-dotnet/sample/MauiProgram.cs
* main:
  feat: mobile-dotnet support init attributes (#420)

# Conflicts:
#	sdk/@launchdarkly/mobile-dotnet/observability/LDObservability.Fat.csproj
#	sdk/@launchdarkly/mobile-dotnet/observability/LDObservability.csproj
#	sdk/@launchdarkly/mobile-dotnet/observability/bridge/DictionaryTypeConverters.cs
@abelonogov-ld abelonogov-ld requested a review from a team as a code owner March 19, 2026 15:23
@abelonogov-ld abelonogov-ld changed the title feat: MAUI integration hooks feat: MAUI integration hooks and refactor Mar 19, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

.anonymous(true)
.build()

//LDClient.get().identify(anonContext)
Copy link

Choose a reason for hiding this comment

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

Accidentally committed debugging code in e2e app

Low Severity

The anonContext variable is defined but only referenced in a commented-out LDClient.get().identify(anonContext) call. This looks like leftover debugging/experimentation code that was accidentally included in the commit.

Fix in Cursor Fix in Web

(cherry picked from commit a56660e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant