From dced75029f25e332e87827bee5793e11b46e38f7 Mon Sep 17 00:00:00 2001 From: junaed-optimizely Date: Wed, 15 May 2024 21:29:13 +0600 Subject: [PATCH 1/6] odp not integrated log level change from error to info --- lib/core/odp/odp_manager.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/core/odp/odp_manager.ts b/lib/core/odp/odp_manager.ts index 4da2f6191..b116d2f6e 100644 --- a/lib/core/odp/odp_manager.ts +++ b/lib/core/odp/odp_manager.ts @@ -65,7 +65,6 @@ export abstract class OdpManager implements IOdpManager { * Promise that returns when the OdpManager is finished initializing */ private initPromise: Promise; - private ready = false; /** @@ -126,7 +125,7 @@ export abstract class OdpManager implements IOdpManager { this.onReady().then(() => { this.ready = true; - if(this.isVuidEnabled() && this.status === Status.Running) { + if (this.isVuidEnabled() && this.status === Status.Running) { this.registerVuid(); } }); @@ -146,7 +145,7 @@ export abstract class OdpManager implements IOdpManager { } if (!this.odpIntegrationConfig) { - return Promise.reject(new Error('cannot start without ODP config')); + return Promise.reject(new Error('cannot start without ODP config')); } if (!this.odpIntegrationConfig.integrated) { @@ -211,13 +210,13 @@ export abstract class OdpManager implements IOdpManager { * @returns {Promise} A promise holding either a list of qualified segments or null. */ async fetchQualifiedSegments(userId: string, options: Array = []): Promise { - if (!this.odpIntegrationConfig) { - this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_CONFIG_NOT_AVAILABLE); + if (!this.odpIntegrationConfig) { + this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_CONFIG_NOT_AVAILABLE); return null; } if (!this.odpIntegrationConfig.integrated) { - this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_NOT_INTEGRATED); + this.logger.log(LogLevel.INFO, ERROR_MESSAGES.ODP_NOT_INTEGRATED); return null; } @@ -225,7 +224,7 @@ export abstract class OdpManager implements IOdpManager { return this.segmentManager.fetchQualifiedSegments(ODP_USER_KEY.VUID, userId, options); } - return this.segmentManager.fetchQualifiedSegments(ODP_USER_KEY.FS_USER_ID, userId, options); + return this.segmentManager.fetchQualifiedSegments(ODP_USER_KEY.FS_USER_ID, userId, options); } /** @@ -241,7 +240,7 @@ export abstract class OdpManager implements IOdpManager { } if (!this.odpIntegrationConfig.integrated) { - this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_NOT_INTEGRATED); + this.logger.log(LogLevel.INFO, ERROR_MESSAGES.ODP_NOT_INTEGRATED); return; } @@ -270,7 +269,7 @@ export abstract class OdpManager implements IOdpManager { } if (!this.odpIntegrationConfig.integrated) { - this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_NOT_INTEGRATED); + this.logger.log(LogLevel.INFO, ERROR_MESSAGES.ODP_NOT_INTEGRATED); return; } @@ -306,7 +305,7 @@ export abstract class OdpManager implements IOdpManager { } if (!this.odpIntegrationConfig.integrated) { - this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_NOT_INTEGRATED); + this.logger.log(LogLevel.INFO, ERROR_MESSAGES.ODP_NOT_INTEGRATED); return; } From 964aa89824887d5b2f0735e0b3c134b8abf7d523 Mon Sep 17 00:00:00 2001 From: junaed-optimizely Date: Thu, 16 May 2024 17:51:42 +0600 Subject: [PATCH 2/6] odp not integrated log level back to prev state, except identifyUser --- lib/core/odp/odp_manager.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/core/odp/odp_manager.ts b/lib/core/odp/odp_manager.ts index b116d2f6e..8da720dde 100644 --- a/lib/core/odp/odp_manager.ts +++ b/lib/core/odp/odp_manager.ts @@ -216,7 +216,7 @@ export abstract class OdpManager implements IOdpManager { } if (!this.odpIntegrationConfig.integrated) { - this.logger.log(LogLevel.INFO, ERROR_MESSAGES.ODP_NOT_INTEGRATED); + this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_NOT_INTEGRATED); return null; } @@ -269,7 +269,7 @@ export abstract class OdpManager implements IOdpManager { } if (!this.odpIntegrationConfig.integrated) { - this.logger.log(LogLevel.INFO, ERROR_MESSAGES.ODP_NOT_INTEGRATED); + this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_NOT_INTEGRATED); return; } @@ -305,7 +305,7 @@ export abstract class OdpManager implements IOdpManager { } if (!this.odpIntegrationConfig.integrated) { - this.logger.log(LogLevel.INFO, ERROR_MESSAGES.ODP_NOT_INTEGRATED); + this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_NOT_INTEGRATED); return; } From 166390abb6fba12f2cdc723079ac7e49a32845e5 Mon Sep 17 00:00:00 2001 From: junaed-optimizely Date: Fri, 17 May 2024 17:03:19 +0000 Subject: [PATCH 3/6] making isOdpIntegrated public --- lib/optimizely/index.ts | 14 +++++--------- lib/shared_types.ts | 8 +++++++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/optimizely/index.ts b/lib/optimizely/index.ts index e29d04daa..423bcb71f 100644 --- a/lib/optimizely/index.ts +++ b/lib/optimizely/index.ts @@ -188,9 +188,8 @@ export default class Optimizely implements Client { this.nextReadyTimeoutId = 0; } - /** - * Returns the project configuration retrieved from projectConfigManager + * Returns the project configuration retrieved from projectConfigManager * @return {projectConfig.ProjectConfig} */ getProjectConfig(): projectConfig.ProjectConfig | null { @@ -1444,10 +1443,7 @@ export default class Optimizely implements Client { createUserContext(userId?: string, attributes?: UserAttributes): OptimizelyUserContext | null { const userIdentifier = userId ?? this.odpManager?.getVuid(); - if ( - userIdentifier === undefined || - !this.validateInputs({ user_id: userIdentifier }, attributes) - ) { + if (userIdentifier === undefined || !this.validateInputs({ user_id: userIdentifier }, attributes)) { return null; } @@ -1671,7 +1667,7 @@ export default class Optimizely implements Client { } if (this.odpManager) { - this.odpManager.updateSettings(projectConfig.odpIntegrationConfig) + this.odpManager.updateSettings(projectConfig.odpIntegrationConfig); } } @@ -1723,7 +1719,7 @@ export default class Optimizely implements Client { } } - private isOdpIntegrated(): boolean { + public isOdpIntegrated(): boolean { return this.projectConfigManager.getConfig()?.odpIntegrationConfig?.integrated ?? false; } @@ -1751,7 +1747,7 @@ export default class Optimizely implements Client { if (!this.odpManager) { return null; } - + return await this.odpManager.fetchQualifiedSegments(userId, options); } diff --git a/lib/shared_types.ts b/lib/shared_types.ts index 361f293d5..08291ecf2 100644 --- a/lib/shared_types.ts +++ b/lib/shared_types.ts @@ -335,7 +335,12 @@ export interface Client { getForcedVariation(experimentKey: string, userId: string): string | null; isFeatureEnabled(featureKey: string, userId: string, attributes?: UserAttributes): boolean; getEnabledFeatures(userId: string, attributes?: UserAttributes): string[]; - getFeatureVariable(featureKey: string, variableKey: string, userId: string, attributes?: UserAttributes): FeatureVariableValue; + getFeatureVariable( + featureKey: string, + variableKey: string, + userId: string, + attributes?: UserAttributes + ): FeatureVariableValue; getFeatureVariableBoolean( featureKey: string, variableKey: string, @@ -371,6 +376,7 @@ export interface Client { close(): Promise<{ success: boolean; reason?: string }>; sendOdpEvent(action: string, type?: string, identifiers?: Map, data?: Map): void; getProjectConfig(): ProjectConfig | null; + isOdpIntegrated(): boolean; } export interface ActivateListenerPayload extends ListenerPayload { From 51be684d967da7fdb571215ca9a80e7ee26a6e9c Mon Sep 17 00:00:00 2001 From: junaed-optimizely Date: Mon, 20 May 2024 17:43:03 +0600 Subject: [PATCH 4/6] Adding JSDoc to newly exposed isODPIntegrated method --- lib/optimizely/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/optimizely/index.ts b/lib/optimizely/index.ts index 423bcb71f..05fed18ce 100644 --- a/lib/optimizely/index.ts +++ b/lib/optimizely/index.ts @@ -1718,7 +1718,10 @@ export default class Optimizely implements Client { this.logger.error(ERROR_MESSAGES.ODP_EVENT_FAILED, e); } } - + /** + * Checks if ODP (Optimizely Data Platform) is integrated into the project. + * @returns { boolean } + */ public isOdpIntegrated(): boolean { return this.projectConfigManager.getConfig()?.odpIntegrationConfig?.integrated ?? false; } From 8ec58b70acd6b82084d2230e3d03174d935076ba Mon Sep 17 00:00:00 2001 From: junaed-optimizely Date: Mon, 20 May 2024 17:47:43 +0600 Subject: [PATCH 5/6] registerVuid method ODP integration log change from error to info --- lib/core/odp/odp_manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/odp/odp_manager.ts b/lib/core/odp/odp_manager.ts index 8da720dde..54278358d 100644 --- a/lib/core/odp/odp_manager.ts +++ b/lib/core/odp/odp_manager.ts @@ -305,7 +305,7 @@ export abstract class OdpManager implements IOdpManager { } if (!this.odpIntegrationConfig.integrated) { - this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_NOT_INTEGRATED); + this.logger.log(LogLevel.INFO, ERROR_MESSAGES.ODP_NOT_INTEGRATED); return; } From a703a33657539487059effaacfdc50134342f8b0 Mon Sep 17 00:00:00 2001 From: Md Junaed Hossain <169046794+junaed-optimizely@users.noreply.github.com> Date: Mon, 20 May 2024 18:13:40 +0600 Subject: [PATCH 6/6] Update lib/optimizely/index.ts Co-authored-by: Mike Chu <104384559+mikechu-optimizely@users.noreply.github.com> --- lib/optimizely/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/optimizely/index.ts b/lib/optimizely/index.ts index 05fed18ce..2a3eb5a0d 100644 --- a/lib/optimizely/index.ts +++ b/lib/optimizely/index.ts @@ -1720,7 +1720,7 @@ export default class Optimizely implements Client { } /** * Checks if ODP (Optimizely Data Platform) is integrated into the project. - * @returns { boolean } + * @returns { boolean } `true` if ODP settings were found in the datafile otherwise `false` */ public isOdpIntegrated(): boolean { return this.projectConfigManager.getConfig()?.odpIntegrationConfig?.integrated ?? false;