Repository navigation
Conversation
* fix: handle newline for slack * fix: update slack tests
Summary by CodeRabbit
WalkthroughThis change removes Rudder-specific types and schemas ( Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant CustomerIO_Audience_Module
participant LocalSegmentTypes
Client->>CustomerIO_Audience_Module: Send event with action
CustomerIO_Audience_Module->>LocalSegmentTypes: Validate action and identifiers
LocalSegmentTypes-->>CustomerIO_Audience_Module: Return validated message
CustomerIO_Audience_Module-->>Client: Processed event (using local SegmentAction)
sequenceDiagram
participant Destination
participant KlaviyoUtil
participant Prometheus
Destination->>KlaviyoUtil: Build request (with config)
KlaviyoUtil->>KlaviyoUtil: Check useNewKlaviyoRevisionVersion
alt New Revision
KlaviyoUtil->>Prometheus: Increment klaviyo_revision_oct2024_requests_total
KlaviyoUtil->>Destination: Send request with revisionOct2024 header
else Old Revision
KlaviyoUtil->>Destination: Send request with revision header
end
Possibly related PRs
Suggested reviewers
Suggestions for improvement:
✨ 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 (4)
src/v0/destinations/klaviyo/config.js (1)
96-97: Fix the date discrepancy in the comment.The comment mentions "2024-10-25" but the actual revision value is "2024-10-15". Please ensure the comment matches the actual date.
-// add revision for 2024-10-25 +// add revision for 2024-10-15 const revisionOct2024 = '2024-10-15';src/v0/destinations/klaviyo/batchUtil.js (1)
50-50: Add metrics tracking for consistency.The conditional revision logic is correct, but consider adding metrics tracking similar to
util.jsfor complete monitoring coverage.revision: useNewKlaviyoRevisionVersion ? revisionOct2024 : revision, + +// Track usage of new revision for monitoring +if (useNewKlaviyoRevisionVersion) { + stats.increment('klaviyo_revision_oct2024_requests_total', { + requestType: 'batch_subscription', + destination_id: destination.ID, + }); +}You'll also need to import
stats:+const stats = require('../../../util/stats');src/v0/destinations/klaviyo/util.js (1)
352-358: Consider refactoring to reduce code duplication.The metrics tracking logic is duplicated across both functions. Consider extracting this into a helper function for better maintainability.
+const trackRevisionUsage = (useNewKlaviyoRevisionVersion, requestType, destinationId) => { + if (useNewKlaviyoRevisionVersion) { + stats.increment('klaviyo_revision_oct2024_requests_total', { + requestType, + destination_id: destinationId, + }); + } +};Then use it in both functions:
- // temporary stats for oct 2024 revision - if (useNewKlaviyoRevisionVersion) { - stats.increment('klaviyo_revision_oct2024_requests_total', { - requestType: category.name, - destination_id: destination.ID, - }); - } + trackRevisionUsage(useNewKlaviyoRevisionVersion, category.name, destination.ID);Also applies to: 608-614
src/v0/destinations/customerio_audience/utils.ts (1)
158-158: Consider validating the action before type casting.While the type cast is necessary, it assumes the
eventActionvalue is always a validSegmentActionType. Since this value comes from external input, consider adding a runtime check to ensure type safety.You could add validation before the type cast:
export const createEventChunk = (event: CustomerIORouterRequest): ProcessedEvent => { validateEvent(event); const eventAction = getEventAction(event); + if (!Object.values(SegmentAction).includes(eventAction)) { + throw new InstrumentationError(`Invalid action: ${eventAction}`); + } const id = Object.values(event.message.identifiers)[0]; return { payload: { ids: [id] }, metadata: event.metadata, eventAction: eventAction as SegmentActionType, }; };This ensures the action is valid before proceeding with the type cast.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (6)
CHANGELOG.mdis excluded by!**/*.mdpackage-lock.jsonis excluded by!**/package-lock.json,!**/*.jsonpackage.jsonis excluded by!**/*.jsontest/integrations/destinations/customerio_audience/router/data.tsis excluded by!**/test/**test/integrations/destinations/klaviyo/processor/identifyTestDataV2.tsis excluded by!**/test/**test/integrations/destinations/slack/processor/data.tsis excluded by!**/test/**
📒 Files selected for processing (10)
src/types/rudderEvents.ts(0 hunks)src/util/prometheus.js(1 hunks)src/v0/destinations/customerio_audience/transform.ts(2 hunks)src/v0/destinations/customerio_audience/type.ts(4 hunks)src/v0/destinations/customerio_audience/utils.test.ts(0 hunks)src/v0/destinations/customerio_audience/utils.ts(3 hunks)src/v0/destinations/klaviyo/batchUtil.js(2 hunks)src/v0/destinations/klaviyo/config.js(2 hunks)src/v0/destinations/klaviyo/util.js(4 hunks)src/v0/destinations/slack/transform.js(1 hunks)
💤 Files with no reviewable changes (2)
- src/v0/destinations/customerio_audience/utils.test.ts
- src/types/rudderEvents.ts
🧰 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/v0/destinations/slack/transform.jssrc/v0/destinations/klaviyo/config.jssrc/v0/destinations/klaviyo/batchUtil.jssrc/v0/destinations/klaviyo/util.jssrc/util/prometheus.js
🧬 Code Graph Analysis (5)
src/v0/destinations/klaviyo/batchUtil.js (3)
src/v0/destinations/klaviyo/config.js (3)
BASE_ENDPOINT(3-3)revisionOct2024(97-97)revision(95-95)src/v0/destinations/klaviyo/util.js (8)
destination(149-149)destination(150-150)destination(339-339)destination(453-453)destination(518-518)destination(519-519)destination(593-593)getSubscriptionPayload(566-582)src/v0/util/constant.js (1)
JSON_MIME_TYPE(11-11)
src/v0/destinations/customerio_audience/transform.ts (1)
src/v0/destinations/customerio_audience/type.ts (1)
SegmentAction(40-44)
src/v0/destinations/customerio_audience/utils.ts (1)
src/v0/destinations/customerio_audience/type.ts (2)
CustomerIORouterRequest(101-105)SegmentActionType(91-91)
src/v0/destinations/klaviyo/util.js (2)
src/v0/util/index.js (4)
stats(31-31)defaultRequestConfig(460-474)defaultPostRequestConfig(434-437)removeUndefinedAndNullValues(53-53)src/v0/destinations/klaviyo/config.js (4)
BASE_ENDPOINT(3-3)revisionOct2024(97-97)revision(95-95)CONFIG_CATEGORIES(10-27)
src/v0/destinations/customerio_audience/type.ts (1)
src/types/rudderEvents.ts (1)
MessageTypeSchema(6-15)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: Code Coverage
- GitHub Check: UT Tests
- GitHub Check: test_and_publish
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (10)
src/v0/destinations/slack/transform.js (1)
22-24: Correct registration of the custom Handlebars helper
Thenewlinehelper is properly registered to return'\n', making it easy to inject line breaks into Slack message templates.src/util/prometheus.js (1)
583-588: LGTM! Metric definition follows established patterns.The new Prometheus counter metric is well-defined with appropriate labels for tracking Klaviyo revision usage. The naming convention and structure align with existing metrics in the codebase.
src/v0/destinations/klaviyo/batchUtil.js (1)
39-39: LGTM! Clean destructuring pattern.The destructuring of config values improves code readability and follows good practices.
src/v0/destinations/klaviyo/util.js (2)
339-339: LGTM! Consistent destructuring pattern across functions.The destructuring of config values is implemented consistently in both
buildRequestandbuildSubscriptionOrUnsubscriptionPayloadfunctions.Also applies to: 593-593
348-348: LGTM! Conditional revision logic is correct.The conditional revision header setting properly switches between old and new API versions based on the configuration flag.
Also applies to: 600-600
src/v0/destinations/customerio_audience/transform.ts (1)
2-2: Changes align well with the type refactoring.The replacement of
RecordActionwithSegmentActionis consistent throughout the file. The filtering logic remains functionally identical while using the locally defined action constants.Also applies to: 45-45, 49-49
src/v0/destinations/customerio_audience/utils.ts (1)
18-18: Import and type changes are appropriate.The addition of
SegmentActionTypeand the return type change forgetEventActiontostringaccurately reflect the actual data types being handled.Also applies to: 23-23, 129-129
src/v0/destinations/customerio_audience/type.ts (3)
40-44: Well-structured action enum definition.The
SegmentActionconstant and correspondingSegmentActionSchemaprovide a clean, type-safe way to handle action values. Usingz.nativeEnumensures proper validation against the constant values.Also applies to: 66-66
69-89: Excellent schema refinement with improved validation.The new
CustomerIOMessageSchemadefinition is more explicit and provides better validation:
- The
typefield is properly constrained to therecordliteral- The
actionfield is validated against the enum schema- The
superRefinemethod provides detailed error messages for identifier validation- The validation rules are clear: exactly one non-empty identifier is required
This is a significant improvement over the previous schema extension approach.
91-91: Type definitions are consistent and well-aligned.The
SegmentActionTypeinference from the schema and its usage inProcessedEventmaintains type consistency throughout the codebase. This ensures compile-time type safety for action values.Also applies to: 124-124
|
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 #4375 +/- ##
===========================================
+ Coverage 91.12% 91.13% +0.01%
===========================================
Files 636 638 +2
Lines 33400 33462 +62
Branches 7896 7899 +3
===========================================
+ Hits 30435 30496 +61
- Misses 2696 2697 +1
Partials 269 269 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|




👑 An automated PR