@@ -103,6 +103,7 @@ export type EppoClientParameters = {
103
103
flagConfigurationStore : IConfigurationStore < Flag | ObfuscatedFlag > ;
104
104
banditVariationConfigurationStore ?: IConfigurationStore < BanditVariation [ ] > ;
105
105
banditModelConfigurationStore ?: IConfigurationStore < BanditParameters > ;
106
+ overrideStore ?: ISyncStore < Variation > ;
106
107
configurationRequestParameters ?: FlagConfigurationRequestParameters ;
107
108
/**
108
109
* Setting this value will have no side effects other than triggering a warning when the actual
@@ -131,40 +132,33 @@ export default class EppoClient {
131
132
private assignmentCache ?: AssignmentCache ;
132
133
// whether to suppress any errors and return default values instead
133
134
private isGracefulFailureMode = true ;
134
- private expectObfuscated : boolean ;
135
- private obfuscationMismatchWarningIssued = false ;
136
- private configObfuscatedCache ?: boolean ;
137
135
private requestPoller ?: IPoller ;
138
136
private readonly evaluator = new Evaluator ( ) ;
139
137
private configurationRequestor ?: ConfigurationRequestor ;
140
138
private readonly overrideValidator = new OverrideValidator ( ) ;
141
139
142
140
constructor ( {
143
141
eventDispatcher = new NoOpEventDispatcher ( ) ,
144
- isObfuscated = false ,
142
+ isObfuscated,
145
143
flagConfigurationStore,
146
144
banditVariationConfigurationStore,
147
145
banditModelConfigurationStore,
148
146
overrideStore,
149
147
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 ) {
161
149
this . eventDispatcher = eventDispatcher ;
162
150
this . flagConfigurationStore = flagConfigurationStore ;
163
151
this . banditVariationConfigurationStore = banditVariationConfigurationStore ;
164
152
this . banditModelConfigurationStore = banditModelConfigurationStore ;
165
153
this . overrideStore = overrideStore ;
166
154
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
+ }
168
162
}
169
163
170
164
private getConfiguration ( ) : IConfiguration {
@@ -177,32 +171,6 @@ export default class EppoClient {
177
171
) ;
178
172
}
179
173
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
-
206
174
/**
207
175
* Validates and parses x-eppo-overrides header sent by Eppo's Chrome extension
208
176
*/
@@ -241,7 +209,6 @@ export default class EppoClient {
241
209
// noinspection JSUnusedGlobalSymbols
242
210
setFlagConfigurationStore ( flagConfigurationStore : IConfigurationStore < Flag | ObfuscatedFlag > ) {
243
211
this . flagConfigurationStore = flagConfigurationStore ;
244
- this . configObfuscatedCache = undefined ;
245
212
}
246
213
247
214
// noinspection JSUnusedGlobalSymbols
@@ -287,8 +254,12 @@ export default class EppoClient {
287
254
* @deprecated The client determines whether the configuration is obfuscated by inspection
288
255
* @param isObfuscated
289
256
*/
257
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
290
258
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
+ ) ;
292
263
}
293
264
294
265
setOverrideStore ( store : ISyncStore < Variation > ) : void {
@@ -354,7 +325,6 @@ export default class EppoClient {
354
325
355
326
const pollingCallback = async ( ) => {
356
327
if ( await configurationRequestor . isFlagConfigExpired ( ) ) {
357
- this . configObfuscatedCache = undefined ;
358
328
return configurationRequestor . fetchAndStoreConfigurations ( ) ;
359
329
}
360
330
} ;
@@ -977,7 +947,7 @@ export default class EppoClient {
977
947
configDetails ,
978
948
subjectKey ,
979
949
subjectAttributes ,
980
- this . isObfuscated ( config ) ,
950
+ config . isObfuscated ( ) ,
981
951
) ;
982
952
983
953
// allocationKey is set along with variation when there is a result. this check appeases typescript below
@@ -1130,7 +1100,7 @@ export default class EppoClient {
1130
1100
) ;
1131
1101
}
1132
1102
1133
- const isObfuscated = this . isObfuscated ( config ) ;
1103
+ const isObfuscated = config . isObfuscated ( ) ;
1134
1104
const result = this . evaluator . evaluateFlag (
1135
1105
flag ,
1136
1106
configDetails ,
@@ -1182,7 +1152,7 @@ export default class EppoClient {
1182
1152
}
1183
1153
1184
1154
private getNormalizedFlag ( config : IConfiguration , flagKey : string ) : Flag | null {
1185
- return this . isObfuscated ( config )
1155
+ return config . isObfuscated ( )
1186
1156
? this . getObfuscatedFlag ( config , flagKey )
1187
1157
: config . getFlag ( flagKey ) ;
1188
1158
}
@@ -1349,7 +1319,7 @@ export default class EppoClient {
1349
1319
1350
1320
private buildLoggerMetadata ( ) : Record < string , unknown > {
1351
1321
return {
1352
- obfuscated : this . isObfuscated ( this . getConfiguration ( ) ) ,
1322
+ obfuscated : this . getConfiguration ( ) . isObfuscated ( ) ,
1353
1323
sdkLanguage : 'javascript' ,
1354
1324
sdkLibVersion : LIB_VERSION ,
1355
1325
} ;
0 commit comments