Repository navigation
feat: added india residency support in mixpanel destination - #4191
Conversation
WalkthroughThe 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
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
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
Suggested reviewers
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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
📒 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
getBaseEndpointutility 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
getBaseEndpointfunction call, which handles endpoint selection based on data residency settings.
96-96: Consistent update to endpoint handling.Updated the default case in
responseBuilderSimpleto 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
getBaseEndpointfunction, 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
getBaseEndpointutility function, which provides the correct endpoint based on data residency.
78-78: Updated deletion task endpoint construction.Modified to use the new
getCreateDeletionTaskEndpointfunction 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_INandCREATE_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
getBaseEndpointfunction 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
getDeletionTaskBaseEndpointfunction follows the same pattern asgetBaseEndpoint, 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
getCreateDeletionTaskEndpointfunction efficiently reuses thegetDeletionTaskBaseEndpointfunction 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.
|
Allure Test reports for this run are available at:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. 🚀 New features to boost your workflow:
|
|



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
Refactor
Tests