-
Notifications
You must be signed in to change notification settings - Fork 284
STRATCONN-6152: Fix batching support for editContactInfo function #3211
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
Conversation
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (66.66%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #3211 +/- ##
==========================================
+ Coverage 79.62% 79.70% +0.07%
==========================================
Files 1177 1184 +7
Lines 21703 21813 +110
Branches 4220 4248 +28
==========================================
+ Hits 17282 17386 +104
- Misses 3679 3684 +5
- Partials 742 743 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR implements batching support for the editContactInfo function in the First Party DV360 destination, allowing multiple contact info updates to be processed in a single API request for improved efficiency.
Key Changes:
- Refactored
editContactInfofunction to support both batched and individual processing modes - Added helper functions to improve code organization and reusability
- Enhanced test coverage with batching-specific test cases
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
packages/destination-actions/src/destinations/first-party-dv360/functions.ts |
Refactored editContactInfo function to support batching with helper functions for payload building |
packages/destination-actions/src/destinations/first-party-dv360/addToAudContactInfo/_tests_/index.test.ts |
Added test coverage for batching functionality with helper functions for creating batch test events |
| // Assume all payloads are for the same audience/advertiser (use first) | ||
| const { external_id: audienceId, advertiser_id: advertiserId } = validPayloads[0] | ||
| if (!audienceId || !advertiserId) { | ||
| throw new IntegrationError( | ||
| 'Missing required audience or advertiser ID for batch request', | ||
| 'MISSING_REQUIRED_FIELD', | ||
| 400 | ||
| ) | ||
| } | ||
| const contactInfos = validPayloads.map(processPayload) | ||
| const contactInfoList = buildContactInfoList(contactInfos) | ||
| const requestPayload = buildRequestPayload(advertiserId, contactInfoList, operation) | ||
| const endpoint = DV360API + '/' + audienceId + ':editCustomerMatchMembers' | ||
| const response = await request<DV360editCustomerMatchResponse>(endpoint, { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json; charset=utf-8' }, | ||
| body: requestPayload | ||
| }) | ||
| statsContext?.statsClient?.incr('addCustomerMatchMembers.success', contactInfos.length, statsContext?.tags) | ||
| return response.data |
Copilot
AI
Aug 28, 2025
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.
The batching logic assumes all payloads belong to the same audience/advertiser by using only the first payload's IDs. This could lead to incorrect behavior if payloads have different external_id or advertiser_id values. Consider validating that all payloads have the same IDs or grouping them accordingly.
|
|
||
| statsContext?.statsClient?.incr('addCustomerMatchMembers.success', 1, statsContext?.tags) | ||
| return response.data | ||
| const batchingEnabled = payloads.some((p) => p.enable_batching) |
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.
It is guranted that all payloads will have the save enable_batching value. So, this check isn't required. Also, payloads is always an array.
This pull request introduces support for batching multiple contact info payloads into a single request for the DV360 "addToAudContactInfo" action. It refactors the
editContactInfofunction to enable batching logic, improves code structure with helper functions, and adds comprehensive test coverage for the new batching behavior.Batching support and refactoring:
editContactInfofunction infunctions.tsto support batching: now, whenenable_batchingis true, multiple payloads are combined into a single API request, improving efficiency and reducing the number of requests sent.buildContactInfoListandbuildRequestPayloadto simplify and clarify payload construction for both batched and individual requests.Testing improvements:
index.test.tsto verify that multiple payloads are correctly batched into a single request whenenable_batchingis set, including utilities for generating test events and contact lists.Testing
Tested with actions-tester