Skip to content

chore: braze identity resolution batching - #4439

Merged
vinayteki95 merged 11 commits into
developfrom
feat.braze-alias-batching
Jul 18, 2025
Merged

vinayteki95 merged 11 commits into
developfrom
feat.braze-alias-batching

Conversation

@vinayteki95

@vinayteki95 vinayteki95 commented Jun 29, 2025 •

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

This PR introduces Identity Resolution Batching functionality for the Braze destination, which optimizes performance by batching multiple identity resolution calls to Braze's /users/identify endpoint.

Key Implementation Details:

  • Batching Logic: Added processBatchedIdentify() function that collects identity resolution calls and batches them into chunks of up to 50 aliases per request
  • Environment Variable Control: Introduced BRAZE_BATCH_IDENTIFY_RESOLUTION environment variable to enable/disable batching (defaults to enabled)
  • Enhanced Router Processing: Modified processRouterDest() to collect identity calls and process them in batches after individual event processing

Technical Implementation

  • Batch Size: Maximum 50 aliases per batch (defined by IDENTIFY_BRAZE_MAX_REQ_COUNT)
  • Error Handling: Comprehensive error handling for network failures, HTTP status errors, and response validation
  • Failure Strategy: If any batch fails, the entire batch of events is marked as failed to maintain data consistency
  • Stats Tracking: Added metrics tracking with braze_batched_identify_func_calls_count

What is the related Linear task?

Resolves INT-3720

Please explain the objectives of your changes below

Required Details:

  • Configuration: The feature is controlled by the shouldBatchBrazeIdentifyResolution() function which reads the BRAZE_BATCH_IDENTIFY_RESOLUTION environment variable
  • Backward Compatibility: When batching is disabled (BRAZE_BATCH_IDENTIFY_RESOLUTION=false), the system falls back to individual identity resolution calls
  • Integration Points: The batching logic integrates with both simpleProcessRouterDest and simpleProcessRouterDestSync functions

Dependent Changes

  • Test Infrastructure: Added comprehensive test cases in test/integrations/destinations/braze/router/identityResolution.ts
  • Mock Functions: Created new mock functions in test/integrations/destinations/braze/mocks.ts for testing batched scenarios
  • Documentation Updates: Updated README.md with detailed documentation of the new batching functionality

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

Reason for Changes

  • Performance Optimization: Reduce API call volume to Braze's /users/identify endpoint by up to 50x in high-volume scenarios
  • Rate Limit Optimization: Better utilization of Braze's rate limits (20,000 requests per minute for /users/identify)
    Improved Throughput: Enhanced overall transformation performance for events requiring identity resolution

What Changed

  • Default Behavior: Identity resolution calls are now batched by default (can be disabled via environment variable)
  • Processing Flow: Identity resolution calls are collected during event processing and executed in batches after individual event transformation
  • Error Handling: Enhanced error handling to maintain proper job metadata association in batched scenarios

Any new dependencies introduced with this change?

N/A

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

N/A

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

Performance Benefits

  • Reduced API Calls: Up to 50x reduction in API calls for identity resolution in high-volume scenarios
  • Better Rate Limit Utilization: More efficient use of Braze's 20,000 requests/minute limit for /users/identify
  • Improved Throughput: Parallel processing of batched requests improves overall performance

Technical Considerations

  • Memory Usage: Temporary collection of identity calls in memory during batch processing
  • Error Propagation: Batch failures affect all events in the batch to maintain data consistency
  • Monitoring: New stats metric braze_batched_identify_func_calls_count for monitoring batch processing
  • Configurability: Environment variable allows fine-tuning based on deployment requirements

Backward Compatibility

  • Graceful Fallback: When batching is disabled, the system maintains existing individual call behavior
  • No Breaking Changes: Existing functionality remains unchanged when batching is disabled
  • Configuration Flexibility: Can be enabled/disabled per environment without code changes

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

@coderabbitai

coderabbitai Bot commented Jun 29, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added support for batching Braze identify calls, improving efficiency for identity resolution requests.
    • Introduced configuration to enable or disable batching for Braze identify resolution.
    • Added Prometheus metrics to monitor batched identify function calls.
  • Bug Fixes

    • Enhanced error handling and logging for Braze identify requests, including network and application-level errors.
  • Tests

    • Added comprehensive tests for Braze identity resolution batching, error cases, configuration, and metrics collection.

Summary by CodeRabbit

  • New Features

    • Introduced batching for Braze identity resolution calls, reducing the number of HTTP requests and improving efficiency.
    • Added an environment variable to enable or disable batching for Braze identify requests.
    • Added a Prometheus metric to monitor the number and status of batched identify function calls.
  • Bug Fixes

    • Enhanced error handling for batched Braze identify requests, ensuring consistent responses in case of network or HTTP errors.

Walkthrough

A batching mechanism for Braze identity resolution calls was introduced. The configuration module now exports a function to check if batching is enabled via an environment variable. The transformation logic supports batching, processes batched requests, and integrates error handling. An internal utility function now passes request metadata to transformation functions. A Prometheus metric was added to track batched identify function calls.

Changes

File(s) Change Summary
src/v0/destinations/braze/config.js Added shouldBatchBrazeIdentifyResolution() to check batching flag via environment variable.
src/v0/destinations/braze/transform.js Added batched identify logic, error handling, updated processing flow to support batching, and modified function signatures.
src/v0/destinations/braze/identityResolutionUtils.ts Added new utility module implementing batched Braze identity resolution requests with error handling and metrics.
src/v0/destinations/braze/identityResolutionUtils.test.ts Added comprehensive Jest test suite covering batching logic, error handling, configuration, and metrics.
src/v0/util/index.js Modified simpleProcessRouterDest to pass reqMetadata to transformation functions.
src/util/prometheus.js Added Prometheus counter metric braze_batched_identify_func_calls_count to track batched identify calls.

Sequence Diagram(s)

sequenceDiagram
    participant Router as processRouterDest
    participant Config as shouldBatchBrazeIdentifyResolution
    participant Transformer as processIdentify/processBatchedIdentify
    participant BrazeAPI as Braze /users/identify

    Router->>Config: Check batching flag
    alt Batching enabled
        Router->>Transformer: Collect identify calls in array
        Router->>Transformer: processBatchedIdentify(identifyCallsArray)
        Transformer->>BrazeAPI: POST batched identify request
        BrazeAPI-->>Transformer: Response (success/error)
        Transformer-->>Router: Batch result
    else Batching disabled
        Router->>Transformer: processIdentify (single call)
        Transformer->>BrazeAPI: POST single identify request
        BrazeAPI-->>Transformer: Response
        Transformer-->>Router: Result
    end
Loading

Suggested reviewers

  • maheshkutty
  • krishna2020
  • sivashanmukh
  • koladilip

Suggestions for improvement:

  • Consider adding unit tests covering both batched and non-batched identify flows to ensure robustness.
  • Document the new environment variable BRAZE_BATCH_IDENTIFY_RESOLUTION and its impact in deployment/configuration guides for clarity.
  • Review and enhance error propagation to ensure failures in batched requests provide actionable diagnostics and facilitate troubleshooting.
  • Monitor the new Prometheus metric to analyze the adoption and performance impact of batching in production.
✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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.

Documentation and Community

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

@codecov

codecov Bot commented Jun 29, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.24%. Comparing base (a196c11) to head (b07f027).
⚠️ Report is 266 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4439      +/-   ##
===========================================
+ Coverage    91.23%   91.24%   +0.01%     
===========================================
  Files          640      641       +1     
  Lines        33700    33749      +49     
  Branches      7951     7960       +9     
===========================================
+ Hits         30745    30794      +49     
  Misses        2690     2690              
  Partials       265      265              

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

1 similar comment
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@vinayteki95
vinayteki95 marked this pull request as ready for review July 1, 2025 04:27
@vinayteki95
vinayteki95 requested review from a team and sivashanmukh as code owners July 1, 2025 04:27
@vinayteki95
vinayteki95 requested review from a team, manish339k and yashasvibajpai July 1, 2025 04:27
@vinayteki95 vinayteki95 added the DO NOT MERGE Don't merge this PR without having discussion label Jul 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: 1

🧹 Nitpick comments (3)
src/v0/destinations/braze/config.js (1)

61-61: Consider case-insensitive comparison for better robustness.

The current implementation requires the exact string 'true'. Consider making it more flexible to handle common variations.

-const shouldBatchBrazeIdentifyResolution = () => process.env.BRAZE_BATCH_IDENTIFY_RESOLUTION === 'true';
+const shouldBatchBrazeIdentifyResolution = () => process.env.BRAZE_BATCH_IDENTIFY_RESOLUTION?.toLowerCase() === 'true';
src/v0/destinations/braze/transform.js (2)

235-237: Use JSON_MIME_TYPE constant for consistency.

Replace hardcoded strings with the imported constant to maintain consistency across the codebase.

-            'Content-Type': 'application/json',
-            Accept: 'application/json',
+            'Content-Type': JSON_MIME_TYPE,
+            Accept: JSON_MIME_TYPE,

305-309: Simplify array validation logic.

The current validation is overly defensive. Since this is an internal function, a simpler check would suffice.

-  if (
-    identifyCallsArray !== undefined &&
-    identifyCallsArray !== null &&
-    Array.isArray(identifyCallsArray)
-  ) {
+  if (identifyCallsArray) {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fa8e0c4 and 0c548a502b22fb5f9bcc39dbc8f2c4e0bbd17860.

⛔ Files ignored due to path filters (4)
  • src/v0/destinations/braze/README.md is excluded by !**/*.md
  • test/integrations/destinations/braze/mocks.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 (3)
  • src/v0/destinations/braze/config.js (2 hunks)
  • src/v0/destinations/braze/transform.js (7 hunks)
  • src/v0/util/index.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.js`: Focus on ESLint errors (max 3) and warnings (max 5).

**/*.js: Focus on ESLint errors (max 3) and warnings (max 5).

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • src/v0/destinations/braze/config.js
  • src/v0/util/index.js
  • src/v0/destinations/braze/transform.js
🧠 Learnings (4)
📓 Common learnings
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.
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` assumes metadata is always an array throughout its implementation, but defensive programming should be added to handle cases where metadata might not be an array type to prevent runtime errors.
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#4364
File: src/v0/util/index.js:2220-2242
Timestamp: 2025-06-02T06:25:17.338Z
Learning: In the rudderlabs/rudder-transformer codebase, jobId values are guaranteed by system contract to always be valid numbers and never undefined or infinite. Additional validation for these edge cases in sorting functions like sortBatchesByMinJobId is not necessary.
Learnt from: vinayteki95
PR: rudderlabs/rudder-transformer#4220
File: src/middlewares/routerTransformCompactedPayloadV1.ts:13-24
Timestamp: 2025-04-02T08:21:38.217Z
Learning: In the Rudder Transformer codebase, use generic Error objects instead of TransformationError when error monitoring with Bugsnag is needed, as TransformationError is configured to not trigger Bugsnag alerts.
src/v0/destinations/braze/config.js (1)
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.
src/v0/util/index.js (3)
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.
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` assumes metadata is always an array throughout its implementation, but defensive programming should be added to handle cases where metadata might not be an array type to prevent runtime errors.
Learnt from: krishna2020
PR: rudderlabs/rudder-transformer#4178
File: src/sources/shopify/transform.js:37-45
Timestamp: 2025-03-21T12:32:28.443Z
Learning: The getBodyFromV2SpecPayload function in Shopify source transformation throws an error if request is not defined, making additional null checks in getEventFromV2Request function unnecessary.
src/v0/destinations/braze/transform.js (3)
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.
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` assumes metadata is always an array throughout its implementation, but defensive programming should be added to handle cases where metadata might not be an array type to prevent runtime errors.
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.
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • 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: 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 (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (2)
src/v0/util/index.js (1)

1819-1819: LGTM! Necessary change for batching support.

The addition of reqMetadata as the third parameter enables downstream transformation functions to access request metadata, which is required for the new Braze batching functionality.

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

666-691: Well-implemented batching logic with proper error handling.

The implementation correctly:

  • Initializes the array for collecting identify calls
  • Conditionally enables batching based on configuration
  • Processes batched calls after all events are handled
  • Fails the entire batch if any identify call fails (ensuring data consistency)

Comment thread src/v0/destinations/braze/transform.js Resolved
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@vinayteki95
vinayteki95 requested a review from a team as a code owner July 1, 2025 08:49
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

1 similar comment
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

Comment thread src/v0/destinations/braze/transform.js Resolved
Comment thread src/v0/destinations/braze/transform.js Resolved
Comment thread src/v0/destinations/braze/transform.js Resolved
Comment thread src/v0/util/index.js Resolved
Comment thread src/v0/destinations/braze/transform.js Resolved

@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

♻️ Duplicate comments (1)
src/v0/destinations/braze/transform.js (1)

213-217: Add validation for destination consistency.

The function assumes all items in identifyCallsArray have the same destination configuration without validation. This could lead to issues if items are incorrectly batched.

+  // Validate all items have the same destination
+  const destinations = new Set(identifyCallsArray.map(item => item.destination?.ID));
+  if (destinations.size > 1) {
+    throw new InstrumentationError('Batched identify calls must have the same destination');
+  }
+
   const { destination } = identifyCallsArray[0];
🧹 Nitpick comments (1)
src/v0/destinations/braze/transform.js (1)

313-327: Simplify the identifyCallsArray validation.

The current validation can be simplified while maintaining the same functionality.

-  if (
-    identifyCallsArray !== undefined &&
-    identifyCallsArray !== null &&
-    Array.isArray(identifyCallsArray)
-  ) {
+  if (Array.isArray(identifyCallsArray)) {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a317c8216eca9f16a2ca461fccf1aaf29485eae8 and 27a47c2e4d4373defb3e158cbb98a34f3b3bb297.

⛔ Files ignored due to path filters (1)
  • test/integrations/destinations/braze/router/identityResolution.ts is excluded by !**/test/**
📒 Files selected for processing (1)
  • src/v0/destinations/braze/transform.js (6 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.js`: Focus on ESLint errors (max 3) and warnings (max 5).

**/*.js: Focus on ESLint errors (max 3) and warnings (max 5).

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • src/v0/destinations/braze/transform.js
🧠 Learnings (2)
📓 Common learnings
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.
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` assumes metadata is always an array throughout its implementation, but defensive programming should be added to handle cases where metadata might not be an array type to prevent runtime errors.
src/v0/destinations/braze/transform.js (10)
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.
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` assumes metadata is always an array throughout its implementation, but defensive programming should be added to handle cases where metadata might not be an array type to prevent runtime errors.
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#4364
File: src/v0/util/index.js:2220-2242
Timestamp: 2025-06-02T06:25:17.338Z
Learning: In the rudderlabs/rudder-transformer codebase, jobId values are guaranteed by system contract to always be valid numbers and never undefined or infinite. Additional validation for these edge cases in sorting functions like sortBatchesByMinJobId is not necessary.
Learnt from: vinayteki95
PR: rudderlabs/rudder-transformer#4220
File: src/middlewares/destTransformCompactedPayloadV1.ts:13-19
Timestamp: 2025-04-02T08:16:58.002Z
Learning: In the Rudder Transformer project, error handling should throw errors with descriptive messages (after logging them) rather than returning HTTP status codes, so that Bugsnag can catch them for debugging purposes.
Learnt from: anantjain45823
PR: rudderlabs/rudder-transformer#2842
File: src/v1/sources/shopify/enrichmentLayer.js:36-42
Timestamp: 2024-10-08T15:52:59.819Z
Learning: The user clarified that errors in the `setExtraNonEcomProperties` function should not cause the event to fail, indicating a preference for resilience over strict error propagation.
Learnt from: anantjain45823
PR: rudderlabs/rudder-transformer#2842
File: src/v1/sources/shopify/enrichmentLayer.js:36-42
Timestamp: 2024-07-27T07:02:57.329Z
Learning: The user clarified that errors in the `setExtraNonEcomProperties` function should not cause the event to fail, indicating a preference for resilience over strict error propagation.
Learnt from: vinayteki95
PR: rudderlabs/rudder-transformer#4220
File: src/middlewares/routerTransformCompactedPayloadV1.ts:13-24
Timestamp: 2025-04-02T08:21:38.217Z
Learning: In the Rudder Transformer codebase, use generic Error objects instead of TransformationError when error monitoring with Bugsnag is needed, as TransformationError is configured to not trigger Bugsnag alerts.
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4186
File: src/middlewares/arraySpreader.ts:48-63
Timestamp: 2025-04-08T02:59:55.677Z
Learning: In the BaseSpreader middleware implementation, error handling for transform functions is already handled in the middleware() method with a try-catch block, which wraps errors in a PlatformError. This makes additional error handling inside individual transform functions unnecessary.
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4186
File: src/middlewares/arraySpreader.ts:48-63
Timestamp: 2025-04-08T02:59:55.677Z
Learning: In the ArraySpreader/BaseSpreader middleware, error handling for the transform function is already implemented in the caller (BaseSpreader's middleware method), making additional error handling in individual transform functions unnecessary.
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.
⏰ Context from checks skipped due to timeout of 90000ms (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: test_and_publish
  • GitHub Check: UT Tests
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (13)
src/v0/destinations/braze/transform.js (13)

20-20: Stats import added for batching metrics.

Good addition to support the new batching functionality metrics tracking.


45-46: Batching configuration constants imported.

The imports for IDENTIFY_BRAZE_MAX_REQ_COUNT and shouldBatchBrazeIdentifyResolution properly support the new batching functionality.


184-212: Comprehensive documentation for the batching function.

The JSDoc documentation is thorough and clearly explains the function's purpose, parameters, return values, and behavior.


218-223: Batching logic implementation is correct.

The chunking logic using lodash.chunk and flattening of aliases_to_identify arrays is implemented correctly for efficient batching.


224-264: Network error handling is comprehensive.

The try-catch block properly handles network errors, logs them appropriately, increments stats with proper labels, and returns a NetworkError with the correct error type.


266-282: HTTP status error handling is well-implemented.

Non-success HTTP status handling includes proper logging, stats collection using existing utility functions, and returns appropriate NetworkError objects with status-specific error types.


284-298: Error throwing for unhandled scenarios is appropriate.

The function correctly throws an Error (not NetworkError) for unhandled response errors to trigger Bugsnag monitoring, which aligns with the codebase's error handling strategy.


300-303: Return strategy for batched processing is sound.

Returning null for successful batches and using Promise.all to handle all batch requests concurrently is an efficient approach.


320-326: Batching integration in processIdentify is well-designed.

The approach of pushing to the array and returning early when batching is enabled maintains backward compatibility while enabling the new functionality.


627-631: Proper integration of batching parameter.

The modified call to processIdentify correctly passes the identifyCallsArray from processParams to enable batching when configured.


676-687: Batching initialization and conditional passing is correct.

The logic initializes the identifyCallsArray and conditionally passes it based on the batching configuration, maintaining backward compatibility.


692-701: Batched processing and stats tracking implementation is solid.

The post-processing logic correctly calls processBatchedIdentify, checks for successful batches, and increments stats appropriately. The Promise.all usage ensures proper async handling.


703-703: Awaiting all responses maintains proper async flow.

The await Promise.all(allResps) ensures all grouped processing completes before proceeding, maintaining the correct execution order.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

Comment thread src/v0/destinations/braze/transform.js Resolved
Comment thread src/v0/destinations/braze/transform.js Resolved
Comment thread src/v0/destinations/braze/transform.js Resolved
Comment thread src/v0/destinations/braze/transform.js Resolved
Comment thread src/v0/destinations/braze/transform.js Resolved
Comment thread src/v0/destinations/braze/transform.js Resolved
Comment thread src/v0/destinations/braze/transform.js Resolved
@vinayteki95
vinayteki95 dismissed utsabc’s stale review July 9, 2025 08:53

The base branch was changed.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@koladilip
koladilip force-pushed the feat.braze-alias-batching branch from 2e87988 to f776f97 Compare July 9, 2025 14:08
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@vinayteki95
vinayteki95 changed the base branch from main to develop July 11, 2025 11:25
@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: 1

♻️ Duplicate comments (1)
src/v0/destinations/braze/identityResolutionUtils.ts (1)

153-176: Critical: Silent failure handling could lead to data loss

The function returns void, preventing callers from knowing if the operation succeeded or failed. This could result in silent data loss if batches fail.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c627909 and b07f027.

📒 Files selected for processing (2)
  • src/v0/destinations/braze/identityResolutionUtils.test.ts (1 hunks)
  • src/v0/destinations/braze/identityResolutionUtils.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
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.
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` assumes metadata is always an array throughout its implementation, but defensive programming should be added to handle cases where metadata might not be an array type to prevent runtime errors.
src/v0/destinations/braze/identityResolutionUtils.test.ts (3)
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.
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.
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` assumes metadata is always an array throughout its implementation, but defensive programming should be added to handle cases where metadata might not be an array type to prevent runtime errors.
src/v0/destinations/braze/identityResolutionUtils.ts (6)
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.
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` assumes metadata is always an array throughout its implementation, but defensive programming should be added to handle cases where metadata might not be an array type to prevent runtime errors.
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#4364
File: src/v0/util/index.js:2220-2242
Timestamp: 2025-06-02T06:25:17.338Z
Learning: In the rudderlabs/rudder-transformer codebase, jobId values are guaranteed by system contract to always be valid numbers and never undefined or infinite. Additional validation for these edge cases in sorting functions like sortBatchesByMinJobId is not necessary.
Learnt from: anantjain45823
PR: rudderlabs/rudder-transformer#2842
File: src/v1/sources/shopify/enrichmentLayer.js:36-42
Timestamp: 2024-10-08T15:52:59.819Z
Learning: The user clarified that errors in the `setExtraNonEcomProperties` function should not cause the event to fail, indicating a preference for resilience over strict error propagation.
Learnt from: anantjain45823
PR: rudderlabs/rudder-transformer#2842
File: src/v1/sources/shopify/enrichmentLayer.js:36-42
Timestamp: 2024-07-27T07:02:57.329Z
Learning: The user clarified that errors in the `setExtraNonEcomProperties` function should not cause the event to fail, indicating a preference for resilience over strict error propagation.
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#4380
File: src/v0/destinations/google_adwords_remarketing_lists/config.js:3-5
Timestamp: 2025-06-04T07:24:58.591Z
Learning: User maheshkutty prefers to handle Google Ads API version upgrades for different destinations in separate pull requests rather than bundling multiple destinations together in a single PR.
🧬 Code Graph Analysis (1)
src/v0/destinations/braze/identityResolutionUtils.ts (5)
src/types/controlPlaneConfig.ts (1)
  • Destination (30-48)
src/v0/destinations/braze/transform.js (3)
  • identifyEndpoint (203-203)
  • brazeIdentifyResp (204-223)
  • tags (21-21)
src/v0/destinations/braze/util.js (2)
  • getEndpointFromConfig (55-78)
  • collectStatsForAliasFailure (778-810)
src/adapters/utils/networkUtils.js (1)
  • getDynamicErrorType (87-95)
src/v0/destinations/braze/config.js (1)
  • IDENTIFY_BRAZE_MAX_REQ_COUNT (35-35)
🪛 Biome (1.9.4)
src/v0/destinations/braze/identityResolutionUtils.test.ts

[error] 148-148: The imported variable IDENTIFY_BRAZE_MAX_REQ_COUNT is read-only

The variable is imported here

Use a local variable instead of reassigning an import.

(lint/suspicious/noImportAssign)

⏰ 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 (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (3)
src/v0/destinations/braze/identityResolutionUtils.ts (2)

13-57: Well-structured TypeScript interfaces

The interface definitions are comprehensive and properly typed, providing excellent type safety for the Braze identity resolution functionality.


65-143: Comprehensive error handling in processSingleBatch

The function properly handles both HTTP-level and application-level errors with appropriate logging, stats collection, and structured error returns. The error differentiation between network errors and base errors is well-implemented.

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

137-1322: Excellent comprehensive test coverage

The test suite is exceptionally thorough, covering:

  • Success and failure scenarios
  • HTTP and application-level error handling
  • Batching logic and concurrency
  • Edge cases and boundary conditions
  • Type safety and interface compliance
  • Mock verification and integration testing

The test organization with descriptive names and clear structure makes it easy to understand the expected behavior.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@sonarqubecloud

Copy link
Copy Markdown

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

optional comment to rename, can be done another pr too

Comment thread src/v0/destinations/braze/transform.js Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DO NOT MERGE Don't merge this PR without having discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants