Skip to content

Conversation

@patrickshih-optimizely
Copy link

What does this PR do?
Wraps all push calls with a conditional, which if window.optimizelyEdge (the edge API) exists on a page, it'll push to window.optimizelyEdge instead of window.optimizely.

Are there breaking changes in this PR?
No, we still track and push to window.optimizely in Web.

Any background context you want to provide?
Allows Performance Edge customers to track Performance Edge experiments now.

Is there parity with the server-side/android/iOS integration components (if applicable)?
N/A

Does this require a new integration setting? If so, please explain how the new setting works
N/A

Links to helpful docs and other external resources

Comment on lines 13 to 14
var push = require('global-queue')('optimizely', { wrap: false });
var pushEdge = require('global-queue')('optimizelyEdge', { wrap: false });
Copy link
Author

@patrickshih-optimizely patrickshih-optimizely Jun 4, 2020

Choose a reason for hiding this comment

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

Tried to do a more succinct variable assignment

var push = window.optimizelyEdge ? require('global-queue')('optimizelyEdge', { wrap: false }) 
                   : require('global-queue')('optimizely', { wrap: false });

But it wasn't passing the unit test I wrote? Would like to hear ideas for testing to get ^ in.

Copy link

Choose a reason for hiding this comment

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

Hmm, I'm guessing these import statements are executed once on the test page before the mocha suite.. So depending on whether window.optimizelyEdge is defined, the push var would statically refer to optimizely or optimizelyEdge, causing tests to fail for optimizelyEdge or optimizely respectively.

Given that window.optimizelyEdge probably isn't defined at the beginning, pushes probably all end up going to optimizely, causing the optimizelyEdge tests to fail.

Choose a reason for hiding this comment

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

Given that window.optimizelyEdge probably isn't defined

Yup. I'll keep this for now so we can write test cases for Edge. Makes implementing slightly more clunky, but still readable

@patrickshih-optimizely patrickshih-optimizely marked this pull request as ready for review June 5, 2020 18:31
Copy link

@nchilada nchilada left a comment

Choose a reason for hiding this comment

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

Kudos for getting up to speed on this! But I suspect we're not done yet. This PR alter the use of push({type: 'event', ...}), but it does not alter the use of push({type: 'addListener', ...}) or the get APIs. Given that window.optimizely.push technically works on Edge pages (though window.optimizelyEdge.push is the only official supported API), this PR will presumably add the most value once it addresses those remaining API calls.

analytics.stub(window.optimizely, 'push');
});

describe('when the experiment running is from Edge', function() {
Copy link

Choose a reason for hiding this comment

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

Suggested change
describe('when the experiment running is from Edge', function() {
context('when Optimizely Edge is implemented on the page', function() {

or

Suggested change
describe('when the experiment running is from Edge', function() {
context('when Optimizely Performance Edge is implemented on the page', function() {

Copy link

@nchilada nchilada Jun 5, 2020

Choose a reason for hiding this comment

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

To help readers understand that this is a variation on the theme, maybe move this describe/context such that it follows it('should send an event')? If that makes sense

});
});
});

Copy link

Choose a reason for hiding this comment

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

Hmm, looking at all the tags tests below, I'm guessing folks will expect to be able to track tags.

A tags property does seem to be documented in the Edge API but I thought we'd decided not to support them...let's chat offline to see if there's anything that needs to be done to support this?

Copy link

Choose a reason for hiding this comment

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

Okay, it looks like we haven't yet added support for visual tags, but custom event tags (and maybe even global tags) passed via the API are probably supported

"karma-sauce-launcher": "^2.0.2",
"karma-spec-reporter": "^0.0.32",
"karma-summary-reporter": "^1.6.0",
"lerna": "^3.15.0",
Copy link

Choose a reason for hiding this comment

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

Seems to be unnecessary, but I'll let the Segment folks weigh in

Choose a reason for hiding this comment

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

TBH, I believe it's a mistake on my end

type: 'integration',
OAuthClientId: '5360906403'
});
}
Copy link

Choose a reason for hiding this comment

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

Interesting, this seems to be documented here, but was only ever active in Classic Web (see here and here) and hasn't been ported to X Web/Edge. Doesn't hurt I guess

Choose a reason for hiding this comment

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

+1 cool, thanks I should've done some due diligence and also checked the codebase! I'll get rid of pushing this if it's edge

Copy link

Choose a reason for hiding this comment

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

No worries! I'm not actually sure what to do about this. We no longer have folks actively developing integrations, but maybe if we get back there one day, it might be useful to be collect this data.

I think we could go either way (continue to track, or not) as long as we do the same thing regardless of what mode we're in (Classic Web, X Web, Edge).

3.6.0 / 2020-06-04
==================

* Exposed `window.optimizelyEdge` so customers with Performance Edge are able to track Performance Edge related experiments in Segment.
Copy link

@nchilada nchilada Jun 5, 2020

Choose a reason for hiding this comment

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

Suggested change
* Exposed `window.optimizelyEdge` so customers with Performance Edge are able to track Performance Edge related experiments in Segment.
* Track conversion events using `window.optimizelyEdge` instead of `window.optimizely` if Optimizely Performance Edge is running on the page.

based on what I'm currently seeing in the PR

Comment on lines 13 to 14
var push = require('global-queue')('optimizely', { wrap: false });
var pushEdge = require('global-queue')('optimizelyEdge', { wrap: false });
Copy link

Choose a reason for hiding this comment

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

Hmm, I'm guessing these import statements are executed once on the test page before the mocha suite.. So depending on whether window.optimizelyEdge is defined, the push var would statically refer to optimizely or optimizelyEdge, causing tests to fail for optimizelyEdge or optimizely respectively.

Given that window.optimizelyEdge probably isn't defined at the beginning, pushes probably all end up going to optimizely, causing the optimizelyEdge tests to fail.

@patrickshih-optimizely patrickshih-optimizely changed the title feat(optimizely): Expose Edge API to track Edge experiments [WIP] feat(optimizely): Expose Edge API to track Edge experiments Jun 24, 2020
@patrickshih-optimizely patrickshih-optimizely deleted the patrickshih/expose-edge branch June 24, 2020 22:24
@nchilada
Copy link

I think this has been superseded by #483

@patrickshih-optimizely
Copy link
Author

Yup, PR is closed

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.

2 participants