-
Notifications
You must be signed in to change notification settings - Fork 55
feat: Add collection of Snap cookie1 #1118
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
Open
gh-mmurph
wants to merge
2
commits into
mParticle:development
Choose a base branch
from
gh-mmurph:feat/snap-cookie-capture
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,8 @@ describe('Integration Capture', () => { | |
| 'gbraid', | ||
| 'wbraid', | ||
| 'ttclid', | ||
| 'ScCid' | ||
| 'ScCid', | ||
| 'sc_cookie1' | ||
| ]); | ||
| }); | ||
|
|
||
|
|
@@ -55,6 +56,7 @@ describe('Integration Capture', () => { | |
| 'wbraid', | ||
| 'ttclid', | ||
| 'ScCid', | ||
| 'sc_cookie1', | ||
| ]; | ||
| for (const key of excludedKeys) { | ||
| expect(mappings).not.toHaveProperty(key); | ||
|
|
@@ -106,7 +108,7 @@ describe('Integration Capture', () => { | |
| it('should return all mapped keys from helpers when captureMode is all (lowercase)', () => { | ||
| jest.spyOn(Date, 'now').mockImplementation(() => 42); | ||
| // Query params | ||
| const url = new URL('https://www.example.com/?fbclid=abc&gclid=g1&rtid=rt1&rclid=rc1&ScCid=snap1'); | ||
| const url = new URL('https://www.example.com/?fbclid=abc&gclid=g1&rtid=rt1&rclid=rc1&ScCid=snap1&sc_cookie1=cookie1'); | ||
|
||
| window.location.href = url.href; | ||
| window.location.search = url.search; | ||
|
|
||
|
|
@@ -125,15 +127,15 @@ describe('Integration Capture', () => { | |
| const clickIdLocalStorage = integrationCapture.captureLocalStorage(); | ||
|
|
||
| // fbclid is formatted with timestamp/domain index | ||
| expect(clickIds).toMatchObject({ fbclid: 'fb.2.42.abc', gclid: 'g1', rtid: 'rt1', rclid: 'rc1', ScCid: 'snap1' }); | ||
| expect(clickIds).toMatchObject({ fbclid: 'fb.2.42.abc', gclid: 'g1', rtid: 'rt1', rclid: 'rc1', ScCid: 'snap1', sc_cookie1: 'cookie1' }); | ||
| expect(clickIdCookies).toMatchObject({ _fbp: '54321', _fbc: 'fb.1.1554763741205.abcdef', RoktTransactionId: 'xyz' }); | ||
| expect(clickIdLocalStorage).toEqual({ RoktTransactionId: 'ls-rok' }); | ||
| }); | ||
|
|
||
| it('should NOT return mapped keys from helpers when captureMode is none (lowercase)', () => { | ||
| jest.spyOn(Date, 'now').mockImplementation(() => 42); | ||
| // Query params | ||
| const url = new URL('https://www.example.com/?fbclid=abc&gclid=g1&rtid=rt1&rclid=rc1&ScCid=snap1'); | ||
| const url = new URL('https://www.example.com/?fbclid=abc&gclid=g1&rtid=rt1&rclid=rc1&ScCid=snap1&sc_cookie1=cookie1'); | ||
| window.location.href = url.href; | ||
| window.location.search = url.search; | ||
|
|
||
|
|
@@ -199,7 +201,8 @@ describe('Integration Capture', () => { | |
| 'wbraid=09876', | ||
| 'rtid=84324', | ||
| 'rclid=7183717', | ||
| 'ScCid=1234' | ||
| 'ScCid=1234', | ||
| 'sc_cookie1=cookie1-value' | ||
| ].join('&'); | ||
|
|
||
| const url = new URL(`https://www.example.com/?${queryParams}`); | ||
|
|
@@ -223,7 +226,8 @@ describe('Integration Capture', () => { | |
| rtid: '84324', | ||
| rclid: '7183717', | ||
| wbraid: '09876', | ||
| ScCid:'1234' | ||
| ScCid:'1234', | ||
| sc_cookie1: 'cookie1-value' | ||
| }); | ||
| }); | ||
|
|
||
|
|
@@ -273,6 +277,53 @@ describe('Integration Capture', () => { | |
| ScCid: '1234', | ||
| }); | ||
| }); | ||
|
|
||
| it('should capture sc_cookie1', () => { | ||
| const url = new URL('https://www.example.com/?sc_cookie1=cookie1-value'); | ||
|
|
||
| window.location.href = url.href; | ||
| window.location.search = url.search; | ||
|
|
||
| const integrationCapture = new IntegrationCapture('all'); | ||
| integrationCapture.capture(); | ||
|
|
||
| expect(integrationCapture.clickIds).toEqual({ | ||
| sc_cookie1: 'cookie1-value', | ||
| }); | ||
| }); | ||
|
|
||
| it('should capture both ScCid and sc_cookie1', () => { | ||
| const url = new URL('https://www.example.com/?ScCid=1234&sc_cookie1=cookie1-value'); | ||
|
|
||
| window.location.href = url.href; | ||
| window.location.search = url.search; | ||
|
|
||
| const integrationCapture = new IntegrationCapture('all'); | ||
| integrationCapture.capture(); | ||
|
|
||
| expect(integrationCapture.clickIds).toEqual({ | ||
| ScCid: '1234', | ||
| sc_cookie1: 'cookie1-value', | ||
| }); | ||
| }); | ||
|
|
||
| it('should capture sc_cookie1 from cookies', () => { | ||
| const url = new URL('https://www.example.com/'); | ||
|
|
||
| window.document.cookie = 'sc_cookie1=cookie1-from-cookie'; | ||
| window.document.cookie = '_cookie1=1234'; | ||
| window.document.cookie = 'baz=qux'; | ||
|
|
||
| window.location.href = url.href; | ||
| window.location.search = url.search; | ||
|
|
||
| const integrationCapture = new IntegrationCapture('all'); | ||
| integrationCapture.capture(); | ||
|
|
||
| expect(integrationCapture.clickIds).toEqual({ | ||
| sc_cookie1: 'cookie1-from-cookie', | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Facebook Click Ids', () => { | ||
|
|
@@ -611,6 +662,19 @@ describe('Integration Capture', () => { | |
| }); | ||
| }); | ||
|
|
||
| it('should capture sc_cookie1 from cookies', () => { | ||
| window.document.cookie = '_cookie1=1234'; | ||
| window.document.cookie = 'sc_cookie1=cookie1-from-cookie'; | ||
| window.document.cookie = 'baz=qux'; | ||
|
|
||
| const integrationCapture = new IntegrationCapture('all'); | ||
| const clickIds = integrationCapture.captureCookies(); | ||
|
|
||
| expect(clickIds).toEqual({ | ||
| sc_cookie1: 'cookie1-from-cookie', | ||
| }); | ||
| }); | ||
|
|
||
| it('should NOT capture cookies if they are not mapped', () => { | ||
| window.document.cookie = '_cookie1=1234'; | ||
| window.document.cookie = '_cookie2=39895811.9165333198'; | ||
|
|
@@ -665,6 +729,8 @@ describe('Integration Capture', () => { | |
| _ttp: '0823422223.23234', | ||
| ttclid: '12345', | ||
| gclid: '123233.23131', | ||
| ScCid: '1234', | ||
| sc_cookie1: 'cookie1-value', | ||
| invalidId: '12345', | ||
| }; | ||
|
|
||
|
|
@@ -675,6 +741,8 @@ describe('Integration Capture', () => { | |
| 'Facebook.BrowserId': '54321', | ||
| 'TikTok.Callback': '12345', | ||
| 'GoogleEnhancedConversions.Gclid': '123233.23131', | ||
| 'SnapchatConversions.ClickId': '1234', | ||
| 'SnapchatConversions.Cookie1': 'cookie1-value', | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Apologies for the confusion here. They cookie key you should capture is
_scid.sc_cookie1is the parameter name that this value is sent to CAPI as. Some information about this can be found here.