Repository navigation
fix: intercom rETL flow when user_id only provided as identifier - #4739
Conversation
Summary by CodeRabbit
WalkthroughModified Intercom destination's contact lookup logic by adding explicit external_id mapping in ETL payload based on email presence, and enhancing the searchContact function to conditionally use external_id as a lookup field when email is absent. Changes
Sequence Diagram(s)sequenceDiagram
participant ETL
participant SearchContact
participant Intercom
alt Email Present
ETL->>SearchContact: message with email + external_id
SearchContact->>SearchContact: lookupField = 'email'
SearchContact->>Intercom: search by email
else Email Absent
ETL->>SearchContact: message with external_id (mapped to user_id)
SearchContact->>SearchContact: lookupField = 'external_id'
SearchContact->>Intercom: search by external_id
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Areas requiring attention:
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/cdk/v2/destinations/intercom/procWorkflow.yaml (1)
50-51: Logic looks good for rETL external_id mapping.The conditional assignment correctly maps
user_idtoexternal_idwhen email is absent, enabling Intercom contact lookups via external_id in rETL flows. The inline comment is helpful.Minor suggestion: The comment describes the positive case ("if email is present...") while the code checks the negative case (
!payload.email). Consider rephrasing for clarity:// map user_id to external_id when email is absent, otherwise leave it nullAlso, verify that downstream validation properly handles the case where both
user_idare absent (line 86 includes this assertion, which is good).
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
test/integrations/destinations/intercom/network.tsis excluded by!**/test/**test/integrations/destinations/intercom/processor/identifyTestData.tsis excluded by!**/test/**test/integrations/destinations/intercom/processor/trackTestData.tsis excluded by!**/test/**
📒 Files selected for processing (2)
src/cdk/v2/destinations/intercom/procWorkflow.yaml(1 hunks)src/cdk/v2/destinations/intercom/utils.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js
⚙️ CodeRabbit configuration file
Focus on ESLint errors (max 3) and warnings (max 5).
Files:
src/cdk/v2/destinations/intercom/utils.js
🧠 Learnings (1)
📓 Common learnings
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4589
File: scripts/common.ts:74-78
Timestamp: 2025-08-28T15:39:08.293Z
Learning: User ItsSudip prefers simpler solutions over complex edge case handling, especially when the simpler approach is sufficient for the actual use case.
🧬 Code graph analysis (1)
src/cdk/v2/destinations/intercom/utils.js (1)
src/v0/util/index.js (3)
message(1157-1157)message(1191-1191)getFieldValueFromMessage(683-689)
⏰ 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 Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build 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 User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Code Coverage
- GitHub Check: test_and_publish
- GitHub Check: UT Tests
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
src/cdk/v2/destinations/intercom/utils.js (2)
278-278: Good change to enable dynamic lookup field adjustment.Changing
lookupFieldfromconsttoletis necessary to support the rETL flow logic below where the field is reassigned toexternal_idwhen appropriate.
283-291: Excellent alignment with workflow logic for rETL lookup.This conditional correctly detects the rETL scenario and switches the contact lookup to use
external_idwhen email is absent. The three-part condition properly handles the edge cases:
message.context?.mappedToDestination- identifies rETL flowmessage.traits?.external_id- confirms external_id was set (falsy if null from workflow when email present)!message.traits?.email- mirrors the workflow's email absence checkThe comment clearly explains the business logic, and the implementation maintains consistency with the
procWorkflow.yamlmapping on lines 50-51.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4739 +/- ##
===========================================
- Coverage 91.92% 91.92% -0.01%
===========================================
Files 651 651
Lines 34609 34624 +15
Branches 8121 8130 +9
===========================================
+ Hits 31816 31827 +11
- Misses 2563 2567 +4
Partials 230 230 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Allure Test reports for this run are available at:
|
|
* feat: introduce e2e tests UT (#4686) * chore: update slack notification list (#4706) * chore: skip pushing docker images for dependabot (#4714) * chore: skip building images for debendabot * chore: review comments * chore: skip docker login for dependabot * chore: skip docker login for dependabot * chore: misc * chore: misc * chore: misc * chore: misc * chore: review comments * chore: review comments * chore: review comments * chore: review comments * chore: review comments * chore: add dub to new test structure (#4717) * chore: add readme for campaign_manager (#4710) * chore: update GAOC readme with quota link (#4723) * chore: apply security best practices (#4708) [StepSecurity] Apply security best practices Signed-off-by: StepSecurity Bot <[email protected]> * feat: add validation of diff in staging deployment workflow (#4722) * chore(deps-dev): bump commander from 10.0.1 to 14.0.2 Bumps [commander](https://github.com/tj/commander.js) from 10.0.1 to 14.0.2. - [Release notes](https://github.com/tj/commander.js/releases) - [Changelog](https://github.com/tj/commander.js/blob/master/CHANGELOG.md) - [Commits](tj/commander.js@v10.0.1...v14.0.2) --- updated-dependencies: - dependency-name: commander dependency-version: 14.0.2 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps-dev): bump supertest from 6.3.4 to 7.1.4 (#4525) --- updated-dependencies: - dependency-name: supertest dependency-version: 7.1.4 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: add env vars for controlling the connection pooling on python transformations (#4738) * chore: update facebook conversion api version from 22.0 to 24.0 (#4734) * chore: update facebook conversion api version from 22.0 to 23.0 * chore: update facebook conversion api version from 23.0 to 45.0 * chore: fix typo * chore: update facebook custom audience api version from 22.0 to 23.0 (#4735) * chore: update facebook custom audience api version from 22.0 to 23.0 * chore: update facebook custom audience api version from 23.0 to 24.0 * chore: update facebook custom audience api version from 24.0 to 23.0 as it has some breaking changes * chore: update facebook pixel api version from 22.0 to 24.0 (#4737) * chore: update facebook pixel api version from 22.0 to 24.0 * chore: update facebook app events api version from 22.0 to 24.0 (#4736) * chore: move rs-ai memory bank to transformer * chore: add nodemon for hot reloading (#4748) * chore: refactor code to update variable name in more readable format (#4747) * feat: source transformation endpoint for facebook_lead_ads_native source (#4746) * chore: disable clustering in nodemon configuration (#4749) * chore: run format check on all files (#4750) * fix: intercom rETL flow when user_id only provided as identifier (#4739) * chore: apply security best practices from step security (#4727) [StepSecurity] Apply security best practices Signed-off-by: StepSecurity Bot <[email protected]> Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com> * chore(deps): bump actions/setup-node from 5.0.0 to 6.0.0 Bumps [actions/setup-node](https://github.com/actions/setup-node) from 5.0.0 to 6.0.0. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](actions/setup-node@v5.0.0...v6.0.0) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: 6.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * chore: remove logs logging request/response body (#4754) * chore: disable pyroscope for primary process in cluster mode (#4756) * feat(reddit): onboard v3 api (#4699) * feat(reddit): onboard v3 api * chore: implement router batching flow * feat: enable batching scenario * chore: add test cases * chore: address coderabbit comments * chore: add mock for timestamp * chore: add documentation for reddit * fix: use crypto for hashing * chore: address coderabbit comment * chore: address comments * chore: add validation and remove double type assertion * chore: remove undefined files from final palyload * chore: fix test case * feat(reddit): onboard v3 api * chore: implement router batching flow * feat: enable batching scenario * chore: add test cases * chore: address coderabbit comments * chore: add mock for timestamp * chore: add documentation for reddit * fix: use crypto for hashing * chore: address coderabbit comment * chore: address comments * chore: add validation and remove double type assertion * chore: remove undefined files from final palyload * chore: fix test case * chore: apply format * chore: apply format * chore(deps): bump actions/checkout from 4.3.0 to 5.0.0 Bumps [actions/checkout](https://github.com/actions/checkout) from 4.3.0 to 5.0.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v4.3.0...08c6903) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: 5.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * feat: add advertiser_tracking_enabled mapping for pinterest without featureFlag (#4740) * chore(deps): bump actions/stale from 10.0.0 to 10.1.0 Bumps [actions/stale](https://github.com/actions/stale) from 10.0.0 to 10.1.0. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](actions/stale@v10.0.0...v10.1.0) --- updated-dependencies: - dependency-name: actions/stale dependency-version: 10.1.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * chore: handle breaking changes for commander * chore: fix breaking commander changes * chore(release): 1.112.0 --------- Signed-off-by: StepSecurity Bot <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Rohith BCS <[email protected]> Co-authored-by: Vinay Teki <[email protected]> Co-authored-by: Mahesh Kutty <[email protected]> Co-authored-by: Sudip Paul <[email protected]> Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com> Co-authored-by: Krishna Chaitanya <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jayachand Mopidevi <[email protected]> Co-authored-by: GitHub Actions <[email protected]> Co-authored-by: shekhar-rudder <[email protected]>



What are the changes introduced in this PR?
This PR fixes the Intercom destination integration for rETL (reverse ETL) flow by properly handling user identification when email is not present in the traits. The changes ensure that
user_idis correctly mapped toexternal_idfor lookups when operating in rETL mode without an email identifier.What is the related Linear task?
Resolves INT-4261
Please explain the objectives of your changes below
Any changes to existing capabilities/behaviour, mention the reason & what are the changes?
Changes:
external_idbased on email presencesearchContactfunction to detect rETL flow and useexternal_idfor user lookupReason:
In rETL scenarios, when users are identified by
user_idwithout an email, the Intercom API requiresexternal_idfor contact lookups, and if the lookups fail, it tries to create a new user. Previously, the integration wasn't mappinguser_idtoexternal_idcorrectly, causing lookup failures and also creating new users to fail, as the' external_id' was not present.Any new dependencies introduced with this change?
No new dependencies introduced.
Any new generic utility introduced or modified. Please explain the changes.
No new utilities introduced. Modified existing utility function
searchContactinsrc/cdk/v2/destinations/intercom/utils.jsto:message.context.mappedToDestinationflag (indicating rETL flow)external_idfrom traits as the lookup field when this flag is presentAny technical or performance related pointers to consider with the change?
mappedToDestinationflag is true)@coderabbitai review
Developer checklist
Reviewer checklist
Technical Details
Files Modified:
external_idtouser_idwhen email is not presentsearchContactfunction to handle rETL flow by usingexternal_idfor lookupsexternal_idin payloadKey Code Changes:
Workflow Update (procWorkflow.yaml):
Utils Update (utils.js):
Test Coverage: