Skip to content

chore: add au data center for braze - #4185

Merged
vinayteki95 merged 1 commit into
developfrom
chore.braze-au-data-center
Mar 20, 2025
Merged

vinayteki95 merged 1 commit into
developfrom
chore.braze-au-data-center

Conversation

@vinayteki95

@vinayteki95 vinayteki95 commented Mar 20, 2025 •

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

Braze introduced AU datacenters. Enhancing braze integration to handle AU datacenters along side EU and US.

What is the related Linear task?

Resolves INT-3125

Please explain the objectives of your changes below

Keeping up with changes in destination.

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

Yes

Any new dependencies introduced with this change?

No

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

No

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

No

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

Summary by CodeRabbit

  • New Features

    • Enhanced endpoint resolution for the Braze integration to support flexible configuration input (e.g., case-insensitive values and trimmed whitespace) and ensure accurate regional routing.
  • Bug Fixes

    • Corrected configuration mismatches by updating destination settings so that endpoints accurately reflect the intended data center selections.

@vinayteki95
vinayteki95 requested review from a team and sivashanmukh as code owners March 20, 2025 09:48
@vinayteki95
vinayteki95 requested review from a team, ItsSudip and utsabc March 20, 2025 09:48
@coderabbitai

coderabbitai Bot commented Mar 20, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The changes focus on enhancing the endpoint resolution logic for Braze integrations. A new function, getEndpointFromConfig, has been introduced and tested to validate, trim, and correctly interpret the dataCenter configuration. The function now uses a switch statement to determine the appropriate endpoint URL based on the region (eu, us, au) and throws errors for invalid inputs. Additionally, integration test data has been updated to reflect new and corrected data center configurations and endpoint URLs.

Changes

File(s) Change Summary
src/.../braze/braze.util.test.js Added getEndpointFromConfig function and comprehensive tests covering valid, lowercase, and whitespace-trimmed inputs, including error cases; updated doApiLookup tests to include a dataCenter property.
src/.../braze/util.js Refactored getEndpointFromConfig to validate the dataCenter input, splitting the string into region and number using a switch statement for endpoint construction; improved error handling via InstrumentationError.
test/.../braze/processor/data.ts Modified destination configurations: updated data center from 'us-01' to 'au-01' for one configuration, added dataCenter: 'eu-01' for others, and updated the corresponding endpoint URL.

Sequence Diagram(s)

sequenceDiagram
    participant Tester as Test Suite
    participant Func as getEndpointFromConfig
    Tester->>Func: Call with dataCenter config
    Func->>Func: Validate type & trim whitespace
    Func->>Func: Split into region and number
    alt Region is 'eu', 'us', or 'au'
        Func->>Tester: Return appropriate endpoint URL
    else Invalid region
        Func->>Tester: Throw InstrumentationError
    end
Loading

Poem

In the code meadows I happily roam,
Finding endpoints to call my own.
Data centers gleam in a structured array,
Whitespace trimmed, errors kept at bay.
Rabbit hops through tests with a joyful cheer,
Celebrating clean code and logic so dear! 🐇✨

✨ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@vinayteki95 vinayteki95 changed the title chore: add au data center chore: add au data center for braze Mar 20, 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

🧹 Nitpick comments (2)
src/v0/destinations/braze/braze.util.test.js (1)

1887-1937: Well-structured test suite for the new dataCenter functionality.

The test suite comprehensively covers all important scenarios for the new Australian data center support along with existing EU and US regions:

  • Valid data center codes for all regions
  • Case insensitivity handling
  • Whitespace trimming
  • Error handling for invalid inputs

Consider adding a few additional test cases:

  • Testing with just region codes without instance numbers (e.g., 'EU', 'US', 'AU')
  • Testing with malformed region-instance combinations (e.g., 'EU-', 'US-ABC')
 describe('getEndpointFromConfig', () => {
   const testCases = [
     {
       name: 'returns correct EU endpoint',
       input: { Config: { dataCenter: 'EU-02' } },
       expected: 'https://rest.fra-02.braze.eu',
     },
     // existing test cases...
+    {
+      name: 'handles region code without instance number',
+      input: { Config: { dataCenter: 'AU' } },
+      expected: 'https://rest.au-01.braze.com', // Assuming default instance
+    },
+    {
+      name: 'handles malformed region-instance combination',
+      input: { Config: { dataCenter: 'US-ABC' } },
+      throws: true,
+      errorMessage: 'Invalid Data Center: US-ABC, valid values are EU, US, AU',
+    },
   ];

   // rest of the implementation...
 });
src/v0/destinations/braze/util.js (1)

32-54: Good implementation of AU data center support!

The enhanced getEndpointFromConfig function properly validates and processes the data center configuration to support the Australian (AU) data centers. The switch statement is a clean approach for determining the appropriate endpoint URL based on the region.

Consider making the error messages consistent:

- throw new InstrumentationError('Invalid Data Center: valid values are EU, US, AU');
+ throw new InstrumentationError(`Invalid Data Center: ${destination.Config.dataCenter}, valid values are EU, US, AU`);

Or alternatively:

- throw new InstrumentationError(
-   `Invalid Data Center: ${destination.Config.dataCenter}, valid values are EU, US, AU`,
- );
+ throw new InstrumentationError('Invalid Data Center: valid values are EU, US, AU');
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4afce03 and eeb7a50.

📒 Files selected for processing (3)
  • src/v0/destinations/braze/braze.util.test.js (4 hunks)
  • src/v0/destinations/braze/util.js (1 hunks)
  • test/integrations/destinations/braze/processor/data.ts (20 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • 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: Analyze (javascript-typescript)
🔇 Additional comments (5)
src/v0/destinations/braze/braze.util.test.js (3)

10-10: LGTM: Added import for the new function.

The addition of getEndpointFromConfig to the imports is appropriate for testing the new functionality.


347-347: LGTM: Test updated with data center configuration.

Adding the dataCenter property to the test destination ensures proper endpoint resolution is tested within the existing test case.


439-439: LGTM: Test updated with data center configuration.

Consistently updating all test cases with the dataCenter property ensures comprehensive testing of the endpoint resolution functionality.

test/integrations/destinations/braze/processor/data.ts (2)

18-18: New Australian datacenter properly configured

The changes add support for the Australian datacenter ('au-01') by updating the dataCenter config value and corresponding endpoint URL. This aligns with the PR objective to add AU datacenter support to the Braze integration.

Also applies to: 90-90


231-231: Test cases updated for EU datacenter configuration

Multiple test cases have been updated to use 'eu-01' as the datacenter value, ensuring comprehensive test coverage across different datacenter configurations. This is important to maintain test integrity while adding the new AU datacenter support.

Also applies to: 349-349, 727-727, 871-871, 1137-1137, 1243-1243, 1434-1434, 1797-1797, 2029-2029, 3137-3137, 3259-3259, 3330-3330, 3733-3733, 3906-3906, 4219-4219, 4319-4319

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@codecov

codecov Bot commented Mar 20, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.39%. Comparing base (131759c) to head (eeb7a50).
Report is 8 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4185   +/-   ##
========================================
  Coverage    91.39%   91.39%           
========================================
  Files          635      636    +1     
  Lines        33113    33144   +31     
  Branches      7821     7833   +12     
========================================
+ Hits         30262    30293   +31     
  Misses        2645     2645           
  Partials       206      206           

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

@sonarqubecloud

Copy link
Copy Markdown

@vinayteki95
vinayteki95 merged commit d641594 into develop Mar 20, 2025
@vinayteki95
vinayteki95 deleted the chore.braze-au-data-center branch March 20, 2025 12:38
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