-
Notifications
You must be signed in to change notification settings - Fork 141
[WIP] feat(optimizely): Expose Edge API to track Edge experiments #479
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
[WIP] feat(optimizely): Expose Edge API to track Edge experiments #479
Conversation
integrations/optimizely/lib/index.js
Outdated
| var push = require('global-queue')('optimizely', { wrap: false }); | ||
| var pushEdge = require('global-queue')('optimizelyEdge', { wrap: false }); |
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.
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.
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.
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.
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.
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
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.
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() { |
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.
| describe('when the experiment running is from Edge', function() { | |
| context('when Optimizely Edge is implemented on the page', function() { |
or
| describe('when the experiment running is from Edge', function() { | |
| context('when Optimizely Performance Edge is implemented on the page', function() { |
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.
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
| }); | ||
| }); | ||
| }); | ||
|
|
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.
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?
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.
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
integrations/optimizely/package.json
Outdated
| "karma-sauce-launcher": "^2.0.2", | ||
| "karma-spec-reporter": "^0.0.32", | ||
| "karma-summary-reporter": "^1.6.0", | ||
| "lerna": "^3.15.0", |
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.
Seems to be unnecessary, but I'll let the Segment folks weigh in
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.
TBH, I believe it's a mistake on my end
integrations/optimizely/lib/index.js
Outdated
| type: 'integration', | ||
| OAuthClientId: '5360906403' | ||
| }); | ||
| } |
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.
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.
+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
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.
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).
integrations/optimizely/HISTORY.md
Outdated
| 3.6.0 / 2020-06-04 | ||
| ================== | ||
|
|
||
| * Exposed `window.optimizelyEdge` so customers with Performance Edge are able to track Performance Edge related experiments in Segment. |
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.
| * 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
integrations/optimizely/lib/index.js
Outdated
| var push = require('global-queue')('optimizely', { wrap: false }); | ||
| var pushEdge = require('global-queue')('optimizelyEdge', { wrap: false }); |
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.
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.
|
I think this has been superseded by #483 |
|
Yup, PR is closed |
What does this PR do?
Wraps all
pushcalls with a conditional, which ifwindow.optimizelyEdge(the edge API) exists on a page, it'll push towindow.optimizelyEdgeinstead ofwindow.optimizely.Are there breaking changes in this PR?
No, we still track and push to
window.optimizelyin 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