Skip to content

feat: introduce endpointPath for iterable - #4599

Merged
atzoum merged 2 commits into
developfrom
feat.iterableEnpointPath
Sep 3, 2025
Merged

atzoum merged 2 commits into
developfrom
feat.iterableEnpointPath

Conversation

@atzoum

@atzoum atzoum commented Aug 29, 2025 •

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

Introducing endpointPath in iterable's transformed message responses. endpointPath field contains a stable representation of the request's target endpoint and will be used by rudder-server for applying throttling during the delivery stage of router.

The idea behind using a new endpointPath field instead of the existing endpoint, is that while the endpoint can change depending on the destination's region (eu/us) or other event information (e.g. including dynamic path & query parameters in the final endpoint url), endpointPath remains stable.

What is the related Linear task?

resolves PIPE-2337

@coderabbitai

coderabbitai Bot commented Aug 29, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added optional endpointPath field to public request/response types.
    • Iterable destination now includes endpointPath in responses and throughout batched operations.
  • Tests

    • Updated test coverage to validate endpointPath across relevant event categories.

Walkthrough

Adds an optional endpointPath property to public types and propagates endpointPath through the Iterable destination: derived in util, passed into batching/processing, assigned in transform responses, and validated in updated tests. No control-flow or error-handling changes.

Changes

Cohort / File(s) Summary
Type additions
src/types/destinationTransformation.ts
Added optional endpointPath?: string to exported types ProcessorTransformationOutput and ProxyV0Request.
Iterable destination — util & batching
src/v0/destinations/iterable/util.js, src/v0/destinations/iterable/util.test.js
getCategoryWithEndpoint now returns endpointPath (from categoryConfig.endpoint); batching helpers accept an endpointPath arg and set batchedRequest.endpointPath; batch processors define/pass endpointPath; tests updated to expect endpointPath.
Iterable destination — transform
src/v0/destinations/iterable/transform.js
Response builder now assigns response.endpointPath = category.endpointPath when constructing transformation outputs.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor SDK as Event
  participant TR as transform.js
  participant UT as util.js
  participant BP as BatchProcessors
  participant RB as ResponseBuilder

  SDK->>TR: send message
  TR->>UT: getCategoryWithEndpoint(message)
  UT-->>TR: { name, action, endpoint, endpointPath }
  alt batched
    TR->>BP: process*Batch(..., endpoint, endpointPath)
    BP->>BP: combineBatchedAndNonBatchedEvents(...)\nset batchedRequest.endpoint & endpointPath
    BP-->>RB: batched request (with endpointPath)
  else non-batched
    TR-->>RB: single request (with endpoint & endpointPath)
  end
  RB-->>SDK: ProcessorTransformationOutput { endpointPath, ... }

  note right of UT: endpointPath newly propagated alongside endpoint
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • sivashanmukh
  • koladilip
  • vinayteki95

Suggested improvements: add a small unit test asserting endpointPath appears on transformation responses (transform.js) and add JSDoc for the new endpointPath fields in types for better consumer docs.

✨ 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.iterableEnpointPath

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@atzoum
atzoum marked this pull request as ready for review September 1, 2025 06:44
@atzoum
atzoum requested review from a team and sivashanmukh as code owners September 1, 2025 06:44
@atzoum
atzoum requested review from a team, chandumlg and krishna2020 September 1, 2025 06:44
@atzoum atzoum changed the title [WIP] feat: introduce endpointPath for iterable feat: introduce endpointPath for iterable Sep 1, 2025

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/types/destinationTransformation.ts (1)

40-53: Add endpointPath to BatchedRequest to keep batch typings consistent

combineBatchedAndNonBatchedEvents now sets batchedRequest.endpointPath. To avoid TS friction for processor/batch paths, include endpointPath in BatchedRequest too.

 export type BatchedRequest<
   TPayload = Record<string, unknown>,
   THeaders = Record<string, unknown>,
   TParams = Record<string, unknown>,
 > = {
   body: BatchedRequestBody<TPayload>;
   version: string;
   type: string;
   method: string;
   endpoint: string;
+  endpointPath?: string;
   headers: THeaders;
   params: TParams;
   files: Record<string, never>;
 };
🧹 Nitpick comments (6)
src/v0/destinations/iterable/transform.js (1)

95-99: Default endpointPath if category.endpointPath is missing

Defensive fallback avoids undefined when a category forgets to set endpointPath. Low risk and future-proof.

   response.endpoint =
     category.action === 'catalogs' ? getCatalogEndpoint(category, message) : category.endpoint;
-  response.endpointPath = category.endpointPath;
+  const pathFromEndpoint =
+    (typeof category.endpoint === 'string' && category.endpoint.split('/api/')[1]) || undefined;
+  response.endpointPath = category.endpointPath || pathFromEndpoint;
src/v0/destinations/iterable/util.test.js (1)

892-956: Good assertions for endpointPath; consider adding batch-path checks

Nice coverage for getCategoryUsingEventName. Add tests to assert endpointPath is set on batched responses too (users/bulkUpdate, events/trackBulk) from processUpdateUserBatch/processTrackBatch.

src/v0/destinations/iterable/util.js (4)

68-72: LGTM: expose endpointPath alongside endpoint

Sourced from categoryConfig.endpoint keeps it region-agnostic. Consider trimming leading slashes to normalize paths (nit).

 const getCategoryWithEndpoint = (categoryConfig, dataCenter) => ({
   ...categoryConfig,
   endpoint: constructEndpoint(dataCenter, categoryConfig),
-  endpointPath: categoryConfig.endpoint,
+  endpointPath: String(categoryConfig.endpoint).replace(/^\/+/, ''),
 });

451-458: Avoid scattering batch path literals

These path strings will get reused; move them to config (e.g., BATCH_ENDPOINT_PATHS) or constants in this module.

-    const endpointPath = 'users/bulkUpdate';
+    const endpointPath = BATCH_ENDPOINT_PATHS.IDENTIFY; // e.g., { IDENTIFY: 'users/bulkUpdate' }

528-538: Catalog batch: propagate stable endpointPath

Reading endpointPath from message keeps throttling key stable across items. LGTM. Consider asserting it exists and defaulting to 'catalogs' if absent.


620-627: Same constantization for track bulk path

Mirror the identify-bulk suggestion: centralize 'events/trackBulk' to avoid typos and ease future changes.

-    const endpointPath = 'events/trackBulk';
+    const endpointPath = BATCH_ENDPOINT_PATHS.TRACK; // e.g., { TRACK: 'events/trackBulk' }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b50b749 and e2989d5.

⛔ Files ignored due to path filters (7)
  • test/integrations/destinations/iterable/dataDelivery/business.ts is excluded by !**/test/**
  • test/integrations/destinations/iterable/processor/aliasTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/iterable/processor/identifyTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/iterable/processor/pageScreenTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/iterable/processor/trackTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/iterable/router/data.ts is excluded by !**/test/**
  • test/integrations/testUtils.ts is excluded by !**/test/**
📒 Files selected for processing (4)
  • src/types/destinationTransformation.ts (2 hunks)
  • src/v0/destinations/iterable/transform.js (1 hunks)
  • src/v0/destinations/iterable/util.js (6 hunks)
  • src/v0/destinations/iterable/util.test.js (4 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/iterable/transform.js
  • src/v0/destinations/iterable/util.test.js
  • src/v0/destinations/iterable/util.js
🧠 Learnings (1)
📚 Learning: 2025-05-29T13:29:39.436Z
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The `combineBatchRequestsWithSameJobIds` function in `src/v0/util/index.js` is used by both Mixpanel and Google AdWords Offline Conversions destinations in production. The function assumes metadata is always an array in multiple operations (forEach, filter, sort, map) and needs defensive programming to handle non-array metadata cases to prevent runtime errors.

Applied to files:

  • src/v0/destinations/iterable/util.js
🧬 Code graph analysis (1)
src/v0/destinations/iterable/util.js (1)
src/v0/destinations/iterable/config.js (1)
  • constructEndpoint (74-77)
🔇 Additional comments (3)
src/types/destinationTransformation.ts (2)

71-79: LGTM: optional endpointPath on ProcessorTransformationOutput

The new field is optional and non-breaking. Good addition for router throttling.


153-160: LGTM: optional endpointPath on ProxyV0Request

Keeps proxy requests aligned with the new router needs. ProxyV1 inherits it via Omit — all good.

src/v0/destinations/iterable/util.js (1)

319-335: No changes needed—metadata and nonBatchedRequests are always arrays
All internal callers build and pass a metadata array and explicit nonBatchedRequests array to combineBatchedAndNonBatchedEvents, so the suggested guards and default value aren’t required here.

@atzoum
atzoum force-pushed the feat.iterableEnpointPath branch from e2989d5 to 2462709 Compare September 2, 2025 06:35
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@codecov

codecov Bot commented Sep 2, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.79%. Comparing base (d74003b) to head (59065ab).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4599   +/-   ##
========================================
  Coverage    91.78%   91.79%           
========================================
  Files          642      642           
  Lines        33931    33935    +4     
  Branches      8032     8041    +9     
========================================
+ Hits         31145    31149    +4     
+ Misses        2556     2534   -22     
- Partials       230      252   +22     

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

koladilip
koladilip previously approved these changes Sep 2, 2025
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@sonarqubecloud

sonarqubecloud Bot commented Sep 3, 2025

Copy link
Copy Markdown

@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 (1)
src/v0/destinations/iterable/util.js (1)

313-318: Update JSDoc parameter documentation for consistency.

The JSDoc comment should be updated to reflect the new parameter signature including endpointPath.

/**
 * Combines batched and non batched requests
 * @param {*} apiKey
 * @param {*} metadata
- * @param {*} endpoint
+ * @param {*} endpoint
+ * @param {*} endpointPath
 * @param {*} destination
 * @param {*} eventResponse
- * @param {*} transformedEvents
+ * @param {*} nonBatchedRequests
 * @returns
 */

Also applies to: 319-327

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2462709 and 59065ab.

⛔ Files ignored due to path filters (7)
  • test/integrations/destinations/iterable/dataDelivery/business.ts is excluded by !**/test/**
  • test/integrations/destinations/iterable/processor/aliasTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/iterable/processor/identifyTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/iterable/processor/pageScreenTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/iterable/processor/trackTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/iterable/router/data.ts is excluded by !**/test/**
  • test/integrations/testUtils.ts is excluded by !**/test/**
📒 Files selected for processing (4)
  • src/types/destinationTransformation.ts (2 hunks)
  • src/v0/destinations/iterable/transform.js (1 hunks)
  • src/v0/destinations/iterable/util.js (6 hunks)
  • src/v0/destinations/iterable/util.test.js (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/v0/destinations/iterable/transform.js
  • src/v0/destinations/iterable/util.test.js
🧰 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/iterable/util.js
🧠 Learnings (1)
📚 Learning: 2025-05-29T13:29:39.436Z
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The `combineBatchRequestsWithSameJobIds` function in `src/v0/util/index.js` is used by both Mixpanel and Google AdWords Offline Conversions destinations in production. The function assumes metadata is always an array in multiple operations (forEach, filter, sort, map) and needs defensive programming to handle non-array metadata cases to prevent runtime errors.

Applied to files:

  • src/v0/destinations/iterable/util.js
🧬 Code graph analysis (1)
src/v0/destinations/iterable/util.js (1)
src/v0/destinations/iterable/config.js (1)
  • constructEndpoint (74-77)
⏰ 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 Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • 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: Code Coverage
  • GitHub Check: UT Tests
  • GitHub Check: test_and_publish
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (7)
src/types/destinationTransformation.ts (2)

76-76: LGTM! Proper addition of optional endpointPath field.

The optional endpointPath field is correctly added to ProcessorTransformationOutput, maintaining backward compatibility while enabling the new throttling functionality described in the PR objectives.


157-157: LGTM! Consistent endpointPath addition to proxy request type.

The optional endpointPath field is properly added to ProxyV0Request, ensuring consistency across the transformation pipeline from processor output to proxy requests.

src/v0/destinations/iterable/util.js (5)

68-72: LGTM! Clean implementation of endpointPath derivation.

The getCategoryWithEndpoint function correctly adds endpointPath using the original category endpoint value, providing the stable path representation needed for throttling while preserving the full constructed endpoint.


329-330: LGTM! Proper assignment of endpoint properties.

Both endpoint and endpointPath are correctly assigned to the batched request, enabling downstream throttling logic to use the stable path representation.


451-452: LGTM! Consistent endpointPath handling in update user batch processing.

The endpointPath is properly defined as a constant and used both for endpoint construction and passed to the batching function, ensuring consistency between the actual endpoint and the throttling path.

Also applies to: 457-457


530-530: LGTM! Proper extraction and propagation of endpointPath for catalog batching.

The endpointPath is correctly extracted from the message and passed through to the batching function, maintaining the stable path representation for catalog operations.

Also applies to: 537-537


620-621: LGTM! Consistent endpointPath implementation for track event batching.

Similar to the update user batch processing, the endpointPath is properly defined and used consistently for track events, ensuring uniform handling across all batch types.

Also applies to: 626-626

@atzoum
atzoum enabled auto-merge (squash) September 3, 2025 09:01
@atzoum
atzoum merged commit 840ba5c into develop Sep 3, 2025
@atzoum
atzoum deleted the feat.iterableEnpointPath branch September 3, 2025 09:31
@coderabbitai coderabbitai Bot mentioned this pull request Sep 11, 2025
7 of 10 tasks
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.

4 participants