Skip to content

feat: added india residency support in mixpanel destination - #4191

Merged
manish339k merged 1 commit into
developfrom
feat.mp_in_residency
Mar 24, 2025
Merged

manish339k merged 1 commit into
developfrom
feat.mp_in_residency

Conversation

@manish339k

@manish339k manish339k commented Mar 21, 2025 •

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

Added India data center support.

What is the related Linear task?

Resolves INT-3416

Please explain the objectives of your changes below

Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here

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

N/A

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?

N/A

@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

    • Added support for region-specific endpoints, enabling tailored processing based on geographical configurations.
  • Refactor

    • Streamlined the logic for dynamic endpoint resolution, resulting in clearer and more consistent task routing.
  • Tests

    • Expanded test coverage to ensure robust behavior of endpoint resolution across different regional scenarios.

@manish339k
manish339k requested a review from a team as a code owner March 21, 2025 11:21
@coderabbitai

coderabbitai Bot commented Mar 21, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The changes update endpoint management for deletion tasks and other Mixpanel operations. New constants and utility functions have been added to handle endpoints based on data residency (EU, IN, default), while redundant functions have been removed. The deletion logic in the user deletion module and event transformation module has been updated to integrate the new utility functions. Corresponding unit tests have been added to validate the new endpoint logic.

Changes

File(s) Change Summary
src/v0/.../config.js - Added constants: BASE_ENDPOINT_IN, CREATE_DELETION_TASK_ENDPOINT_EU, CREATE_DELETION_TASK_ENDPOINT_IN
- Updated CREATE_DELETION_TASK_ENDPOINT
- Removed getCreateDeletionTaskEndpoint function
src/v0/.../deleteUsers.js - Removed import of getCreateDeletionTaskEndpoint
- Added import of getBaseEndpoint from util
- Updated createDeletionTask call to include config parameter
src/v0/.../transform.js - Removed hardcoded endpoints (BASE_ENDPOINT, BASE_ENDPOINT_EU)
- Replaced with dynamic calls to getBaseEndpoint(destConfig)
- Minor formatting adjustment for traits declaration
src/v0/.../util.js and src/v0/.../util.test.js - Added constants: BASE_ENDPOINT_EU, BASE_ENDPOINT_IN, BASE_ENDPOINT, CREATE_DELETION_TASK_ENDPOINT_EU, CREATE_DELETION_TASK_ENDPOINT_IN, CREATE_DELETION_TASK_ENDPOINT
- Added functions: getBaseEndpoint, getDeletionTaskBaseEndpoint, getCreateDeletionTaskEndpoint
- Added unit tests for the new functions

Sequence Diagram(s)

sequenceDiagram
    participant DU as DeleteUsers Module
    participant Util as Utility Module
    participant Config as Configuration Object

    DU->>Util: getCreateDeletionTaskEndpoint(config, token)
    Util->>Util: getDeletionTaskBaseEndpoint(config)
    Util-->>DU: Return deletion task endpoint URL with token appended
Loading
sequenceDiagram
    participant Trans as Transform Module
    participant Util as Utility Module
    participant DestConfig as Destination Config

    Trans->>Util: getBaseEndpoint(destConfig)
    Util-->>Trans: Return appropriate base endpoint
Loading

Suggested reviewers

  • sivashanmukh
  • ItsSudip
  • koladilip
  • utsabc

Poem

Hopping through lines of code today,
Endpoints shift in a clever display.
Constants bloom like springtime flowers,
Tests ensure we’re strong like towers.
I, a rabbit, cheer in delight—
CodeRabbit’s path is bright and light!
🐇💻

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

@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/mp/util.test.js (1)

766-785: Added test for getCreateDeletionTaskEndpoint function.

The test verifies that the function correctly combines the base endpoint with the token parameter.

Consider adding more test cases to cover the 'in' data residency and default scenarios for more complete coverage.

describe('getCreateDeletionTaskEndpoint', () => {
  const testCases = [
    {
      name: 'should return endpoint for EU residency',
      input: {
        config: {
          dataResidency: 'eu',
        },
        token: 'dummy-Token',
      },
      expected: 'https://eu.mixpanel.com/api/app/data-deletions/v3.0/?token=dummy-Token',
    },
+    {
+      name: 'should return endpoint for India residency',
+      input: {
+        config: {
+          dataResidency: 'in',
+        },
+        token: 'dummy-Token',
+      },
+      expected: 'https://in.mixpanel.com/api/app/data-deletions/v3.0/?token=dummy-Token',
+    },
+    {
+      name: 'should return default endpoint when dataResidency is not specified',
+      input: {
+        config: {},
+        token: 'dummy-Token',
+      },
+      expected: 'https://mixpanel.com/api/app/data-deletions/v3.0/?token=dummy-Token',
+    },
  ];
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c47103d and 7288eba.

📒 Files selected for processing (5)
  • src/v0/destinations/mp/config.js (2 hunks)
  • src/v0/destinations/mp/deleteUsers.js (2 hunks)
  • src/v0/destinations/mp/transform.js (4 hunks)
  • src/v0/destinations/mp/util.js (3 hunks)
  • src/v0/destinations/mp/util.test.js (2 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
src/v0/destinations/mp/util.test.js (1)
src/v0/destinations/mp/util.js (3) (3)
  • getBaseEndpoint (387-397)
  • getDeletionTaskBaseEndpoint (399-409)
  • getCreateDeletionTaskEndpoint (411-412)
src/v0/destinations/mp/util.js (2)
src/v0/destinations/mp/deleteUsers.js (1) (1)
  • config (70-70)
src/v0/destinations/mp/config.js (6) (6)
  • BASE_ENDPOINT_EU (5-5)
  • BASE_ENDPOINT_IN (6-6)
  • BASE_ENDPOINT (4-4)
  • CREATE_DELETION_TASK_ENDPOINT_EU (10-10)
  • CREATE_DELETION_TASK_ENDPOINT_IN (11-11)
  • CREATE_DELETION_TASK_ENDPOINT (9-9)
⏰ 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 AMD64
  • GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
  • GitHub Check: Code Coverage
  • GitHub Check: test_and_publish
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (20)
src/v0/destinations/mp/transform.js (5)

38-38: New import added for endpoint management.

The getBaseEndpoint utility has been imported to support dynamically selecting the appropriate endpoint based on data residency configuration.


46-46: Good refactoring of endpoint construction.

Replaced hardcoded endpoint with getBaseEndpoint function call, which handles endpoint selection based on data residency settings.


96-96: Consistent update to endpoint handling.

Updated the default case in responseBuilderSimple to use the dynamic endpoint function, maintaining consistent implementation throughout the codebase.


163-163: Code cleanup and simplification.

Simplified the ternary operation for trait selection, making the code more compact and readable.


410-410: Completed endpoint refactoring for group events.

Updated the group response endpoint to use the same getBaseEndpoint function, ensuring consistent implementation for all Mixpanel endpoints.

src/v0/destinations/mp/config.js (3)

6-6: Added India data center support.

Added a new constant for the India-specific Mixpanel endpoint, addressing the PR's main objective of supporting India data residency.


8-11: Added GDPR API reference and updated deletion task endpoints.

Improved documentation with a reference to the GDPR API and added region-specific deletion task endpoints for EU and India.


75-78: Updated exports to include new constants.

Ensured all the newly added constants are properly exported, making them available for use throughout the codebase.

src/v0/destinations/mp/deleteUsers.js (4)

5-5: Simplified imports from config module.

Removed the function import and kept only the necessary constants, part of the refactoring to move endpoint logic to utility functions.


11-11: Added utility functions for endpoint management.

Imported the new utility functions that handle endpoint construction based on data residency configuration.


14-14: Refactored endpoint construction in deleteProfile function.

Updated to use the getBaseEndpoint utility function, which provides the correct endpoint based on data residency.


78-78: Updated deletion task endpoint construction.

Modified to use the new getCreateDeletionTaskEndpoint function with the config parameter, ensuring proper endpoint selection based on data residency.

src/v0/destinations/mp/util.test.js (3)

9-11: Added imports for new utility functions.

Imported the new endpoint management utility functions that need to be tested.


704-733: Comprehensive test coverage for getBaseEndpoint function.

Added thorough test cases covering all data residency scenarios (EU, India, US, and undefined), ensuring the function returns the correct endpoint for each case.


735-764: Comprehensive test coverage for getDeletionTaskBaseEndpoint function.

Added test cases for all data residency scenarios, ensuring the correct deletion task base endpoint is returned in each case.

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

27-32: LGTM: Import statements for supporting India data residency.

The new import statements correctly include the necessary constants for supporting India data residency (BASE_ENDPOINT_IN and CREATE_DELETION_TASK_ENDPOINT_IN), alongside the existing ones for EU and default.


387-397: Well-implemented function to determine base endpoint based on data residency.

The getBaseEndpoint function correctly handles the three possible data residency scenarios (EU, IN, and default), returning the appropriate endpoint for each case. The switch statement is clear and follows the pattern established for other regions.


399-409: Well-implemented function to determine deletion task base endpoint.

The getDeletionTaskBaseEndpoint function follows the same pattern as getBaseEndpoint, providing consistent handling of data residency for deletion task endpoints. The implementation is clean and easy to understand.


411-412: Elegant implementation of endpoint URL construction.

The getCreateDeletionTaskEndpoint function efficiently reuses the getDeletionTaskBaseEndpoint function to construct the complete URL with the project token. This approach maintains good separation of concerns and code reusability.


425-427: Appropriate exports of the new utility functions.

All three new utility functions are properly exported, making them available for use in other modules that need to determine the appropriate endpoints based on data residency.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@codecov

codecov Bot commented Mar 21, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.40%. Comparing base (eeb7a50) to head (7288eba).
Report is 12 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4191   +/-   ##
========================================
  Coverage    91.39%   91.40%           
========================================
  Files          636      636           
  Lines        33144    33158   +14     
  Branches      7833     7832    -1     
========================================
+ Hits         30293    30307   +14     
+ Misses        2645     2614   -31     
- Partials       206      237   +31     

☔ 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

@manish339k
manish339k merged commit 173c50f into develop Mar 24, 2025
@manish339k
manish339k deleted the feat.mp_in_residency branch March 24, 2025 06:01
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