Skip to content

chore(release): pull main into develop post release v1.101.1 - #4375

Merged
6 commits merged into
developfrom
main
Jun 3, 2025
Merged

6 commits merged into
developfrom
main

Conversation

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

👑 An automated PR

@coderabbitai

coderabbitai Bot commented Jun 3, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added support for a new Klaviyo API revision (2024-10-15), including a configuration option to use this version and conditional request handling.
    • Introduced a Prometheus metric to track requests using the new Klaviyo revision.
    • Added a custom Handlebars helper for inserting newlines in Slack message templates.
  • Bug Fixes

    • Improved validation and typing for Customer.io audience event actions, ensuring stricter identifier checks and decoupling from external types.
  • Chores

    • Removed deprecated fields and types from internal schemas and test cases to streamline event processing and validation.

Walkthrough

This change removes Rudder-specific types and schemas (RudderRecordV2Schema, RecordAction, and the rudderId field) from the codebase, particularly in the Customer.io Audience integration, and replaces them with explicit, local definitions. It also adds support for a new Klaviyo API revision with corresponding metrics and configuration, and introduces a Handlebars helper for Slack message formatting.

Changes

File(s) Change Summary
src/types/rudderEvents.ts Removed rudderId from RudderMessageSchema; deleted RecordAction enum and RudderRecordV2Schema and related types.
src/v0/destinations/customerio_audience/type.ts Introduced local SegmentAction enum/schema; replaced Rudder types with explicit schemas and stricter validation.
src/v0/destinations/customerio_audience/transform.ts Replaced usage of RecordAction with new SegmentAction; updated event filtering logic.
src/v0/destinations/customerio_audience/utils.ts Switched from RecordAction to SegmentActionType for event action typing and logic.
src/v0/destinations/customerio_audience/utils.test.ts Removed rudderId and messageId from test message inputs to align with schema changes.
src/v0/destinations/klaviyo/config.js Added and exported new constant revisionOct2024.
src/v0/destinations/klaviyo/batchUtil.js Added support for revisionOct2024 and config flag for new revision in header selection.
src/v0/destinations/klaviyo/util.js Conditional logic for new revision header and metric tracking; updated config extraction.
src/util/prometheus.js Added new Prometheus counter metric for tracking requests using the new Klaviyo revision.
src/v0/destinations/slack/transform.js Registered a new Handlebars helper for newline insertion in templates.

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)
Loading
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
Loading

Possibly related PRs

  • rudderlabs/rudder-transformer#4356: Directly related, as both PRs modify the same schemas and fields (rudderId, RudderRecordV2Schema) but in opposite directions.
  • rudderlabs/rudder-transformer#4343: Closely related, as this PR removes the Rudder V2 types and replaces them with local types, effectively reversing the integration introduced in the referenced PR.

Suggested reviewers

  • sivashanmukh
  • koladilip
  • utsabc
  • yashasvibajpai

Suggestions for improvement:

  • Ensure all downstream consumers of the removed Rudder types are updated to prevent type errors.
  • Consider documenting the rationale for decoupling from Rudder-specific schemas for future maintainers.
  • For the new Klaviyo revision support, add integration tests to verify correct metric tracking and header selection.
  • For the Handlebars helper, include usage examples in documentation or comments for template authors.
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.js for 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 eventAction value is always a valid SegmentActionType. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9c3938e and e5ae5b8.

⛔ Files ignored due to path filters (6)
  • CHANGELOG.md is excluded by !**/*.md
  • package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • package.json is excluded by !**/*.json
  • test/integrations/destinations/customerio_audience/router/data.ts is excluded by !**/test/**
  • test/integrations/destinations/klaviyo/processor/identifyTestDataV2.ts is excluded by !**/test/**
  • test/integrations/destinations/slack/processor/data.ts is 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.js
  • src/v0/destinations/klaviyo/config.js
  • src/v0/destinations/klaviyo/batchUtil.js
  • src/v0/destinations/klaviyo/util.js
  • src/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
The newline helper 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 buildRequest and buildSubscriptionOrUnsubscriptionPayload functions.

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 RecordAction with SegmentAction is 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 SegmentActionType and the return type change for getEventAction to string accurately 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 SegmentAction constant and corresponding SegmentActionSchema provide a clean, type-safe way to handle action values. Using z.nativeEnum ensures proper validation against the constant values.

Also applies to: 66-66


69-89: Excellent schema refinement with improved validation.

The new CustomerIOMessageSchema definition is more explicit and provides better validation:

  • The type field is properly constrained to the record literal
  • The action field is validated against the enum schema
  • The superRefine method 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 SegmentActionType inference from the schema and its usage in ProcessedEvent maintains type consistency throughout the codebase. This ensures compile-time type safety for action values.

Also applies to: 124-124

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor Author

Allure Test reports for this run are available at:

@codecov

codecov Bot commented Jun 3, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.13%. Comparing base (c684b65) to head (e5ae5b8).
Report is 19 commits behind head on develop.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

sonarqubecloud Bot commented Jun 3, 2025

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants