Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented May 28, 2025

Resolves #13259

Summary by CodeRabbit

  • New Features

    • Introduced a WhatConverts integration with actions and sources to find leads, emit events for new leads added, and emit events when leads are updated.
    • Added support for filtering and querying leads with various parameters and pagination.
    • Provided sample event data for testing new and updated lead sources.
  • Chores

    • Updated package metadata and dependencies for the WhatConverts component.
    • Removed obsolete files and improved internal structure for maintainability.

@vercel
Copy link

vercel bot commented May 28, 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 28, 2025 9:06pm
pipedream-docs ⬜️ Ignored (Inspect) May 28, 2025 9:06pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) May 28, 2025 9:06pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 28, 2025

Walkthrough

This update introduces a new WhatConverts integration, including an app definition, base components for polling sources, two event sources for new and updated leads, a Find Lead action, and test event data. The package metadata is updated, and obsolete files are removed. The integration enables querying and reacting to lead data from WhatConverts.

Changes

File(s) Change Summary
components/whatconverts/whatconverts.app.mjs New app module for WhatConverts API integration, including property definitions and API methods.
components/whatconverts/app/whatconverts.app.ts Deleted obsolete app definition file.
components/whatconverts/actions/find-lead/find-lead.mjs Added new "Find Lead" action for querying leads with multiple filtering options.
components/whatconverts/sources/common/base.mjs Added common base source for polling and processing lead data.
components/whatconverts/sources/new-lead-added/new-lead-added.mjs Added "New Lead Added" source for emitting events on new leads.
components/whatconverts/sources/new-lead-added/test-event.mjs Added test event data for "New Lead Added" source.
components/whatconverts/sources/updated-lead/updated-lead.mjs Added "Updated Lead" source for emitting events on updated leads.
components/whatconverts/sources/updated-lead/test-event.mjs Added test event data for "Updated Lead" source.
components/whatconverts/package.json Updated package metadata, version, entry point, and dependencies.
components/whatconverts/.gitignore Deleted .gitignore file; files are no longer ignored in this directory.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WhatConvertsApp
    participant WhatConvertsAPI

    User->>WhatConvertsApp: Trigger "Find Lead" Action
    WhatConvertsApp->>WhatConvertsAPI: listLeads(params)
    WhatConvertsAPI-->>WhatConvertsApp: Return leads array
    WhatConvertsApp-->>User: Return found leads

    User->>NewLeadSource: Poll for new leads
    NewLeadSource->>WhatConvertsApp: listLeads(params)
    WhatConvertsApp->>WhatConvertsAPI: listLeads(params)
    WhatConvertsAPI-->>WhatConvertsApp: Return leads
    WhatConvertsApp-->>NewLeadSource: Return leads
    NewLeadSource-->>User: Emit new lead events

    User->>UpdatedLeadSource: Poll for updated leads
    UpdatedLeadSource->>WhatConvertsApp: listLeads(params)
    WhatConvertsApp->>WhatConvertsAPI: listLeads(params)
    WhatConvertsAPI-->>WhatConvertsApp: Return leads
    WhatConvertsApp-->>UpdatedLeadSource: Return leads
    UpdatedLeadSource-->>User: Emit updated lead events
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement new-lead-added polling source with required and optional props (#13259)
Implement updated-lead polling source with required and optional props (#13259)
Implement find-lead action with 'leadId' and optional 'criteria' prop (#13259) The action supports various filters but does not implement a 'leadId' prop as required.

Poem

A bunny hops through leads anew,
With actions, sources—quite a few!
Find, fetch, and filter, all in stride,
New and updated leads, none to hide.
WhatConverts now is in the mix,
🐇 CodeRabbit’s clever integration tricks!

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/whatconverts/actions/find-lead/find-lead.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 Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
at #link (node:internal/modules/esm/module_job:170:49)

components/whatconverts/sources/common/base.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 Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
at #link (node:internal/modules/esm/module_job:170:49)

components/whatconverts/sources/new-lead-added/test-event.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 Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
at #link (node:internal/modules/esm/module_job:170:49)

  • 4 others
✨ 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.

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
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (7)
components/whatconverts/sources/updated-lead/test-event.mjs (1)

10-10: Verify timestamp differentiation for updated lead test data.

The test data has date_created and last_updated with identical times ("2025-05-28T19:19:51Z" and "2025-05-28T19:20:03Z"). For an "updated lead" test event, consider making the last_updated timestamp significantly different from date_created to better demonstrate a lead that was genuinely updated after initial creation.

-    "last_updated": "2025-05-28T19:20:03Z",
+    "last_updated": "2025-05-29T14:30:15Z",

Also applies to: 35-35

components/whatconverts/sources/new-lead-added/test-event.mjs (1)

1-55: Differentiate test data between new and updated lead sources.

The test event data is identical to the updated-lead test event. For a "new lead added" source, the test data should better represent a newly created lead rather than an updated one.

Consider these changes to make it more representative of a new lead:

-    "last_updated": "2025-05-28T19:20:03Z",
+    "last_updated": "2025-05-28T19:19:51Z",

Additionally, consider using a different lead_id to distinguish between the two test scenarios:

-    "lead_id": 178849242,
+    "lead_id": 178849243,
components/whatconverts/sources/updated-lead/updated-lead.mjs (1)

23-30: Consider more robust ID generation for event deduplication.

The current ID generation concatenates lead_id and timestamp, which could potentially create collisions if multiple updates occur within the same millisecond.

Consider a more robust approach:

    generateMeta(item) {
      const ts = Date.parse(item.last_updated);
      return {
-        id: `${item.lead_id}${ts}`,
+        id: `${item.lead_id}-${ts}`,
        summary: `Lead Updated with ID: ${item.lead_id}`,
        ts,
      };
    },

This adds a separator to make the ID more readable and less prone to parsing ambiguity.

components/whatconverts/whatconverts.app.mjs (3)

12-28: Improve error handling in options loader.

The options loader catches all errors but doesn't log them, making debugging difficult. Consider adding error logging for better observability.

        } catch {
+         console.error("Failed to load accounts:", error);
          return [];
        }

35-54: Improve error handling in profileId options loader.

Same issue as the accountId options loader - errors are silently caught without logging.

        } catch {
+         console.error("Failed to load profiles:", error);
          return [];
        }

110-135: Review pagination logic for potential infinite loop.

The pagination logic relies on response.total_pages to determine when to stop. If the API returns an invalid total_pages value or if there's an issue with the response structure, this could potentially cause issues.

Consider adding additional safeguards:

        hasMore = params.page_number < response.total_pages;
+       hasMore = hasMore && items && items.length > 0;
        params.page_number++;
components/whatconverts/sources/common/base.mjs (1)

39-44: Consider adding type safety for timestamp values.

The timestamp storage and retrieval could benefit from type validation to prevent potential issues with invalid timestamp values.

    _getLastTs() {
-     return this.db.get("lastTs") || 0;
+     const lastTs = this.db.get("lastTs");
+     return typeof lastTs === 'number' ? lastTs : 0;
    },
    _setLastTs(lastTs) {
+     if (typeof lastTs !== 'number' || isNaN(lastTs)) {
+       throw new Error("Invalid timestamp value");
+     }
      this.db.set("lastTs", lastTs);
    },
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between acb55d0 and 639eaae.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • components/whatconverts/.gitignore (0 hunks)
  • components/whatconverts/actions/find-lead/find-lead.mjs (1 hunks)
  • components/whatconverts/app/whatconverts.app.ts (0 hunks)
  • components/whatconverts/package.json (1 hunks)
  • components/whatconverts/sources/common/base.mjs (1 hunks)
  • components/whatconverts/sources/new-lead-added/new-lead-added.mjs (1 hunks)
  • components/whatconverts/sources/new-lead-added/test-event.mjs (1 hunks)
  • components/whatconverts/sources/updated-lead/test-event.mjs (1 hunks)
  • components/whatconverts/sources/updated-lead/updated-lead.mjs (1 hunks)
  • components/whatconverts/whatconverts.app.mjs (1 hunks)
💤 Files with no reviewable changes (2)
  • components/whatconverts/app/whatconverts.app.ts
  • components/whatconverts/.gitignore
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Verify TypeScript components
  • GitHub Check: pnpm publish
  • GitHub Check: Lint Code Base
  • GitHub Check: Publish TypeScript components
🔇 Additional comments (9)
components/whatconverts/package.json (3)

3-3: LGTM! Version bump is appropriate for new integration.

The version update from 0.0.2 to 0.1.0 correctly indicates the addition of new functionality for this WhatConverts integration.


5-5: LGTM! Main entry point change aligns with new structure.

The change from "dist/app/whatconverts.app.mjs" to "whatconverts.app.mjs" correctly reflects the new app structure without compiled distribution files.


15-17: LGTM! Platform dependency addition is correct.

The addition of "@pipedream/platform": "^3.0.3" dependency is appropriate for new Pipedream components and follows the expected pattern.

components/whatconverts/sources/updated-lead/updated-lead.mjs (2)

14-16: LGTM! Resource function properly defined.

The getResourceFn() correctly returns the listLeads method from the WhatConverts app, which is appropriate for polling lead updates.


17-19: LGTM! Timestamp field correctly configured.

Using "last_updated" as the timestamp field is appropriate for tracking lead updates.

components/whatconverts/sources/new-lead-added/new-lead-added.mjs (1)

1-29: Well-structured source component implementation.

The component correctly extends the common base and implements all required abstract methods. The structure follows Pipedream conventions with proper metadata and method implementations.

components/whatconverts/whatconverts.app.mjs (1)

78-89: Secure authentication implementation.

The authentication using basic auth with API token and secret is correctly implemented. The credentials are properly accessed from $auth context.

components/whatconverts/sources/common/base.mjs (2)

59-87: Robust event processing logic with good timestamp filtering.

The event processing logic correctly handles timestamp filtering, pagination, and early termination for sorted data. The implementation properly updates the maximum timestamp and emits events with generated metadata.


88-96: Good use of abstract methods with clear error messages.

The abstract methods throw clear configuration errors that will help developers understand what needs to be implemented in subclasses.

Copy link
Collaborator

@luancazarine luancazarine left a comment

Choose a reason for hiding this comment

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

Hi @michelle0927, LGTM! Ready for QA!

@michelle0927 michelle0927 merged commit 0b96440 into master Jun 2, 2025
11 checks passed
@michelle0927 michelle0927 deleted the issue-13259 branch June 2, 2025 14:25
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.

[Components] whatconverts

3 participants