-
Notifications
You must be signed in to change notification settings - Fork 305
STRATCONN-6767 - [GEC] Treat updated events as add in mirror sync mode #3731
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
varadarajan-tw
wants to merge
6
commits into
main
Choose a base branch
from
STRATCONN-6767
base: main
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.
+109
−3
Open
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
67c3896
STRATCONN-6767 - [GEC] Treat updated events as add in mirror sync mode
varadarajan-tw 6d1d088
Merge branch 'main' into STRATCONN-6767
varadarajan-tw 45651d9
STRATCONN-6767 - [GEC] Strengthen test assertion for updated event in…
varadarajan-tw 64ff275
STRATCONN-6767 - [GEC] Use customerId variable in nock URLs for consi…
varadarajan-tw fbc7155
Merge branch 'main' into STRATCONN-6767
varadarajan-tw 19abc61
Merge branch 'main' into STRATCONN-6767
varadarajan-tw 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -347,6 +347,67 @@ describe('GoogleEnhancedConversions', () => { | |
| ) | ||
| }) | ||
|
|
||
| it('sends an event with default mappings - syncMode = mirror and event = updated', async () => { | ||
| const event = createTestEvent({ | ||
| timestamp, | ||
| event: 'updated', | ||
| properties: { | ||
| gclid: '54321', | ||
| email: '[email protected]', | ||
| orderId: '1234', | ||
| phone: '3234567890', | ||
| firstName: 'Jane', | ||
| lastName: 'Doe', | ||
| currency: 'USD', | ||
| value: '123', | ||
| address: { | ||
| street: '123 Street SW', | ||
| city: 'San Diego', | ||
| state: 'CA', | ||
| postalCode: '982004' | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| nock(`https://googleads.googleapis.com/${API_VERSION}/customers/${customerId}/offlineUserDataJobs:create`) | ||
| .post(/.*/) | ||
| .reply(200, { data: 'offlineDataJob' }) | ||
|
|
||
| nock(`https://googleads.googleapis.com/${API_VERSION}/offlineDataJob:addOperations`) | ||
| .post(/.*/) | ||
| .reply(200, { data: 'offlineDataJob' }) | ||
|
|
||
| nock(`https://googleads.googleapis.com/${API_VERSION}/offlineDataJob:run`) | ||
|
varadarajan-tw marked this conversation as resolved.
|
||
| .post(/.*/) | ||
| .reply(200, { data: 'offlineDataJob' }) | ||
|
|
||
| const responses = await testDestination.testAction('userList', { | ||
| event, | ||
| mapping: { | ||
| ad_user_data_consent_state: 'GRANTED', | ||
| ad_personalization_consent_state: 'GRANTED', | ||
| external_audience_id: '1234', | ||
| __segment_internal_sync_mode: 'mirror', | ||
| retlOnMappingSave: { | ||
| outputs: { | ||
| id: '1234', | ||
| name: 'Test List', | ||
| external_id_type: 'CONTACT_INFO' | ||
| } | ||
| } | ||
| }, | ||
| useDefaultMappings: true, | ||
| settings: { | ||
| customerId | ||
| } | ||
| }) | ||
|
|
||
| expect(responses.length).toEqual(3) | ||
| expect(responses[1].options.body).toMatchInlineSnapshot( | ||
| `"{\\"operations\\":[{\\"create\\":{\\"userIdentifiers\\":[{\\"hashedEmail\\":\\"87924606b4131a8aceeeae8868531fbb9712aaa07a5d3a756b26ce0f5d6ca674\\"},{\\"hashedPhoneNumber\\":\\"0506a1f3f4c515fd310fce54d253b731f71e33e7e7d2b10848528ca4411120b0\\"},{\\"addressInfo\\":{\\"hashedFirstName\\":\\"4f23798d92708359b734a18172c9c864f1d48044a754115a0d4b843bca3a5332\\",\\"hashedLastName\\":\\"fd53ef835b15485572a6e82cf470dcb41fd218ae5751ab7531c956a2a6bcd3c7\\",\\"countryCode\\":\\"\\",\\"postalCode\\":\\"\\"}}]}}],\\"enable_warnings\\":true}"` | ||
| ) | ||
| }) | ||
|
|
||
| it('sends an event with default mappings - syncMode = delete', async () => { | ||
| const event = createTestEvent({ | ||
| timestamp, | ||
|
|
@@ -1531,7 +1592,52 @@ describe('GoogleEnhancedConversions', () => { | |
| }) | ||
| }) | ||
|
|
||
| it('Could not deteremine operation type due to invalid event name or syncMode', async () => { | ||
| it('treats updated event as add when syncMode = mirror', async () => { | ||
| nock(`https://googleads.googleapis.com/${API_VERSION}/customers/${customerId}/offlineUserDataJobs:create`) | ||
| .post(/.*/) | ||
| .reply(200, { resourceName: 'customers/1234/userLists/1234' }) | ||
|
|
||
| nock(`https://googleads.googleapis.com/${API_VERSION}/customers/1234/userLists/1234:addOperations`) | ||
| .post(/.*/, (body: Record<string, unknown>) => { | ||
| const operations = body.operations as Array<Record<string, unknown>> | ||
| return operations.every((op) => 'create' in op && !('remove' in op)) | ||
| }) | ||
| .reply(200, {}) | ||
|
|
||
| nock(`https://googleads.googleapis.com/${API_VERSION}/customers/1234/userLists/1234:run`) | ||
|
varadarajan-tw marked this conversation as resolved.
Outdated
|
||
| .post(/.*/) | ||
| .reply(200, {}) | ||
|
|
||
| const events: SegmentEvent[] = [ | ||
| createTestEvent({ | ||
| timestamp, | ||
| event: 'updated', | ||
| properties: { | ||
| email: '[email protected]', | ||
| phone: '3234567890', | ||
| firstName: 'Jane', | ||
| lastName: 'Doe' | ||
| } | ||
| }) | ||
| ] | ||
|
|
||
| const responses = await testDestination.executeBatch('userList', { | ||
| events, | ||
| mapping: { | ||
| ...mapping, | ||
| __segment_internal_sync_mode: 'mirror' | ||
| }, | ||
| settings: { | ||
| customerId | ||
| } | ||
| }) | ||
|
|
||
| expect(responses[0]).toMatchObject({ | ||
| status: 200 | ||
| }) | ||
| }) | ||
|
varadarajan-tw marked this conversation as resolved.
|
||
|
|
||
| it('Could not determine operation type due to invalid event name or syncMode', async () => { | ||
| nock(`https://googleads.googleapis.com/${API_VERSION}/customers/${customerId}/offlineUserDataJobs:create`) | ||
| .post(/.*/) | ||
| .reply(200, { resourceName: 'customers/1234/userLists/1234' }) | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -571,7 +571,7 @@ const extractUserIdentifiers = ( | |
| if ( | ||
| payload.event_name === 'Audience Entered' || | ||
| syncMode === 'add' || | ||
| (syncMode === 'mirror' && payload.event_name === 'new') | ||
| (syncMode === 'mirror' && (payload.event_name === 'new' || payload.event_name === 'updated')) | ||
|
Contributor
Author
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. More improvements for this are on the way with standardized audience membership evaluators |
||
| ) { | ||
| addUserIdentifiers.push({ create: { userIdentifiers: identifierFunctions[idType](payload) } }) | ||
| } else if ( | ||
|
|
@@ -969,7 +969,7 @@ const determineOperationType = (payload: UserListPayload, syncMode?: string) => | |
| if ( | ||
| payload.event_name === 'Audience Entered' || | ||
| syncMode === 'add' || | ||
| (syncMode === 'mirror' && payload.event_name === 'new') | ||
| (syncMode === 'mirror' && (payload.event_name === 'new' || payload.event_name === 'updated')) | ||
| ) { | ||
| return 'add' | ||
| } else if ( | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.