Repository navigation
[FFL-2871] Support static-context offline initialization - #346
Conversation
cfd296c to
12d980f
Compare
12d980f to
78c4cd7
Compare
78c4cd7 to
1f5b770
Compare
ced7f3b to
18b6555
Compare
c5671fe to
d22ce15
Compare
592713b to
d22d4e7
Compare
d22d4e7 to
9d718e1
Compare
9d718e1 to
1adf3ea
Compare
1adf3ea to
7beba56
Compare
7beba56 to
e1d30d6
Compare
e1d30d6 to
9160faa
Compare
9160faa to
81106cc
Compare
| const context = getPrecomputedContext(configuration) | ||
|
|
||
| await OpenFeature.setProviderAndWait(provider) | ||
|
|
||
| await OpenFeature.setContext({ targetingKey: 'user-123', plan: 'enterprise' }) | ||
| if (context === undefined) { | ||
| await OpenFeature.setProviderAndWait(provider) | ||
| } else { | ||
| await OpenFeature.setProviderAndWait(provider, context) | ||
| } |
There was a problem hiding this comment.
thought: When seeing this, I was surprised why it cannot be simplified as:
await OpenFeature.setProviderAndWait(provider, getPrecomputedContext(configuration))
I understand now this is to work around OpenFeature typings, where context is not optional, but it is definitely surprising. Maybe a PR upstream could help simplifying this!
There was a problem hiding this comment.
Yep that’s why the conditional is needed. getPrecomputedContext() returns EvaluationContext | undefined, while the OpenFeature overload accepts either no second argument or a defined EvaluationContext.
We also cannot substitute {} for undefined, because this provider treats {} as an explicitly selected empty context. I agree an upstream typing/API change could make this simpler. The fix I'm imagining would live in the OpenFeature code though. Specifically here and here would let context be optional
setProviderAndWait(provider: Provider, context?: EvaluationContext): Promise<void>
setProviderAndWait(
domain: string,
provider: Provider,
context?: EvaluationContext
): Promise<void>
…k/FFL-2871/static-context-offline-init
This comment has been minimized.
This comment has been minimized.
…k/FFL-2871/static-context-offline-init # Conflicts: # packages/browser/README.md
ce82cff to
9493df4
Compare
…k/FFL-2871/static-context-offline-init
Summary
This PR contains documentation and regression-test changes only. The browser provider implementation is introduced in #336, while the supported
getPrecomputedContext(configuration)accessor is provided by #344 through its merge of #353.getPrecomputedContext(configuration)instead of inspecting the opaque wire or parsed configurationsetConfiguration()before registering the providerOpenFeature.setProviderAndWait(provider, context){}and contexts containing only undefined values literallyINVALID_CONTEXTbehavior for context-specific precomputed snapshots that do not match/rules-basedfor dynamic-context rulesWhy
A context-specific precomputed configuration is a snapshot for the context used to generate it. The effective OpenFeature context must match so provider hooks and Datadog tracking observe the same subject used for evaluation.
The configuration wire and parsed configuration are opaque contracts.
getPrecomputedContext(configuration)lets consumers obtain a detached copy without inspecting internal fields.An empty OpenFeature context is a real context. It does not mean “restore the embedded context.” Clearing context therefore supplies
{}and puts a context-specific precomputed-only provider intoERRORuntil the matching context is set again.Behavior
DatadogOfflineProvider, then load configuration withsetConfiguration(){},{ targetingKey: undefined }, and cleared global context are treated literallyINVALID_CONTEXTREADYDependency and merge order
This PR is stacked on #336.
main.main.mainand merge it.PR #349 adds opt-in exposure, evaluation, and RUM tracking parity to
DatadogOfflineProvider. PR #351 adds explicit precomputed and rules-based configuration fetchers; both are independent follow-ups.Jira: https://datadoghq.atlassian.net/browse/FFL-2871
Validation