Repository navigation
feat: cm360 router batching - #2836
Conversation
|
Important Auto Review SkippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the WalkthroughThe changes across various files in the codebase primarily focus on enhancing error handling and reporting, introducing new constants and error types, and refining event processing logic. A new Changes
Assessment against linked issues
Poem
TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Review Status
Actionable comments generated: 4
Configuration used: CodeRabbit UI
Files selected for processing (10)
- src/services/destination/postTransformation.ts (3 hunks)
- src/types/index.ts (1 hunks)
- src/v0/destinations/am/transform.js (1 hunks)
- src/v0/destinations/campaign_manager/config.js (2 hunks)
- src/v0/destinations/campaign_manager/networkHandler.js (2 hunks)
- src/v0/destinations/campaign_manager/transform.js (3 hunks)
- src/v0/util/errorTypes/index.js (1 hunks)
- src/v0/util/errorTypes/transformerProxyError.js (1 hunks)
- test/tests/facebook_conversions.test.js (1 hunks)
- test/integrations/destinations/campaign_manager/router/data.ts (2 hunks)
Files skipped from review due to trivial changes (3)
- src/types/index.ts
- src/v0/destinations/campaign_manager/config.js
- test/tests/facebook_conversions.test.js
Additional comments: 9
src/services/destination/postTransformation.ts (2)
19-25: The new
ErrorResponsetype is well-defined and should provide a structured way to handle errors within theDestinationPostTransformationService. Ensure that the rest of the codebase is updated to use this new type where applicable.161-172: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [150-171]
The
handleDeliveryFailureEventsmethod has been correctly updated to accept anErrorResponseand to conditionally include aresponsefield if present in theerror. This should enhance error handling and reporting.src/v0/destinations/am/transform.js (1)
- 643-649: The changes to prioritize a custom screen event name (
customScreenEv) over the default event type (eventType) are correctly implemented. The use ofreplaceAllto substitute placeholders with actual values from the message is also correctly done.src/v0/destinations/campaign_manager/networkHandler.js (2)
93-145: The updates to the
responseHandlerfunction to handle individual events and throw aTransformerProxyErrorin case of failure status are correctly implemented. The function now provides more granular error handling and response population.186-186: The
networkHandlerfunction is correctly updated to include the newresponseHandlerfunction, ensuring that the network handling capabilities are extended as intended.src/v0/util/errorTypes/index.js (1)
- 1-7: The changes to the module's exports look correct and are properly formatted. Ensure that corresponding documentation and type definitions are updated to reflect the new public interface.
src/v0/util/errorTypes/transformerProxyError.js (1)
- 6-28: The implementation of the
TransformerProxyErrorclass is correct and follows best practices for extending errors in JavaScript. It properly initializes default tags and allows for the specification of error type and meta tags, with validation against predefined types. Theresponseparameter is also correctly assigned to the instance.test/integrations/destinations/campaign_manager/router/data.ts (2)
348-354: The change from
batched: falsetobatched: trueis consistent with the new batch processing behavior described in the summary. Ensure that the corresponding test cases and application logic are updated to handle this change correctly.411-417: The change from
batched: falsetobatched: truefor the second test case is also consistent with the new batch processing behavior. As with the first hunk, ensure that the corresponding test cases and application logic are updated to handle this change correctly.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #2836 +/- ##
========================================
Coverage 87.25% 87.26%
========================================
Files 775 775
Lines 28869 28921 +52
Branches 6780 6789 +9
========================================
+ Hits 25189 25237 +48
- Misses 3340 3344 +4
Partials 340 340 ☔ View full report in Codecov by Sentry. |
|
Kudos, SonarCloud Quality Gate passed! |
* fix: timestamp microseconds input cm360 * feat: batching in cm360 * chore: addressed comments * chore: addressed comments * fix: return aborted inside cath block * feat: update batching partial events * feat: update batching partial events * feat: update batching partial events * feat: update batching partial events * chore: removed hardcoded response * feat: added new error class * chore: develop merge * feat: handle metadata as obj * feat: handle metadata as obj * chore: removed commented code * fix: merged develop * fix: merged develop * chore: added tests for batching * chore: added tests for batching
…nation (#5681) ## What are the changes introduced in this PR? Adds `MARKETO_AUDIENCE`, a batching-framework destination that adds leads to, and removes them from, an existing Marketo static list. It is used by rETL and by Lookout activations. - **`src/v0/destinations/marketo_audience/`** (`DestinationIntegration`, registered `{ routerTransform: true, batching: true }` in `src/features.ts`): - **`transformEvents` override (pre-stage), run once per batch before `super.transformEvents`:** - fetches the token once per call, using the shared `getAuthToken` and a `MARKETO_AUDIENCE_AUTH` cache. A failed token call gets a fixed reason per class (throttled, retry, or abort with its status), so Marketo's message text never reaches a row; a network failure with no HTTP status retries; - checks each row's own list and identifiers; - looks up emails in batches (up to 300 per `POST /rest/v1/leads.json?_method=GET`, with a `URLSearchParams` form body). A returned lead whose email wasn't requested is ignored, so it can't fail the other emails in the batch; a network failure with no HTTP status retries the rows. A 1003 (more than 1,000 leads match) halves the batch until single emails remain, so only the email that still returns 1003 fails, with "More than 1,000 Marketo leads match this email". A `nextPageToken` is followed even when `moreResult` is absent. - **Rows:** if the router input both adds and removes one lead on one list, every row for that lead fails, including a `dontBatch` row that the framework transforms in a separate call. Each later row naming a lead already seen goes in its own request. Every failure is a typed error on its own row; an unexpected pre-stage error fails the remaining rows with a retryable error and is logged with its error name and stack frames only (no message text, which can contain emails). - **`transformEvent`:** synchronous. Builds one `POST`/`DELETE /rest/v1/lists/{listId}/leads.json` per row with `Authorization: Bearer`. - **Batching:** `ChunkBatchStrategy` of 300 lead IDs, body `{ input }`. - **`delivery.ts`:** overrides 2xx, 4xx and 5xx, and every verdict goes through `perItem`, so the raw body stays out of job errors. 2xx: Marketo's HTTP-200 responses become one verdict per job, matched by lead ID (codes 1004/1015/1008, token 601/602 eviction, throttled 502/606/608/615 and daily quota 607, 1013, 603). 4xx: abort, except the proxy's synthetic 400 for a network failure (EPIPE, ENOTFOUND…), which retries because Marketo never saw the request. 5xx: retry with a fixed reason. No lead ID, email or Marketo message text appears in any reason. - **`secretPaths.json`:** `"MARKETO_AUDIENCE": ["headers.Authorization"]`, so Live Events masks the token. - **`test/integrations/destinations/marketo_audience/`:** router (8 cases), dataDelivery (9 cases), network mocks. ## What is the related Linear task? Resolves ACT2-1230 (parent ACT2-1013) ## Please explain the objectives of your changes below Spec: [rudder-specs#214](rudderlabs/rudder-specs#214), §6.3, decisions D5–D12. Pattern: HubSpot `hs_audience` (#5638). **Dependencies and merge order:** - `check:secret-paths` passes: the `marketo_audience` definition (rudder-integrations-config #2836, ACT2-1228) is merged to config `main`. - Operator values (router batch, proxy, throttle) are in rudderstack-operator ACT2-1233. Delivery needs `transformerProxy: true`. ### Any changes to existing capabilities/behaviour, mention the reason & what are the changes ? N/A. No shared code changes; `network.js` is untouched. Following the review of #5638, there's no per-destination log suppression: request bodies reach network logs only at the global `LOG_LEVEL=event`. ### Any new dependencies introduced with this change? N/A ### Any new generic utility introduced or modified. Please explain the changes. N/A. `getAuthToken` is reused unchanged. This destination strips the shared error when Marketo returns `expires_in: 0`, because that error contains the token. MARKETO and MARKETO_STATIC_LIST still have that leak; it's out of scope here. ### Any technical or performance related pointers to consider with the change? - **Token:** at most one identity call per batch. A failed fetch fails every remaining row once. 601/602 from the lookup or delivery evicts the cached token, per pod; a later `dontBatch` call on the same instance then fetches a new one. - **Daily quota (607):** throttled, as in MARKETO and MARKETO_STATIC_LIST. Rows retry until Marketo resets the quota at 12:00 AM CST, and the rETL sync stays running until then. - **Repeated leads:** if two rows resolve to the same lead with the same operation (the same Lead ID twice, or a Lead ID and an email for one lead), they go in separate requests via `internalGroupKey`. No request holds a lead ID twice, so delivery matches each result to its job by lead ID. - **Accepted for v1:** with `LOG_LEVEL=event`, network logs include the lookup body (up to 300 emails) and the identity response, the same as other destinations today (documented in the spec's observability notes). **Not covered (phase 2, waiting on Marketo credentials):** - `live.ts` is left out until `LIVE_SECRET_MARKETO_AUDIENCE` exists in Vault. The live matrix ignores `enabled: false` and would fail on every push. - Live checks: - POST and DELETE accept the JSON `input` body, and result IDs echo the sent IDs. - The status for re-adding a member and for removing a non-member. - Case-insensitive email lookup through the `_method=GET` form post. - Real 606/607/1008 bodies and paging. - What Marketo echoes for a merged lead. <hr> ### Developer checklist - [x] My code follows the style guidelines of this project - [x] **No breaking changes are being introduced.** - [x] All related docs linked with the PR? - [ ] All changes manually tested? (mocked only; live checks in phase 2) - [ ] Any documentation changes needed with this change? - [ ] Is the PR limited to 10 file changes? (18 files: one new destination plus its tests and fixtures) - [x] Is the PR limited to one linear task? - [x] Are relevant unit and component test-cases added in **new readability format**? **Checks** (Node 22, the repo's pinned major): - The pre-commit hook (`test:ts`, `test:js`, lint-staged, commitlint) passed on every commit; the latest run had `test:ts` 128 suites and `test:js` 101 suites. - Component tests (`--destination=marketo_audience`) pass, and `tsc --noEmit` on src and test is clean. ### Reviewer checklist - [ ] Is the type of change in the PR title appropriate as per the changes? - [ ] Verified that there are no credentials or confidential data exposed with the changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)








Description of the change
Type of change
Related issues
Checklists
Development
Code review
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Documentation
Style
Tests
Chores