Skip to content

feat(flags): add per-provider trackExposures and trackEvaluations - #1325

Draft
leoromanovsky wants to merge 2 commits into
developfrom
leo.romanovsky/flags-per-client-peeking
Draft

leoromanovsky wants to merge 2 commits into
developfrom
leo.romanovsky/flags-per-client-peeking

Conversation

@leoromanovsky

Copy link
Copy Markdown
Contributor

What and why?

Some apps need a flag value before the subject sees the result. For example, they pick the copy of a push notification when they send it. Today every DatadogProvider evaluation counts as an exposure. It also counts as evaluation telemetry and as a RUM feature-flag evaluation. So an app that evaluates at send time records an exposure that may never happen, and the later real exposure is deduplicated away.

DatadogFlagsConfiguration.trackExposures: false does not fix this. It stops sending, but the provider still writes the dedup cache and ExposureHook still reports the evaluation as an exposure. DatadogRumHook has no setting at all.

flowchart LR
  E[Send-time evaluation] --> X[Exposure intake]
  E --> C[Dedup cache]
  E --> T[Evaluation telemetry]
  E --> R[RUM view]
  L[Later evaluation when shown] --> C
  C -. deduplicated, no exposure .-> X
Loading

This PR adds "peeking", which the server SDKs (Java, Go, Ruby) and the iOS client already have as per-client options. A provider created with trackExposures: false / trackEvaluations: false evaluates flags without recording them. Other providers keep both, and a later evaluation through one of them records the exposure.

How?

The options are named parameters of DatadogProvider.fromConfiguration. Both default to true:

await api.setProviderForDomainAndWait(
  'preview',
  DatadogProvider.fromConfiguration(
    configuration,
    trackExposures: false,
    trackEvaluations: false,
  ),
);

Decisions:

  • Per provider, matching iOS. In OpenFeature, one provider serves one domain, which is the Flutter equivalent of an iOS FlagsClient. The names match iOS's per-client trackExposures / trackEvaluations. A peeking provider is a second domain next to the app's normal provider, so nothing changes for existing callers.
  • Exposures off is decided where the exposure is admitted. The provider never hands the pending exposure to its finally hook. Nothing reaches the intake, the dedup cache is not written, and ExposureHook gets isExposure: false. This matches Java, where the shared cache, delivery, and hooks all see "not an exposure". DatadogFlagsConfiguration.trackExposures: false keeps its current meaning: it does not send, but hooks still deduplicate. The README now tells the two apart.
  • Evaluations off covers aggregation and RUM. The provider's client skips the evaluation aggregator. Successful results carry the internal metadata key __dd_track_evaluations: false, and DatadogRumHook skips them. Metadata is used because the RUM hook lives in datadog_flags_flutter and only sees OpenFeature details. Other __dd_ keys already work this way and are documented as internal.
  • Narrow only. If the configuration turns tracking off, a provider option of true does not turn it back on.
  • Values unchanged. Values, variants, reasons, and assignment metadata are the same as for a tracking provider.
  • Not added to the deprecated DatadogFlags / DatadogFlagsPlugin clients. Their removal is planned for the next major version. Peeking is available only on the OpenFeature provider.
  • No native dependency. The Flutter flags packages are pure Dart. This change does not depend on the iOS or Android peeking PRs.
flowchart LR
  P["preview provider<br/>trackExposures: false<br/>trackEvaluations: false"] --> V[Value]
  P -. no event .-> X[Exposure intake]
  P -. no entry .-> C1[Its dedup cache]
  P -. skipped .-> R[RUM view]
  D[default provider] --> X
  D --> C2[Its dedup cache]
  D --> T[Evaluation telemetry]
  D --> R
Loading

Rollout: this is additive, and both options default to the current behavior. Version skew: if datadog_flags_flutter is used with an older datadog_flags, the provider has no options to set. If it is used with a newer one, the RUM hook skips the evaluations as intended.

Tests cover the defaults, each option alone, both options off, and the key cross-provider case: a peeking evaluation followed by a default evaluation sends exactly one exposure, and the hook reports no cache hit. They also cover that the options cannot turn tracking back on, and that DatadogRumHook skips marked evaluations. We broke each option on purpose and checked that its tests fail. The web and wasm runs of datadog_flags_flutter were not run locally (Chrome is not available on this host). CI covers them.

Review checklist

  • This pull request has appropriate unit and / or integration tests
  • This pull request references a Github or JIRA issue

Let one DatadogProvider evaluate flags without recording them, for
example to choose notification content at send time, while other
providers keep exposures and evaluation telemetry.

With trackExposures: false, the provider sends no exposure, leaves the
exposure deduplication cache untouched, and ExposureHook reports the
evaluation as not an exposure, so a later evaluation through a tracking
provider still sends its exposure. With trackEvaluations: false, the
provider records no evaluation telemetry and DatadogRumHook skips its
evaluations. Both default to true and can only narrow the
DatadogFlagsConfiguration settings.
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Pipelines

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 8885464 | Docs | Give us feedback!

Document that each peeking provider fetches its own assignments, and that
an unregistered peeking domain falls back to the default provider. Clarify
which trackExposures the ExposureHook doc means. Honor the tracking-off
marker in DatadogRumHook only from the Datadog provider. Cover missing
flags, type mismatches, and structures with trackEvaluations: false.
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