Skip to content

feat: add productAnalytics option, track API, taps#205

Open
abelonogov-ld wants to merge 3 commits into
mainfrom
andrey/ldobserve-track
Open

feat: add productAnalytics option, track API, taps#205
abelonogov-ld wants to merge 3 commits into
mainfrom
andrey/ldobserve-track

Conversation

@abelonogov-ld
Copy link
Copy Markdown
Contributor

@abelonogov-ld abelonogov-ld commented Jun 2, 2026

Summary

Introduces a productAnalytics configuration block to the Swift Observability SDK, consolidating product-analytics telemetry (taps, track events) to mirror the TypeScript/web SDK, and adds a public LDObserve.track(...) API.

Key points:

  • New ObservabilityOptions.ProductAnalytics(taps, trackEvents) option, with .enabled / .disabled presets.
  • userTaps is removed from Instrumentation and moved to productAnalytics.taps.
  • The tap span is renamed user.tap -> click and is gated by productAnalytics.taps (Session Replay capture is unaffected).
  • Custom track events are emitted as launchdarkly.track spans, both automatically (via the LD afterTrack hook) and manually (via the new LDObserve.track(...) API). Both paths funnel through a single emitter in ObservabilityService.

Changes

Configuration (ObservabilityOptions)

  • Added ProductAnalytics struct:
    • taps (default .disabled): emit a click span for each tap.
    • trackEvents (default .enabled): emit a launchdarkly.track span when a custom event is tracked.
    • .enabled / .disabled presets.
  • Removed userTaps from Instrumentation; added a productAnalytics property and init parameter.

Public API (Observe / LDObserve)

  • Added func track(name:value:attributes:) to the Observe protocol, plus default-argument convenience overloads (track(name:), track(name:value:), track(name:attributes:)).
  • Implemented track(...) in LDObserve, ObservabilityService, and NoOpObservabilityService.
  • Added the launchdarkly.track span-name constant to SemanticConvention.

Tap spans

  • Renamed the tap span from user.tap to click in UInteraction+Span.swift.
  • Gated only the tap span emission on productAnalytics.taps (capture still flows to Session Replay unconditionally).

Track events / hook wiring

  • ObservabilityHook.afterTrack(seriesContext:) extracts the event data and context keys and forwards them through ObservabilityHookExporter into a single ObservabilityService.track(...) emitter.
  • afterIdentify caches the latest context keys in ObservabilityService so manual LDObserve.track(...) calls can attribute events; the hook path's fresh keys take precedence over the cache.
  • Span attributes are applied in increasing precedence (user track data, then context keys, then the reserved key/value) so the event name and metric value can never be clobbered by a user field named "key" or "value".
  • track emits via AppTraceClient, so it respects `tracesApi.includ

Note

Medium Risk
Removes Instrumentation.userTaps (breaking config migration) and adds new automatic track/tap span emission tied to tracing and SDK hooks; behavior is gated but affects default telemetry shape.

Overview
Adds productAnalytics on ObservabilityOptions (taps, trackEvents) and moves tap telemetry out of Instrumentation by removing userTaps. Tap spans are renamed user.tapclick and only emitted when productAnalytics.taps is enabled; Session Replay tap capture is unchanged.

Custom events are exported as launchdarkly.track spans via a new LDObserve.track(...) API and the LaunchDarkly afterTrack hook, both routed through one emitter in ObservabilityService (gated by trackEvents, with identify context keys cached for manual tracks). Docs, sample apps, and TestApp demos are updated; TestApp also wires a local ios-client-sdk package for hook support.

Reviewed by Cursor Bugbot for commit 8abb432. Bugbot is set up for automated code reviews on this repo. Configure here.

@abelonogov-ld abelonogov-ld requested a review from a team as a code owner June 2, 2026 03:03
Copy link
Copy Markdown

@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 using default effort 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.

Reviewed by Cursor Bugbot for commit 2aa75b7. Configure here.

Comment thread Sources/LaunchDarklyObservability/API/ObservabilityOptions.swift
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