Repository navigation
fix: zendesk identify flow (develop) - #4450
Conversation
* fix: zendesk primary email update issue * chore: minor changes * chore: added test for updating secondary email * chore: minor change * chore: added util test * chore: minor change * chore: minor change * chore: undo minor change * chore: fix sonarqube code smell * fix: addressing comments * chore: addressing comments
* feat: update primary email verification status * chore: remove promise.all to process the events sequentially
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughThe changes introduce asynchronous API interactions for managing Zendesk user email identities, including updating and removing emails. Core transformation and utility logic are refactored to support these async flows, and batch processing with enhanced error handling is added for router destination processing. Comprehensive unit tests are implemented for the new utility functions. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Transform
participant Util
participant ZendeskAPI
Client->>Transform: processIdentify(message, config, headers, endpoint, metadata)
Transform->>Util: createOrUpdateUser(payload, endpoint, headers, metadata)
Util->>ZendeskAPI: POST /users
ZendeskAPI-->>Util: Response (userId)
Util-->>Transform: userId
alt Email update needed
Transform->>Util: getUserIdentities(endpoint, headers, metadata)
Util->>ZendeskAPI: GET /users/{userId}/identities
ZendeskAPI-->>Util: Response (identities)
Util-->>Transform: identities
Transform->>Util: deleteEmailFromUser(endpoint, headers, metadata)
Util->>ZendeskAPI: DELETE /users/{userId}/identities/{identityId}
ZendeskAPI-->>Util: Response
Transform->>Util: updatePrimaryEmailOfUser(endpoint, payload, headers, metadata)
Util->>ZendeskAPI: PUT /users/{userId}/identities/{identityId}/make_primary
ZendeskAPI-->>Util: Response
end
Transform-->>Client: Response (success or error)
Possibly related PRs
Suggested reviewers
Suggestions for Improvement
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:
SupportNeed 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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
src/v0/destinations/zendesk/transform.js (1)
77-104: Function performs action but returns unused response objectThis function makes the API call to update the primary email but then returns a response object that appears to be unused by the caller. Consider either:
- Renaming the function to clarify it performs the action (not just builds a response)
- Removing the response building if it's not needed
-const responseBuilderToUpdatePrimaryAccount = async ( +const updatePrimaryEmailAccount = async ( userIdentityId, userId, headers, email, baseEndpoint, metadata, destinationConfig, ) => { - const response = defaultRequestConfig(); - const updatedHeaders = { - ...headers, - ...DEFAULT_HEADERS, - }; - response.endpoint = `${baseEndpoint}users/${userId}/identities/${userIdentityId}`; - response.method = defaultPutRequestConfig.requestMethod; - response.headers = updatedHeaders; - response.body.JSON = { + const endpoint = `${baseEndpoint}users/${userId}/identities/${userIdentityId}`; + const payload = { identity: { type: 'email', value: `${email}`, verified: !!destinationConfig.createUsersAsVerified, }, }; // API call to update primary email of the user - await updatePrimaryEmailOfUser(response.endpoint, response.body.JSON, response.headers, metadata); - return response; + await updatePrimaryEmailOfUser(endpoint, payload, headers, metadata); };
🧹 Nitpick comments (4)
src/v0/destinations/zendesk/util.js (4)
27-59: Inconsistent endpointPath in statTagsThe
endpointPathvalue 'users/userId/identities' doesn't match the actual endpoint pattern. Consider using a more accurate representation or parameterizing it.const statTags = { metadata, destType: 'zendesk', - endpointPath: 'users/userId/identities', + endpointPath: '/users/{userId}/identities', feature: 'transformation', requestMethod: 'GET', module: 'router', };
61-90: Generic endpointPath in statTags for delete operationThe
endpointPathvalue '/users' is too generic and doesn't reflect the actual endpoint pattern for deleting email identities.const statTags = { metadata, destType: 'zendesk', - endpointPath: '/users', + endpointPath: '/users/{userId}/identities/{identityId}', feature: 'transformation', requestMethod: 'DELETE', module: 'router', };
92-122: Generic endpointPath in statTags for update operationThe
endpointPathvalue '/users' doesn't accurately represent the endpoint for updating user identities.const statTags = { metadata, destType: 'zendesk', - endpointPath: '/users', + endpointPath: '/users/{userId}/identities/{identityId}', feature: 'transformation', requestMethod: 'PUT', module: 'router', };
158-187: Placeholder-like endpointPath in statTagsThe
endpointPathvalue '/membershipId.json' appears to be a placeholder and should represent the actual endpoint pattern.const statTags = { metadata, destType: 'zendesk', - endpointPath: '/membershipId.json', + endpointPath: '/users/{userId}/organization_memberships/{membershipId}.json', feature: 'transformation', requestMethod: 'DELETE', module: 'router', };
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
test/integrations/destinations/zendesk/network.tsis excluded by!**/test/**test/integrations/destinations/zendesk/processor/data.tsis excluded by!**/test/**test/integrations/destinations/zendesk/router/data.tsis excluded by!**/test/**
📒 Files selected for processing (3)
src/v0/destinations/zendesk/transform.js(8 hunks)src/v0/destinations/zendesk/util.js(2 hunks)src/v0/destinations/zendesk/util.test.js(2 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/zendesk/util.test.jssrc/v0/destinations/zendesk/transform.jssrc/v0/destinations/zendesk/util.js
🧠 Learnings (2)
src/v0/destinations/zendesk/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: 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.
src/v0/destinations/zendesk/util.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.
⏰ Context from checks skipped due to timeout of 90000ms (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 (7)
src/v0/destinations/zendesk/util.js (2)
22-26: Clean implementation of status code determinationThe function correctly returns appropriate status codes based on event type, following a clear and maintainable pattern.
124-156: Well-structured user creation/update functionThe implementation correctly handles the create or update flow with proper error handling and returns the user ID on success.
src/v0/destinations/zendesk/util.test.js (2)
39-90: Comprehensive test coverage for getUserIdentitiesWell-structured table-driven tests covering success, edge cases (missing identities), and error scenarios.
92-272: Excellent test coverage for all utility functionsThe test suites maintain consistency across all functions with proper mocking, error handling verification, and both positive/negative test cases.
src/v0/destinations/zendesk/transform.js (3)
554-571: Clean refactoring using new utility functionsThe implementation is streamlined by using
createOrUpdateUserand properly handles the async email update flow.
783-808: Excellent refactoring with enhanced error handlingThe batch processing implementation with proper error handling and sequential processing is a significant improvement over the previous approach.
522-524: Improved error logging with additional contextAdding the error details to the log message will help with debugging issues in production.
|
Allure Test reports for this run are available at:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4450 +/- ##
===========================================
+ Coverage 91.18% 91.24% +0.05%
===========================================
Files 638 639 +1
Lines 33536 33627 +91
Branches 7921 7929 +8
===========================================
+ Hits 30581 30684 +103
- Misses 2686 2707 +21
+ Partials 269 236 -33 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
|
* fix: zendesk indentify flow (#4288) * fix: zendesk primary email update issue * chore: minor changes * chore: added test for updating secondary email * chore: minor change * chore: added util test * chore: minor change * chore: minor change * chore: undo minor change * chore: fix sonarqube code smell * fix: addressing comments * chore: addressing comments * feat: update primary email verification status (#4400) * feat: update primary email verification status * chore: remove promise.all to process the events sequentially * chore: addressing comment * chore: fix sonar issue * chore: cleanup test network calls



What are the changes introduced in this PR?
For identify flow, We are transforming and delivering the event through transformer and then returning 299 status code. We have eliminated the need for searching of user id when we are updating the primary email. We have added one extra API call to delete duplicate email from the user profile.
What is the related Linear task?
Resolves INT-3793
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.