@@ -303,7 +303,7 @@ def __finalize_exposures(self, end_result):
303
303
def __evaluate_rule (self , user , rule , end_result ):
304
304
total_eval_result = True
305
305
for condition in rule .get ("conditions" , []):
306
- eval_result = self .__evaluate_condition (user , condition , end_result )
306
+ eval_result = self .__evaluate_condition (user , condition , end_result , rule . get ( "samplingRate" , None ) )
307
307
if not eval_result :
308
308
total_eval_result = False
309
309
end_result .boolean_value = total_eval_result
@@ -325,13 +325,14 @@ def __evaluate_delegate(self, user, rule, end_result):
325
325
end_result .allocated_experiment = config_delegate
326
326
return end_result
327
327
328
- def __evaluate_condition (self , user , condition , end_result ):
328
+ def __evaluate_condition (self , user , condition , end_result , sampling_rate = None ):
329
329
value = None
330
330
type = condition .get ("type" , "" ).upper ()
331
331
target = condition .get ("targetValue" )
332
332
field = condition .get ("field" , "" )
333
333
id_Type = condition .get ("idType" , "userID" )
334
334
if type == "PUBLIC" :
335
+ end_result .analytical_condition = sampling_rate is None
335
336
return True
336
337
if type in ("FAIL_GATE" , "PASS_GATE" ):
337
338
self .check_gate (user , target , end_result , True )
@@ -343,11 +344,16 @@ def __evaluate_condition(self, user, condition, end_result):
343
344
}
344
345
345
346
end_result .secondary_exposures .append (new_exposure )
347
+ if end_result .analytical_condition and isinstance (target , str ) and not target .startswith ("segment:" ):
348
+ end_result .seen_analytical_gates = True
346
349
347
350
pass_gate = end_result .boolean_value if type == "PASS_GATE" else not end_result .boolean_value
351
+
352
+ end_result .analytical_condition = sampling_rate is None
348
353
return pass_gate
349
354
if type in ("MULTI_PASS_GATE" , "MULTI_FAIL_GATE" ):
350
355
if target is None or len (target ) == 0 :
356
+ end_result .analytical_condition = sampling_rate is None
351
357
return False
352
358
pass_gate = False
353
359
for gate in target :
@@ -359,10 +365,14 @@ def __evaluate_condition(self, user, condition, end_result):
359
365
"ruleID" : other_result .rule_id
360
366
}
361
367
end_result .secondary_exposures .append (new_exposure )
368
+ if end_result .analytical_condition and isinstance (target , str ) and not target .startswith ("segment:" ):
369
+ end_result .seen_analytical_gates = True
362
370
363
371
pass_gate = pass_gate or other_result .boolean_value if type == "MULTI_PASS_GATE" else pass_gate or not other_result .boolean_value
364
372
if pass_gate :
365
373
break
374
+
375
+ end_result .analytical_condition = sampling_rate is None
366
376
return pass_gate
367
377
if type == "IP_BASED" :
368
378
value = self .__get_from_user (user , field )
@@ -373,6 +383,7 @@ def __evaluate_condition(self, user, condition, end_result):
373
383
self ._country_lookup = CountryLookup ()
374
384
value = self ._country_lookup .lookupStr (ip )
375
385
if value is None :
386
+ end_result .analytical_condition = sampling_rate is None
376
387
return False
377
388
elif type == "UA_BASED" :
378
389
value = self .__get_from_user (user , field )
@@ -394,6 +405,8 @@ def __evaluate_condition(self, user, condition, end_result):
394
405
elif type == "UNIT_ID" :
395
406
value = self .__get_unit_id (user , id_Type )
396
407
408
+ end_result .analytical_condition = sampling_rate is None
409
+
397
410
op = condition .get ("operator" )
398
411
user_bucket = condition .get ("user_bucket" )
399
412
if op == "gt" :
0 commit comments