Skip to content

feat: MAUI integration hooks and refactor for 0.4.1 nuget#425

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

feat: MAUI integration hooks and refactor for 0.4.1 nuget#425
abelonogov-ld wants to merge 47 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
Refactors plugin wiring and session replay export behavior (session manager capture, identify flow, and extra payload pushes), which can impact initialization order and replay delivery if assumptions differ across apps.

Overview
Refactors the Android Observability + Session Replay integration to remove the old InstrumentationContributor/InstrumentationContributorManager + LDExtendedInstrumentation registration path, and instead capture/expose the OTel SessionManager via an AndroidInstrumentation bridge (ObservabilityClient.sessionManagerObservabilityContext.sessionManager). The log pipeline in InstrumentationManager is simplified by dropping per-instrumentation log routing.

Session Replay is reworked around a standalone SessionReplayService (ReplayInstrumentationSessionReplayService, ReplayControlSessionReplayServicing): the SessionReplay plugin now constructs the service directly, initializes it on onPluginsReady(), and routes SDK identify events through a delegate-based SessionReplayHook plus a new bridge-friendly SessionReplayHookProxy/LDReplay.hookProxy. Replay exporting adds app title propagation, sets client_id, sends identify events even when session id is missing by falling back to the last capture session, and may emit an additional “wake-up” payload (reload + synthetic interactions) to resume playback.

Adds AttributeConverter and LDObserve overloads to accept MAUI-friendly Map<String, Any?> attributes and severity numbers without exposing OpenTelemetry types. Also includes small demo app UI tweaks (Session Replay header/toggle) and updated tests for the new wiring and extra replay payload.

Written by Cursor Bugbot for commit b79b772. 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 1 potential issue.

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.

// put wake up in the try/catch do not break buffering logic
logger.error(e)
}
}
Copy link

Choose a reason for hiding this comment

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

shouldWakeUpSession not restored during export rollback

Medium Severity

The export method snapshots and restores lastCaptureState, payloadIdCounter, pushedCanvasSize, and eventGenerator state on failure, but shouldWakeUpSession is not included. If wakeUpEvents succeeds (setting shouldWakeUpSession = false) but a subsequent session's pushPayload throws, the outer catch rolls back all other state while shouldWakeUpSession stays false. On retry, wake-up events are never re-sent and the rolled-back payloadIdCounter reuses IDs that the already-sent wake-up events consumed.

Additional Locations (1)
Fix in Cursor Fix in Web

@abelonogov-ld abelonogov-ld changed the title feat: MAUI integration hooks and refactor feat: MAUI integration hooks and refactor for 0.4.1 nuget Mar 25, 2026
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