11import { evaluateRulesBasedConfiguration , matchesRule , OperatorType } from '@datadog/flagging-core'
2- import { configurationFromString , configurationToString } from '@datadog/openfeature-browser'
2+ import { configurationFromString , configurationToString , DatadogProvider } from '@datadog/openfeature-browser'
33import { assert , reportSuccess } from './smoke'
44
55const protobufRulesResponse =
66 'EgRwcm9kGigKDGJyb3dzZXItZmxhZxIYEAQaAigBIhAKCmFsbG9jYXRpb24iAiADGigKDGludGVnZXItZmxhZxIYEAIaAhgqIhAKCmFsbG9jYXRpb24iAiADKgJvbg=='
7+ const precomputedResponse = {
8+ data : {
9+ attributes : {
10+ createdAt : '2026-07-06T23:01:56.822Z' ,
11+ flags : {
12+ 'provider-flag' : {
13+ allocationKey : 'allocation' ,
14+ variationKey : 'on' ,
15+ variationType : 'BOOLEAN' ,
16+ variationValue : true ,
17+ reason : 'STATIC' ,
18+ doLog : false ,
19+ } ,
20+ } ,
21+ } ,
22+ } ,
23+ }
724const configuration = configurationFromString (
8- JSON . stringify ( { version : 1 , rules : { response : protobufRulesResponse } } )
25+ JSON . stringify ( {
26+ version : 1 ,
27+ precomputed : { response : JSON . stringify ( precomputedResponse ) } ,
28+ rules : { response : protobufRulesResponse } ,
29+ } )
930)
1031
1132assert ( configuration . rules , 'protobuf rules configuration was not decoded' )
@@ -31,6 +52,16 @@ const integerDetails = evaluateRulesBasedConfiguration(
3152 context ,
3253 console
3354)
55+ const provider = new DatadogProvider ( {
56+ clientToken : 'test-token' ,
57+ site : 'datadoghq.com' ,
58+ env : 'test' ,
59+ enableExposureLogging : false ,
60+ enableFlagEvaluationTracking : false ,
61+ enableRumFeatureFlagTracking : false ,
62+ initialFlagsConfiguration : configuration ,
63+ } )
64+ const providerDetails = provider . resolveBooleanEvaluation ( 'provider-flag' , false , context , console )
3465const restored = configurationFromString ( configurationToString ( configuration ) )
3566const sha256Matched = matchesRule (
3667 {
@@ -50,6 +81,7 @@ const sha256Matched = matchesRule(
5081
5182assert ( booleanDetails . value === true , 'protobuf boolean evaluation returned the wrong value' )
5283assert ( integerDetails . value === 42 , 'protobuf int64 evaluation returned the wrong value' )
84+ assert ( providerDetails . value === true , 'DatadogProvider did not evaluate the decoded configuration' )
5385assert (
5486 restored . rules ?. response . $typeName === 'datadog.ffe.flagging.ufc.v1.FlagsConfiguration' ,
5587 'protobuf rules configuration did not survive a round trip'
@@ -61,5 +93,6 @@ reportSuccess({
6193 protobufTypeName : configuration . rules . response . $typeName ,
6294 booleanValue : booleanDetails . value ,
6395 integerValue : integerDetails . value ,
96+ providerValue : providerDetails . value ,
6497 sha256Matched,
6598} )
0 commit comments