@@ -108,6 +108,7 @@ export type EppoClientParameters = {
108
108
flagConfigurationStore : IConfigurationStore < Flag | ObfuscatedFlag > ;
109
109
banditVariationConfigurationStore ?: IConfigurationStore < BanditVariation [ ] > ;
110
110
banditModelConfigurationStore ?: IConfigurationStore < BanditParameters > ;
111
+ overrideStore ?: ISyncStore < Variation > ;
111
112
configurationRequestParameters ?: FlagConfigurationRequestParameters ;
112
113
/**
113
114
* Setting this value will have no side effects other than triggering a warning when the actual
@@ -136,9 +137,6 @@ export default class EppoClient {
136
137
private assignmentCache ?: AssignmentCache ;
137
138
// whether to suppress any errors and return default values instead
138
139
private isGracefulFailureMode = true ;
139
- private expectObfuscated : boolean ;
140
- private obfuscationMismatchWarningIssued = false ;
141
- private configObfuscatedCache ?: boolean ;
142
140
private requestPoller ?: IPoller ;
143
141
private readonly evaluator = new Evaluator ( ) ;
144
142
private configurationRequestor ?: ConfigurationRequestor ;
@@ -147,30 +145,27 @@ export default class EppoClient {
147
145
148
146
constructor ( {
149
147
eventDispatcher = new NoOpEventDispatcher ( ) ,
150
- isObfuscated = false ,
148
+ isObfuscated,
151
149
flagConfigurationStore,
152
150
banditVariationConfigurationStore,
153
151
banditModelConfigurationStore,
154
152
overrideStore,
155
153
configurationRequestParameters,
156
- } : {
157
- // Dispatcher for arbitrary, application-level events (not to be confused with Eppo specific assignment
158
- // or bandit events). These events are application-specific and captures by EppoClient#track API.
159
- eventDispatcher ?: EventDispatcher ;
160
- flagConfigurationStore : IConfigurationStore < Flag | ObfuscatedFlag > ;
161
- banditVariationConfigurationStore ?: IConfigurationStore < BanditVariation [ ] > ;
162
- banditModelConfigurationStore ?: IConfigurationStore < BanditParameters > ;
163
- overrideStore ?: ISyncStore < Variation > ;
164
- configurationRequestParameters ?: FlagConfigurationRequestParameters ;
165
- isObfuscated ?: boolean ;
166
- } ) {
154
+ } : EppoClientParameters ) {
167
155
this . eventDispatcher = eventDispatcher ;
168
156
this . flagConfigurationStore = flagConfigurationStore ;
169
157
this . banditVariationConfigurationStore = banditVariationConfigurationStore ;
170
158
this . banditModelConfigurationStore = banditModelConfigurationStore ;
171
159
this . overrideStore = overrideStore ;
172
160
this . configurationRequestParameters = configurationRequestParameters ;
173
- this . expectObfuscated = isObfuscated ;
161
+
162
+ if ( isObfuscated !== undefined ) {
163
+ logger . warn (
164
+ '[Eppo SDK] specifying isObfuscated no longer has an effect and will be removed in the next major release; obfuscation ' +
165
+ 'is now inferred from the configuration, so you can safely remove the option.' ,
166
+ ) ;
167
+ }
168
+
174
169
175
170
// Initialize the configuration manager
176
171
this . configurationManager = new ConfigurationManager (
@@ -184,32 +179,6 @@ export default class EppoClient {
184
179
return this . configurationManager . getConfiguration ( ) ;
185
180
}
186
181
187
- private maybeWarnAboutObfuscationMismatch ( configObfuscated : boolean ) {
188
- // Don't warn again if we did on the last check.
189
- if ( configObfuscated !== this . expectObfuscated && ! this . obfuscationMismatchWarningIssued ) {
190
- this . obfuscationMismatchWarningIssued = true ;
191
- logger . warn (
192
- `[Eppo SDK] configuration obfuscation [${ configObfuscated } ] does not match expected [${ this . expectObfuscated } ]` ,
193
- ) ;
194
- } else if ( configObfuscated === this . expectObfuscated ) {
195
- // Reset the warning to false in case the client configuration (re-)enters a mismatched state.
196
- this . obfuscationMismatchWarningIssued = false ;
197
- }
198
- }
199
-
200
- /**
201
- * This method delegates to the configuration to determine whether it is obfuscated, then caches the actual
202
- * obfuscation state and issues a warning if it hasn't already.
203
- * This method can be removed with the next major update when the @deprecated setIsObfuscated is removed
204
- */
205
- private isObfuscated ( config : IConfiguration ) {
206
- if ( this . configObfuscatedCache === undefined ) {
207
- this . configObfuscatedCache = config . isObfuscated ( ) ;
208
- }
209
- this . maybeWarnAboutObfuscationMismatch ( this . configObfuscatedCache ) ;
210
- return this . configObfuscatedCache ;
211
- }
212
-
213
182
/**
214
183
* Validates and parses x-eppo-overrides header sent by Eppo's Chrome extension
215
184
*/
@@ -248,8 +217,6 @@ export default class EppoClient {
248
217
// noinspection JSUnusedGlobalSymbols
249
218
setFlagConfigurationStore ( flagConfigurationStore : IConfigurationStore < Flag | ObfuscatedFlag > ) {
250
219
this . flagConfigurationStore = flagConfigurationStore ;
251
- this . configObfuscatedCache = undefined ;
252
-
253
220
// Update the configuration manager
254
221
this . innerSetConfigurationStores ( ) ;
255
222
}
@@ -303,6 +270,29 @@ export default class EppoClient {
303
270
this . eventDispatcher ?. attachContext ( key , value ) ;
304
271
}
305
272
273
+ // noinspection JSUnusedGlobalSymbols
274
+ setBanditModelConfigurationStore (
275
+ banditModelConfigurationStore : IConfigurationStore < BanditParameters > ,
276
+ ) {
277
+ this . banditModelConfigurationStore = banditModelConfigurationStore ;
278
+ }
279
+
280
+ // noinspection JSUnusedGlobalSymbols
281
+ /**
282
+ * Setting this value will have no side effects other than triggering a warning when the actual
283
+ * configuration's obfuscated does not match the value set here.
284
+ *
285
+ * @deprecated The client determines whether the configuration is obfuscated by inspection
286
+ * @param isObfuscated
287
+ */
288
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
289
+ setIsObfuscated ( isObfuscated : boolean ) {
290
+ logger . warn (
291
+ '[Eppo SDK] setIsObfuscated no longer has an effect and will be removed in the next major release; obfuscation ' +
292
+ 'is now inferred from the configuration, so you can safely remove the call to this method.' ,
293
+ ) ;
294
+ }
295
+
306
296
setOverrideStore ( store : ISyncStore < Variation > ) : void {
307
297
this . overrideStore = store ;
308
298
}
@@ -360,7 +350,7 @@ export default class EppoClient {
360
350
apiKey,
361
351
sdkName,
362
352
sdkVersion,
363
- baseUrl,
353
+ baseUrl, // Default is set in ApiEndpoints constructor if undefined
364
354
requestTimeoutMs = DEFAULT_REQUEST_TIMEOUT_MS ,
365
355
numInitialRequestRetries = DEFAULT_INITIAL_CONFIG_REQUEST_RETRIES ,
366
356
numPollRequestRetries = DEFAULT_POLL_CONFIG_REQUEST_RETRIES ,
@@ -392,7 +382,6 @@ export default class EppoClient {
392
382
393
383
const pollingCallback = async ( ) => {
394
384
if ( await this . flagConfigurationStore . isExpired ( ) ) {
395
- this . configObfuscatedCache = undefined ;
396
385
return configurationRequestor . fetchAndStoreConfigurations ( ) ;
397
386
}
398
387
} ;
@@ -1015,7 +1004,7 @@ export default class EppoClient {
1015
1004
configDetails ,
1016
1005
subjectKey ,
1017
1006
subjectAttributes ,
1018
- this . isObfuscated ( config ) ,
1007
+ config . isObfuscated ( ) ,
1019
1008
) ;
1020
1009
1021
1010
// allocationKey is set along with variation when there is a result. this check appeases typescript below
@@ -1168,7 +1157,7 @@ export default class EppoClient {
1168
1157
) ;
1169
1158
}
1170
1159
1171
- const isObfuscated = this . isObfuscated ( config ) ;
1160
+ const isObfuscated = config . isObfuscated ( ) ;
1172
1161
const result = this . evaluator . evaluateFlag (
1173
1162
flag ,
1174
1163
configDetails ,
@@ -1220,7 +1209,7 @@ export default class EppoClient {
1220
1209
}
1221
1210
1222
1211
private getNormalizedFlag ( config : IConfiguration , flagKey : string ) : Flag | null {
1223
- return this . isObfuscated ( config )
1212
+ return config . isObfuscated ( )
1224
1213
? this . getObfuscatedFlag ( config , flagKey )
1225
1214
: config . getFlag ( flagKey ) ;
1226
1215
}
@@ -1387,7 +1376,7 @@ export default class EppoClient {
1387
1376
1388
1377
private buildLoggerMetadata ( ) : Record < string , unknown > {
1389
1378
return {
1390
- obfuscated : this . isObfuscated ( this . getConfiguration ( ) ) ,
1379
+ obfuscated : this . getConfiguration ( ) . isObfuscated ( ) ,
1391
1380
sdkLanguage : 'javascript' ,
1392
1381
sdkLibVersion : LIB_VERSION ,
1393
1382
} ;
0 commit comments