Skip to content

Conversation

harsh-joshi99
Copy link
Contributor

@harsh-joshi99 harsh-joshi99 commented Aug 26, 2025

Add multistatus for upsert profile.
Removed the group by list Id logic since we have batch keys now.
Added explicit email validation to support multistatus.

Testing

Stage Testing Doc.

  • Added unit tests for new functionality
  • Tested end-to-end using the local server
  • [If destination is already live] Tested for backward compatibility of destination. Note: New required fields are a breaking change.
  • [Segmenters] Tested in the staging environment
  • [Segmenters] [If applicable for this change] Tested for regression with Hadron.

Copy link

codecov bot commented Aug 26, 2025

Codecov Report

❌ Patch coverage is 94.44444% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.91%. Comparing base (300a848) to head (226cda4).
⚠️ Report is 24 commits behind head on main.

Files with missing lines Patch % Lines
...ns/src/destinations/klaviyo/upsertProfile/index.ts 90.47% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3203      +/-   ##
==========================================
+ Coverage   79.62%   79.91%   +0.28%     
==========================================
  Files        1177     1184       +7     
  Lines       21703    21826     +123     
  Branches     4216     4251      +35     
==========================================
+ Hits        17282    17442     +160     
+ Misses       3679     3634      -45     
- Partials      742      750       +8     

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

@harsh-joshi99 harsh-joshi99 marked this pull request as ready for review September 1, 2025 06:55
@harsh-joshi99 harsh-joshi99 requested a review from a team as a code owner September 1, 2025 06:55
Copilot

This comment was marked as outdated.

Copy link
Contributor

@varadarajan-tw varadarajan-tw left a comment

Choose a reason for hiding this comment

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

✨ - Looks great @harsh-joshi99 . Just one comment that I'd like to get answer to before approving.

Comment on lines +928 to +935
if (!payload.email && !payload.phone_number && !payload.external_id) {
response.error = {
status: 400,
errortype: 'PAYLOAD_VALIDATION_FAILED',
errormessage: 'One of External ID, Phone Number or Email is required.'
}
return response
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for later - we can move this to conditionally required field configuration and remove this code.

*
* Ensures that at least one of `email`, `phone_number`, or `external_id` is present.
* If `phone_number` is provided, it validates and converts it to E.164 format using the `country_code`.
* If `email` is provided, it validates the email format.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment needs to be updated?

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds multistatus response support for the Klaviyo upsertProfile action, enabling individual error handling for each profile in a batch operation. The changes streamline the batching logic by removing the previous group-by-list-ID approach in favor of using batch keys, and add explicit email validation to support proper error reporting.

Key Changes

  • Implements MultiStatusResponse for granular error handling in batch operations
  • Removes complex list ID grouping logic in favor of simplified batch processing
  • Adds comprehensive payload validation with specific error messages for email and phone number validation

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/destination-actions/src/destinations/klaviyo/upsertProfile/index.ts Refactored performBatch method to use MultiStatusResponse with payload validation and simplified batch processing
packages/destination-actions/src/destinations/klaviyo/functions.ts Added validateProfilePayload function, removed groupByListId and processProfilesByGroup functions, exported multistatus helper functions
packages/destination-actions/src/destinations/klaviyo/types.ts Added validateProfilePayloadResult interface and removed GroupedProfiles interface
packages/destination-actions/src/destinations/klaviyo/upsertProfile/__tests__/index.test.ts Removed outdated tests for grouping logic and error handling that no longer apply
packages/destination-actions/src/destinations/klaviyo/__tests__/multistatus.test.ts Added comprehensive test suite for multistatus functionality with various validation scenarios

* @param payload - The profile payload to validate.
* @returns An object containing the validated payload or an error response if validation fails.
*/
export function validateProfilePayload(payload: Payload): validateProfilePayloadResult {
Copy link
Preview

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

The function documentation mentions email validation, but the actual implementation doesn't include email format validation. Either update the documentation to remove the email validation reference or implement the missing email validation logic.

Copilot uses AI. Check for mistakes.

@joe-ayoub-segment joe-ayoub-segment merged commit b88f43d into main Sep 9, 2025
14 checks passed
@joe-ayoub-segment joe-ayoub-segment deleted the STRATCONN-6139 branch September 9, 2025 11:17
@joe-ayoub-segment
Copy link
Contributor

Hi @harsh-joshi99 PR deployed

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

Successfully merging this pull request may close these issues.

4 participants