Repository navigation
feat: onboard userpilot integration - #4238
Conversation
Summary by CodeRabbit
WalkthroughThis pull request introduces three new files related to the Userpilot integration. A configuration file exports constants for the base URL and key mappings. A YAML file outlines a multi-step workflow for processing events like identification, tracking, and grouping, which includes validation and payload construction. Additionally, a utilities module provides functions for constructing endpoint URLs and transforming user traits based on the defined mappings. These changes centralize the configuration and processing logic specific to Userpilot within the application. Changes
Sequence Diagram(s)sequenceDiagram
participant C as Client Event
participant W as Workflow Processor
participant U as Utility Functions
C->>W: Send event (identify/track/group)
W->>W: Validate input (check message type)
W->>W: Prepare context (set type, payload, headers)
alt Event Type Decision
W->>W: For IDENTIFY: construct identify payload
W->>W: For TRACK: construct track payload
W->>W: For GROUP: construct group payload
end
W->>U: Retrieve endpoints & transform traits based on config
W->>C: Return configured response with endpoint, headers, and payload
Possibly related PRs
Suggested reviewers
🪧 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
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/cdk/v2/destinations/userpilot/utils.js (1)
14-18: Consider alternative implementation for transformTraitsWhile the current implementation works well, consider using Object.entries and Object.fromEntries for a more declarative approach:
- const transformTraits = (traits) => - Object.keys(traits).reduce((acc, key) => { - acc[MAPPINGS[key] || key] = traits[key]; - return acc; - }, {}); + const transformTraits = (traits) => + Object.fromEntries( + Object.entries(traits).map(([key, value]) => [ + MAPPINGS[key] || key, + value + ]) + );This alternative would achieve the same result with potentially improved readability.
src/cdk/v2/destinations/userpilot/procWorkflow.yaml (1)
16-16: Remove trailing whitespaceThere's a trailing space at the end of this line 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)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between ab427cd and ec5f6fb863cd1d0373dcd61e93507bea8a345c1d.
⛔ Files ignored due to path filters (1)
test/integrations/destinations/userpilot/processor/data.tsis excluded by!**/test/**
📒 Files selected for processing (3)
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)
🧰 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).
src/cdk/v2/destinations/userpilot/config.jssrc/cdk/v2/destinations/userpilot/utils.js
🧬 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 (11)
- GitHub Check: Check PR Title
- 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 ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Code Coverage
- GitHub Check: test_and_publish
- GitHub Check: UT Tests
- GitHub Check: ingestion-service-test
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (6)
src/cdk/v2/destinations/userpilot/config.js (1)
1-9: Configuration setup looks goodThe configuration file properly exports the necessary constants for the Userpilot integration. The code is clean and follows the project's structure.
src/cdk/v2/destinations/userpilot/utils.js (1)
3-12: Well-structured endpoint generation functionThe
getEndpointsfunction correctly handles base URL normalization by removing trailing slashes, which prevents potential URL formation issues. The endpoint construction is clear and maintainable.src/cdk/v2/destinations/userpilot/procWorkflow.yaml (4)
1-11: Bindings look goodThe bindings are correctly defined to import necessary dependencies. Good job including both standard utilities and custom functions.
13-28: Input validation and context preparationThe input validation correctly checks for required fields and supported message types. The context preparation step properly sets up the necessary headers and API version.
🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 16-16: trailing spaces
(trailing-spaces)
30-70: Payload construction for different event typesThe payload construction for each event type (identify, track, group) is well-structured with appropriate assertions for required fields. The implementation correctly uses the utility functions for transforming traits and getting endpoints.
71-78: Response formatting looks goodThe response formatting correctly sets up the necessary properties using the context built throughout the workflow.
|
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 #4238 +/- ##
===========================================
+ Coverage 91.05% 91.15% +0.10%
===========================================
Files 627 632 +5
Lines 33049 33063 +14
Branches 7818 7824 +6
===========================================
+ Hits 30092 30139 +47
+ Misses 2710 2679 -31
+ Partials 247 245 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
8a226b6 to
3c0692e
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/cdk/v2/destinations/userpilot/procWorkflow.yaml (1)
13-18: Input Validation & Trailing Space Notice
ThevalidateInputstep correctly asserts the presence ofmessage.typeand verifies it against the supported types. However, note that line 16 contains trailing spaces. Removing these will help maintain adherence to YAML linting standards and improve overall file cleanliness.🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 16-16: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between ec5f6fb863cd1d0373dcd61e93507bea8a345c1d and 3c0692ebe5c99efe76ad6e3c3aff9167656a2ff0.
⛔ Files ignored due to path filters (1)
test/integrations/destinations/userpilot/processor/data.tsis excluded by!**/test/**
📒 Files selected for processing (3)
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)
🚧 Files skipped from review as they are similar to previous changes (2)
- src/cdk/v2/destinations/userpilot/config.js
- src/cdk/v2/destinations/userpilot/utils.js
🧰 Additional context used
🪛 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 (7)
- 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: Analyze (javascript-typescript)
🔇 Additional comments (6)
src/cdk/v2/destinations/userpilot/procWorkflow.yaml (6)
1-11: Bindings Definition Review
The bindings are defined clearly, importing constants and utility functions required for the Userpilot processing workflow. Please ensure that the relative paths (e.g.,../../../../constantsand./utils) accurately reflect your repository structure, as any changes in the directory layout may require updates here.
19-28: Context Preparation Review
TheprepareContextstep is well structured—it initializes the context with the message type, creates an empty payload, and sets up the API version and headers (including Authorization and Content-Type). Consider whether the hardcoded API version ("2020-09-22") should be made configurable in the future.
30-42: Identify Payload Construction
TheidentifyPayloadstep effectively asserts the presence of a user ID, creates a payload with theuser_id, and processes user traits by applyingtransformTraitsand cleaning up undefined or null values. This approach ensures that the payload is structured correctly for IDENTIFY events.
43-56: Track Payload Construction
ThetrackPayloadstep validates both the user ID and event name before constructing the payload. The method of integrating properties with the help ofremoveUndefinedAndNullValuesis consistent and clear. This setup should function reliably for TRACK events.
57-70: Group Payload Construction
ThegroupPayloadstep presents a clear validation for the group ID and handles trait transformation consistently with the IDENTIFY step. The use of the key"company_id"in the payload is appropriate given the expected API input.
71-78: Return Response Construction
The finalreturnResponsestep builds the response using the default request configuration, then explicitly sets the endpoint, headers, HTTP method, and body payload. Verify that, in your workflow processing engine, returningresponseas the final line of the template meets the expected syntax requirements for output.
|
Allure Test reports for this run are available at:
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/cdk/v2/destinations/userpilot/utils.test.js (2)
13-32: Comprehensive tests for the getEndpoints function.Your tests effectively cover both the default and custom base URL scenarios. The assertions correctly verify that the endpoints are constructed as expected.
Consider adding a test case for handling invalid input types (null, undefined) for apiEndpoint to ensure robust error handling.
it('should handle invalid apiEndpoint values', () => { // Test with null expect(getEndpoints({ apiEndpoint: null })).toEqual({ IDENTIFY: 'https://api.userpilot.com/v1/identify', TRACK: 'https://api.userpilot.com/v1/track', GROUP: 'https://api.userpilot.com/v1/companies/identify', }); // Test with undefined expect(getEndpoints({ apiEndpoint: undefined })).toEqual({ IDENTIFY: 'https://api.userpilot.com/v1/identify', TRACK: 'https://api.userpilot.com/v1/track', GROUP: 'https://api.userpilot.com/v1/companies/identify', }); });
34-46: Good coverage for the transformTraits function.The tests appropriately verify that traits are transformed based on mappings and that unmapped traits remain unchanged.
Consider adding tests for edge cases:
- Empty traits object
- Null/undefined input handling
These would ensure the function is robust against different input scenarios.
it('should handle empty traits object', () => { const traits = {}; const transformed = transformTraits(traits); expect(transformed).toEqual({}); }); it('should handle null or undefined traits', () => { // Assuming the implementation handles this gracefully // If not, you might need to update the implementation first expect(() => transformTraits(null)).not.toThrow(); expect(() => transformTraits(undefined)).not.toThrow(); });
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 3c0692ebe5c99efe76ad6e3c3aff9167656a2ff0 and 937ab7d56881b2128ed10e8d1b6e672c14a38144.
📒 Files selected for processing (2)
src/cdk/v2/destinations/userpilot/utils.js(1 hunks)src/cdk/v2/destinations/userpilot/utils.test.js(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/cdk/v2/destinations/userpilot/utils.js
🧰 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).
src/cdk/v2/destinations/userpilot/utils.test.js
🧬 Code Definitions (1)
src/cdk/v2/destinations/userpilot/utils.test.js (1)
src/cdk/v2/destinations/userpilot/utils.js (4)
require(1-1)require(2-2)getEndpoints(4-12)transformTraits(14-18)
⏰ Context from checks skipped due to timeout of 90000ms (10)
- 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: ingestion-service-test
- GitHub Check: test_and_publish
- GitHub Check: UT Tests
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
src/cdk/v2/destinations/userpilot/utils.test.js (1)
1-12: Well-structured test dependencies and mocks.The imports and mock setups look good. You've properly isolated the tests by mocking the required dependencies. The implementation of the mock for stripTrailingSlash correctly handles URL normalization.
|
Allure Test reports for this run are available at:
|
937ab7d to
a0357b3
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
src/cdk/v2/destinations/userpilot/procWorkflow.yaml (4)
13-18: Validate Input Step: Assertions and FormattingThe assertions correctly ensure that a
message.typeis present and that its value belongs to the supported event types. However, please remove the trailing spaces on line 16 (as highlighted by YAMLlint) and double-check that the list membership syntax{{$.EventType.([.IDENTIFY, .TRACK, .GROUP])}}is correctly interpreted by your templating engine.
🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 16-16: trailing spaces
(trailing-spaces)
19-28: Prepare Context Step: Setting up the Request ContextThe context is set up properly with the message type, an empty payload, API version, and final headers. The hardcoded API version (
"2020-09-22") should be reviewed; consider parameterizing it or ensuring documentation is provided if this might change in the future.
30-42: Identify Payload Step: Constructing Identify RequestThe step for identify events asserts the presence of a user ID and constructs the payload correctly. It also transforms and cleans the trait data. Ensure that the
transformTraitsfunction handles unexpected or malformed trait data gracefully.
43-56: Track Payload Step: Constructing Track RequestThe validations for user ID and event name are in place, and the payload is assembled using the provided properties. It would be beneficial to verify that all event property types (including any nested structures) are properly managed by your transformation functions.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 937ab7d56881b2128ed10e8d1b6e672c14a38144 and a0357b32ebb45d7f6185955ed2140546186b1b6b.
⛔ Files ignored due to path filters (1)
test/integrations/destinations/userpilot/processor/data.tsis excluded by!**/test/**
📒 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)src/cdk/v2/destinations/userpilot/utils.test.js(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- src/cdk/v2/destinations/userpilot/config.js
- src/cdk/v2/destinations/userpilot/utils.js
- src/cdk/v2/destinations/userpilot/utils.test.js
🧰 Additional context used
🪛 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 (10)
- 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: UT Tests
- GitHub Check: ingestion-service-test
- GitHub Check: test_and_publish
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (3)
src/cdk/v2/destinations/userpilot/procWorkflow.yaml (3)
1-11: Bindings Configuration CheckThe bindings section clearly defines the required entities and their relative paths. Please verify that the paths (e.g.,
"../../../../constants","../../../../v0/util","./utils") are correct relative to this file’s location to avoid potential runtime issues.
57-70: Group Payload Step: Handling Group EventsThe group event step asserts that a group ID is provided and forms the payload with the key
company_id. Please confirm that this key name aligns with the expectations of the Userpilot API.
71-79: Return Response Step: Finalizing the API RequestThe response construction correctly utilizes the default request configuration and assigns the endpoint, headers, method (POST), and payload. It is advisable to ensure that the
defaultRequestConfigfunction returns all necessary default values expected by downstream processes.
|
Allure Test reports for this run are available at:
|
* Userpilot - Rudderstack transformer * fix: user id is not required & include `v1` in the path rather than DEFAULT_BASE_URL * test: remove v1 from apiEndpoint
Co-authored-by: Dilip Kola <[email protected]>
a0357b3 to
80705e2
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/cdk/v2/destinations/userpilot/procWorkflow.yaml (1)
12-18: ValidateInput Step: Remove Trailing SpacesThe
validateInputstep correctly ensures that a valid message type is provided and supported (IDENTIFY, TRACK, GROUP). However, YAML linting has flagged trailing spaces on line 16. Please remove any trailing white spaces to comply with style guidelines.🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 16-16: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between a0357b32ebb45d7f6185955ed2140546186b1b6b and 80705e2.
⛔ Files ignored due to path filters (1)
test/integrations/destinations/userpilot/processor/data.tsis excluded by!**/test/**
📒 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)src/cdk/v2/destinations/userpilot/utils.test.js(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- src/cdk/v2/destinations/userpilot/config.js
- src/cdk/v2/destinations/userpilot/utils.test.js
- src/cdk/v2/destinations/userpilot/utils.js
🧰 Additional context used
🪛 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 (10)
- 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: UT Tests
- GitHub Check: test_and_publish
- GitHub Check: ingestion-service-test
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (6)
src/cdk/v2/destinations/userpilot/procWorkflow.yaml (6)
1-11: Binding Configuration Looks GoodThe new bindings are clearly defined and structured to modularize the configuration for Userpilot. Please verify that the provided relative paths (e.g.,
../../../../constants,./utils) correctly resolve in your project’s directory structure.
19-29: PrepareContext Step is Well-FormedThe
prepareContextstep is implemented effectively—initializing the context, setting the API version, and constructing the final headers (including authorization). This clear separation of concerns will help in maintaining consistency across API calls.
30-42: IdentifyPayload Step Constructs User Data CorrectlyThe
identifyPayloadstep validates the presence of a user ID, constructs the payload, and cleans metadata using thetransformTraitsandremoveUndefinedAndNullValuesfunctions. The endpoint is also correctly set usinggetEndpoints. This segment appears robust.
43-56: TrackPayload Step is Implemented EffectivelyThe
trackPayloadstep asserts the key properties (user ID and event name) and builds the payload accordingly, including a metadata cleanup. The logic is clear and maintains consistency with the other payload steps.
57-70: GroupPayload Step Handles Group Data AdequatelyThe
groupPayloadstep is crafted to enforce the requirement for a group ID and to transform group traits accurately. The configuration for endpoints usinggetEndpointsappears consistent with other steps.
71-79: ReturnResponse Step Compiles API Request ProperlyThe
returnResponsestep neatly encapsulates the final request configuration by assigning the endpoint, headers, method, and payload. The implicit return of the response at the end aligns with the templating conventions.
|
Allure Test reports for this run are available at:
|
|



What are the changes introduced in this PR?
Onboard Userpilot integration contribution
What is the related Linear task?
Resolves INT-3425
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.