Skip to content

feat(klaviyo): add unique_id support for create events APIs - #4646

Merged
koladilip merged 4 commits into
release/v1.108.0from
feature/klaviyo-unique-id-support
Sep 16, 2025
Merged

koladilip merged 4 commits into
release/v1.108.0from
feature/klaviyo-unique-id-support

Conversation

@koladilip

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

This PR adds support for unique_id field in Klaviyo create events APIs for both v1 and v2 versions. The unique_id is used for event deduplication and is set to the messageId from the incoming event.

What is the related Linear task?

Resolves INT-4135

Please explain the objectives of your changes below

The changes implement unique_id support for Klaviyo track events to enable proper event deduplication. This ensures that duplicate events are not processed multiple times by Klaviyo's API.

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

  • Added unique_id field to track events in both transform.js (v1) and transformV2.js (v2)
  • The unique_id is populated with message.messageId for proper event identification
  • Updated test data to include unique_id validation
  • No breaking changes to existing functionality

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?

  • The unique_id field is added to the event payload structure
  • Uses existing messageId from the event, no additional processing overhead
  • Maintains backward compatibility with existing event processing

@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.

web-flow and others added 2 commits September 15, 2025 12:27
- Add unique_id field to track events in both v1 and v2 APIs
- Use messageId as unique_id for event deduplication
- Update test data to include unique_id validation
- Resolves INT-4135
@koladilip
koladilip requested review from a team and sivashanmukh as code owners September 16, 2025 11:28
@koladilip
koladilip requested review from a team, manish339k and utsabc September 16, 2025 11:28
@coderabbitai

coderabbitai Bot commented Sep 16, 2025 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Summary by CodeRabbit

  • New Features
    • Klaviyo destination now adds a unique_id attribute to Track and Screen events. The value is automatically populated from each event’s message ID, providing a consistent identifier within event attributes. This supports more reliable deduplication, segmentation, and troubleshooting in Klaviyo and any downstream tools that consume these events.

Walkthrough

A new field unique_id is set on event attributes in trackOrScreenRequestHandler within src/v0/destinations/klaviyo/transformV2.js, assigning attributes.unique_id = message.messageId for track and screen events. No other code paths or exports are modified.

Changes

Cohort / File(s) Summary
Klaviyo transform update
src/v0/destinations/klaviyo/transformV2.js
Adds attributes.unique_id set from message.messageId within track/screen handling before payload return; no export/signature changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Suggested reviewers

  • sivashanmukh
  • utsabc
  • chandumlg
  • ItsSudip

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description follows the repository template and documents intent and the Linear task, but it asserts changes to both transform.js (v1) and transformV2.js plus updated tests while the provided raw_summary only shows a change to src/v0/destinations/klaviyo/transformV2.js, creating an inconsistency between the described scope and the actual changeset. Please update the PR description to accurately reflect the files actually changed or add the missing commits for v1 and the test updates; also reconcile the developer checklist (tests/docs) and explicitly note any documentation changes required so reviewers can verify the claimed updates.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title is concise, clearly names the subsystem (klaviyo) and summarizes the primary change (adding unique_id support for create events APIs), making it easy for a teammate scanning history to understand the main intent of the PR.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@koladilip
koladilip changed the base branch from develop to release/v1.108.0 September 16, 2025 11:28

@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 (1)
src/v0/destinations/klaviyo/transformV2.js (1)

100-101: Preserve caller-provided unique_id; only fallback to message.messageId

Don't overwrite attributes.unique_id — set it from message.messageId only when unique_id is absent and message.messageId is defined.

File: src/v0/destinations/klaviyo/transformV2.js (around lines 98–102)

-  attributes.unique_id = message.messageId;
+  // Prefer caller-provided unique_id; fall back to messageId when absent
+  if (!isDefinedAndNotNull(attributes.unique_id) && isDefinedAndNotNull(message.messageId)) {
+    attributes.unique_id = message.messageId;
+  }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 04e2ace and 3ca8623.

⛔ Files ignored due to path filters (7)
  • 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/klaviyo/processor/ecomTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/klaviyo/processor/trackTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/klaviyo/processor/trackTestDataV2.ts is excluded by !**/test/**
  • test/integrations/destinations/klaviyo/router/dataV2.ts is excluded by !**/test/**
📒 Files selected for processing (1)
  • src/v0/destinations/klaviyo/transformV2.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js

⚙️ CodeRabbit configuration file

Focus on ESLint errors (max 3) and warnings (max 5).

Files:

  • src/v0/destinations/klaviyo/transformV2.js
🧠 Learnings (1)
📓 Common learnings
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4497
File: src/v0/destinations/tiktok_ads/transformV2.js:686-691
Timestamp: 2025-07-15T06:27:07.528Z
Learning: For TikTok Ads destination in src/v0/destinations/tiktok_ads/transformV2.js, there are plans for a future enhancement to group events by eventSource when batching to ensure all events in a batch have the same event_source value, as acknowledged by ItsSudip in PR #4497.
🧬 Code graph analysis (1)
src/v0/destinations/klaviyo/transformV2.js (3)
src/v0/destinations/klaviyo/util.js (1)
  • attributes (181-184)
src/v0/destinations/klaviyo/transform.js (1)
  • attributes (171-171)
src/v0/util/index.js (2)
  • message (1162-1162)
  • message (1196-1196)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@koladilip
koladilip merged commit 1b4e601 into release/v1.108.0 Sep 16, 2025
@koladilip
koladilip deleted the feature/klaviyo-unique-id-support branch September 16, 2025 11:37
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@codecov

codecov Bot commented Sep 16, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.78%. Comparing base (b12cacb) to head (c82704d).
⚠️ Report is 1 commits behind head on release/v1.108.0.

Additional details and impacted files
@@                Coverage Diff                @@
##           release/v1.108.0    #4646   +/-   ##
=================================================
  Coverage             91.78%   91.78%           
=================================================
  Files                   642      642           
  Lines                 33973    33974    +1     
  Branches               8045     8048    +3     
=================================================
+ Hits                  31183    31184    +1     
  Misses                 2538     2538           
  Partials                252      252           

☔ 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

Copy link
Copy Markdown

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.

4 participants