-
Notifications
You must be signed in to change notification settings - Fork 14
[CDX-201] Tracking other related parameters #459
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
Changes from all commits
30ba12c
70909ff
55b5819
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,7 @@ | |
| "testdata", | ||
| "Bytespider", | ||
| "Timespans", | ||
| "googlequicksearchbox" | ||
| "googlequicksearchbox", | ||
| "cnstrc" | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,6 +75,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { | |
|
|
||
| delete window.CLIENT_VERSION; | ||
| delete global.CLIENT_VERSION; | ||
| delete window.cnstrc; | ||
| cleanup(); | ||
|
|
||
| setTimeout(done, delayBetweenTests); | ||
|
|
@@ -459,6 +460,50 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { | |
|
|
||
| expect(tracker.trackSessionStart()).to.equal(true); | ||
| }); | ||
|
|
||
| it('Should include window globals in tracking requests when useWindowParameters is true', (done) => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Important Issue: This test contradicts the PR description which says the tracker should NOT use window globals. See the comment on Additionally, this test is missing a corresponding negative test ("Should NOT include window globals in tracking requests when |
||
| window.cnstrc = { userId: 'window-user-id', testCells: { exp: 'var' }, userSegments: ['seg1', 'seg2'] }; | ||
| const { tracker } = new ConstructorIO({ | ||
| apiKey: testApiKey, | ||
| useWindowParameters: true, | ||
| fetch: fetchSpy, | ||
| ...requestQueueOptions, | ||
| }); | ||
|
|
||
| tracker.on('success', () => { | ||
| try { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
| expect(requestedUrlParams).to.have.property('ui').to.equal('window-user-id'); | ||
| expect(requestedUrlParams).to.have.property('ef-exp').to.equal('var'); | ||
| expect(requestedUrlParams).to.have.property('us').to.deep.equal(['seg1', 'seg2']); | ||
| done(); | ||
| } catch (e) { | ||
| done(e); | ||
| } | ||
| }); | ||
|
|
||
| expect(tracker.trackSessionStart()).to.equal(true); | ||
| }); | ||
|
|
||
| it('Should prefer options.userId over window global in tracking requests when useWindowParameters is true', (done) => { | ||
| window.cnstrc = { userId: 'window-user-id' }; | ||
| const instance = new ConstructorIO({ | ||
| apiKey: testApiKey, | ||
| useWindowParameters: true, | ||
| fetch: fetchSpy, | ||
| ...requestQueueOptions, | ||
| }); | ||
|
|
||
| instance.setClientOptions({ userId: 'explicit-user-id' }); | ||
|
|
||
| instance.tracker.on('success', () => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
| expect(requestedUrlParams).to.have.property('ui').to.equal('explicit-user-id'); | ||
| done(); | ||
| }); | ||
|
|
||
| expect(instance.tracker.trackSessionStart()).to.equal(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe('trackInputFocus', () => { | ||
|
|
||
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.
Suggestion: The
search.jstests include a "Should prefer options.userId over window global when useWindowParameters is true" priority test (around line 185), butbrowse.js,autocomplete.js, andrecommendations.jsdo not have equivalent priority tests foruserId,testCells, andsegments. For consistency and to fully verify that explicit options take precedence over window globals in all modules, consider adding these priority tests across all four module test files — or at minimum document that the priority is exclusively tested insearch.js.