Skip to content

feat: cm360 router batching - #2836

Merged
aashishmalik merged 30 commits into
developfrom
feat.cm360-proxyV1
Nov 30, 2023
Merged

aashishmalik merged 30 commits into
developfrom
feat.cm360-proxyV1

Conversation

@aashishmalik

@aashishmalik aashishmalik commented Nov 19, 2023 •

Copy link
Copy Markdown
Contributor

Description of the change

cm360 transformer proxy v1

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Related issues

Fix #1

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers mentioned in a comment
  • Changes have been reviewed by at least one other engineer
  • Issue from task tracker has a link to this pull request

Summary by CodeRabbit

  • New Features

    • Enhanced error handling in the destination post-transformation service.
    • Introduced a new error type for improved error reporting.
    • Added batch processing capabilities for campaign manager events.
  • Bug Fixes

    • Updated event type determination logic to correctly handle custom event types.
  • Refactor

    • Improved retry logic in network handlers for campaign manager.
    • Streamlined batch event processing with new utility functions.
  • Documentation

    • No visible changes to end-user documentation.
  • Style

    • Minor style adjustments in test files for better readability.
  • Tests

    • Adjusted tests to reflect changes in batch processing behavior.
  • Chores

    • Added necessary configurations for batch processing limits.

@aashishmalik
aashishmalik requested review from a team and sivashanmukh as code owners November 19, 2023 17:56
@aashishmalik
aashishmalik requested review from a team, ItsSudip and utsabc November 19, 2023 17:56
@coderabbitai

coderabbitai Bot commented Nov 27, 2023 •

Copy link
Copy Markdown
Contributor

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

Walkthrough

The 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 ErrorResponse type is added to improve error parameterization, and functions are updated to handle batch processing and error conditions more effectively. The adjustments are aimed at improving the robustness and functionality of the destination transformation services.

Changes

File Path Change Summary
src/services/destination/postTransformation.ts Added ErrorResponse type; updated handleDeliveryFailureEvents method.
src/types/index.ts Added optional response property to DeliveryResponse interface.
src/v0/destinations/am/transform.js Modified event type determination logic.
src/v0/destinations/campaign_manager/... Introduced MAX_BATCH_CONVERSATIONS_SIZE constant; updated functions for batch processing and error handling.
src/v0/util/errorTypes/... Exported new TransformerProxyError class; updated error handling.
test/... Minor whitespace addition; updated batched property from false to true.

Assessment against linked issues

Objective Addressed Explanation
#1: Merging latest GATransformer artifacts into master branch ❌ The provided summary does not mention any changes related to GATransformer artifacts or the merging of such artifacts into the master branch.

Poem

In the code where bugs may hide,
A rabbit hops with eyes so wide.
With each leap, a fix in place,
🐇💻 Errors gone without a trace.


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 9eda50e and 7559d7b.
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 ErrorResponse type is well-defined and should provide a structured way to handle errors within the DestinationPostTransformationService. 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 handleDeliveryFailureEvents method has been correctly updated to accept an ErrorResponse and to conditionally include a response field if present in the error. 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 of replaceAll to 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 responseHandler function to handle individual events and throw a TransformerProxyError in case of failure status are correctly implemented. The function now provides more granular error handling and response population.

  • 186-186: The networkHandler function is correctly updated to include the new responseHandler function, 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 TransformerProxyError class 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. The response parameter is also correctly assigned to the instance.
test/integrations/destinations/campaign_manager/router/data.ts (2)
  • 348-354: The change from batched: false to batched: true is 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: false to batched: true for 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.

utsabc
utsabc previously approved these changes Nov 27, 2023
@aashishmalik aashishmalik changed the title feat: cm360 transformer proxy v1 feat: cm360 router batching Nov 30, 2023
@codecov

codecov Bot commented Nov 30, 2023 •

Copy link
Copy Markdown

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (571dbf5) 87.25% compared to head (db59918) 87.26%.

❗ Current head db59918 differs from pull request most recent head d126f95. Consider uploading reports for the commit d126f95 to get more accurate results

Files Patch % Lines
src/v0/destinations/campaign_manager/transform.js 95.91% 2 Missing ⚠️
src/services/destination/postTransformation.ts 66.66% 1 Missing ⚠️
...v0/destinations/campaign_manager/networkHandler.js 90.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

90.5% 90.5% Coverage
14.3% 14.3% Duplication

@aashishmalik
aashishmalik merged commit 4b260e4 into develop Nov 30, 2023
anantjain45823 pushed a commit that referenced this pull request Dec 1, 2023
* 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
@devops-github-rudderstack
devops-github-rudderstack deleted the feat.cm360-proxyV1 branch March 1, 2024 01:26
am6010 added a commit that referenced this pull request Oct 20, 2026
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants