From 4eb8e5374489aa3693944b1b1184e385fcad725b Mon Sep 17 00:00:00 2001 From: Raju Ahmed Date: Wed, 6 Nov 2024 19:50:29 +0600 Subject: [PATCH] [FSSDK-10867] ensure odpManager.setVuid is done before resolving onReady --- lib/core/odp/odp_manager.ts | 4 ++++ lib/optimizely/index.ts | 18 ++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/core/odp/odp_manager.ts b/lib/core/odp/odp_manager.ts index e57909d31..2ff820215 100644 --- a/lib/core/odp/odp_manager.ts +++ b/lib/core/odp/odp_manager.ts @@ -258,6 +258,10 @@ export abstract class OdpManager implements IOdpManager { return; } + if (!vuid && this.vuid) { + vuid = this.vuid; + } + this.eventManager.identifyUser(userId, vuid); } diff --git a/lib/optimizely/index.ts b/lib/optimizely/index.ts index 42a4dc20d..17d9ff500 100644 --- a/lib/optimizely/index.ts +++ b/lib/optimizely/index.ts @@ -181,28 +181,26 @@ export default class Optimizely implements Client { this.eventProcessor = config.eventProcessor; const eventProcessorStartedPromise = this.eventProcessor.start(); - + this.readyPromise = Promise.all([ projectConfigManagerReadyPromise, eventProcessorStartedPromise, config.odpManager ? config.odpManager.onReady() : Promise.resolve(), config.vuidManager ? config.vuidManager.configure(this.vuidOptions ?? { enableVuid: false }) : Promise.resolve(), ]).then(promiseResults => { - // Only return status from project config promise because event processor promise does not return any status. - return promiseResults[0]; - }); - - this.readyTimeouts = {}; - this.nextReadyTimeoutId = 0; - - this.onReady().then(({ success }) => { - if (success) { + // Only return status from project config promise because event processor promise does not return any status. + const result = promiseResults[0]; + if (result.success) { const vuid = this.vuidManager?.vuid; if (vuid) { this.odpManager?.setVuid(vuid); } } + return result; }); + + this.readyTimeouts = {}; + this.nextReadyTimeoutId = 0; } /**