Repository navigation
feat: Userpilot - Rudderstack transformer - #4164
yashasvibajpai merged 3 commits into
Conversation
There was a problem hiding this comment.
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
src/cdk/v2/destinations/userpilot/procWorkflow.yaml:63
- The extraction of traits in the groupPayload step uses .message.traits, whereas the identifyPayload step uses .message.context.traits. Confirm whether the groupPayload should also use .message.context.traits to ensure consistent behavior.
let traits = $.transformTraits(.message.traits || {});
WalkthroughThis update introduces new files and functionality for the Userpilot integration. A configuration file exports the base URL and key mapping for event processing. A YAML file defines a workflow that validates inputs, prepares context, and constructs payloads for identify, track, and group events. Additionally, utility functions handle endpoint construction and trait transformation. Test data has been added to verify the integration, ensuring proper request and response formatting with the external Userpilot API. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Workflow as Userpilot Workflow
participant Utils as Utility Module
Client->>Workflow: Send event request (identify/track/group)
Workflow->>Workflow: validateInput()
Workflow->>Workflow: prepareContext()
alt Event is Identify
Workflow->>Workflow: construct identifyPayload
else Event is Track
Workflow->>Workflow: construct trackPayload
else Event is Group
Workflow->>Workflow: construct groupPayload
end
Workflow->>Client: returnResponse()
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 (2)
src/cdk/v2/destinations/userpilot/procWorkflow.yaml (2)
16-17: Fix trailing whitespace.There is a trailing space at the end of line 16 that should be removed.
- $.assert(.message.type in {{$.EventType.([.IDENTIFY, .TRACK, .GROUP])}}, + $.assert(.message.type in {{$.EventType.([.IDENTIFY, .TRACK, .GROUP])}},🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 16-16: trailing spaces
(trailing-spaces)
39-40: Consider adding protection against undefined context.The code assumes that message.context always exists. Add a fallback for when context is undefined to prevent potential runtime errors.
- let traits = $.transformTraits(.message.context.traits || {}); + let traits = $.transformTraits(.message.context?.traits || {});
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/cdk/v2/destinations/userpilot/config.js(1 hunks)src/cdk/v2/destinations/userpilot/procWorkflow.yaml(1 hunks)src/cdk/v2/destinations/userpilot/utils.js(1 hunks)test/integrations/destinations/userpilot/processor/data.ts(1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
src/cdk/v2/destinations/userpilot/utils.js (1)
src/cdk/v2/destinations/userpilot/config.js (2)
DEFAULT_BASE_URL(1-1)MAPPINGS(3-5)
🪛 YAMLlint (1.35.1)
src/cdk/v2/destinations/userpilot/procWorkflow.yaml
[error] 16-16: trailing spaces
(trailing-spaces)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Code Coverage
- GitHub Check: test_and_publish
- GitHub Check: UT Tests
🔇 Additional comments (9)
src/cdk/v2/destinations/userpilot/config.js (1)
1-9: LGTM! The configuration file is well-structured.The file correctly exports the necessary constants for the Userpilot integration. The base URL and key mapping for transforming camelCase to snake_case are appropriately defined.
src/cdk/v2/destinations/userpilot/utils.js (2)
3-12: LGTM! Well-implemented utility functions.The
getEndpointsfunction correctly handles the API endpoint configuration with proper URL normalization to remove trailing slashes. The function returns appropriate endpoints for all required operations.
14-18: LGTM! Efficient trait transformation.The
transformTraitsfunction efficiently transforms object keys based on the provided mappings using a reducer pattern. This approach allows for flexibility as more mappings can be added to the config file in the future.test/integrations/destinations/userpilot/processor/data.ts (3)
1-147: LGTM! Comprehensive test data for the identify event.The test data properly covers the Userpilot identify flow with appropriate request and response structures, including all necessary headers and payload attributes.
148-290: LGTM! Comprehensive test data for the track event.The test data properly covers the Userpilot track event flow, including revenue tracking and other custom properties.
291-433: LGTM! Comprehensive test data for the group event.The test data properly covers the Userpilot company/group identification with appropriate request and response structures for organization data.
src/cdk/v2/destinations/userpilot/procWorkflow.yaml (3)
30-42: Consider validating userId for all event types in the validateInput step.Currently, userId validation is done separately in each payload preparation step. Since userId is required for all event types, consider moving this validation to the common validateInput step for consistency.
- name: validateInput template: | $.assert(.message.type, "message Type is not present. Aborting message."); $.assert(.message.type in {{$.EventType.([.IDENTIFY, .TRACK, .GROUP])}}, "message type " + .message.type + " is not supported by Userpilot"); + $.assert(.message.userId, "User ID is required for Userpilot calls");Then you can remove the duplicated userId assertions from each payload preparation step.
Also applies to: 43-56, 57-70
62-67: LGTM! Proper handling of group payload.The groupPayload step correctly transforms and processes the company metadata, ensuring consistent formatting for the Userpilot API.
71-78: LGTM! Clean response construction.The returnResponse step effectively utilizes the default request configuration and properly sets all required parameters for the API request.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feat.userpilot.integration.contribution #4164 +/- ##
==========================================================================
Coverage ? 91.04%
==========================================================================
Files ? 628
Lines ? 32937
Branches ? 7798
==========================================================================
Hits ? 29987
Misses ? 2703
Partials ? 247 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The base branch was changed.
* feat: Userpilot - Rudderstack transformer (#4164) * Userpilot - Rudderstack transformer * fix: user id is not required & include `v1` in the path rather than DEFAULT_BASE_URL * test: remove v1 from apiEndpoint * chore: update functionality Co-authored-by: Dilip Kola <[email protected]> * chore: add util tests --------- Co-authored-by: ThabetIbrahim <[email protected]> Co-authored-by: Dilip Kola <[email protected]>
What are the changes introduced in this PR?
Add support for Userpilot integration
What is the related Linear task?
Resolves INT-XXX
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