Repository navigation
feat: add endpoint path details to AM destination responses - #4668
Conversation
Summary by CodeRabbit
WalkthroughReplaces string-returning endpoint helpers in Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Event as Event
participant Transform as AM Transform
participant Helpers as EndpointHelpers
participant Builder as ResponseBuilder
participant Sender as Sender/Batcher
Event->>Transform: incoming message
Transform->>Helpers: call ...EndpointDetails(config)
Helpers-->>Transform: { endpoint, path }
Transform->>Builder: build response (set endpoint + endpointPath)
Builder-->>Transform: response object(s)
Transform->>Sender: send/queue with endpoint + endpointPath
note right of Sender: endpointPath included in request metadata
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Suggestions
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/v0/destinations/am/transform.js (1)
415-415: Small consistency nit: destructure endpoint details like other call sitesOther call sites destructure { endpoint, path }. Align here for consistency.
Apply this diff:
- const endpointDetails = defaultEndpointDetails(destination.Config); + const { endpoint, path } = defaultEndpointDetails(destination.Config); ... - response.endpoint = endpointDetails.endpoint; - response.endpointPath = endpointDetails.path; + response.endpoint = endpoint; + response.endpointPath = path;Also applies to: 457-459
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
test/integrations/destinations/am/batch/data.tsis excluded by!**/test/**test/integrations/destinations/am/processor/data.tsis excluded by!**/test/**test/integrations/destinations/am/router/data.tsis excluded by!**/test/**
📒 Files selected for processing (1)
src/v0/destinations/am/transform.js(6 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js
⚙️ CodeRabbit configuration file
Focus on ESLint errors (max 3) and warnings (max 5).
Files:
src/v0/destinations/am/transform.js
🧠 Learnings (1)
📚 Learning: 2025-08-13T04:47:19.615Z
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4497
File: src/v0/destinations/tiktok_ads/transformV2.js:422-435
Timestamp: 2025-08-13T04:47:19.615Z
Learning: The getSuccessRespEvents function in src/v0/util/index.js is designed to be flexible and can accept both single request objects and arrays as the first parameter (message). It simply assigns the input directly to the batchedRequest property without processing, allowing downstream consumers to handle the appropriate format.
Applied to files:
src/v0/destinations/am/transform.js
🧬 Code graph analysis (1)
src/v0/destinations/am/transform.js (3)
src/v0/util/index.js (2)
defaultPostRequestConfig(436-439)set(13-13)src/v0/destinations/am/config.js (1)
AMBatchSizeLimit(125-125)src/v0/destinations/am/utils.js (1)
set(14-14)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Code Coverage
- GitHub Check: UT Tests
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (5)
src/v0/destinations/am/transform.js (5)
71-77: LGTM: batch endpoint detailsReturning both endpoint and path looks correct for batch. No issues spotted.
474-478: LGTM: group identify response carries endpointPathBoth endpoint and endpointPath are set for group calls. Looks good.
565-569: LGTM: alias response carries endpointPathAlias flow correctly sets endpoint and endpointPath. No issues.
883-890: LGTM: batch first-event sets endpointPathSetting batchedRequest.endpoint and .endpointPath on first event ensures observability for batched uploads. Good addition.
79-85: Action: Confirm and fix Amplitude host selection for Group Identify vs User MapGroup Identify (/groupidentify) and Identify (/identify) must use https://api2.amplitude.com (US) or https://api.eu.amplitude.com (EU); User Map (/usermap) uses https://api.amplitude.com (examples also show https://amplitude.com/api/2/usermap).
Location: src/v0/destinations/am/transform.js — lines 79–85 and 87–93
- Ensure baseEndpoint(destConfig) yields api2.amplitude.com / api.eu.amplitude.com for identify/groupidentify, or add a per-endpoint host override for groupidentify.
- Ensure usermap uses api.amplitude.com (verify whether EU tenants require api.eu.amplitude.com for usermap).
Official docs:
- Identify: https://amplitude.com/docs/apis/analytics/identify
- Group Identify: https://amplitude.com/docs/apis/analytics/group-identify
- User Mapping: https://amplitude.com/docs/apis/analytics/user-mapping
94ee5f5 to
4937068
Compare
|
Allure Test reports for this run are available at:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4668 +/- ##
========================================
Coverage 91.78% 91.78%
========================================
Files 642 642
Lines 33974 33982 +8
Branches 8043 8040 -3
========================================
+ Hits 31184 31192 +8
Misses 2538 2538
Partials 252 252 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Update endpoint functions to return both endpoint URL and path details - Add comprehensive test coverage for batch, processor, and router components - Include endpoint path information in transformation responses for better observability
4937068 to
1f90ec3
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/v0/destinations/am/transform.js (2)
71-77: DRY up endpoint details with a tiny helperReduce duplication and future drift by centralizing the construction of endpoint/path.
Apply this diff:
@@ -const batchEndpointDetails = (destConfig) => { - const retVal = `${baseEndpoint(destConfig)}/batch`; - return { - endpoint: retVal, - path: 'batch', - }; -}; - -const groupEndpointDetails = (destConfig) => { - const retVal = `${baseEndpoint(destConfig)}/groupidentify`; - return { - endpoint: retVal, - path: 'groupidentify', - }; -}; - -const aliasEndpointDetails = (destConfig) => { - const retVal = `${baseEndpoint(destConfig)}/usermap`; - return { - endpoint: retVal, - path: 'usermap', - }; -}; +const makeEndpointDetails = (destConfig, suffix) => { + const base = baseEndpoint(destConfig); + const trimmed = suffix.replace(/^\/+/, ''); + return { endpoint: `${base}/${trimmed}`, path: trimmed }; +}; + +const batchEndpointDetails = (destConfig) => makeEndpointDetails(destConfig, 'batch'); +const groupEndpointDetails = (destConfig) => makeEndpointDetails(destConfig, 'groupidentify'); +const aliasEndpointDetails = (destConfig) => makeEndpointDetails(destConfig, 'usermap');And optionally:
-const defaultEndpointDetails = (destConfig) => { - const retVal = `${baseEndpoint(destConfig)}/2/httpapi`; - return { - endpoint: retVal, - path: '2/httpapi', - }; -}; +const defaultEndpointDetails = (destConfig) => makeEndpointDetails(destConfig, '2/httpapi');Also applies to: 79-85, 87-93
415-415: Style consistency: destructure endpoint details at call-siteOther call-sites destructure; mirror that here for consistency.
-const endpointDetails = defaultEndpointDetails(destination.Config); +const { endpoint, path } = defaultEndpointDetails(destination.Config);Then:
-response.endpoint = endpointDetails.endpoint; -response.endpointPath = endpointDetails.path; +response.endpoint = endpoint; +response.endpointPath = path;
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (5)
test/apitests/data_scenarios/destination/batch/failure_batch.jsonis excluded by!**/test/**,!**/*.jsontest/apitests/data_scenarios/destination/batch/successful_batch.jsonis excluded by!**/test/**,!**/*.jsontest/integrations/destinations/am/batch/data.tsis excluded by!**/test/**test/integrations/destinations/am/processor/data.tsis excluded by!**/test/**test/integrations/destinations/am/router/data.tsis excluded by!**/test/**
📒 Files selected for processing (1)
src/v0/destinations/am/transform.js(6 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js
⚙️ CodeRabbit configuration file
Focus on ESLint errors (max 3) and warnings (max 5).
Files:
src/v0/destinations/am/transform.js
🧠 Learnings (1)
📚 Learning: 2025-08-13T04:47:19.615Z
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4497
File: src/v0/destinations/tiktok_ads/transformV2.js:422-435
Timestamp: 2025-08-13T04:47:19.615Z
Learning: The getSuccessRespEvents function in src/v0/util/index.js is designed to be flexible and can accept both single request objects and arrays as the first parameter (message). It simply assigns the input directly to the batchedRequest property without processing, allowing downstream consumers to handle the appropriate format.
Applied to files:
src/v0/destinations/am/transform.js
🧬 Code graph analysis (1)
src/v0/destinations/am/transform.js (3)
src/v0/util/index.js (2)
defaultPostRequestConfig(436-439)set(13-13)src/v0/destinations/am/config.js (1)
AMBatchSizeLimit(125-125)src/v0/destinations/am/utils.js (1)
set(14-14)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Code Coverage
- GitHub Check: UT Tests
- GitHub Check: test_and_publish
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (2)
src/v0/destinations/am/transform.js (2)
63-69: Resolved: endpointPath now includes version segmentGood fix aligning endpointPath ('2/httpapi') with the endpoint. This addresses the earlier inconsistency.
457-459: Approve — endpointPath propagated and old helpers removedNo references remain to defaultEndpoint|batchEndpoint|groupEndpoint|aliasEndpoint; endpointPath is set in src/v0/destinations/am/transform.js for single (line 458), group (477), alias (568) and first-batch (889) flows.
|
Allure Test reports for this run are available at:
|
|
- Update endpoint functions to return both endpoint URL and path details - Add comprehensive test coverage for batch, processor, and router components - Include endpoint path information in transformation responses for better observability



Summary
This PR adds endpoint path details to the Amazon (AM) destination transformation responses for better observability and debugging.
Resolves https://linear.app/rudderstack/issue/INT-4102/add-endpoint-path-details-in-rudder-transformer-for-top-15
Changes
Benefits
Testing
Files Modified
src/v0/destinations/am/transform.js- Core transformation logictest/integrations/destinations/am/batch/data.ts- Batch test datatest/integrations/destinations/am/processor/data.ts- Processor test datatest/integrations/destinations/am/router/data.ts- Router test data