1
1
import * as md5 from 'md5' ;
2
2
3
3
import { IAssignmentEvent , IAssignmentLogger } from './assignment-logger' ;
4
- import { MAX_EVENT_QUEUE_SIZE , NULL_SENTINEL , SESSION_ASSIGNMENT_CONFIG_LOADED } from './constants' ;
4
+ import { MAX_EVENT_QUEUE_SIZE } from './constants' ;
5
5
import { IExperimentConfiguration } from './experiment/experiment-configuration' ;
6
6
import { EppoLocalStorage } from './local-storage' ;
7
7
import { Rule } from './rule' ;
@@ -50,30 +50,16 @@ export default class EppoClient implements IEppoClient {
50
50
getAssignment ( subjectKey : string , experimentKey : string , subjectAttributes = { } ) : string {
51
51
validateNotBlank ( subjectKey , 'Invalid argument: subjectKey cannot be blank' ) ;
52
52
validateNotBlank ( experimentKey , 'Invalid argument: experimentKey cannot be blank' ) ;
53
- // If getAssignment was called when the latest configuration were still being downloaded
54
- // use the old assignment for the remainder of the session to avoid a flickering effect;
55
- // we don't want a subject to switch between 2 variations during the same session.
56
- const sessionOverrideKey = `${ subjectKey } -${ experimentKey } -session-override` ;
57
- const sessionOverride = this . sessionStorage . get ( sessionOverrideKey ) ;
58
- if ( sessionOverride ) {
59
- if ( sessionOverride === NULL_SENTINEL ) {
60
- return null ;
61
- }
62
- this . logAssignment ( experimentKey , sessionOverride , subjectKey , subjectAttributes ) ;
63
- return sessionOverride ;
64
- }
65
53
const experimentConfig = this . configurationStore . get < IExperimentConfiguration > ( experimentKey ) ;
66
54
const allowListOverride = this . getSubjectVariationOverride ( subjectKey , experimentConfig ) ;
67
55
if ( allowListOverride ) {
68
- this . setSessionOverrideIfLoadingConfigurations ( sessionOverrideKey , allowListOverride ) ;
69
56
return allowListOverride ;
70
57
}
71
58
if (
72
59
! experimentConfig ?. enabled ||
73
60
! this . subjectAttributesSatisfyRules ( subjectAttributes , experimentConfig . rules ) ||
74
61
! this . isInExperimentSample ( subjectKey , experimentKey , experimentConfig )
75
62
) {
76
- this . setSessionOverrideIfLoadingConfigurations ( sessionOverrideKey , NULL_SENTINEL ) ;
77
63
return null ;
78
64
}
79
65
const { variations, subjectShards } = experimentConfig ;
@@ -82,7 +68,6 @@ export default class EppoClient implements IEppoClient {
82
68
isShardInRange ( shard , variation . shardRange ) ,
83
69
) . name ;
84
70
this . logAssignment ( experimentKey , assignedVariation , subjectKey , subjectAttributes ) ;
85
- this . setSessionOverrideIfLoadingConfigurations ( sessionOverrideKey , assignedVariation ) ;
86
71
return assignedVariation ;
87
72
}
88
73
@@ -129,12 +114,6 @@ export default class EppoClient implements IEppoClient {
129
114
}
130
115
}
131
116
132
- private setSessionOverrideIfLoadingConfigurations ( overrideKey : string , assignmentValue : string ) {
133
- if ( this . sessionStorage . get ( SESSION_ASSIGNMENT_CONFIG_LOADED ) !== 'true' ) {
134
- this . sessionStorage . set ( overrideKey , assignmentValue ) ;
135
- }
136
- }
137
-
138
117
// eslint-disable-next-line @typescript-eslint/no-explicit-any
139
118
private subjectAttributesSatisfyRules ( subjectAttributes ?: Record < string , any > , rules ?: Rule [ ] ) {
140
119
if ( ! rules || rules . length === 0 ) {
0 commit comments