Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented May 7, 2025

Resolves #16494

Summary by CodeRabbit

  • New Features

    • Added support for sorting and limiting the number of lists fetched from Klaviyo.
    • Introduced pagination when browsing lists and profile IDs, improving navigation through large datasets.
  • Improvements

    • Updated action descriptions to reference the latest Klaviyo API documentation.
    • Enhanced summary messages to reflect multiple members added or lists fetched.
    • Improved handling of API responses for more consistent and user-friendly results.
  • Chores

    • Updated package dependencies to ensure compatibility with the latest Klaviyo API.

@vercel
Copy link

vercel bot commented May 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) May 7, 2025 4:21pm
pipedream-docs ⬜️ Ignored (Inspect) May 7, 2025 4:21pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) May 7, 2025 4:21pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 7, 2025

Walkthrough

The changes introduce cursor-based pagination for Klaviyo list and profile fetching, update action descriptions to reference current API documentation, and increment version numbers. The get-lists action now supports sorting, direction, and maximum results, utilizing a new asynchronous pagination method. The Klaviyo app’s options methods now return paginated results.

Changes

File(s) Change Summary
components/klaviyo/actions/add-member-to-list/add-member-to-list.mjs Updated description to link to current docs, incremented version, and revised summary message for multiple members.
components/klaviyo/actions/create-new-list/create-new-list.mjs Updated description to link to current docs and incremented version.
components/klaviyo/actions/get-lists/get-lists.mjs Added optional props for sorting and max results, switched to asynchronous pagination, updated summary message, and changed return value to an array of lists.
components/klaviyo/klaviyo.app.mjs Added cursor-based pagination to list/profile options, added helper for extracting cursor from URLs, introduced a generic async pagination generator, and updated methods to support pagination and new options signatures.
components/klaviyo/package.json Bumped package version and updated klaviyo-api dependency from ^11.0.0 to ^18.0.0.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PipedreamAction
    participant KlaviyoApp
    participant KlaviyoAPI

    User->>PipedreamAction: Request to fetch lists (with options)
    PipedreamAction->>KlaviyoApp: Call paginate() with sorting/maxResults
    loop Until maxResults or no more pages
        KlaviyoApp->>KlaviyoAPI: getLists(opts with pageCursor)
        KlaviyoAPI-->>KlaviyoApp: Return lists, next page link
        KlaviyoApp->>KlaviyoApp: Extract cursor from next link
    end
    KlaviyoApp-->>PipedreamAction: Yield lists array
    PipedreamAction-->>User: Return lists
Loading

Assessment against linked issues

Objective Addressed Explanation
Fetch and display the full list of Klaviyo options instead of being limited to 20 (#16494)

Suggested labels

action

Suggested reviewers

  • GTFalcao

Poem

A hop and a skip, pagination’s in play,
Now Klaviyo lists won’t just hop away.
With cursors and sorting, results overflow,
No more just twenty—fetch all in a row!
🐇✨

The rabbit is pleased, the options abound,
In Pipedream fields, full lists are now found!

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/klaviyo/actions/create-new-list/create-new-list.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

components/klaviyo/actions/get-lists/get-lists.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

components/klaviyo/actions/add-member-to-list/add-member-to-list.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

  • 1 others

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d1bbe8b and 4f04325.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • components/klaviyo/actions/add-member-to-list/add-member-to-list.mjs (2 hunks)
  • components/klaviyo/actions/create-new-list/create-new-list.mjs (1 hunks)
  • components/klaviyo/actions/get-lists/get-lists.mjs (1 hunks)
  • components/klaviyo/klaviyo.app.mjs (4 hunks)
  • components/klaviyo/package.json (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: pnpm publish
  • GitHub Check: Verify TypeScript components
🔇 Additional comments (18)
components/klaviyo/package.json (2)

3-3: Version increment reflects the feature enhancements

The package version has been appropriately bumped from 0.1.1 to 0.1.2, following semantic versioning guidelines as this PR introduces feature enhancements without breaking existing functionality.


17-17:

✅ Verification successful

Significant API version upgrade

The dependency on klaviyo-api has been updated from ^11.0.0 to ^18.0.0, which is a major version jump. This aligns with the PR objective to update to API version v2025-04-15.


🏁 Script executed:

#!/bin/bash
# Check what breaking changes might exist between these versions
npm view klaviyo-api@18.0.0 description
npm view klaviyo-api@18.0.0 homepage

Length of output: 171


I’d like to verify the exact breaking‐change notes in the v18.0.0 release. Let’s pull the changelog entry directly from GitHub:


🏁 Script executed:

#!/usr/bin/env bash
set -e
# Try main and master branches for CHANGELOG.md and extract version 18.0.0 section
for branch in main master; do
  url="https://raw.githubusercontent.com/klaviyo/klaviyo-api-node/$branch/CHANGELOG.md"
  status=$(curl -sI "$url" | head -n1)
  if echo "$status" | grep -q "200"; then
    echo "Using changelog from branch: $branch"
    curl -sL "$url" | grep -E -A5 "## \\[?18\\.0\\.0\\]?"
    exit 0
  fi
done
echo "Version 18.0.0 changelog entry not found"

Length of output: 869


Let’s pull the entire 18.0.0 release notes (not just the first few lines) to confirm there are no breaking changes:


🏁 Script executed:

#!/usr/bin/env bash
set -e
url="https://raw.githubusercontent.com/klaviyo/klaviyo-api-node/main/CHANGELOG.md"
# Print lines after "## [18.0.0]" up to—but not including—the next "## [" header
curl -sL "$url" | awk '
  $0 ~ /^## \[18\.0\.0\]/ {in_section=1; next}
  in_section && $0 ~ /^## \[/ {exit}
  in_section {print}
'

Length of output: 3076


Upgrade to klaviyo-api@^18.0.0 is safe (no breaking changes found)
Release notes for v18.0.0 (revision 2025-04-15) introduce new APIs (Web Feeds, Custom Metrics, Push Tokens) and enhancements (push-notification badge options, optional AMP field) but do not document any removals or breaking changes. This aligns with the PR’s objective. Please run your integration tests against the updated client to confirm everything works as expected.

• components/klaviyo/package.json (line 17): bumped klaviyo-api from ^11.0.0 to ^18.0.0

components/klaviyo/actions/create-new-list/create-new-list.mjs (1)

6-7: Documentation URL and version updated

The action's description now references the updated Klaviyo API documentation URL, changing from the v1-2 endpoint to the current reference endpoint. The version has been appropriately incremented from 0.0.2 to 0.0.3.

components/klaviyo/actions/add-member-to-list/add-member-to-list.mjs (2)

7-8: Documentation URL and version updated

The action's description now references the updated Klaviyo API documentation URL, changing from the v1-2 endpoint to the current reference endpoint. The version has been appropriately incremented from 1.0.0 to 1.0.1.


34-34: Improved summary message for multiple members

The summary message has been updated to handle both single and multiple member additions with "Member(s)" phrasing, making it more versatile.

components/klaviyo/actions/get-lists/get-lists.mjs (5)

6-7: Documentation URL and version updated

The action's description now references the updated Klaviyo API documentation URL, and the version has been appropriately incremented from 0.0.3 to 0.0.4.


11-41: Enhanced filtering options with new properties

Added three new optional input properties: sort, sortDirection, and maxResults, giving users more control over the lists they retrieve. The properties include sensible defaults and clear descriptions.


44-52: Implemented cursor-based pagination

The implementation now uses the new paginate method from the Klaviyo app object, which handles cursor-based pagination, applying the sort and direction parameters correctly by prefixing with "-" for descending order.


54-57: Efficient async result collection

The code now efficiently collects paginated results using an async iterator pattern, which is a more elegant approach for handling paginated data.


59-63: Improved summary message and return value

The summary message now dynamically reflects the number of lists with proper pluralization. The return value has been changed from the raw response body to just the array of list objects, which is more intuitive for consumers of this action.

components/klaviyo/klaviyo.app.mjs (8)

13-35: Well-implemented cursor-based pagination for lists

The updated implementation properly handles paginated list retrieval using cursor-based pagination, which is more efficient than offset-based pagination, especially for large datasets.


39-41: Improved label and description

The label and description are now more clear and concise.


48-49: Consistent pagination approach for profile IDs

The profile ID retrieval now uses the same cursor-based pagination approach as the lists, ensuring consistency across the API.

Also applies to: 59-60


67-68: Improved description

The description for the list name is clearer and more concise.


78-81: Enhanced getLists method with pagination support

The method now accepts optional parameters, allowing for more flexible API calls with pagination support.


92-97: Well-implemented cursor extraction utility

This utility method correctly extracts the cursor parameter from the next link URL and safely handles null URLs.


98-117: Excellent implementation of async pagination generator

The paginate method is well-designed as an async generator that:

  • Handles pagination logic gracefully
  • Yields items one by one
  • Respects the maximum limit parameter
  • Properly terminates when there are no more pages

One minor note: the method mutates the passed opts object by setting opts.pageCursor directly, which is fine in this context but worth noting if the same options object is reused elsewhere.


1-119:

❓ Verification inconclusive

Verify API version compatibility with the updated code

The PR title mentions updating to API version v2025-04-15, but the code doesn't explicitly reference this version. Ensure that these changes align with the Klaviyo API v2025-04-15 requirements.


🏁 Script executed:

#!/bin/bash
# Check Klaviyo API version in package.json
echo "Checking Klaviyo API version in package.json..."
cat components/klaviyo/package.json | grep klaviyo-api

# Check whether any documentation references mention the API version
echo "Checking for API version references in documentation..."
rg -i "v2025-04-15" --type md components/klaviyo/

Length of output: 361


Ensure Klaviyo API version alignment

It looks like you’ve bumped the API version in the PR title to v2025-04-15, but:

  • In components/klaviyo/package.json you’re still on "klaviyo-api": "^18.0.0".
  • There’s no explicit reference to v2025-04-15 in your SDK initialization or docs.

Please confirm that:

  • The klaviyo-api@^18.0.0 client you’ve imported defaults to v2025-04-15, or
  • You need to pass the new version when instantiating the SDK (e.g., via a version parameter), and update any endpoints if they’ve changed.

File to check:

  • components/klaviyo/klaviyo.app.mjs → sdk() method and import
✨ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link
Collaborator

@GTFalcao GTFalcao left a comment

Choose a reason for hiding this comment

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

LGTM!

@michelle0927 michelle0927 merged commit d2cce1d into master May 8, 2025
11 checks passed
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.

Klaviyo

3 participants