Skip to content

feat: add OpenFeature track() API for event tracking#348

Draft
nicklasl wants to merge 4 commits intomainfrom
nicklasl/feat-event-tracking
Draft

feat: add OpenFeature track() API for event tracking#348
nicklasl wants to merge 4 commits intomainfrom
nicklasl/feat-event-tracking

Conversation

@nicklasl
Copy link
Copy Markdown
Member

@nicklasl nicklasl commented Mar 20, 2026

Summary

Implements the OpenFeature track() API across all three providers (JS, Java, Go) for recording business events tied to feature flag evaluations. This enables A/B test analytics and experimentation metrics via the Confidence events ingestion service.

Data flow

Provider.track(eventName, context, details)
  → construct Event (auto-prefix "eventDefinitions/", merge context+details into payload, set event_time)
  → call wasm_msg_guest_track_event(Event) into WASM
  → EventLogger buffers the Event in a lock-free SegQueue

Provider flush cycle (every ~15s, piggybacked on existing flag log flush)
  → call wasm_msg_guest_flush_events() into WASM
  → EventLogger drains buffer, returns FlushEventsResponse with events list
  → Provider constructs PublishEventsRequest (adds client_secret, sets send_time)
  → Java/Go: gRPC call to EventsService.PublishEvents
  → JS: HTTP POST of serialized protobuf to events.confidence.dev/v1/events:publish

What is included

  • Rust core: Lock-free EventLogger using crossbeam_queue::SegQueue
  • WASM guest: track_event and flush_events exports
  • Proto: Event and FlushEventsResponse added to WASM boundary protos; confidence/events/v1/ service proto vendored for gRPC stubs
  • JS provider: track() method, event flush in flush(), HTTP+protobuf sender
  • Java provider: track() override, GrpcEventSender using EventsServiceGrpc, event flush on state refresh + shutdown
  • Go provider: Track() implementing openfeature.Tracker, GrpcEventSender, event flush piggybacked on log ticker + shutdown

What is not included yet

  • Delivery guarantees: Events are currently drained from the WASM buffer unconditionally on flush. If the backend request fails (network error, server error), those events are lost. A future iteration should only drop events from memory after the provider confirms successful delivery from the backend.
  • Dedicated event tracking tests: The existing test suites all pass with the new code, but dedicated tests for the track/flush/send cycle (mocking the events endpoint, verifying payload structure, testing flush-on-shutdown) are not yet added.
  • Retry/backpressure in event senders: The gRPC event senders (Java/Go) do a single async attempt. Failed sends are logged but not retried. The JS provider has 5 retries via its fetch middleware.

Test plan

  • Rust event_logger unit tests (4 tests including concurrency)
  • JS provider tests (135 pass)
  • Java provider tests (83 pass)
  • Go provider tests (all pass)
  • Docker full build (docker build .)
  • E2E: track events flow through to events backend

🤖 Generated with Claude Code

nicklasl and others added 4 commits March 20, 2026 10:22
Implement the OpenFeature track() API across all providers (JS, Java, Go)
to enable recording business events for A/B test analytics.

Events are buffered in the WASM core via a lock-free EventLogger,
flushed alongside flag logs, and sent to EventsService via gRPC (Java/Go)
or HTTP+protobuf (JS).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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