Skip to content

Commit

Permalink
[FSSDK-10867] ensure odpManager.setVuid is done before resolving onRe…
Browse files Browse the repository at this point in the history
…ady (#956)
  • Loading branch information
raju-opti authored Nov 6, 2024
1 parent 8feb1c0 commit 973cbf7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 4 additions & 0 deletions lib/core/odp/odp_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ export abstract class OdpManager implements IOdpManager {
return;
}

if (!vuid && this.vuid) {
vuid = this.vuid;
}

this.eventManager.identifyUser(userId, vuid);
}

Expand Down
18 changes: 8 additions & 10 deletions lib/optimizely/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 973cbf7

Please sign in to comment.