Skip to content

feat: add endpoint path details to AM destination responses - #4668

Merged
koladilip merged 1 commit into
developfrom
feat/am-destination-updates
Sep 23, 2025
Merged

koladilip merged 1 commit into
developfrom
feat/am-destination-updates

Conversation

@koladilip

@koladilip koladilip commented Sep 22, 2025 •

Copy link
Copy Markdown
Contributor

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

  • Transform Logic: Updated endpoint functions (, , , ) to return both endpoint URL and path information
  • Test Coverage: Added comprehensive test cases for:
    • Batch processing scenarios
    • Processor component functionality
    • Router component behavior
  • Response Enhancement: Endpoint path information is now included in transformation responses

Benefits

  • Improved observability for AM destination integrations
  • Better debugging capabilities with endpoint path visibility
  • Enhanced monitoring and troubleshooting of data flows

Testing

  • All existing tests pass
  • New test cases added for endpoint path functionality
  • Pre-commit hooks validated the changes

Files Modified

  • src/v0/destinations/am/transform.js - Core transformation logic
  • test/integrations/destinations/am/batch/data.ts - Batch test data
  • test/integrations/destinations/am/processor/data.ts - Processor test data
  • test/integrations/destinations/am/router/data.ts - Router test data

@koladilip
koladilip requested a review from a team as a code owner September 22, 2025 16:21
@coderabbitai

coderabbitai Bot commented Sep 22, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Requests now include both endpoint and endpoint path, enabling clearer routing in responses.
  • Refactor
    • Standardized request construction across batching, grouping, aliasing, and mobile flows to use endpoint + path details.
  • Bug Fixes
    • Improved consistency in endpoint selection and path handling, reducing edge-case discrepancies in batched and grouped requests.

Walkthrough

Replaces string-returning endpoint helpers in src/v0/destinations/am/transform.js with new helpers that return objects { endpoint, path }, updates all call sites to destructure and assign response.endpoint and new response.endpointPath, and propagates endpoint/path into single, group, alias, mobile, and batch flows.

Changes

Cohort / File(s) Summary of Changes
Endpoint details refactor
src/v0/destinations/am/transform.js
Replaced defaultEndpoint, batchEndpoint, groupEndpoint, aliasEndpoint with defaultEndpointDetails, batchEndpointDetails, groupEndpointDetails, aliasEndpointDetails returning { endpoint, path }. Updated call sites to destructure and use endpoint and path, set response.endpoint and new response.endpointPath, removed legacy BATCH_ENDPOINT usage, and propagated endpointPath across single, group, alias, mobile, and batch flows.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • vinayteki95
  • ItsSudip
  • maheshkutty

Suggestions

  • Add unit tests covering single, group, alias, mobile, and batch flows asserting both response.endpoint and response.endpointPath.
  • Introduce a shared type/interface for endpoint details ({ endpoint, path }) to enforce consistency across destinations.
  • Update any internal docs or integration notes to mention the response.endpointPath metadata field.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title "feat: add endpoint path details to AM destination responses" succinctly and accurately describes the primary change in this changeset—adding endpoint path details to AM destination transformation responses. It follows a conventional commit prefix, is concise, and is clearly related to the modified files and PR objectives. The phrasing is specific enough for a reviewer scanning history to understand the main intent without listing implementation details.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed The PR description is clear and covers the core information: a concise summary, a link to the Linear task (INT-4102), a changes list, benefits, testing notes, and files modified, so reviewers can understand intent and scope; however it does not strictly follow the repository template headings and omits the developer checklist and explicit sub-sections for behavioral changes, dependencies, and objectives. Given the presence of the critical details and the resolved ticket reference, the description is mostly complete for review purposes.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/am-destination-updates

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@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.

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 sites

Other 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

📥 Commits

Reviewing files that changed from the base of the PR and between c6d26c4 and 94ee5f5.

⛔ Files ignored due to path filters (3)
  • test/integrations/destinations/am/batch/data.ts is excluded by !**/test/**
  • test/integrations/destinations/am/processor/data.ts is excluded by !**/test/**
  • test/integrations/destinations/am/router/data.ts is 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 details

Returning both endpoint and path looks correct for batch. No issues spotted.


474-478: LGTM: group identify response carries endpointPath

Both endpoint and endpointPath are set for group calls. Looks good.


565-569: LGTM: alias response carries endpointPath

Alias flow correctly sets endpoint and endpointPath. No issues.


883-890: LGTM: batch first-event sets endpointPath

Setting 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 Map

Group 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:

Comment thread src/v0/destinations/am/transform.js Resolved
@koladilip
koladilip force-pushed the feat/am-destination-updates branch from 94ee5f5 to 4937068 Compare September 22, 2025 17:14
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@codecov

codecov Bot commented Sep 22, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.78%. Comparing base (e7628ec) to head (1f90ec3).
⚠️ Report is 10 commits behind head on develop.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- 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
@koladilip
koladilip force-pushed the feat/am-destination-updates branch from 4937068 to 1f90ec3 Compare September 23, 2025 03:04

@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.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/v0/destinations/am/transform.js (2)

71-77: DRY up endpoint details with a tiny helper

Reduce 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-site

Other 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4937068 and 1f90ec3.

⛔ Files ignored due to path filters (5)
  • test/apitests/data_scenarios/destination/batch/failure_batch.json is excluded by !**/test/**, !**/*.json
  • test/apitests/data_scenarios/destination/batch/successful_batch.json is excluded by !**/test/**, !**/*.json
  • test/integrations/destinations/am/batch/data.ts is excluded by !**/test/**
  • test/integrations/destinations/am/processor/data.ts is excluded by !**/test/**
  • test/integrations/destinations/am/router/data.ts is 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 segment

Good fix aligning endpointPath ('2/httpapi') with the endpoint. This addresses the earlier inconsistency.


457-459: Approve — endpointPath propagated and old helpers removed

No 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.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@sonarqubecloud

Copy link
Copy Markdown

@koladilip
koladilip enabled auto-merge (squash) September 23, 2025 10:31
@koladilip
koladilip merged commit 412f3f5 into develop Sep 23, 2025
@koladilip
koladilip deleted the feat/am-destination-updates branch September 23, 2025 11:47
maheshkutty pushed a commit that referenced this pull request Sep 24, 2025
- 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
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