Skip to content

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

Merged
merged 13 commits into from
Apr 11, 2023
Merged

Conversation

opti-jnguyen
Copy link
Contributor

@opti-jnguyen opti-jnguyen commented Mar 30, 2023

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:

  • Patched fetchQualifiedSegments method signature in the OptimizelyUserContext interface export to include optional parameter options to match expected external-facing interface for OptimizelyUserContext.
  • Added qualifiedSegments to OptimizelyUserContext interface to match expected exported interface for external-facing interface for OptimizelyUserContext.
  • Refactored OptimizelyUserContext in shared_types.ts and optimizely_user_context/index.ts to couple class implementation with interface in order to avoid future interface mismatches. Renamed the interface to IOptimizelyUserContext while keeping the export name the same as before (OptimizelyUserContext) in order to avoid external regression.
  • Added enum OptimizelySegmentsOption to exported values to be exposed to external consumers.
  • Added BrowserClient to exported values to be exposed to external consumers, enabling getVuid to be accessible to external consumers as well.
  • Refactored sendOdpEvent's method signature from a single object input to four parameters to be consistent with other SDKs.
  • Additionally refactored the action parameter's type from ODP_EVENT_ACTION to string to accept custom action types that will be defined by end users.
  • Consolidated BrowserClient back into Client and added isBrowserContext() catches for browser-specific functionality in createUserContext and getVuid.

The above changes fix the SDK to expose the expected interfaces to consumers for fetchQualifiedSegments, qualifiedSegments, OptimizelySegmentsOption, BrowserClient/getVuid(), and sendOdpEvent.

  • 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

  • All existing tests should pass. Some changes will not need to be reflected in existing tests (i.e. external exports via export_types.ts) and instead are meant to enable the implementation of their corresponding tests in FSC.
  • Further testing for the Node-specific implementation will be done later on.

Issues

@coveralls
Copy link

coveralls commented Mar 31, 2023

Coverage Status

Coverage: 90.532% (+0.8%) from 89.703% when pulling 9feb351 on jnguyen/9023-fix-odp-exports into 8991d6e on master.

opti-jnguyen and others added 7 commits March 31, 2023 15:16
…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>
@opti-jnguyen opti-jnguyen marked this pull request as ready for review April 10, 2023 21:22
@opti-jnguyen opti-jnguyen requested a review from a team as a code owner April 10, 2023 21:22
Copy link
Contributor

@jaeopt jaeopt left a 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>;
Copy link
Contributor

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(
Copy link
Contributor

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".

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor

@jaeopt jaeopt left a 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(
Copy link
Contributor

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.

Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jaeopt jaeopt merged commit 2580ea0 into master Apr 11, 2023
@jaeopt jaeopt deleted the jnguyen/9023-fix-odp-exports branch April 11, 2023 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants