Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Sep 4, 2025

Resolves #18168

Summary by CodeRabbit

  • New Features

    • Added Merge Deals action for combining two deals.
    • Added Merge Persons action for combining two people.
    • Introduced New Event (Instant) source with filters for event action and object.
  • Bug Fixes

    • Improved event ID handling for webhooks to prevent missing-data errors and ensure reliable emissions.
  • Chores

    • Bumped Pipedrive package to 0.10.0.
    • Updated versions for instant sources: New Deal, New Person, Updated Deal, Updated Lead, Updated Person.

@vercel
Copy link

vercel bot commented Sep 4, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
pipedream-docs Ignored Ignored Sep 4, 2025 5:43pm
pipedream-docs-redirect-do-not-edit Ignored Ignored Sep 4, 2025 5:43pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 4, 2025

Walkthrough

Introduces two new Pipedrive actions to merge deals and persons, adds a new instant source for general webhook events, updates common source ID construction for safer fallback, and bumps versions for several existing sources and the package.

Changes

Cohort / File(s) Summary
New actions: Merge operations
components/pipedrive/actions/merge-deals/merge-deals.mjs, components/pipedrive/actions/merge-persons/merge-persons.mjs
Adds actions to merge deals and persons via Pipedrive API (DealsApi.mergeDeals, PersonsApi.mergePersons); defines required source/target IDs; returns API data and sets execution summary.
New source: Webhook events
components/pipedrive/sources/new-event-instant/new-event-instant.mjs
Adds instant source for webhook events with selectable event_action and event_object (supports "*"); provides summary “New {action}.{entity} event”; dedupe unique.
Common base: Emission robustness
components/pipedrive/sources/common/base.mjs
Adjusts emitted event ID to use `body.data?.id
Version bumps
components/pipedrive/package.json, components/pipedrive/sources/new-deal-instant/new-deal-instant.mjs, components/pipedrive/sources/new-person-instant/new-person-instant.mjs, components/pipedrive/sources/updated-deal-instant/updated-deal-instant.mjs, components/pipedrive/sources/updated-lead-instant/updated-lead-instant.mjs, components/pipedrive/sources/updated-person-instant/updated-person-instant.mjs
Bumps package to 0.10.0; updates source versions only (no functional changes).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Action as Pipedrive Action
  participant SDK as pipedriveApp API Client
  participant PD as Pipedrive API

  rect rgba(220,245,255,0.5)
    note over User,Action: Merge Deals / Merge Persons
    User->>Action: Run with {sourceId, targetId}
    Action->>SDK: api("<Entity>Api")
    Action->>PD: merge<Entities>({ id: sourceId, merge_with_id: targetId })
    PD-->>Action: { data }
    Action-->>User: Export summary + return data
  end
Loading
sequenceDiagram
  autonumber
  participant PD as Pipedrive Webhooks
  participant Source as New Event (Instant) Source
  participant Base as Common Base
  participant App as Subscriber

  rect rgba(240,255,240,0.6)
    note over PD,Source: Webhook delivery
    PD-->>Source: POST { meta: { action, entity, id }, data? }
    Source->>Base: getExtraData() => { event_action, event_object }
    Source->>Base: getSummary(body) => "New action.entity event"
    Base-->>App: emit { id: (data.id || meta.id)-ts, summary, ts }
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Assessment against linked issues

Objective Addressed Explanation
New Event source with webhooks using . for all events (#18168) Source supports "" for action/object but default/enforcement of ".*" when creating webhook is unclear.
Action: Merge Contacts (Persons) (#18168)
Action: Merge Deals (#18168)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Adjusted emitted event ID fallback in common base (components/pipedrive/sources/common/base.mjs) Not explicitly requested in the issue; functionally affects all sources. Likely a robustness improvement but outside stated objectives.

Suggested labels

User submitted

Suggested reviewers

  • luancazarine
  • jcortes

Poem

A rabbit taps keys with nimble zeal,
Merging persons, deals—what a squeal!
Webhooks hop in, events cascade,
IDs safe even when data’s frayed.
Version bumps sprinkled like morning dew—
Thump-thump, ship it! Onward we hop, anew. 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue-18168

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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 (10)
components/pipedrive/sources/updated-person-instant/updated-person-instant.mjs (2)

21-23: Harden getSummary against missing body.data.

Base now tolerates missing body.data; getSummary should too to avoid Cannot read properties of undefined.

Apply:

-    getSummary(body) {
-      return `Person successfully updated: ${body.data.id}`;
-    },
+    getSummary(body) {
+      const id = body?.data?.id ?? body?.meta?.id ?? "unknown";
+      return `Person successfully updated: ${id}`;
+    },

24-30: Guard parseData for cases with no data payload.

If webhooks arrive without body.data, parseData may not have the ID it needs. Consider early-returning raw body or skipping custom field enrichment when no ID is present.

components/pipedrive/sources/updated-lead-instant/updated-lead-instant.mjs (2)

21-23: Avoid potential crash when body.data is absent.

Mirror base behavior with a safe fallback.

Apply:

-    getSummary(body) {
-      return `Lead successfully updated: ${body.data.id}`;
-    },
+    getSummary(body) {
+      const id = body?.data?.id ?? body?.meta?.id ?? "unknown";
+      return `Lead successfully updated: ${id}`;
+    },

24-29: Confirm custom fields source for Leads.

Using getDealCustomFields for a lead looks suspicious. If a getLeadCustomFields helper exists (or leads use a different schema), switch to it; otherwise add a comment explaining the intentional reuse.

-        fn: this.pipedrive.getDealCustomFields,
+        // If available, prefer a lead-specific custom fields fetcher
+        fn: this.pipedrive.getLeadCustomFields ?? this.pipedrive.getDealCustomFields,
components/pipedrive/sources/new-deal-instant/new-deal-instant.mjs (1)

20-22: Make summary resilient to missing data.

Use optional chaining and meta fallback.

-    getSummary(body) {
-      return `New Deal successfully created: ${body.data.id}`;
-    },
+    getSummary(body) {
+      const id = body?.data?.id ?? body?.meta?.id ?? "unknown";
+      return `New Deal successfully created: ${id}`;
+    },
components/pipedrive/sources/new-person-instant/new-person-instant.mjs (1)

20-22: Handle missing body.data in summary.

Align with base’s safer ID logic.

-    getSummary(body) {
-      return `New Person successfully created: ${body.data.id}`;
-    },
+    getSummary(body) {
+      const id = body?.data?.id ?? body?.meta?.id ?? "unknown";
+      return `New Person successfully created: ${id}`;
+    },
components/pipedrive/sources/common/base.mjs (1)

42-42: Safer ID and timestamp handling for v2 webhooks

Good fallback. Two optional hardening tweaks:

  • Prefer entity_id before event id to keep grouping by entity when data is null: meta.entity_id exists in v2. (pipedrive.readme.io)
  • Make timestamp parsing resilient to both RFC3339 strings and legacy UNIX seconds (notably v2 user webhooks pre–June 30, 2025). (developers.pipedrive.com)

Apply:

-    this.$emit(await this.parseData(body), {
-      id: `${body.data?.id || body.meta?.id}-${ts}`,
-      summary: this.getSummary(body),
-      ts,
-    });
+    const rawTs = body?.meta?.timestamp;
+    const tsParsed = typeof rawTs === "number"
+      ? rawTs * 1000
+      : Date.parse(rawTs || "");
+    const tsSafe = Number.isFinite(tsParsed) ? tsParsed : Date.now();
+
+    const entityId = body?.data?.id ?? body?.meta?.entity_id;
+    const eventId = body?.meta?.id; // UUID in v2
+
+    this.$emit(await this.parseData(body), {
+      id: `${entityId ?? eventId}-${tsSafe}`,
+      summary: this.getSummary(body),
+      ts: tsSafe,
+    });
components/pipedrive/sources/new-event-instant/new-event-instant.mjs (2)

7-7: Link to v2 docs instead of v1

This source targets webhooks v2; point users to the v2 guide. (pipedrive.readme.io)

-  description: "Emit new event when a new webhook event is received. [See the documentation](https://developers.pipedrive.com/docs/api/v1/Webhooks#addWebhook)",
+  description: "Emit new event when a new webhook event is received. See the Webhooks v2 guide.",

Additional (outside diff): consider linking to the v2 guide URL used in docs.


12-41: Default to “.” to match issue requirement and v2 pattern

Setting defaults improves UX and aligns with “receive notifications for all events”. v2 supports create/change/delete and listed objects incl. lead/user. (pipedrive.readme.io)

     eventAction: {
       type: "string",
       label: "Event Action",
       description: "The type of action to receive notifications about. Wildcard (*) will match all supported actions.",
+      default: "*",
       options: [
         "*",
         "create",
         "change",
         "delete",
       ],
     },
     eventObject: {
       type: "string",
       label: "Event Object",
       description: "The type of object to receive notifications about. Wildcard (*) will match all supported objects.",
+      default: "*",
       options: [
         "*",
         "activity",
         "deal",
         "lead",
         "note",
         "organization",
         "person",
         "pipeline",
         "product",
         "stage",
         "user",
       ],
     },
components/pipedrive/actions/merge-deals/merge-deals.mjs (1)

6-6: Docstring is fine; optionally mention target precedence

You may mirror Persons wording to note the target’s data is prioritized on conflicts for consistency. (github.com)

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cc81de2 and 0022d29.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • components/pipedrive/actions/merge-deals/merge-deals.mjs (1 hunks)
  • components/pipedrive/actions/merge-persons/merge-persons.mjs (1 hunks)
  • components/pipedrive/package.json (1 hunks)
  • components/pipedrive/sources/common/base.mjs (1 hunks)
  • components/pipedrive/sources/new-deal-instant/new-deal-instant.mjs (1 hunks)
  • components/pipedrive/sources/new-event-instant/new-event-instant.mjs (1 hunks)
  • components/pipedrive/sources/new-person-instant/new-person-instant.mjs (1 hunks)
  • components/pipedrive/sources/updated-deal-instant/updated-deal-instant.mjs (1 hunks)
  • components/pipedrive/sources/updated-lead-instant/updated-lead-instant.mjs (1 hunks)
  • components/pipedrive/sources/updated-person-instant/updated-person-instant.mjs (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2024-10-10T19:18:27.998Z
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#14265
File: components/the_magic_drip/sources/common.mjs:35-43
Timestamp: 2024-10-10T19:18:27.998Z
Learning: In `components/the_magic_drip/sources/common.mjs`, when processing items in `getAndProcessData`, `savedIds` is intentionally updated with IDs of both emitted and non-emitted items to avoid emitting retroactive events upon first deployment and ensure only new events are emitted as they occur.

Applied to files:

  • components/pipedrive/sources/common/base.mjs
📚 Learning: 2024-10-08T15:33:38.240Z
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#12697
File: components/salesforce_rest_api/sources/common-webhook-methods.mjs:1-71
Timestamp: 2024-10-08T15:33:38.240Z
Learning: The `common-webhook-methods.mjs` object is designed to be extended, similar to an abstract class, and intentionally does not implement certain methods like `generateWebhookMeta` and `getEventType` to enforce implementation in subclasses.

Applied to files:

  • components/pipedrive/sources/new-event-instant/new-event-instant.mjs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components
  • GitHub Check: pnpm publish
  • GitHub Check: Lint Code Base
🔇 Additional comments (7)
components/pipedrive/package.json (1)

3-3: Package version bump looks consistent with new components.

Confirm CHANGELOG and release notes reflect 0.10.0 and that any publishing automation picks up the new actions/sources.

components/pipedrive/sources/updated-person-instant/updated-person-instant.mjs (1)

10-10: Version bump only — OK.

components/pipedrive/sources/updated-lead-instant/updated-lead-instant.mjs (1)

10-10: Version bump only — OK.

components/pipedrive/sources/new-deal-instant/new-deal-instant.mjs (1)

9-9: Version bump only — OK.

components/pipedrive/sources/new-person-instant/new-person-instant.mjs (1)

9-9: Version bump only — OK.

components/pipedrive/sources/updated-deal-instant/updated-deal-instant.mjs (1)

10-10: Version bump only — LGTM

No functional changes. Safe patch release.

components/pipedrive/sources/new-event-instant/new-event-instant.mjs (1)

51-53: Summary format — LGTM

v2 uses meta.action and meta.entity; this is accurate. (pipedrive.readme.io)

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!

@vunguyenhung vunguyenhung merged commit ef68123 into master Sep 6, 2025
10 checks passed
@vunguyenhung vunguyenhung deleted the issue-18168 branch September 6, 2025 07:30
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.

Pipedrive

4 participants