Repository navigation
feat(browser): send SDK lifecycle telemetry - #444
Conversation
OpenFeature Browser Provider Bundle SizesMeasured from the Vite production output after installing packed Both scenarios initialize an OpenFeature provider, evaluate a boolean flag, change context, and evaluate again. Telemetry is disabled for DatadogProvider; no tracking hooks are registered for DatadogCoreProvider. DatadogProvider fetches precomputed assignments for each context; DatadogCoreProvider receives rules from fetchRulesConfiguration once and evaluates locally. Sizes include OpenFeature and the same small scenario harness. Configuration responses are supplied by Playwright and are not bundled. These are complete scenario JS sizes, not configuration payload sizes or isolated provider/Protobuf costs; the difference between rows is not a decoder-only delta.
Dependency checks passed: no Protobuf markers in default/precomputed scenarios; markers present in rules-based scenarios. OpenFeature Browser Tracking Hook Bundle SizesSynthetic entrypoints import and call tracking hook factories from the packed
OpenFeature Node Server Bundle SizesIndependent Webpack production builds of the installed core and Node SDK tarballs, targeting Node 18 with ESM (
Adding SSR helpers to the provider adds 80.0 KiB raw / 22.3 KiB gzip in this build. This includes fetching, parsing, and serialization, not just the decoder. SSR helpers fetch rules for the browser, not for configuring that provider (which uses its existing JSON API). These are bundler sizes, not npm install sizes, unbundled Node require/import costs, payload sizes, or latency. Gzip compares compressed artifacts. The browser scenarios include OpenFeature and a different harness, so their sizes are not directly comparable. Dependency checks passed: no Protobuf runtime or generated schema modules in the provider-only bundle; present in both SSR bundles (checked using Webpack module statistics). This report shows current PR artifact sizes only; it does not compare against the base branch. |
FFE reviewer selectionReviewers: @ethan-romero-dg, @typotter Why: Guided and observable onboarding — The PR adds a new browser SDK startup and lifecycle telemetry capability. Reviewers come from the matched pod. 🤖 Automated selection. Selection detailsInitiative: project / guided-onboarding Why this match: The PR adds a new browser SDK startup and lifecycle telemetry capability. It emits bounded sdk_initialization outcomes (ready, failed, cached_fallback or incomplete) with elapsed timings, plus a one-time CONFIG_FETCH_FAILED provider_error, through the existing intake. The stated purpose is onboarding and SDK troubleshooting. This is the catalog's 'SDK startup/lifecycle telemetry' for telling apart provider readiness, configuration received and failure. It is not routine evaluation or exposure transport maintenance.
Additional review: openfeature-architecture — The DatadogProvider lifecycle changes in substance. initialize() now creates a shared transport once per provider and records an initialization failure before rethrowing. onClose() stops lifecycle telemetry, then stops and clears the shared transport in a finally block after tracking shutdown. Provider-tracking now takes an injected transport getter. Together these change initialization, re-initialization and shutdown semantics, which this area covers. Coverage: @typotter. Evidence: packages/browser/src/openfeature/provider.ts, packages/browser/src/openfeature/provider-tracking.ts The PR author was excluded. Existing reviewers and teams were preserved. Debug or fix a problemWorkflow run · Bits Code session
Evidence and run details✅ Complete — reviewer coverage verified. The workflow checked pending requests or submitted reviews on the evaluated head. Generated asynchronously by the FFE reviewer-routing workflow. Changed paths: Evaluated head: Registry revision: Pinned skill source: Instructions: workflow-injected snapshot (no plugin loaded) Instruction snapshot SHA-256: |
Purpose
Send browser SDK startup results and configuration-fetch errors to Datadog. These reports support SDK setup and troubleshooting. The event format matches the backend schema from https://github.com/ddoghq/dd-source/pull/98932.
Behavior
DatadogProvidersends diagnostics through the existing/api/v2/flagevaluationJSONL batch. Diagnostics do not require a flag evaluation or RUM. Evaluation, exposure, and RUM tracking settings do not control diagnostics.Initialization reports use these outcomes:
ready: the provider received and accepted a fresh configuration.failed: initialization failed.cached_fallback: the configuration request failed, but the provider can use a cached configuration.incomplete: the page exited or the provider closed before initialization finished.A pending initialization can send one incomplete report. If the page resumes and initialization finishes, the provider can also send its final result. There is no timed initialization report.
After initialization finishes, the provider can send one
provider_errorreport withCONFIG_FETCH_FAILED. Requests cancelled by a newer context update do not count as errors, including requests cancelled while waiting for cached configuration.Each initialize-to-close lifecycle sends at most three diagnostic records. Initializing a closed provider starts a new lifecycle with new timings and report limits. Responses from a closed lifecycle do not complete the new initialization. Evaluation tracking also restarts.
Diagnostics and evaluations share the existing endpoint, batch limits, and page-exit flush. Diagnostic setup, queue, and shutdown failures do not interrupt flag evaluation. Batching can delay delivery. Page-exit delivery is best effort. Missing reports do not prove that the SDK failed.
Data
Reports require
envand eitherapplicationIdorservice. The application ID takes priority when both are set.Reports contain SDK name and version, application or service identity, environment, timings, and error codes. They exclude flag values, evaluation context, client tokens, and raw errors. There is no instance ID or sequence field. Reports must not be linked to a specific instance by timestamp alone.
Named limits match the backend schema fixture. The 24-hour duration limit validates reports; it does not trigger a report. This PR adds no debug-mode option or diagnostic console logging.
Example event:
Validation
Passed locally:
Regression tests cover cancellation during cache fallback, provider reuse, fresh error limits, and late responses from a closed lifecycle. Schema tests check diagnostic payloads against the backend contract.
For a manual staging check, run
yarn test:browser-install, then runyarn devintest-appand open/diagnostics.html. Enter staging credentials, initialize the provider, and close it to flush. Check the stored records through the SDK diagnostics API. This branch has not been tested against staging.Checklist
AI-assisted implementation.