Skip to content

feat: add endpoint path to Braze response objects - #4677

Merged
koladilip merged 1 commit into
developfrom
feat/braze-identity-resolution-improvements
Sep 24, 2025
Merged

koladilip merged 1 commit into
developfrom
feat/braze-identity-resolution-improvements

Conversation

@koladilip

@koladilip koladilip commented Sep 24, 2025 •

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

Enhanced Braze destination endpoint functions to return both the full endpoint URL and the path component for better debugging and monitoring capabilities.

What is the related Linear task?

Resolves https://linear.app/rudderstack/issue/INT-4102/add-endpoint-path-details-in-rudder-transformer-for-top-15

Please explain the objectives of your changes below

Modified endpoint functions (identify, track, subscription group, and alias merge) to return structured objects containing both the complete endpoint URL and the path component. This improves debugging capabilities and provides better visibility into which specific Braze API endpoints are being called.

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

The endpoint functions now return objects with endpoint and path properties instead of just the URL string. This is a non-breaking change as the endpoint property contains the same URL that was previously returned.

Any new dependencies introduced with this change?

N/A

Any new generic utility introduced or modified. Please explain the changes.

Modified endpoint utility functions in config.js to return structured response objects.

Any technical or performance related pointers to consider with the change?

No performance impact. The change only affects the structure of returned data, not the actual API calls.

@coderabbitai review


Developer checklist

  • My code follows the style guidelines of this project
  • No breaking changes are being introduced.
  • All related docs linked with the PR?
  • All changes manually tested?
  • Any documentation changes needed with this change?
  • Is the PR limited to 10 file changes?
  • Is the PR limited to one linear task?
  • Are relevant unit and component test-cases added in new readability format?

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.

- Modified endpoint functions to return both endpoint URL and path
- Updated identify, track, subscription group, and alias merge endpoints
- Enhanced response structure for better debugging and monitoring
@koladilip
koladilip requested a review from a team as a code owner September 24, 2025 08:25
@coderabbitai

coderabbitai Bot commented Sep 24, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Refactor

    • Standardized Braze endpoint handling to use structured endpoint + path across identify, track, group, alias merge, and batch flows.
    • Added endpointPath to requests for improved observability and routing consistency.
    • No user-facing behavior changes expected.
  • Tests

    • Updated mocks, fixtures, and assertions to align with the new endpoint structure.

Walkthrough

Endpoint resolver functions in Braze now return an object with endpoint and path. Call sites in transform, util, and identity resolution code are updated to extract and propagate both fields, including setting response.endpointPath. Tests are adjusted to mock and assert the new structure. One helper signature (buildResponse) is updated.

Changes

Cohort / File(s) Summary of changes
Endpoint resolver return shape
src/v0/destinations/braze/config.js
Functions now accept baseEndpoint and return { endpoint, path } instead of a string; param renamed from endPoint to baseEndpoint across getIdentifyEndpoint, getTrackEndPoint, getSubscriptionGroupEndPoint, getAliasMergeEndPoint.
Transform flow propagation
src/v0/destinations/braze/transform.js
buildResponse signature changed to accept endpointDetails; response now sets endpoint and endpointPath. Identify and group flows extract endpoint/path from resolver results and assign both.
Batch/util propagation
src/v0/destinations/braze/util.js
Batch builders now destructure { endpoint, path } from resolver calls and set both response.endpoint and response.endpointPath across merge, subscription, and track batches.
Identity resolution runtime usage
src/v0/destinations/braze/identityResolutionUtils.ts
Destructure { endpoint } from getIdentifyEndpoint(...) and pass to HTTP request; variable rename aligning with new resolver return type.
Test adjustments
src/v0/destinations/braze/identityResolutionUtils.test.ts
Mocks and assertions updated to handle { endpoint, path } return from getIdentifyEndpoint; fixture shaping and multiline formatting adjusted accordingly.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Msg as Message
  participant Cfg as Destination Config
  participant Res as Endpoint Resolver
  participant Tx as Transform/Util
  participant HTTP as HTTP Client

  Msg->>Tx: Build request payload
  Tx->>Cfg: Read baseEndpoint
  Tx->>Res: get*EndPoint(baseEndpoint)
  Res-->>Tx: { endpoint, path }
  Note over Tx: Assign response.endpoint and response.endpointPath
  Tx->>HTTP: POST endpoint (uses endpointPath for metadata)
  HTTP-->>Tx: Response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • utsabc
  • maheshkutty
  • vinayteki95
  • sivashanmukh

Suggestions

  • Add TypeScript types/interfaces for { endpoint, path } and response shapes to prevent regressions.
  • Search for any remaining call sites expecting string endpoints to ensure full migration.
  • Consider centralizing endpoint/path assignment into a helper to reduce duplication.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "feat: add endpoint path to Braze response objects" is concise, follows a conventional commit style, and accurately captures the primary change in this PR — adding a path field alongside the endpoint in Braze response objects; it names the affected area (Braze) and avoids noise or vague wording. This makes the intent clear to reviewers scanning history.
Description Check ✅ Passed The PR description closely follows the repository template and includes a clear change summary, the linked Linear issue, objectives, notes that the change is non-breaking, and the specific utility changes to endpoint functions; it also indicates testing and checklist status, providing sufficient context for reviewers. The description aligns with the raw changes (endpoint functions returning {endpoint,path}, updated tests, and updated buildResponse usage) and is therefore mostly complete.
✨ 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/braze-identity-resolution-improvements

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

@codecov

codecov Bot commented Sep 24, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.79%. Comparing base (2a5b355) to head (877d748).
⚠️ Report is 29 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4677   +/-   ##
========================================
  Coverage    91.78%   91.79%           
========================================
  Files          642      642           
  Lines        33976    34006   +30     
  Branches      8034     8042    +8     
========================================
+ Hits         31186    31215   +29     
+ Misses        2560     2539   -21     
- 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.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@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 (4)
src/v0/destinations/braze/identityResolutionUtils.ts (1)

70-71: Use returned path instead of hardcoding endpointPath; normalize leading slash

You already resolve the identify endpoint via getIdentifyEndpoint. Also destructure path and pass it through to endpointPath to keep telemetry consistent with the rest of the Braze flows.

Apply:

-  const { endpoint } = getIdentifyEndpoint(getEndpointFromConfig(destination));
+  const { endpoint, path } = getIdentifyEndpoint(getEndpointFromConfig(destination));
@@
       {
         destType: 'braze',
         feature: 'transformation',
         requestMethod: 'POST',
         module: 'router',
-        endpointPath: '/users/identify',
+        endpointPath: path?.startsWith('/') ? path : `/${path}`,
       },

Please confirm there are no other hardcoded occurrences of '/users/identify' left in this package. I can provide a repo scan script if needed.

Also applies to: 79-95

src/v0/destinations/braze/transform.js (2)

202-206: Derive endpointPath from config instead of hardcoding; normalize leading slash

Align identify flow with the rest by using the returned path instead of a string literal. This prevents drift if the path changes in config.

-  const { endpoint } = getIdentifyEndpoint(getEndpointFromConfig(destination));
+  const { endpoint, path } = getIdentifyEndpoint(getEndpointFromConfig(destination));
@@
-      endpointPath: '/users/identify',
+      endpointPath: path?.startsWith('/') ? path : `/${path}`,

Also applies to: 219-221


389-392: Normalize endpointPath to a single convention

To keep observability keys consistent with other destinations, ensure a leading slash or standardize in config.

-    response.endpointPath = path;
+    response.endpointPath = path?.startsWith('/') ? path : `/${path}`;
src/v0/destinations/braze/util.js (1)

444-447: Normalize endpointPath format (ensure leading slash) for consistent telemetry

path can be provided both with and without a leading /, producing inconsistent telemetry keys — normalize before assigning to response.endpointPath. Example local fix:
response.endpointPath = path?.startsWith('/') ? path : /${path}

Apply in src/v0/destinations/braze/util.js at the response.endpointPath assignments (around lines 444–447, 452–455, 561–564). Prefer standardizing config paths to include a leading slash if possible.

📜 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 a5b16f1 and 877d748.

⛔ Files ignored due to path filters (3)
  • test/integrations/destinations/braze/processor/data.ts is excluded by !**/test/**
  • test/integrations/destinations/braze/router/data.ts is excluded by !**/test/**
  • test/integrations/destinations/braze/router/identityResolution.ts is excluded by !**/test/**
📒 Files selected for processing (5)
  • src/v0/destinations/braze/config.js (1 hunks)
  • src/v0/destinations/braze/identityResolutionUtils.test.ts (51 hunks)
  • src/v0/destinations/braze/identityResolutionUtils.ts (2 hunks)
  • src/v0/destinations/braze/transform.js (3 hunks)
  • src/v0/destinations/braze/util.js (3 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/braze/config.js
  • src/v0/destinations/braze/transform.js
  • src/v0/destinations/braze/util.js
🧠 Learnings (2)
📚 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/braze/util.js
📚 Learning: 2024-07-27T07:02:57.329Z
Learnt from: anantjain45823
PR: rudderlabs/rudder-transformer#2842
File: src/v1/sources/shopify/identifierEventsLayer.test.js:5-40
Timestamp: 2024-07-27T07:02:57.329Z
Learning: The `processIdentifierEvent` function in `identifierEventsLayer.test.js` is designed to succeed for any input, hence no negative test cases are required.

Applied to files:

  • src/v0/destinations/braze/identityResolutionUtils.test.ts
🧬 Code graph analysis (5)
src/v0/destinations/braze/identityResolutionUtils.ts (2)
src/v0/destinations/braze/transform.js (1)
  • getIdentifyEndpoint (202-202)
src/v0/destinations/braze/util.js (1)
  • getEndpointFromConfig (55-78)
src/v0/destinations/braze/config.js (2)
src/v0/destinations/braze/transform.js (2)
  • getIdentifyEndpoint (202-202)
  • getSubscriptionGroupEndPoint (389-389)
src/v0/destinations/braze/util.js (3)
  • getTrackEndPoint (539-539)
  • getSubscriptionGroupEndPoint (452-452)
  • getAliasMergeEndPoint (444-444)
src/v0/destinations/braze/transform.js (4)
src/v0/destinations/google_adwords_offline_conversions/utils.js (3)
  • endpointDetails (239-242)
  • endpointDetails (319-322)
  • endpointDetails (400-403)
src/v0/util/index.js (2)
  • defaultRequestConfig (462-476)
  • path (11-11)
src/v0/destinations/braze/util.js (2)
  • getEndpointFromConfig (55-78)
  • getSubscriptionGroupEndPoint (452-452)
src/adapters/network.js (1)
  • handleHttpRequest (424-429)
src/v0/destinations/braze/util.js (2)
src/v0/destinations/braze/transform.js (4)
  • response (55-55)
  • response (388-388)
  • response (454-454)
  • getSubscriptionGroupEndPoint (389-389)
src/v0/destinations/snapchat_custom_audience/networkHandler.js (1)
  • response (44-51)
src/v0/destinations/braze/identityResolutionUtils.test.ts (4)
src/adapters/utils/networkUtils.js (1)
  • getDynamicErrorType (87-95)
src/v0/destinations/braze/util.js (6)
  • collectStatsForAliasFailure (783-815)
  • getEndpointFromConfig (55-78)
  • _ (2-2)
  • i (120-120)
  • i (148-148)
  • i (540-540)
src/v0/destinations/braze/transform.js (1)
  • getIdentifyEndpoint (202-202)
src/types/controlPlaneConfig.ts (1)
  • Destination (31-49)
⏰ 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 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: test_and_publish
  • GitHub Check: UT Tests
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
src/v0/destinations/braze/transform.js (1)

54-69: buildResponse: good migration to endpointDetails

Accepts endpointDetails and sets endpoint and endpointPath cleanly. Call sites are updated accordingly.

src/v0/destinations/braze/identityResolutionUtils.test.ts (1)

153-164: Tests & mocks are consistent — no change required now

getIdentifyEndpoint() returns path 'users/identify' (no leading slash); callers pass endpointPath '/users/identify' to handleHttpRequest and tests mock the former while asserting the latter — current state is consistent. If you later standardize on a leading slash in config.path, update the mocked getIdentifyEndpoint return values to '/users/identify' (or instead normalize in callers and adjust expectations).

src/v0/destinations/braze/config.js (1)

12-17: Standardize returned path strings with a leading slash

Return leading-slash paths from braze config; braze callers set response.endpoint from the full URL and only assign response.endpointPath = path (no extra concatenation), so this change is safe and aligns endpointPath formatting across the codebase.

 function getIdentifyEndpoint(baseEndpoint) {
   return {
     endpoint: `${baseEndpoint}/users/identify`,
-    path: 'users/identify',
+    path: '/users/identify',
   };
 }
 
 function getTrackEndPoint(baseEndpoint) {
   return {
     endpoint: `${baseEndpoint}/users/track`,
-    path: 'users/track',
+    path: '/users/track',
   };
 }
 
 function getSubscriptionGroupEndPoint(baseEndpoint) {
   return {
     endpoint: `${baseEndpoint}/v2/subscription/status/set`,
-    path: 'v2/subscription/status/set',
+    path: '/v2/subscription/status/set',
   };
 }
 
 function getAliasMergeEndPoint(baseEndpoint) {
   return {
     endpoint: `${baseEndpoint}/users/merge`,
-    path: 'users/merge',
+    path: '/users/merge',
   };
 }

@sonarqubecloud

sonarqubecloud Bot commented Sep 24, 2025 •

Copy link
Copy Markdown

@koladilip
koladilip merged commit e6acf3e into develop Sep 24, 2025
@koladilip
koladilip deleted the feat/braze-identity-resolution-improvements branch September 24, 2025 12:55
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