-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
base: master
Are you sure you want to change the base?
New Components - nextlead #16752
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
""" WalkthroughThis 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
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
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
Assessment against linked issues
Poem
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
components/nextlead/sources/new-lead-added-to-list/new-lead-added-to-list.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/nextlead/sources/new-lead-updated/new-lead-updated.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/nextlead/sources/new-lead-created/new-lead-created.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
⏰ Context from checks skipped due to timeout of 90000ms (3)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 maintainabilityThe 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
⛔ 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 from0.0.1
to0.1.0
correctly reflects the addition of new components and integrations.
14-16
: Add dependencies and fix JSON structure
ThepublishConfig
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 innew-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 nestedresult
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 sharedprops
object establishesnextlead
andtimer
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.
components/nextlead/sources/new-lead-created/new-lead-created.mjs
Outdated
Show resolved
Hide resolved
components/nextlead/sources/new-lead-created/new-lead-created.mjs
Outdated
Show resolved
Hide resolved
components/nextlead/sources/new-lead-added-to-list/new-lead-added-to-list.mjs
Show resolved
Hide resolved
components/nextlead/sources/new-lead-updated/new-lead-updated.mjs
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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!
Resolves #16728
Summary by CodeRabbit