Skip to content

[FSSDK-8993]feat: switch odp event rest endpoint #808

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 6 commits into from
Mar 27, 2023

Conversation

andrewleap-optimizely
Copy link
Contributor

@andrewleap-optimizely andrewleap-optimizely commented Mar 23, 2023

Summary

Changed the behavior of sendOdpEvent in the browser to utilize the ODP Pixel API (https://jumbe.zaius.com/v2/zaius.gif) via GET call.

  • Key/value pairs from data and identifiers as well as apiKey, type and action are shifted to to the URL query parameters of the GET request.
  • Pixel API does not support batching

Test plan

  • added tests to index.browser.tests.js
  • existing tests pass

Ticket

FSSDK-8993

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 - a nit

@opti-jnguyen
Copy link
Contributor

Tested in ODP JS Test app on regular Chrome instance - seems to work as expected! Great job!

Note:
While testing found that fs_user_id doesn't seem to be included in the payload for sendOdpEvent - will look further into this and create a new JIRA ticket if needed.

@coveralls
Copy link

coveralls commented Mar 24, 2023

Coverage Status

Coverage: 89.703% (+0.09%) from 89.615% when pulling c337eac on aleap/switch_odp_event_rest_endpoint into 70bdda4 on master.

@@ -582,14 +585,29 @@ describe('javascript-sdk (Browser)', function() {

const testFsUserId = 'fs_test_user';
const testVuid = 'vuid_test_user';
var clock;
const requestParams = new Map;
Copy link
Contributor

@opti-jnguyen opti-jnguyen Mar 24, 2023

Choose a reason for hiding this comment

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

Nit: Usage of Map isn't needed in the succeeding code. Can use const requestParams = {} instead, or refactor the following code to make use of Map() by calling the associated functions.

i.e.

const requestParams = new Map();
requestParams.set('endpoint', endpoint);
requestParams.get('endpoint');

More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch- Refactored to Map for the ease of teardown via the clear method and since it worked I assumed dot notation was syntactic sugar for the getters/setters. Will fix!

* @returns True if in the browser
* @private
*/
export function browserMode(): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Thoughts on renaming to isBrowser() or isBrowserContext()?

this.queueSize = queueSize || defaultQueueSize;
this.batchSize = batchSize || DEFAULT_BATCH_SIZE;
if (flushInterval === 0) {

if (flushInterval === 0 || isBrowser) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Thoughts on leaving a comment here and/or in OdpOptions to denote certain odpOptions (queueSize, batchSize, flushInterval) will always be overridden in the browser context?

@opti-jnguyen
Copy link
Contributor

Left some nits - otherwise LGTM overall!

@andrewleap-optimizely andrewleap-optimizely merged commit 8991d6e into master Mar 27, 2023
@andrewleap-optimizely andrewleap-optimizely deleted the aleap/switch_odp_event_rest_endpoint branch March 27, 2023 15:19
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