Repository navigation
feat: bluecore email subscription event - #4304
Conversation
Summary by CodeRabbit
WalkthroughThe changes introduce dedicated support for subscription events in the Bluecore destination, including configuration, utility functions for validation and payload construction, workflow modifications to handle subscription events separately, and tests to verify these functionalities. Changes
Sequence Diagram(s)sequenceDiagram
participant Source as Message Source
participant Utils as Bluecore Utils
participant Workflow as Bluecore Workflow
Source->>Workflow: Receive Track Event (message)
alt Subscription Event
Workflow->>Utils: isSubscriptionEvent(event)
Utils-->>Workflow: true
Workflow->>Utils: constructSubscriptionEventPayload(message)
Utils-->>Workflow: subscription event payload
Workflow->>Workflow: Validate and set payload context
else Non-Subscription Event
Workflow->>Utils: isSubscriptionEvent(event)
Utils-->>Workflow: false
Workflow->>Utils: constructCommonPayload(message)
Utils-->>Workflow: common event payload
Workflow->>Workflow: Validate and set payload context
end
Suggestions for Improvement
Suggested Reviewers
✨ 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:
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: 0
🧹 Nitpick comments (5)
src/cdk/v2/destinations/bluecore/config.js (1)
71-83: Constant naming – favour readability
OPTINEVENTSis functional but a bit dense to read. Renaming toOPTIN_EVENTS(orOPT_IN_EVENTS) follows the existing uppercase-snake style used elsewhere (BLUECORE_EXCLUSION_FIELDS). Totally optional, yet helps future readers spot the word boundary quickly.-const OPTINEVENTS = ['optin', 'unsubscribe']; +const OPTIN_EVENTS = ['optin', 'unsubscribe']; … - OPTINEVENTS, + OPTIN_EVENTS,src/cdk/v2/destinations/bluecore/utils.js (4)
76-83: Duplication withvalidateCustomerEvent– DRY up the validators
validateOptinEventis identical to the first half ofvalidateCustomerEvent. Consider re-using the existing helper instead of introducing a new one:-const validateOptinEvent = (payload, message) => { - if (!isDefinedAndNotNullAndNotEmpty(getFieldValueFromMessage(message, 'email'))) { - throw new InstrumentationError( - `[Bluecore] property:: email is required for ${payload.event} action`, - ); - } -}; +// Re–export to keep the switch-map readable +const validateOptinEvent = validateCustomerEvent;This removes duplicate logic and keeps the list of validators easier to maintain.
168-171: Case-handling is great; add early-return guard for non-strings
isOptinEventattempts a lowercase conversion only for strings, but still callsincludeson the result even when the argument is e.g.undefined. Although today all callers pass a string, adding a guard prevents accidental runtime errors:-const isOptinEvent = (eventName) => { - const eventNameLowerCase = typeof eventName === 'string' ? eventName.toLowerCase() : eventName; - return OPTINEVENTS.includes(eventNameLowerCase); -}; +const isOptinEvent = (eventName) => { + if (typeof eventName !== 'string') return false; + return OPTINEVENTS.includes(eventName.toLowerCase()); +};
225-233: Property merge logic – safeguard against empty customer traitsWhen
customerPropertiesis an empty object{}, the opt-in branch still spreads it intocustomProperties.properties, which is harmless but unnecessary. A tiny guard removes redundant keys:-if (isOptinEvent(message?.event)) { - customProperties.properties = { - ...customProperties.properties, - ...customerProperties, - }; +if (isOptinEvent(message?.event) && Object.keys(customerProperties).length) { + customProperties.properties = { + ...customProperties.properties, + ...customerProperties, + };This avoids polluting the final payload with empty fields.
240-245: Single-responsibility – collapseconstructCommonPayload
constructCommonPayloadis a thin wrapper that callsconstructPayloadwith one of two mappings. Inlining its logic intoconstructPropertiesreduces an extra function hop and keeps the flow easier to follow. If you keep it, mark it/** @private */to signal its limited scope.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 2913244 and bcb0d55768da3993851fa9756a823f6d2620ac11.
⛔ Files ignored due to path filters (2)
src/cdk/v2/destinations/bluecore/data/bluecoreOptinEventConfig.jsonis excluded by!**/*.jsontest/integrations/destinations/bluecore/trackTestData.tsis excluded by!**/test/**
📒 Files selected for processing (2)
src/cdk/v2/destinations/bluecore/config.js(3 hunks)src/cdk/v2/destinations/bluecore/utils.js(4 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/bluecore/config.jssrc/cdk/v2/destinations/bluecore/utils.js
⏰ Context from checks skipped due to timeout of 90000ms (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 ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Code Coverage
- GitHub Check: UT Tests
- GitHub Check: test_and_publish
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
src/cdk/v2/destinations/bluecore/config.js (1)
18-22: Add unit-tests for the new config categoryThe
OPTINcategory is now part of the public contract returned bygetMappingConfig(). Please ensure there is at least one unit / integration test that asserts:
CONFIG_CATEGORIES.OPTINis returned bygetMappingConfig.- The mapping for the new category resolves without throwing when the corresponding JSON file is absent or malformed.
Without a test, a future refactor of the config loader could silently break opt-in events.
|
Allure Test reports for this run are available at:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4304 +/- ##
===========================================
+ Coverage 91.10% 91.12% +0.01%
===========================================
Files 636 636
Lines 33378 33404 +26
Branches 7888 7896 +8
===========================================
+ Hits 30410 30439 +29
+ Misses 2729 2696 -33
- Partials 239 269 +30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Allure Test reports for this run are available at:
|
2837e15 to
6c5cbfb
Compare
|
Allure Test reports for this run are available at:
|
6c5cbfb to
508c298
Compare
|
Allure Test reports for this run are available at:
|
1 similar comment
|
Allure Test reports for this run are available at:
|
af18a3f to
79afb7a
Compare
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
669ee79 to
1ec594a
Compare
|
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:
|
|
Allure Test reports for this run are available at:
|
5209a8b to
2847fd9
Compare
|
Allure Test reports for this run are available at:
|
|
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (2)
src/cdk/v2/destinations/bluecore/procWorkflow.yaml (1)
59-59: Consider if the event validation is redundant.The condition checks if
isSubscriptionEvent(.message.event)is true, but this validation might be redundant if the function already handles undefined/null cases internally.src/cdk/v2/destinations/bluecore/utils.js (1)
225-246: Document the property precedence behavior.The function merges custom customer properties with the base payload. As mentioned in a past review comment, it's important to document that values from
traitsandcontext.traitswill overwrite values frompropertieswhen property names match.Consider adding a JSDoc comment to clarify this behavior:
+/** + * Constructs subscription event payload for opt-in/unsubscribe events. + * Note: Customer properties from traits will overwrite properties with the same name. + * + * @param {Object} message - The message object containing subscription event data + * @returns {Object} - The constructed payload for subscription events + * @throws {InstrumentationError} - When email consent is missing or not a boolean + */ const constructSubscriptionEventPayload = (message) => {
🧹 Nitpick comments (1)
src/cdk/v2/destinations/bluecore/utils.test.js (1)
406-464: Consider adding test cases for edge scenarios.The test suite covers the main scenarios well. However, consider adding test cases for:
- When
channelConsentsis present but- When
channelConsentsitself is not an object (e.g., null, string, etc.)These edge cases would ensure more robust error handling.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 0668d63f7c8c2b7bac6eabecce47182a46e725fc and 2847fd9.
⛔ Files ignored due to path filters (3)
src/cdk/v2/destinations/bluecore/data/bluecoreSubscriptionEventConfig.jsonis excluded by!**/*.jsontest/integrations/destinations/bluecore/trackTestData.tsis excluded by!**/test/**test/integrations/destinations/bluecore/validationTestData.tsis excluded by!**/test/**
📒 Files selected for processing (4)
src/cdk/v2/destinations/bluecore/config.js(3 hunks)src/cdk/v2/destinations/bluecore/procWorkflow.yaml(2 hunks)src/cdk/v2/destinations/bluecore/utils.js(8 hunks)src/cdk/v2/destinations/bluecore/utils.test.js(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/cdk/v2/destinations/bluecore/config.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/bluecore/utils.test.jssrc/cdk/v2/destinations/bluecore/utils.js
⏰ Context from checks skipped due to timeout of 90000ms (6)
- 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: 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
🔇 Additional comments (1)
src/cdk/v2/destinations/bluecore/utils.js (1)
166-171: LGTM! Good defensive programming.The function correctly handles non-string inputs before performing the case-insensitive comparison.
* feat: update destination type with optional account types (#4291) * feat: update destination type with optional account types * chore: add authenticationType * chore: update types with generics * chore: add optional config to accountDefiition * chore: update deleteAccount to regulationAccount * chore: update regulationAccount to deleteAccount * chore(destination): migrate slack destination tests to new format (#4279) * chore(destination): migrate slack destination tests to new format * refactor: tests to use proper types * chore: fix status in mailchimp, fix cognitive complexity, add unit tests (#4314) * chore: fix status in mailchimp, fix cognitive complexity, add unit tests * chore: fix PR comments for mailchimp tests * test: add tests for error cases to improve code coverage --------- Co-authored-by: Dilip Kola <[email protected]> * chore(braze): added docs for braze destination (#4297) * chore(braze): added docs for braze destination * chore: update braze docs * chore: add multiplexing section --------- Co-authored-by: Utsab Chowdhury <[email protected]> * chore: add string check for phone in gaoc (#4311) * chore: add string check for phone in gaoc * chore: add unit test * chore: update condition Co-authored-by: Sudip Paul <[email protected]> --------- Co-authored-by: Sudip Paul <[email protected]> * chore: correct dotenv import (#4320) * chore: payload size middleware performance improvement (#4318) * fix: add uuid as fallback to missing anonymousId in webhook events (#4276) * chore: bump codecov/codecov-action from 5.4.2 to 5.4.3 (#4335) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.4.2 to 5.4.3. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](codecov/codecov-action@v5.4.2...v5.4.3) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-version: 5.4.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: bump slackapi/slack-github-action from 1.27.0 to 2.1.0 (#4312) Bumps [slackapi/slack-github-action](https://github.com/slackapi/slack-github-action) from 1.27.0 to 2.1.0. - [Release notes](https://github.com/slackapi/slack-github-action/releases) - [Commits](slackapi/slack-github-action@v1.27.0...v2.1.0) --- updated-dependencies: - dependency-name: slackapi/slack-github-action dependency-version: 2.1.0 dependency-type: direct:production 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: mp add content type header to all apis (#4344) * fix: mp add content-type header and follow strict for engage and group apis * chore: mp add content type header to all apis * feat: bluecore email subscription event (#4304) * fix: blucore optin event mapping * fix: review comments * chore: add subscription event * chore: add subscription event * fix: reviews comments * fix: review comments * fix: review comments * fix: review comments * chore: test description * chore(release): 1.101.0 * chore: pass copy of metadata to avoid actual metadata modifications (#4351) * Revert "feat: update destination type with optional account types (#4291)" (#4348) This reverts commit f368f00. --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Sudip Paul <[email protected]> Co-authored-by: Yashasvi Bajpai <[email protected]> Co-authored-by: Dilip Kola <[email protected]> Co-authored-by: Dilip Kola <[email protected]> Co-authored-by: Vinay Teki <[email protected]> Co-authored-by: Utsab Chowdhury <[email protected]> Co-authored-by: Aris Tzoumas <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mahesh Kutty <[email protected]> Co-authored-by: GitHub Actions <[email protected]> Co-authored-by: Jayachand Mopidevi <[email protected]>



What are the changes introduced in this PR?
In this pr, we will introduce new subscription event specs for Bluecore.
A notion doc
https://www.notion.so/rudderstacks/Subscribing-and-Unsubscribing-in-RudderStack-1edf2b415dd080fc91b3cd053d536c23?d=1f8f2b415dd0807fa9a1001c0682b03c#1edf2b415dd080c48581e6ab24f2e083
Supported Link:
https://help.bluecore.com/en/articles/6786828-events-api#h_2eb9c99eaa
Video Link:
https://uploads.linear.app/b24eb84f-05bc-42db-9924-4b4b37f9650a/ba5008f9-f235-4b0b-b7d5-9d80d2025d4f/499af0ab-0dab-4a56-9720-bc1607d2c7d5?signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXRoIjoiL2IyNGViODRmLTA1YmMtNDJkYi05OTI0LTRiNGIzN2Y5NjUwYS9iYTUwMDhmOS1mMjM1LTRiMGItYjdkNS05ZDgwZDIwMjVkNGYvNDk5YWYwYWItMGRhYi00YTU2LTk3MjAtYmMxNjA3ZDJjN2Q1IiwiaWF0IjoxNzQ4MjMzNTczLCJleHAiOjMzMzE4NzkzNTczfQ.Ctxmm7isFNJmTap1qO1vvyNr0TcgnefBIxJsAE0BGbI
What is the related Linear task?
Resolves INT-3602
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.