Skip to content

Commit 0fb6e07

Browse files
refactor: remove SDK experiment eligibility reporting (#23)
1 parent db09e8b commit 0fb6e07

5 files changed

Lines changed: 35 additions & 112 deletions

File tree

‎fbclient/common_types.py‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,22 +285,20 @@ def __init__(self,
285285
id: str,
286286
value: Optional[str],
287287
reason: str,
288-
is_send_to_expt: bool = False,
289288
key_name: Optional[str] = None,
290289
name: Optional[str] = None,
291290
flag_type: Optional[str] = 'string'):
292291

293292
self.__id = id
294293
self.__value = value
295294
self.__reason = reason
296-
self.__is_send_to_expt = is_send_to_expt
297295
self.__key_name = key_name
298296
self.__name = name
299297
self.__flag_type = flag_type
300298

301299
@staticmethod
302300
def error(default_value: Optional[str], reason: str, key_name: Optional[str] = None, flag_type: Optional[str] = 'string'):
303-
return _EvalResult(__NO_VARIATION__, default_value, reason, False, key_name if key_name else __FLAG_KEY_UNKNOWN__, __FLAG_NAME_UNKNOWN__, flag_type)
301+
return _EvalResult(__NO_VARIATION__, default_value, reason, key_name if key_name else __FLAG_KEY_UNKNOWN__, __FLAG_NAME_UNKNOWN__, flag_type)
304302

305303
@property
306304
def id(self) -> str:
@@ -314,10 +312,6 @@ def value(self) -> Optional[str]:
314312
def reason(self) -> str:
315313
return self.__reason
316314

317-
@property
318-
def is_send_to_expt(self) -> bool:
319-
return self.__is_send_to_expt
320-
321315
@property
322316
def key_name(self) -> Optional[str]:
323317
return self.__key_name

‎fbclient/evaluator.py‎

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@
6666

6767
__NOT_IN_SEGMENT_CLAUSE__ = 'User is not in segment'
6868

69-
__EXPT_KEY_PREFIX__ = "expt"
70-
7169

7270
class Evaluator:
7371
def __init__(self,
@@ -96,7 +94,7 @@ def _match_user_variation(self, flag: dict, user: FBUser, fb_event: Optional[FBE
9694
if er is not None:
9795
log.info('FB Python SDK: User %s, Feature Flag %s, Flag Value %s' % (user.get('KeyId'), er.key_name, er.value))
9896
# Match the server default: only an explicit boolean false
99-
# disables insights; evaluation and experiment eligibility stay unchanged.
97+
# disables insights; evaluation stays unchanged.
10098
if fb_event is not None and flag.get('insightsEnabled') is not False:
10199
fb_event.add(FlagEventVariation(er))
102100

@@ -106,7 +104,6 @@ def _match_feature_flag_disabled_user_variation(self, flag: dict, user: FBUser)
106104
return _EvalResult(flag['disabledVariationId'],
107105
flag['variationMap'][flag['disabledVariationId']],
108106
REASON_FLAG_OFF,
109-
False,
110107
flag['key'],
111108
flag['name'],
112109
flag['variationType'])
@@ -119,7 +116,6 @@ def _match_targeted_user_variation(self, flag: dict, user: FBUser) -> Optional[_
119116
return _EvalResult(target['variationId'],
120117
flag['variationMap'][target['variationId']],
121118
REASON_TARGET_MATCH,
122-
flag['exptIncludeAllTargets'],
123119
flag['key'],
124120
flag['name'],
125121
flag['variationType'])
@@ -269,36 +265,14 @@ def _get_rollout_variation_option(self,
269265
key_name: str,
270266
name: str) -> Optional[_EvalResult]:
271267

272-
def is_send_to_expt(dispatch_key: str,
273-
rollout: dict,
274-
expt_include_all_targets: bool,
275-
rule_inclued_in_expt: bool) -> bool:
276-
if expt_include_all_targets:
277-
return True
278-
if rule_inclued_in_expt:
279-
send_to_expt_percentage = rollout['exptRollout']
280-
splitting_percentage = rollout['rollout'][1] - rollout['rollout'][0]
281-
282-
if send_to_expt_percentage == 0 or splitting_percentage == 0:
283-
return False
284-
285-
upper_bound = send_to_expt_percentage / splitting_percentage
286-
if upper_bound > 1:
287-
upper_bound = 1
288-
new_dispatch_key = "".join((__EXPT_KEY_PREFIX__, dispatch_key))
289-
return VariationSplittingAlgorithm(new_dispatch_key, [0, upper_bound]).is_key_belongs_to_percentage()
290-
return False
291-
292268
dispatch_key = rollout_variations.get('dispatchKey')
293269
dispatch_key = dispatch_key if dispatch_key else 'keyid'
294270
dispatch_key_value = "".join((flag['key'], user.get(dispatch_key, ""))) # type: ignore
295271
for rollout in rollout_variations['variations']:
296272
if VariationSplittingAlgorithm(dispatch_key_value, rollout['rollout']).is_key_belongs_to_percentage(): # type: ignore
297-
send_to_expt = is_send_to_expt(dispatch_key_value, rollout, flag['exptIncludeAllTargets'], rollout_variations['includedInExpt']) # type: ignore
298273
return _EvalResult(rollout['id'],
299274
flag['variationMap'][rollout['id']],
300275
reason,
301-
send_to_expt,
302276
key_name,
303277
name,
304278
flag['variationType'])

‎fbclient/event_types.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ def to_json_dict(self) -> dict:
121121
arr = []
122122
for variation in self.__variations:
123123
flag_json_dict = {'featureFlagKey': variation.variation.key_name,
124-
'sendToExperiment': variation.variation.is_send_to_expt,
125124
'timestamp': variation.timestamp,
126125
'variation': {
127126
'id': variation.variation.id,

0 commit comments

Comments
 (0)