Repository navigation
Conversation
Summary by CodeRabbit
WalkthroughConsolidates user traits sourcing from Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Src as Source
participant WF as procWorkflow.yaml
participant UP as Userpilot API
rect rgba(200,220,255,0.25)
note over WF: Identify flow
Src->>WF: message (Identify)
WF->>WF: userTraits = message.traits || message.context.traits
WF->>WF: companyTraits = userTraits.company
alt companyTraits && companyTraits.id
WF->>UP: Identify payload { user: userTraits, company: companyTraits }
Note right of UP: Company included
else no company id
WF->>UP: Identify payload { user: userTraits, company: null }
Note right of UP: Company omitted
end
end
rect rgba(220,255,220,0.15)
note over WF: Track / Group flows
Src-->>WF: message (Track/Group)
WF-->>UP: Unchanged payload logic
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (1)
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 |
| const userTraits = .message.traits ?? .message.context.traits ?? {}; | ||
| const companyTraits = userTraits.company ?? {}; | ||
|
|
There was a problem hiding this comment.
Preserve traits from both message.traits and message.context.traits.
Picking whichever object is non-null means we drop any fields (notably company) that may exist only under context.traits whenever message.traits is present—even if it’s just {}. That regresses existing payloads where company data still lives under context.traits. Please merge both sources and only fall back when a source is absent.
- const userTraits = .message.traits ?? .message.context.traits ?? {};
- const companyTraits = userTraits.company ?? {};
+ const contextTraits = (.message.context && .message.context.traits) ?? {};
+ const rootTraits = .message.traits ?? {};
+ const userTraits = { ...contextTraits, ...rootTraits };
+ const companyTraits = userTraits.company ?? contextTraits.company ?? {};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const userTraits = .message.traits ?? .message.context.traits ?? {}; | |
| const companyTraits = userTraits.company ?? {}; | |
| const contextTraits = (.message.context && .message.context.traits) ?? {}; | |
| const rootTraits = .message.traits ?? {}; | |
| const userTraits = { ...contextTraits, ...rootTraits }; | |
| const companyTraits = userTraits.company ?? contextTraits.company ?? {}; |
🤖 Prompt for AI Agents
In src/cdk/v2/destinations/userpilot/procWorkflow.yaml around lines 38 to 40,
the code currently picks one traits object and drops fields from the other;
instead merge message.traits and message.context.traits so fields from both are
preserved (e.g., company under context.traits), then derive companyTraits from
the merged object with a fallback to {}. Ensure the merge treats undefined
sources as empty objects and does not mutate originals.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## external/ThabetIbrahim/fix-identify-payload #4682 +/- ##
==============================================================================
Coverage ? 91.79%
==============================================================================
Files ? 645
Lines ? 34086
Branches ? 8051
==============================================================================
Hits ? 31290
Misses ? 2566
Partials ? 230 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Currently we are in process updating CI CD so we will create another PR from our side this change. Later will update our contributing guide with the new changes. |
6ffc4c5
into
rudderlabs:external/ThabetIbrahim/fix-identify-payload
* fix: check on traits and traits.context * prioritize message.context.traits Co-authored-by: ThabetIbrahim <[email protected]>
What are the changes introduced in this PR?
Write a brief explainer on your code changes.
Checking user traits for both .message.context.traits as well as .message.traits
What is the related Linear task?
N/A
Please explain the objectives of your changes below
When users send an identify request to Cloud integration, in some cases, they opt to include the traits inside the payload itself rather than the context, causing those properties to get dropped.
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.