Skip to content

New Components - nextlead #16752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

New Components - nextlead #16752

wants to merge 3 commits into from

Conversation

michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented May 21, 2025

Resolves #16728

Summary by CodeRabbit

  • New Features
    • Added ability to search for leads by email in NextLead.
    • Introduced event triggers for new leads created, updated, or added to a list in NextLead.
  • Improvements
    • Enhanced NextLead integration with expanded API support for retrieving and searching leads.
  • Chores
    • Updated package dependencies and versioning.
    • Added sample event data for testing and demonstration purposes.

Copy link

vercel bot commented May 21, 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) Visit Preview May 21, 2025 5:59pm
pipedream-docs ⬜️ Ignored (Inspect) May 21, 2025 5:59pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) May 21, 2025 5:59pm

Copy link
Contributor

coderabbitai bot commented May 21, 2025

"""

Walkthrough

This update introduces and implements the NextLead integration, adding a reusable app module with HTTP request handling and API methods, polling source components for lead creation, updates, and list additions, as well as an action for searching leads by email. Supporting test event fixtures and a shared base for sources are included. Package metadata and dependencies are updated accordingly.

Changes

Files / Areas Changed Summary
components/nextlead/actions/search-leads/search-leads.mjs New action: "Search Leads" to find leads by email via the NextLead API.
components/nextlead/nextlead.app.mjs Refactored app module: adds HTTP request handling, API methods for searching, and retrieving leads.
components/nextlead/package.json Version bump to 0.1.0, adds @pipedream/platform dependency, fixes JSON.
components/nextlead/sources/common/base.mjs New base module for polling sources with shared NextLead app and timer prop.
components/nextlead/sources/new-lead-added-to-list/new-lead-added-to-list.mjs
components/nextlead/sources/new-lead-added-to-list/test-event.mjs
New polling source and test event for "New Lead Added to List".
components/nextlead/sources/new-lead-created/new-lead-created.mjs
components/nextlead/sources/new-lead-created/test-event.mjs
New polling source and test event for "New Lead Created".
components/nextlead/sources/new-lead-updated/new-lead-updated.mjs
components/nextlead/sources/new-lead-updated/test-event.mjs
New polling source and test event for "New Lead Updated".

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SearchLeadsAction
    participant NextLeadApp
    participant NextLeadAPI

    User->>SearchLeadsAction: Provide email to search
    SearchLeadsAction->>NextLeadApp: searchLeads({ email })
    NextLeadApp->>NextLeadAPI: POST /contacts/find with email
    NextLeadAPI-->>NextLeadApp: Lead search results
    NextLeadApp-->>SearchLeadsAction: Lead search results
    SearchLeadsAction-->>User: Summary and results
Loading
sequenceDiagram
    participant SourceComponent
    participant NextLeadApp
    participant NextLeadAPI
    participant Workflow

    SourceComponent->>NextLeadApp: getNewlyCreatedLeads / getNewlyUpdatedLeads / getContactsAddedToList
    NextLeadApp->>NextLeadAPI: GET respective endpoint
    NextLeadAPI-->>NextLeadApp: Lead data
    NextLeadApp-->>SourceComponent: Lead data
    loop For each lead
        SourceComponent->>Workflow: Emit event with lead and metadata
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement new-lead-created polling source (#16728)
Implement new-lead-updated polling source (#16728)
Implement new-lead-added-to-list polling source (#16728)
Implement search-leads action with required email prop, no optional props (#16728)

Poem

In the warren of code, a new lead appears,
With sources and actions, we hop without fears.
We search and we poll, with emails in tow,
NextLead now listens to data that flows.
So thump your soft foot, let your whiskers twitch—
For rabbits and leads, life's never a glitch!
🐇✨
"""

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/nextlead/sources/new-lead-added-to-list/new-lead-added-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 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:163:49)

components/nextlead/sources/new-lead-updated/new-lead-updated.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:163:49)

components/nextlead/sources/new-lead-created/new-lead-created.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:163:49)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between ed0deef and 4af550e.

📒 Files selected for processing (3)
  • components/nextlead/sources/new-lead-added-to-list/new-lead-added-to-list.mjs (1 hunks)
  • components/nextlead/sources/new-lead-created/new-lead-created.mjs (1 hunks)
  • components/nextlead/sources/new-lead-updated/new-lead-updated.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • components/nextlead/sources/new-lead-created/new-lead-created.mjs
  • components/nextlead/sources/new-lead-added-to-list/new-lead-added-to-list.mjs
  • components/nextlead/sources/new-lead-updated/new-lead-updated.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Lint Code Base
  • GitHub Check: Publish TypeScript components
✨ 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: 6

🧹 Nitpick comments (5)
components/nextlead/sources/new-lead-updated/new-lead-updated.mjs (1)

1-29: Consider adding documentation comments for maintainability

The component would benefit from JSDoc comments to document the expected structure of the lead objects and the behavior of the component methods.

 import common from "../common/base.mjs";
 import sampleEmit from "./test-event.mjs";
 
+/**
+ * NextLead source component that emits events when leads are updated
+ * @typedef {Object} Lead
+ * @property {string} id - The unique identifier of the lead
+ * @property {string} updated_at - The timestamp when the lead was updated
+ * @property {Object} - Other lead properties returned by the NextLead API
+ */
 export default {
   ...common,
   key: "nextlead-new-lead-updated",
   name: "New Lead Updated",
   description: "Emit new event when a lead is updated in NextLead. [See the documentation](https://dashboard.nextlead.app/en/api-documentation#edited)",
   version: "0.0.1",
   type: "source",
   dedupe: "unique",
   methods: {
+    /**
+     * Generate metadata for a lead update event
+     * @param {Lead} lead - The lead object from NextLead API
+     * @returns {Object} The event metadata
+     */
     generateMeta(lead) {
       return {
         id: lead.id,
         summary: "Lead Updated",
         ts: Date.parse(lead.updated_at),
       };
     },
   },
components/nextlead/nextlead.app.mjs (4)

11-21: Consider adding error handling and timeout settings.

The _makeRequest method provides a great foundation for centralized HTTP requests. However, it lacks error handling and request timeout settings.

_makeRequest({
  $ = this, path, ...opts
}) {
+  const timeout = 10000; // 10 seconds timeout
+  try {
    return axios($, {
      url: `${this._baseUrl()}${path}`,
      headers: {
        Authorization: `Bearer ${this.$auth.api_key}`,
      },
+     timeout,
      ...opts,
    });
+  } catch (error) {
+    const status = error.response?.status;
+    const errorMsg = error.response?.data?.message || error.message;
+    throw new Error(`NextLead API error (${status}): ${errorMsg}`);
+  }
},

22-28: Add JSDoc comments for improved documentation.

This method works correctly, but adding JSDoc comments would improve maintainability and developer experience.

+/**
+ * Search for leads by email or other criteria
+ * @param {Object} opts - Additional options to pass to the request
+ * @param {Object} [opts.data] - Search criteria to send in the request body
+ * @returns {Promise<Object>} The API response with matching leads
+ */
searchLeads(opts = {}) {
  return this._makeRequest({
    path: "/receive/contact/find-contact",
    method: "POST",
    ...opts,
  });
},

29-34: Add explicit HTTP method for clarity in GET endpoints.

While GET is the default HTTP method in axios, explicitly specifying it would improve code clarity and maintainability.

getNewlyCreatedLeads(opts = {}) {
  return this._makeRequest({
    path: "/polling/contact/user-created",
+   method: "GET",
    ...opts,
  });
},
getNewlyUpdatedLeads(opts = {}) {
  return this._makeRequest({
    path: "/polling/contact/user-edited",
+   method: "GET",
    ...opts,
  });
},
getContactsAddedToList(opts = {}) {
  return this._makeRequest({
    path: "/polling/email/added-to-list",
+   method: "GET",
    ...opts,
  });
},

Also applies to: 35-40, 41-46


22-46: Consider adding parameter validation for API methods.

The public API methods currently don't validate any required parameters. If certain parameters are necessary for the API endpoints to function correctly, adding validation would help catch issues early.

For example, if email is required for searchLeads:

searchLeads(opts = {}) {
+  const { data } = opts;
+  if (!data?.email) {
+    throw new Error("An email is required for searching leads");
+  }
  return this._makeRequest({
    path: "/receive/contact/find-contact",
    method: "POST",
    ...opts,
  });
},
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between cd3067c and ed0deef.

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

3-3: Bump version for new NextLead features
Upgrading from 0.0.1 to 0.1.0 correctly reflects the addition of new components and integrations.


14-16: Add dependencies and fix JSON structure
The publishConfig object is properly closed, and @pipedream/platform has been added as a dependency to support platform utilities in the new components. JSON syntax is valid.


18-18: Ensure closing brace for JSON
The final closing brace correctly terminates the package manifest.

components/nextlead/sources/new-lead-updated/test-event.mjs (1)

1-18: Verify test-event fixture for "New Lead Updated"
The sample event exports a realistic lead object structure to validate the source logic. Ensure fields align with API responses used in new-lead-updated.mjs.

components/nextlead/sources/new-lead-created/test-event.mjs (1)

1-19: Verify test-event fixture for "New Lead Created"
The sample event provides a valid lead payload for testing the new-lead-created source. Confirm consistency with the fields expected by the component.

components/nextlead/sources/new-lead-added-to-list/test-event.mjs (1)

1-16: Verify test-event fixture for "New Lead Added to List"
The exported object correctly models a contact addition event, including nested result data. Ensure this matches the shape returned by the NextLead API.

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

1-2: Correct imports for NextLead app and timer interface
Importing the NextLead app instance and the default polling interval from @pipedream/platform is accurate and necessary for source components.


4-14: Define common polling source base
The shared props object establishes nextlead and timer props for all polling sources. Configuration aligns with Pipedream conventions and the platform interface.

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

1-1: Good import choice for HTTP requests.

Using the axios import from @pipedream/platform is the recommended approach for making HTTP requests in Pipedream integrations.


8-10: LGTM: Clean method for base URL retrieval.

The _baseUrl() method follows proper conventions with the underscore prefix for private methods and cleanly retrieves the API URL from auth configuration.


1-48: Great foundation for the NextLead integration.

The overall structure of the app module is well-designed with a clean separation of concerns:

  • Private helper methods for infrastructure (_baseUrl, _makeRequest)
  • Public methods for specific API endpoints
  • Consistent parameter handling with options overriding

This foundation will make it easier to add more API methods in the future.

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!

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] nextlead
2 participants