@@ -103,6 +103,7 @@ export type EppoClientParameters = {
103103 flagConfigurationStore : IConfigurationStore < Flag | ObfuscatedFlag > ;
104104 banditVariationConfigurationStore ?: IConfigurationStore < BanditVariation [ ] > ;
105105 banditModelConfigurationStore ?: IConfigurationStore < BanditParameters > ;
106+ overrideStore ?: ISyncStore < Variation > ;
106107 configurationRequestParameters ?: FlagConfigurationRequestParameters ;
107108 /**
108109 * Setting this value will have no side effects other than triggering a warning when the actual
@@ -131,40 +132,33 @@ export default class EppoClient {
131132 private assignmentCache ?: AssignmentCache ;
132133 // whether to suppress any errors and return default values instead
133134 private isGracefulFailureMode = true ;
134- private expectObfuscated : boolean ;
135- private obfuscationMismatchWarningIssued = false ;
136- private configObfuscatedCache ?: boolean ;
137135 private requestPoller ?: IPoller ;
138136 private readonly evaluator = new Evaluator ( ) ;
139137 private configurationRequestor ?: ConfigurationRequestor ;
140138 private readonly overrideValidator = new OverrideValidator ( ) ;
141139
142140 constructor ( {
143141 eventDispatcher = new NoOpEventDispatcher ( ) ,
144- isObfuscated = false ,
142+ isObfuscated,
145143 flagConfigurationStore,
146144 banditVariationConfigurationStore,
147145 banditModelConfigurationStore,
148146 overrideStore,
149147 configurationRequestParameters,
150- } : {
151- // Dispatcher for arbitrary, application-level events (not to be confused with Eppo specific assignment
152- // or bandit events). These events are application-specific and captures by EppoClient#track API.
153- eventDispatcher ?: EventDispatcher ;
154- flagConfigurationStore : IConfigurationStore < Flag | ObfuscatedFlag > ;
155- banditVariationConfigurationStore ?: IConfigurationStore < BanditVariation [ ] > ;
156- banditModelConfigurationStore ?: IConfigurationStore < BanditParameters > ;
157- overrideStore ?: ISyncStore < Variation > ;
158- configurationRequestParameters ?: FlagConfigurationRequestParameters ;
159- isObfuscated ?: boolean ;
160- } ) {
148+ } : EppoClientParameters ) {
161149 this . eventDispatcher = eventDispatcher ;
162150 this . flagConfigurationStore = flagConfigurationStore ;
163151 this . banditVariationConfigurationStore = banditVariationConfigurationStore ;
164152 this . banditModelConfigurationStore = banditModelConfigurationStore ;
165153 this . overrideStore = overrideStore ;
166154 this . configurationRequestParameters = configurationRequestParameters ;
167- this . expectObfuscated = isObfuscated ;
155+
156+ if ( isObfuscated !== undefined ) {
157+ logger . warn (
158+ '[Eppo SDK] specifying isObfuscated no longer has an effect and will be removed in the next major release; obfuscation ' +
159+ 'is now inferred from the configuration, so you can safely remove the option.' ,
160+ ) ;
161+ }
168162 }
169163
170164 private getConfiguration ( ) : IConfiguration {
@@ -177,32 +171,6 @@ export default class EppoClient {
177171 ) ;
178172 }
179173
180- private maybeWarnAboutObfuscationMismatch ( configObfuscated : boolean ) {
181- // Don't warn again if we did on the last check.
182- if ( configObfuscated !== this . expectObfuscated && ! this . obfuscationMismatchWarningIssued ) {
183- this . obfuscationMismatchWarningIssued = true ;
184- logger . warn (
185- `[Eppo SDK] configuration obfuscation [${ configObfuscated } ] does not match expected [${ this . expectObfuscated } ]` ,
186- ) ;
187- } else if ( configObfuscated === this . expectObfuscated ) {
188- // Reset the warning to false in case the client configuration (re-)enters a mismatched state.
189- this . obfuscationMismatchWarningIssued = false ;
190- }
191- }
192-
193- /**
194- * This method delegates to the configuration to determine whether it is obfuscated, then caches the actual
195- * obfuscation state and issues a warning if it hasn't already.
196- * This method can be removed with the next major update when the @deprecated setIsObfuscated is removed
197- */
198- private isObfuscated ( config : IConfiguration ) {
199- if ( this . configObfuscatedCache === undefined ) {
200- this . configObfuscatedCache = config . isObfuscated ( ) ;
201- }
202- this . maybeWarnAboutObfuscationMismatch ( this . configObfuscatedCache ) ;
203- return this . configObfuscatedCache ;
204- }
205-
206174 /**
207175 * Validates and parses x-eppo-overrides header sent by Eppo's Chrome extension
208176 */
@@ -241,7 +209,6 @@ export default class EppoClient {
241209 // noinspection JSUnusedGlobalSymbols
242210 setFlagConfigurationStore ( flagConfigurationStore : IConfigurationStore < Flag | ObfuscatedFlag > ) {
243211 this . flagConfigurationStore = flagConfigurationStore ;
244- this . configObfuscatedCache = undefined ;
245212 }
246213
247214 // noinspection JSUnusedGlobalSymbols
@@ -287,8 +254,12 @@ export default class EppoClient {
287254 * @deprecated The client determines whether the configuration is obfuscated by inspection
288255 * @param isObfuscated
289256 */
257+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
290258 setIsObfuscated ( isObfuscated : boolean ) {
291- this . expectObfuscated = isObfuscated ;
259+ logger . warn (
260+ '[Eppo SDK] setIsObfuscated no longer has an effect and will be removed in the next major release; obfuscation ' +
261+ 'is now inferred from the configuration, so you can safely remove the call to this method.' ,
262+ ) ;
292263 }
293264
294265 setOverrideStore ( store : ISyncStore < Variation > ) : void {
@@ -354,7 +325,6 @@ export default class EppoClient {
354325
355326 const pollingCallback = async ( ) => {
356327 if ( await configurationRequestor . isFlagConfigExpired ( ) ) {
357- this . configObfuscatedCache = undefined ;
358328 return configurationRequestor . fetchAndStoreConfigurations ( ) ;
359329 }
360330 } ;
@@ -977,7 +947,7 @@ export default class EppoClient {
977947 configDetails ,
978948 subjectKey ,
979949 subjectAttributes ,
980- this . isObfuscated ( config ) ,
950+ config . isObfuscated ( ) ,
981951 ) ;
982952
983953 // allocationKey is set along with variation when there is a result. this check appeases typescript below
@@ -1130,7 +1100,7 @@ export default class EppoClient {
11301100 ) ;
11311101 }
11321102
1133- const isObfuscated = this . isObfuscated ( config ) ;
1103+ const isObfuscated = config . isObfuscated ( ) ;
11341104 const result = this . evaluator . evaluateFlag (
11351105 flag ,
11361106 configDetails ,
@@ -1182,7 +1152,7 @@ export default class EppoClient {
11821152 }
11831153
11841154 private getNormalizedFlag ( config : IConfiguration , flagKey : string ) : Flag | null {
1185- return this . isObfuscated ( config )
1155+ return config . isObfuscated ( )
11861156 ? this . getObfuscatedFlag ( config , flagKey )
11871157 : config . getFlag ( flagKey ) ;
11881158 }
@@ -1349,7 +1319,7 @@ export default class EppoClient {
13491319
13501320 private buildLoggerMetadata ( ) : Record < string , unknown > {
13511321 return {
1352- obfuscated : this . isObfuscated ( this . getConfiguration ( ) ) ,
1322+ obfuscated : this . getConfiguration ( ) . isObfuscated ( ) ,
13531323 sdkLanguage : 'javascript' ,
13541324 sdkLibVersion : LIB_VERSION ,
13551325 } ;
0 commit comments