Skip to content

17080 components leaddyno #17099

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

Merged
merged 3 commits into from
Jun 17, 2025
Merged

17080 components leaddyno #17099

merged 3 commits into from
Jun 17, 2025

Conversation

luancazarine
Copy link
Collaborator

@luancazarine luancazarine commented Jun 13, 2025

Resolves #17080

Summary by CodeRabbit

  • New Features
    • Added LeadDyno integration with actions to create affiliates, leads, purchases, and retrieve lead details.
    • Introduced event sources for new affiliates, leads, and purchases, supporting real-time event emission.
    • Included sample event data for testing and demonstration of event sources.
    • Enhanced LeadDyno app with comprehensive API methods and dynamic input options for seamless interaction.
  • Chores
    • Updated package version and dependencies for improved compatibility and functionality.

Sources
 - New Affiliates
 - New Leads
 - New Purchases

Actions
 - Create Affiliate
 - Create Lead
 - Create Purchase
 - Retrieve Lead
@luancazarine luancazarine linked an issue Jun 13, 2025 that may be closed by this pull request
Copy link
Contributor

coderabbitai bot commented Jun 13, 2025

Walkthrough

This update introduces a comprehensive LeadDyno integration, adding the main app implementation, actions for creating and retrieving affiliates, leads, and purchases, as well as polling sources for new affiliates, leads, and purchases. Supporting modules for event emission, test data, utility parsing, and a package dependency update are also included.

Changes

Files / Groups Change Summary
components/leaddyno/leaddyno.app.mjs Implements the LeadDyno app with API methods, prop definitions, and pagination utilities.
components/leaddyno/actions/create-affiliate/create-affiliate.mjs Adds action to create a new affiliate in LeadDyno.
components/leaddyno/actions/create-lead/create-lead.mjs Adds action to create a new lead in LeadDyno.
components/leaddyno/actions/create-purchase/create-purchase.mjs Adds action to create a new purchase in LeadDyno.
components/leaddyno/actions/retrieve-lead/retrieve-lead.mjs Adds action to retrieve a lead by ID from LeadDyno.
components/leaddyno/sources/common/base.mjs Adds a common base module for polling sources, handling event emission and state.
components/leaddyno/sources/new-affiliates/new-affiliates.mjs Adds polling source for new affiliates, extending the common base.
components/leaddyno/sources/new-affiliates/test-event.mjs Adds test event data for new affiliates source.
components/leaddyno/sources/new-leads/new-leads.mjs Adds polling source for new leads, extending the common base.
components/leaddyno/sources/new-leads/test-event.mjs Adds test event data for new leads source.
components/leaddyno/sources/new-purchases/new-purchases.mjs Adds polling source for new purchases, extending the common base.
components/leaddyno/sources/new-purchases/test-event.mjs Adds test event data for new purchases source.
components/leaddyno/common/utils.mjs Adds utility function to parse JSON strings safely into objects or arrays.
components/leaddyno/package.json Bumps version to 0.1.0 and adds @pipedream/platform dependency.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Action
    participant LeadDynoApp
    participant LeadDynoAPI

    User->>Action: Trigger (e.g., create affiliate/lead/purchase)
    Action->>LeadDynoApp: Call method (e.g., createAffiliate)
    LeadDynoApp->>LeadDynoAPI: HTTP request (POST/GET)
    LeadDynoAPI-->>LeadDynoApp: API response
    LeadDynoApp-->>Action: Return data
    Action-->>User: Export summary and response
Loading
sequenceDiagram
    participant Source
    participant BaseSource
    participant LeadDynoApp
    participant LeadDynoAPI
    participant DB

    Source->>BaseSource: run/deploy
    BaseSource->>DB: Get last processed ID
    BaseSource->>LeadDynoApp: Paginate API (list* methods)
    LeadDynoApp->>LeadDynoAPI: HTTP GET
    LeadDynoAPI-->>LeadDynoApp: API data
    LeadDynoApp-->>BaseSource: Return items
    BaseSource->>DB: Update last processed ID
    BaseSource-->>Source: Emit new events
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement LeadDyno integration with REST API methods (#17080)
Provide actions for creating/retrieving affiliates, leads, purchases (#17080)
Implement polling sources for new affiliates, leads, purchases (#17080)
Include test data for sources and update dependencies (#17080)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Suggested labels

action, trigger / source

Poem

🐇 In fields of code where data flows,
LeadDyno's magic swiftly grows.
Affiliates, leads, and purchases bright,
Hop into action, day and night.
Polling sources watch and cheer,
Bringing new events ever near.
CodeRabbit smiles, the path is clear! 🥕✨

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/leaddyno/actions/create-purchase/create-purchase.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:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:201:49)

components/leaddyno/common/utils.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:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:201:49)

✨ 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

vercel bot commented Jun 13, 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 Jun 16, 2025 7:49pm
pipedream-docs ⬜️ Ignored (Inspect) Jun 16, 2025 7:49pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Jun 16, 2025 7:49pm

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

♻️ Duplicate comments (1)
components/leaddyno/leaddyno.app.mjs (1)

44-51: Same dropdown issue for “Affiliate” property

Make the same { label, value } change here to render options correctly.

🧹 Nitpick comments (7)
components/leaddyno/package.json (2)

3-3: Consider tagging releases with conventional semver increments

Jumping straight from 0.0.x to 0.1.0 is fine, but please confirm this reflects a breaking‐change or new-feature release per semver.


14-17: Lock the platform dependency to an exact patch to guarantee reproducible builds

Using a caret (^3.1.0) lets every CI run pull newer 3.x releases, which might introduce untested behaviour. Pinning ("3.1.0") or using an exact range ("~3.1.0") keeps builds deterministic.

components/leaddyno/sources/new-purchases/new-purchases.mjs (1)

17-19: Guard against undefined fields in summary

If purchase_code or purchase_amount is missing the summary renders “undefined”. Consider a fallback:

-return `New Purchase: ${item.purchase_code} - $${item.purchase_amount}`;
+const code = item.purchase_code ?? item.id ?? "unknown";
+const amount = item.purchase_amount ?? 0;
+return `New Purchase: ${code} – $${amount}`;
components/leaddyno/sources/new-affiliates/new-affiliates.mjs (1)

17-19: Guard against undefined email in summary

item.email can be null/undefined on some LeadDyno accounts (e.g., deleted or partially-created affiliates).
A short fallback avoids rendering “New Affiliate: undefined”.

-      return `New Affiliate: ${item.email}`;
+      return `New Affiliate: ${item?.email ?? "unknown"}`;
components/leaddyno/actions/create-lead/create-lead.mjs (1)

86-102: Strip undefined fields before POSTing

undefined properties are still serialised by axios/fetch as the string "undefined" in some environments, leading to 422/400 errors from the API.
Filter them out before the request:

-      data: {
-        email: this.email,
-        first_name: this.firstName,
-        last_name: this.lastName,
-        address1: this.address1,
-        address2: this.address2,
-        city: this.city,
-        state: this.state,
-        zipcode: this.zipcode,
-        country: this.country,
-        phone: this.phone,
-        affiliate: this.affiliate,
-        custom_status: this.customStatus,
-      },
+      data: Object.fromEntries(
+        Object.entries({
+          email: this.email,
+          first_name: this.firstName,
+          last_name: this.lastName,
+          address1: this.address1,
+          address2: this.address2,
+          city: this.city,
+          state: this.state,
+          zipcode: this.zipcode,
+          country: this.country,
+          phone: this.phone,
+          affiliate: this.affiliate,
+          custom_status: this.customStatus,
+        }).filter(([, v]) => v !== undefined),
+      ),
components/leaddyno/actions/create-affiliate/create-affiliate.mjs (1)

60-71: Mirror payload-cleaning logic across actions

For consistency and to avoid "undefined" string values, apply the same Object.fromEntries(...filter()) approach used in the Create Lead refactor.

components/leaddyno/sources/new-leads/new-leads.mjs (1)

17-19: Guard against missing e-mail in summary generation

item.email may be null/undefined for anonymous leads, producing “New Lead: undefined”.
Add a sensible fallback to keep the UI tidy.

-      return `New Lead: ${item.email}`;
+      return `New Lead: ${item.email ?? item.id ?? "unknown"}`;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8832bfe and ad9d922.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (13)
  • components/leaddyno/actions/create-affiliate/create-affiliate.mjs (1 hunks)
  • components/leaddyno/actions/create-lead/create-lead.mjs (1 hunks)
  • components/leaddyno/actions/create-purchase/create-purchase.mjs (1 hunks)
  • components/leaddyno/actions/retrieve-lead/retrieve-lead.mjs (1 hunks)
  • components/leaddyno/leaddyno.app.mjs (1 hunks)
  • components/leaddyno/package.json (2 hunks)
  • components/leaddyno/sources/common/base.mjs (1 hunks)
  • components/leaddyno/sources/new-affiliates/new-affiliates.mjs (1 hunks)
  • components/leaddyno/sources/new-affiliates/test-event.mjs (1 hunks)
  • components/leaddyno/sources/new-leads/new-leads.mjs (1 hunks)
  • components/leaddyno/sources/new-leads/test-event.mjs (1 hunks)
  • components/leaddyno/sources/new-purchases/new-purchases.mjs (1 hunks)
  • components/leaddyno/sources/new-purchases/test-event.mjs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
  • GitHub Check: pnpm publish
  • GitHub Check: Lint Code Base
🔇 Additional comments (6)
components/leaddyno/sources/new-affiliates/test-event.mjs (1)

1-26: LGTM – good anonymised fixture

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

75-79: Verify the query-param name for the API key

LeadDyno docs usually accept api_key, not key. If incorrect, every request will 401.

components/leaddyno/sources/new-leads/test-event.mjs (1)

1-27: Fixture looks good

components/leaddyno/sources/new-purchases/test-event.mjs (1)

1-40: Fixture looks good

The sample structure matches LeadDyno’s purchase schema and provides realistic payloads for local testing.

components/leaddyno/sources/common/base.mjs (1)

29-33: Early break may skip newer items on subsequent pages

paginate usually streams page-by-page in descending order (newest first).
If page 1 contains one old item, the break exits the loop before even requesting page 2, potentially missing newer records that simply didn’t fit into page 1.

Consider continuing iteration but continue when item.id <= lastId.
Alternatively, build the stop-condition into the paginator itself (if supported) to avoid extra requests.

components/leaddyno/actions/retrieve-lead/retrieve-lead.mjs (1)

20-26: Great – lean action with clear summary

The action cleanly delegates to the app, exports a useful summary, and returns the raw response. No issues spotted here. 👍

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: 1

🧹 Nitpick comments (2)
components/leaddyno/common/utils.mjs (2)

4-15: Consider deep parsing & DRYing the array branch

Right now, items that themselves contain JSON-encoded arrays/objects inside strings are parsed only one level deep.
A small recursive helper (or a single call to parseObject inside the map) keeps the implementation concise and uniformly handles nested structures.

-    return obj.map((item) => {
-      if (typeof item === "string") {
-        try {
-          return JSON.parse(item);
-        } catch (e) {
-          return item;
-        }
-      }
-      return item;
-    });
+    return obj.map(parseObject);

16-23: Nit: narrow the try/catch and avoid duplicated logic

Parsing logic is duplicated for array items and single strings. Extracting a tiny safeJsonParse(str) function reduces repetition and centralizes error handling.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ad9d922 and 18f6f6c.

📒 Files selected for processing (2)
  • components/leaddyno/actions/create-purchase/create-purchase.mjs (1 hunks)
  • components/leaddyno/common/utils.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/leaddyno/actions/create-purchase/create-purchase.mjs

Copy link
Collaborator

@michelle0927 michelle0927 left a comment

Choose a reason for hiding this comment

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

LGTM!

@luancazarine luancazarine merged commit fa2bc6d into master Jun 17, 2025
11 checks passed
@luancazarine luancazarine deleted the 17080-components-leaddyno branch June 17, 2025 14:42
joy-chanboop pushed a commit to joy-chanboop/pipedream that referenced this pull request Jun 21, 2025
* [Components] leaddyno PipedreamHQ#17080
Sources
 - New Affiliates
 - New Leads
 - New Purchases

Actions
 - Create Affiliate
 - Create Lead
 - Create Purchase
 - Retrieve Lead

* pnpm update

* some adjusts
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] leaddyno
2 participants