@@ -30,6 +30,7 @@ type evalResult struct {
30
30
ForwardAllExposures bool `json:"forward_all_exposures,omitempty"`
31
31
SamplingRate * int `json:"sampling_rate,omitempty"`
32
32
ConfigVersion * int `json:"config_version,omitempty"`
33
+ HasSeenAnalyticalGates bool `json:"has_seen_analytical_gates,omitempty"`
33
34
}
34
35
35
36
type DerivedDeviceMetadata struct {
@@ -375,6 +376,7 @@ func (e *evaluator) eval(user User, spec configSpec, depth int, context *evalCon
375
376
var deviceMetadata * DerivedDeviceMetadata
376
377
if spec .Enabled {
377
378
for _ , rule := range spec .Rules {
379
+ context .EvalSamplingRate = rule .SamplingRate
378
380
r := e .evalRule (user , rule , depth + 1 , context )
379
381
if r .Unsupported {
380
382
r .EvaluationDetails = e .createEvaluationDetails (ReasonUnsupported )
@@ -405,22 +407,24 @@ func (e *evaluator) eval(user User, spec configSpec, depth int, context *evalCon
405
407
DerivedDeviceMetadata : deviceMetadata ,
406
408
SamplingRate : rule .SamplingRate ,
407
409
ConfigVersion : spec .ConfigVersion ,
410
+ HasSeenAnalyticalGates : context .EvalHasSeenAnalyticalGates ,
408
411
}
409
412
if rule .IsExperimentGroup != nil {
410
413
result .IsExperimentGroup = rule .IsExperimentGroup
411
414
}
412
415
return result
413
416
} else {
414
417
return & evalResult {
415
- Value : pass ,
416
- RuleID : rule .ID ,
417
- IDType : spec .IDType ,
418
- GroupName : rule .GroupName ,
419
- SecondaryExposures : exposures ,
420
- EvaluationDetails : evalDetails ,
421
- DerivedDeviceMetadata : deviceMetadata ,
422
- SamplingRate : rule .SamplingRate ,
423
- ConfigVersion : spec .ConfigVersion ,
418
+ Value : pass ,
419
+ RuleID : rule .ID ,
420
+ IDType : spec .IDType ,
421
+ GroupName : rule .GroupName ,
422
+ SecondaryExposures : exposures ,
423
+ EvaluationDetails : evalDetails ,
424
+ DerivedDeviceMetadata : deviceMetadata ,
425
+ SamplingRate : rule .SamplingRate ,
426
+ ConfigVersion : spec .ConfigVersion ,
427
+ HasSeenAnalyticalGates : context .EvalHasSeenAnalyticalGates ,
424
428
}
425
429
}
426
430
}
@@ -440,10 +444,12 @@ func (e *evaluator) eval(user User, spec configSpec, depth int, context *evalCon
440
444
EvaluationDetails : evalDetails ,
441
445
DerivedDeviceMetadata : deviceMetadata ,
442
446
ConfigVersion : spec .ConfigVersion ,
447
+ HasSeenAnalyticalGates : context .EvalHasSeenAnalyticalGates ,
443
448
}
444
449
}
445
450
return & evalResult {Value : false , RuleID : defaultRuleID , IDType : spec .IDType ,
446
- SecondaryExposures : exposures , DerivedDeviceMetadata : deviceMetadata , ConfigVersion : spec .ConfigVersion }
451
+ SecondaryExposures : exposures , DerivedDeviceMetadata : deviceMetadata , ConfigVersion : spec .ConfigVersion , HasSeenAnalyticalGates : context .EvalHasSeenAnalyticalGates ,
452
+ }
447
453
}
448
454
449
455
func (e * evaluator ) evalDelegate (user User , rule configRule , exposures []SecondaryExposure , depth int , context * evalContext ) * evalResult {
@@ -539,6 +545,10 @@ func (e *evaluator) evalCondition(user User, cond configCondition, depth int, co
539
545
allExposures = append (result .SecondaryExposures , newExposure )
540
546
}
541
547
548
+ if context .EvalSamplingRate == nil && ! strings .HasPrefix (dependentGateName , "segment:" ) {
549
+ context .EvalHasSeenAnalyticalGates = true
550
+ }
551
+
542
552
if strings .EqualFold (condType , "pass_gate" ) {
543
553
return & evalResult {Value : result .Value , SecondaryExposures : allExposures , DerivedDeviceMetadata : result .DerivedDeviceMetadata }
544
554
} else {
0 commit comments