-
Notifications
You must be signed in to change notification settings - Fork 86
fix(ats): [FSSDK-9023] Fix ODP Exports #812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… Update getVuid to accept undefined return
…813) * refactored event manager and event api manager and removed platform specific checks * moved vuid management to odpManager and removed browserContext altogether * Clean up + fix tests; inject NodeOdpManager * Finish splitting of event manager to variant-specific implementations * Split segment manager logic to variant-specific implementations --------- Co-authored-by: John Nguyen <john.nguyen@optimizely.com>
jaeopt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. A quick for sendOdpEvent async.
| type?: string, | ||
| identifiers?: Map<string, string>, | ||
| data?: Map<string, unknown> | ||
| ): Promise<void>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this asynchronous while "track" is synchronous?
| identifiers?: Map<string, string>; | ||
| data?: Map<string, unknown>; | ||
| }): Promise<void> { | ||
| public async sendOdpEvent( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we need to make it "sync".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 1705, it await for sync odpManager.sendOdpManager. Is it allowed or maybe some interface error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see "async" on identifyUser as well. It can be cleaned up too.
jaeopt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more async issue.
| identifiers?: Map<string, string>; | ||
| data?: Map<string, unknown>; | ||
| }): Promise<void> { | ||
| public async sendOdpEvent( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see "async" on identifyUser as well. It can be cleaned up too.
jaeopt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary
Consolidated & patched external-facing interfaces for FSC testing.
Additionally, also refactored internal implementations of Browser/Node-specific implementations to avoid using unnecessary implicit contextual checks.
Breakdown of Changes:
fetchQualifiedSegmentsmethod signature in theOptimizelyUserContextinterface export to include optional parameteroptionsto match expected external-facing interface forOptimizelyUserContext.qualifiedSegmentstoOptimizelyUserContextinterface to match expected exported interface for external-facing interface forOptimizelyUserContext.OptimizelyUserContextinshared_types.tsandoptimizely_user_context/index.tsto couple class implementation with interface in order to avoid future interface mismatches. Renamed the interface toIOptimizelyUserContextwhile keeping the export name the same as before (OptimizelyUserContext) in order to avoid external regression.OptimizelySegmentsOptionto exported values to be exposed to external consumers.BrowserClientto exported values to be exposed to external consumers, enablinggetVuidto be accessible to external consumers as well.sendOdpEvent's method signature from a single object input to four parameters to be consistent with other SDKs.actionparameter's type fromODP_EVENT_ACTIONtostringto accept custom action types that will be defined by end users.BrowserClientback intoClientand addedisBrowserContext()catches for browser-specific functionality increateUserContextandgetVuid.The above changes fix the SDK to expose the expected interfaces to consumers for
fetchQualifiedSegments,qualifiedSegments,OptimizelySegmentsOption,BrowserClient/getVuid(), andsendOdpEvent.Also refactored ODP implementations to avoid implicit platform-specific checks for OdpManager, OdpEventManager, OdpSegmentManager, and related files.
Also refactored top-level ODP API interfaces to be synchronous instead of async (TODO: need to implement VUID initialization promise dependency top-level in a later PR)
Additionally, a reversion in package-lock.json (specifically downgrading lockfileVersion from 2 back to 1) was included in order to temporarily help the JS SDK pass linting. Lockfile version 2 seems to have peer dependency issues with types to some extent - will have to look into updating the SDK with better support for modern Node/NPM options.
Test plan
export_types.ts) and instead are meant to enable the implementation of their corresponding tests in FSC.Issues