From 3d617e38a205c76d1e601091fa1bc90c82b2f1bc Mon Sep 17 00:00:00 2001 From: Ty Potter Date: Wed, 19 Mar 2025 08:50:14 -0600 Subject: [PATCH 1/4] fix: warn when setting isObfuscated not when checking config, also change level to info --- src/client/eppo-client.ts | 66 ++++++++++----------------------------- 1 file changed, 17 insertions(+), 49 deletions(-) diff --git a/src/client/eppo-client.ts b/src/client/eppo-client.ts index 9c641de..dc70b2b 100644 --- a/src/client/eppo-client.ts +++ b/src/client/eppo-client.ts @@ -103,6 +103,7 @@ export type EppoClientParameters = { flagConfigurationStore: IConfigurationStore; banditVariationConfigurationStore?: IConfigurationStore; banditModelConfigurationStore?: IConfigurationStore; + overrideStore?: ISyncStore; configurationRequestParameters?: FlagConfigurationRequestParameters; /** * Setting this value will have no side effects other than triggering a warning when the actual @@ -131,9 +132,6 @@ export default class EppoClient { private assignmentCache?: AssignmentCache; // whether to suppress any errors and return default values instead private isGracefulFailureMode = true; - private expectObfuscated: boolean; - private obfuscationMismatchWarningIssued = false; - private configObfuscatedCache?: boolean; private requestPoller?: IPoller; private readonly evaluator = new Evaluator(); private configurationRequestor?: ConfigurationRequestor; @@ -141,30 +139,25 @@ export default class EppoClient { constructor({ eventDispatcher = new NoOpEventDispatcher(), - isObfuscated = false, + isObfuscated, flagConfigurationStore, banditVariationConfigurationStore, banditModelConfigurationStore, overrideStore, configurationRequestParameters, - }: { - // Dispatcher for arbitrary, application-level events (not to be confused with Eppo specific assignment - // or bandit events). These events are application-specific and captures by EppoClient#track API. - eventDispatcher?: EventDispatcher; - flagConfigurationStore: IConfigurationStore; - banditVariationConfigurationStore?: IConfigurationStore; - banditModelConfigurationStore?: IConfigurationStore; - overrideStore?: ISyncStore; - configurationRequestParameters?: FlagConfigurationRequestParameters; - isObfuscated?: boolean; - }) { + }: EppoClientParameters) { this.eventDispatcher = eventDispatcher; this.flagConfigurationStore = flagConfigurationStore; this.banditVariationConfigurationStore = banditVariationConfigurationStore; this.banditModelConfigurationStore = banditModelConfigurationStore; this.overrideStore = overrideStore; this.configurationRequestParameters = configurationRequestParameters; - this.expectObfuscated = isObfuscated; + + if (isObfuscated !== undefined) { + logger.info( + `[Eppo SDK] specifying isObfuscated no longer has an effect; obfuscation is inferred from the configuration.`, + ); + } } private getConfiguration(): IConfiguration { @@ -177,32 +170,6 @@ export default class EppoClient { ); } - private maybeWarnAboutObfuscationMismatch(configObfuscated: boolean) { - // Don't warn again if we did on the last check. - if (configObfuscated !== this.expectObfuscated && !this.obfuscationMismatchWarningIssued) { - this.obfuscationMismatchWarningIssued = true; - logger.warn( - `[Eppo SDK] configuration obfuscation [${configObfuscated}] does not match expected [${this.expectObfuscated}]`, - ); - } else if (configObfuscated === this.expectObfuscated) { - // Reset the warning to false in case the client configuration (re-)enters a mismatched state. - this.obfuscationMismatchWarningIssued = false; - } - } - - /** - * This method delegates to the configuration to determine whether it is obfuscated, then caches the actual - * obfuscation state and issues a warning if it hasn't already. - * This method can be removed with the next major update when the @deprecated setIsObfuscated is removed - */ - private isObfuscated(config: IConfiguration) { - if (this.configObfuscatedCache === undefined) { - this.configObfuscatedCache = config.isObfuscated(); - } - this.maybeWarnAboutObfuscationMismatch(this.configObfuscatedCache); - return this.configObfuscatedCache; - } - /** * Validates and parses x-eppo-overrides header sent by Eppo's Chrome extension */ @@ -241,7 +208,6 @@ export default class EppoClient { // noinspection JSUnusedGlobalSymbols setFlagConfigurationStore(flagConfigurationStore: IConfigurationStore) { this.flagConfigurationStore = flagConfigurationStore; - this.configObfuscatedCache = undefined; } // noinspection JSUnusedGlobalSymbols @@ -287,8 +253,11 @@ export default class EppoClient { * @deprecated The client determines whether the configuration is obfuscated by inspection * @param isObfuscated */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars setIsObfuscated(isObfuscated: boolean) { - this.expectObfuscated = isObfuscated; + logger.info( + '[Eppo SDK] setIsObfuscated no longer has an effect; obfuscation is inferred from the configuration.', + ); } setOverrideStore(store: ISyncStore): void { @@ -354,7 +323,6 @@ export default class EppoClient { const pollingCallback = async () => { if (await configurationRequestor.isFlagConfigExpired()) { - this.configObfuscatedCache = undefined; return configurationRequestor.fetchAndStoreConfigurations(); } }; @@ -977,7 +945,7 @@ export default class EppoClient { configDetails, subjectKey, subjectAttributes, - this.isObfuscated(config), + config.isObfuscated(), ); // allocationKey is set along with variation when there is a result. this check appeases typescript below @@ -1130,7 +1098,7 @@ export default class EppoClient { ); } - const isObfuscated = this.isObfuscated(config); + const isObfuscated = config.isObfuscated(); const result = this.evaluator.evaluateFlag( flag, configDetails, @@ -1182,7 +1150,7 @@ export default class EppoClient { } private getNormalizedFlag(config: IConfiguration, flagKey: string): Flag | null { - return this.isObfuscated(config) + return config.isObfuscated() ? this.getObfuscatedFlag(config, flagKey) : config.getFlag(flagKey); } @@ -1349,7 +1317,7 @@ export default class EppoClient { private buildLoggerMetadata(): Record { return { - obfuscated: this.isObfuscated(this.getConfiguration()), + obfuscated: this.getConfiguration().isObfuscated(), sdkLanguage: 'javascript', sdkLibVersion: LIB_VERSION, }; From b1144394bf20d06c43537375f48c33fb3ddd70db Mon Sep 17 00:00:00 2001 From: Ty Potter Date: Wed, 19 Mar 2025 08:53:40 -0600 Subject: [PATCH 2/4] v4.14.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9f48415..29bba33 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eppo/js-client-sdk-common", - "version": "4.14.2", + "version": "4.14.3", "description": "Common library for Eppo JavaScript SDKs (web, react native, and node)", "main": "dist/index.js", "files": [ From 18234634807476133e4316f350149347ea9031ab Mon Sep 17 00:00:00 2001 From: Ty Potter Date: Wed, 19 Mar 2025 09:36:36 -0600 Subject: [PATCH 3/4] update logs --- src/client/eppo-client.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/client/eppo-client.ts b/src/client/eppo-client.ts index dc70b2b..bf64732 100644 --- a/src/client/eppo-client.ts +++ b/src/client/eppo-client.ts @@ -155,7 +155,8 @@ export default class EppoClient { if (isObfuscated !== undefined) { logger.info( - `[Eppo SDK] specifying isObfuscated no longer has an effect; obfuscation is inferred from the configuration.`, + '[Eppo SDK] specifying isObfuscated no longer has an effect and will be removed in the next major release; obfuscation ' + + 'is now inferred from the configuration, so you can safely remove the option.', ); } } @@ -256,7 +257,8 @@ export default class EppoClient { // eslint-disable-next-line @typescript-eslint/no-unused-vars setIsObfuscated(isObfuscated: boolean) { logger.info( - '[Eppo SDK] setIsObfuscated no longer has an effect; obfuscation is inferred from the configuration.', + '[Eppo SDK] setIsObfuscated no longer has an effect and will be removed in the next major release; obfuscation ' + + 'is now inferred from the configuration, so you can safely remove the call to this method.', ); } From ae2d6060d2ec332fcbc8ece93a2013c1b67e6fb2 Mon Sep 17 00:00:00 2001 From: Ty Potter Date: Wed, 19 Mar 2025 14:08:40 -0600 Subject: [PATCH 4/4] warn --- src/client/eppo-client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/eppo-client.ts b/src/client/eppo-client.ts index bf64732..fb58fa2 100644 --- a/src/client/eppo-client.ts +++ b/src/client/eppo-client.ts @@ -154,7 +154,7 @@ export default class EppoClient { this.configurationRequestParameters = configurationRequestParameters; if (isObfuscated !== undefined) { - logger.info( + logger.warn( '[Eppo SDK] specifying isObfuscated no longer has an effect and will be removed in the next major release; obfuscation ' + 'is now inferred from the configuration, so you can safely remove the option.', ); @@ -256,7 +256,7 @@ export default class EppoClient { */ // eslint-disable-next-line @typescript-eslint/no-unused-vars setIsObfuscated(isObfuscated: boolean) { - logger.info( + logger.warn( '[Eppo SDK] setIsObfuscated no longer has an effect and will be removed in the next major release; obfuscation ' + 'is now inferred from the configuration, so you can safely remove the call to this method.', );