Skip to content

Conversation

@anush
Copy link

@anush anush commented Nov 5, 2025

WHY

The order.* Xola webhooks are deprecated will be discontinued in 2026.

The purchase.* webhooks are their successor and offer much richer data including support for audits.

Summary by CodeRabbit

  • New Features

    • Added "New Purchase Created (Instant)", "Purchase Canceled (Instant)", and "Purchase Updated (Instant)" webhook sources with sample/test event payloads.
  • Chores

    • Deprecated "New Order Created (Instant)", "Order Deleted (Instant)", and "Order Updated (Instant)"; please migrate to the corresponding "Purchase ..." sources.
    • Deprecated sources received metadata version bumps.

@vercel
Copy link

vercel bot commented Nov 5, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
pipedream-docs-redirect-do-not-edit Ignored Ignored Nov 5, 2025 9:16pm

@adolfo-pd adolfo-pd added the User submitted Submitted by a user label Nov 5, 2025
@anush anush changed the title Deprecated order.* sources and introduced purchase.* sources to replace them [Xola] Deprecated order.* sources and introduced purchase.* sources to replace them Nov 5, 2025
@pipedream-component-development
Copy link
Collaborator

Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified.

@pipedream-component-development
Copy link
Collaborator

Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 5, 2025

Walkthrough

Three legacy Xola "Order" webhook sources were marked deprecated (description updated and version bumped). Three new Xola "Purchase" instant webhook sources were added (create, update, cancel), each with a sample test-event payload and minimal methods for event naming and meta generation.

Changes

Cohort / File(s) Summary
Deprecated Sources
components/xola/sources/new-order-created-instant/new-order-created-instant.mjs, components/xola/sources/order-deleted-instant/order-deleted-instant.mjs, components/xola/sources/order-updated-instant/order-updated-instant.mjs
Appended deprecation notice to description directing to corresponding "Purchase ..." replacements; bumped version from 0.0.10.0.2. No functional changes.
New: Purchase Canceled Source
components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs, components/xola/sources/purchase-canceled-instant/test-event.mjs
Added xola-purchase-canceled-instant source (type: source, version: 0.0.1) with getEventName()"purchase.cancel" and generateMeta(body) producing { summary, ts }. Includes comprehensive purchase.cancel test payload.
New: Purchase Created Source
components/xola/sources/purchase-created-instant/purchase-created-instant.mjs, components/xola/sources/purchase-created-instant/test-event.mjs
Added xola-new-purchase-created-instant source (type: source, version: 0.0.1) with getEventName()"purchase.create" and generateMeta(body). Includes comprehensive purchase.create test payload.
New: Purchase Updated Source
components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs, components/xola/sources/purchase-updated-instant/test-event.mjs
Added xola-purchase-updated-instant source (type: source, version: 0.0.1) with getEventName()"purchase.update" and generateMeta(body). Includes comprehensive purchase.update test payload.

Sequence Diagram(s)

sequenceDiagram
  participant X as Xola Webhook
  participant S as Source Module
  participant E as Event Emitter

  rect rgb(245,250,255)
    note over X,S: Incoming webhook POST (purchase.create/update/cancel)
    X->>S: POST payload
    S->>S: getEventName(payload)
    S->>S: generateMeta(payload)
    S->>E: emit(eventName, { data: payload.data, meta })
    E-->>S: ack
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review focus:
    • Consistency of getEventName() and generateMeta() across new sources.
    • Accuracy and completeness of the large nested test-event payloads (field names, IDs, monetary amounts, audit deltas).
    • Correctness of deprecation messages and that referenced replacement source names match the new source names/keys.

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main changes: deprecating old order sources and introducing purchase sources as replacements, which aligns with the changeset.
Description check ✅ Passed The description addresses the core reason for the changes but is minimal, covering only the WHY section required by the template.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1ccd2b4 and a4cf642.

📒 Files selected for processing (9)
  • components/xola/sources/new-order-created-instant/new-order-created-instant.mjs (1 hunks)
  • components/xola/sources/order-deleted-instant/order-deleted-instant.mjs (1 hunks)
  • components/xola/sources/order-updated-instant/order-updated-instant.mjs (1 hunks)
  • components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs (1 hunks)
  • components/xola/sources/purchase-canceled-instant/test-event.mjs (1 hunks)
  • components/xola/sources/purchase-created-instant/purchase-created-instant.mjs (1 hunks)
  • components/xola/sources/purchase-created-instant/test-event.mjs (1 hunks)
  • components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs (1 hunks)
  • components/xola/sources/purchase-updated-instant/test-event.mjs (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2024-07-24T02:06:47.016Z
Learnt from: GTFalcao
Repo: PipedreamHQ/pipedream PR: 12697
File: components/salesforce_rest_api/sources/common-webhook-methods.mjs:1-71
Timestamp: 2024-07-24T02:06:47.016Z
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/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs
  • components/xola/sources/purchase-created-instant/purchase-created-instant.mjs
  • components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs
📚 Learning: 2024-10-10T19:18:27.998Z
Learnt from: GTFalcao
Repo: PipedreamHQ/pipedream PR: 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/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs
  • components/xola/sources/purchase-created-instant/purchase-created-instant.mjs
🧬 Code graph analysis (2)
components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs (5)
components/xola/sources/new-order-created-instant/new-order-created-instant.mjs (1)
  • body (18-18)
components/xola/sources/order-deleted-instant/order-deleted-instant.mjs (2)
  • body (18-18)
  • ts (19-19)
components/xola/sources/order-updated-instant/order-updated-instant.mjs (2)
  • body (18-18)
  • ts (19-19)
components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs (2)
  • body (18-18)
  • ts (19-19)
components/xola/sources/purchase-created-instant/purchase-created-instant.mjs (1)
  • body (18-18)
components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs (5)
components/xola/sources/new-order-created-instant/new-order-created-instant.mjs (1)
  • body (18-18)
components/xola/sources/order-deleted-instant/order-deleted-instant.mjs (2)
  • body (18-18)
  • ts (19-19)
components/xola/sources/order-updated-instant/order-updated-instant.mjs (2)
  • body (18-18)
  • ts (19-19)
components/xola/sources/purchase-created-instant/purchase-created-instant.mjs (1)
  • body (18-18)
components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs (2)
  • body (18-18)
  • ts (19-19)
🔇 Additional comments (8)
components/xola/sources/order-updated-instant/order-updated-instant.mjs (1)

8-9: LGTM! Deprecation notice clearly communicates migration path.

The deprecation notice properly directs users to the replacement source and the version bump follows semantic versioning for metadata changes.

components/xola/sources/new-order-created-instant/new-order-created-instant.mjs (1)

8-9: LGTM! Deprecation notice properly guides users to the replacement.

The metadata changes correctly communicate the deprecation and migration path.

components/xola/sources/purchase-canceled-instant/test-event.mjs (1)

1-543: LGTM! Test event payload is comprehensive and correctly structured.

The test payload appropriately reflects a canceled purchase with the correct event name "purchase.cancel" and includes an audit trail showing the status transition from "confirmed" to "canceled".

components/xola/sources/purchase-created-instant/test-event.mjs (1)

1-534: LGTM! Test event payload correctly represents a purchase creation.

The test payload appropriately uses event name "purchase.create" with an empty audit object (since there's no prior state for a creation event).

components/xola/sources/purchase-created-instant/purchase-created-instant.mjs (1)

1-28: LGTM! New purchase created source is correctly implemented.

The implementation properly replaces the deprecated "New Order Created" source with the correct event name "purchase.create" and follows the established pattern.

components/xola/sources/order-deleted-instant/order-deleted-instant.mjs (1)

8-9: LGTM! Deprecation notice correctly maps deletion to cancellation.

The deprecation appropriately directs users from "Order Deleted" to "Purchase Canceled" and the version bump is consistent with other deprecated sources.

components/xola/sources/purchase-updated-instant/test-event.mjs (1)

1-543: LGTM! Test event payload correctly represents a purchase update.

The test payload appropriately uses event name "purchase.update" and includes an audit trail showing the arrivalDate field change, which is representative of an update event.

components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs (1)

1-11: LGTM! Structure follows established conventions.

The imports, base configuration, and properties are correctly structured and consistent with other Xola webhook sources. The key, name, and description clearly identify this as the purchase update webhook source, and the dedupe setting is appropriate for webhook events.

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

♻️ Duplicate comments (2)
components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs (1)

16-24: Deduplication issue with timestamp-based ID (already flagged).

The use of Date.now() for generating event IDs causes duplicate event emissions on webhook retries, as previously noted. The past review comment provides the correct solution: use data.updatedAt from the webhook payload to ensure stable IDs across retries.

components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs (1)

10-11: Missing dedupe property.

The dedupe: "unique" property should be defined between type: "source" and methods: to follow Pipedream best practices for webhook sources.

Apply this diff:

   type: "source",
+  dedupe: "unique",
   methods: {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a4cf642 and b078d0e.

📒 Files selected for processing (3)
  • components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs (1 hunks)
  • components/xola/sources/purchase-created-instant/purchase-created-instant.mjs (1 hunks)
  • components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2024-07-24T02:06:47.016Z
Learnt from: GTFalcao
Repo: PipedreamHQ/pipedream PR: 12697
File: components/salesforce_rest_api/sources/common-webhook-methods.mjs:1-71
Timestamp: 2024-07-24T02:06:47.016Z
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/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs
  • components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs
  • components/xola/sources/purchase-created-instant/purchase-created-instant.mjs
📚 Learning: 2024-10-10T19:18:27.998Z
Learnt from: GTFalcao
Repo: PipedreamHQ/pipedream PR: 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/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs
  • components/xola/sources/purchase-created-instant/purchase-created-instant.mjs
📚 Learning: 2025-07-09T18:07:12.426Z
Learnt from: GTFalcao
Repo: PipedreamHQ/pipedream PR: 17538
File: components/aircall/sources/new-sms/new-sms.mjs:19-25
Timestamp: 2025-07-09T18:07:12.426Z
Learning: In Aircall API webhook payloads, the `created_at` field is returned as an ISO 8601 string format (e.g., "2020-02-18T20:52:22.000Z"), not as milliseconds since epoch. For Pipedream components, this needs to be converted to milliseconds using `Date.parse()` before assigning to the `ts` field in `generateMeta()`.

Applied to files:

  • components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs
🧬 Code graph analysis (2)
components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs (5)
components/xola/sources/purchase-created-instant/purchase-created-instant.mjs (1)
  • body (17-17)
components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs (2)
  • body (17-17)
  • ts (18-18)
components/xola/sources/order-updated-instant/order-updated-instant.mjs (2)
  • body (18-18)
  • ts (19-19)
components/xola/sources/new-order-created-instant/new-order-created-instant.mjs (1)
  • body (18-18)
components/xola/sources/order-deleted-instant/order-deleted-instant.mjs (2)
  • body (18-18)
  • ts (19-19)
components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs (5)
components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs (2)
  • body (17-17)
  • ts (18-18)
components/xola/sources/purchase-created-instant/purchase-created-instant.mjs (1)
  • body (17-17)
components/xola/sources/order-updated-instant/order-updated-instant.mjs (2)
  • body (18-18)
  • ts (19-19)
components/xola/sources/new-order-created-instant/new-order-created-instant.mjs (1)
  • body (18-18)
components/xola/sources/order-deleted-instant/order-deleted-instant.mjs (2)
  • body (18-18)
  • ts (19-19)
🔇 Additional comments (9)
components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs (4)

1-3: LGTM - Standard import structure.

The imports correctly reference the common webhook configuration and test event sample, following the established pattern for Pipedream components.


4-10: LGTM - Component metadata follows Pipedream guidelines.

The component key follows the app_name_slug-slugified-component-name pattern, the naming is clear, and the version is appropriate for a new component. This aligns with the PR objective of replacing deprecated order.* webhooks with purchase.* webhooks.


13-15: LGTM - Correct webhook event name.

The getEventName() method returns "purchase.update", which correctly aligns with the new purchase-based webhook events that are replacing the deprecated order events.


26-26: LGTM - Test event sample included.

Including sampleEmit follows Pipedream best practices for providing example webhook payloads, which aids in testing and documentation.

components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs (3)

1-2: LGTM: Imports are correct.

The imports follow standard patterns for Pipedream webhook sources.


11-25: LGTM: Methods implementation follows established patterns.

The getEventName() and generateMeta() methods are correctly implemented and consistent with other purchase webhook sources in this codebase. The ID generation strategy (appending timestamp) ensures each webhook call is treated as a unique event, which is appropriate for instant webhook sources.


26-26: LGTM: Sample emit is properly exported.

The sampleEmit export provides test event data as required for Pipedream sources.

components/xola/sources/purchase-created-instant/purchase-created-instant.mjs (2)

1-2: LGTM!

The imports follow the standard pattern for extending webhook sources in Pipedream.


25-26: LGTM!

The sampleEmit reference follows the standard pattern for providing test event payloads in Pipedream sources.

Comment on lines +4 to +10
export default {
...common,
key: "xola-new-purchase-created-instant",
name: "New Purchase Created (Instant)",
description: "Emit new event when a new purchase is created.",
version: "0.0.1",
type: "source",
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider adding a dedupe strategy.

Since generateMeta returns an id field, you should specify a deduplication strategy to prevent duplicate events from being emitted.

Apply this diff to add automatic deduplication:

   key: "xola-new-purchase-created-instant",
   name: "New Purchase Created (Instant)",
   description: "Emit new event when a new purchase is created.",
   version: "0.0.1",
   type: "source",
+  dedupe: "unique",
   methods: {

As per coding guidelines.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export default {
...common,
key: "xola-new-purchase-created-instant",
name: "New Purchase Created (Instant)",
description: "Emit new event when a new purchase is created.",
version: "0.0.1",
type: "source",
export default {
...common,
key: "xola-new-purchase-created-instant",
name: "New Purchase Created (Instant)",
description: "Emit new event when a new purchase is created.",
version: "0.0.1",
type: "source",
dedupe: "unique",
🤖 Prompt for AI Agents
In components/xola/sources/purchase-created-instant/purchase-created-instant.mjs
around lines 4–10, add a deduplication configuration so the source uses the
generated meta.id to avoid emitting duplicate events; update the exported object
to include the project’s dedupe property (e.g., set the dedupe/dedupeStrategy to
"id" per repo convention) so the runtime will dedupe events by the generated id.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add this suggestion!

Comment on lines 16 to 23
generateMeta(body) {
const { data } = body;
return {
id: data.id,
summary: `New Purchase ${data.id}`,
ts: Date.now(),
};
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Use webhook payload timestamp and add error handling.

The generateMeta method has two concerns:

  1. Timestamp: Using Date.now() means the timestamp reflects when the webhook was received, not when the purchase was created. This affects event ordering and historical accuracy. Webhook payloads typically include a creation timestamp that should be used instead.

  2. Error handling: No validation for body.data or body.data.id — if either is undefined, this will throw a runtime error.

Run the following script to check the test event payload structure and verify if a timestamp field is available:

Also check how other Xola instant sources handle timestamps:


🏁 Script executed:

#!/bin/bash
# Description: Examine the test event payload to identify available timestamp fields

# Check the test event structure
cat components/xola/sources/purchase-created-instant/test-event.mjs

Length of output: 20507


🏁 Script executed:

#!/bin/bash
# Description: Check timestamp handling in other Xola instant sources

# Find similar generateMeta implementations
rg -A 10 'generateMeta.*body' components/xola/sources/ --type=js

Length of output: 0


Use the createdAt timestamp from the webhook payload instead of Date.now().

The test event shows webhook payloads include createdAt in ISO 8601 format. The current code uses Date.now(), which captures when the webhook was received, not when the purchase was created. This affects event ordering and historical accuracy.

Convert the ISO 8601 timestamp to milliseconds using Date.parse(data.createdAt) in the ts field:

generateMeta(body) {
  const { data } = body;
  return {
    id: data.id,
    summary: `New Purchase ${data.id}`,
    ts: Date.parse(data.createdAt),
  };
},

Also add defensive checks for body.data and data.id to prevent runtime errors if the payload structure is malformed.

🤖 Prompt for AI Agents
In components/xola/sources/purchase-created-instant/purchase-created-instant.mjs
around lines 16 to 23, change the generated event timestamp to use the webhook's
createdAt value and add defensive checks: validate body and body.data exist and
that data.id is present, compute ts with Date.parse(data.createdAt) (fallback to
Date.now() if createdAt is missing or invalid), and keep id and summary as
before; ensure the function returns a valid meta object even for malformed
payloads by throwing or returning a safe default.

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

♻️ Duplicate comments (2)
components/xola/sources/purchase-created-instant/purchase-created-instant.mjs (2)

4-10: Add deduplication strategy.

The component should include dedupe: "unique" to prevent duplicate events from being emitted. Even though Xola webhooks may not retry, deduplication protects against system restarts, race conditions, or manual re-deployments.

Apply this diff:

   key: "xola-new-purchase-created-instant",
   name: "New Purchase Created (Instant)",
   description: "Emit new event when a new purchase is created.",
   version: "0.0.1",
   type: "source",
+  dedupe: "unique",
   methods: {

As per coding guidelines.


16-22: Add id field and use payload timestamp.

The generateMeta method has several issues:

  1. Missing id field: Required for deduplication to work properly
  2. Timestamp accuracy: Using Date.now() captures processing time, not event creation time
  3. Error handling: No validation for body.data or data.id

Apply this diff:

 generateMeta(body) {
   const { data } = body;
+  if (!data?.id) {
+    throw new Error("Invalid webhook payload: missing data.id");
+  }
   return {
+    id: data.id,
     summary: `New Purchase ${data.id}`,
-    ts: Date.now(),
+    ts: data.createdAt ? Date.parse(data.createdAt) : Date.now(),
   };
 },

Based on learnings about timestamp handling in webhook sources.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b078d0e and e6ed2e9.

📒 Files selected for processing (3)
  • components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs (1 hunks)
  • components/xola/sources/purchase-created-instant/purchase-created-instant.mjs (1 hunks)
  • components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2024-07-24T02:06:47.016Z
Learnt from: GTFalcao
Repo: PipedreamHQ/pipedream PR: 12697
File: components/salesforce_rest_api/sources/common-webhook-methods.mjs:1-71
Timestamp: 2024-07-24T02:06:47.016Z
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/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs
  • components/xola/sources/purchase-created-instant/purchase-created-instant.mjs
  • components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs
📚 Learning: 2024-10-10T19:18:27.998Z
Learnt from: GTFalcao
Repo: PipedreamHQ/pipedream PR: 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/xola/sources/purchase-created-instant/purchase-created-instant.mjs
  • components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs
📚 Learning: 2025-07-09T18:07:12.426Z
Learnt from: GTFalcao
Repo: PipedreamHQ/pipedream PR: 17538
File: components/aircall/sources/new-sms/new-sms.mjs:19-25
Timestamp: 2025-07-09T18:07:12.426Z
Learning: In Aircall API webhook payloads, the `created_at` field is returned as an ISO 8601 string format (e.g., "2020-02-18T20:52:22.000Z"), not as milliseconds since epoch. For Pipedream components, this needs to be converted to milliseconds using `Date.parse()` before assigning to the `ts` field in `generateMeta()`.

Applied to files:

  • components/xola/sources/purchase-created-instant/purchase-created-instant.mjs
  • components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs
🧬 Code graph analysis (3)
components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs (5)
components/xola/sources/purchase-created-instant/purchase-created-instant.mjs (1)
  • body (17-17)
components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs (1)
  • body (17-17)
components/xola/sources/new-order-created-instant/new-order-created-instant.mjs (1)
  • body (18-18)
components/xola/sources/order-updated-instant/order-updated-instant.mjs (1)
  • body (18-18)
components/xola/sources/order-deleted-instant/order-deleted-instant.mjs (1)
  • body (18-18)
components/xola/sources/purchase-created-instant/purchase-created-instant.mjs (5)
components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs (1)
  • body (17-17)
components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs (1)
  • body (17-17)
components/xola/sources/new-order-created-instant/new-order-created-instant.mjs (1)
  • body (18-18)
components/xola/sources/order-updated-instant/order-updated-instant.mjs (1)
  • body (18-18)
components/xola/sources/order-deleted-instant/order-deleted-instant.mjs (1)
  • body (18-18)
components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs (5)
components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs (1)
  • body (17-17)
components/xola/sources/purchase-created-instant/purchase-created-instant.mjs (1)
  • body (17-17)
components/xola/sources/new-order-created-instant/new-order-created-instant.mjs (1)
  • body (18-18)
components/xola/sources/order-updated-instant/order-updated-instant.mjs (1)
  • body (18-18)
components/xola/sources/order-deleted-instant/order-deleted-instant.mjs (1)
  • body (18-18)

Comment on lines +16 to +22
generateMeta(body) {
const { data } = body;
return {
summary: `Purchase Canceled ${data.id}`,
ts: Date.now(),
};
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Add id field, use payload timestamp, and add error handling.

The generateMeta method needs improvements:

  1. Missing id field: Provides event identification and tracking
  2. Timestamp accuracy: Date.now() reflects processing time, not cancellation time. The payload likely includes a cancellation timestamp that should be used instead
  3. Error handling: No validation for body.data or data.id could cause runtime errors

Apply this diff:

 generateMeta(body) {
   const { data } = body;
+  if (!data?.id) {
+    throw new Error("Invalid webhook payload: missing data.id");
+  }
   return {
+    id: data.id,
     summary: `Purchase Canceled ${data.id}`,
-    ts: Date.now(),
+    ts: data.canceledAt ? Date.parse(data.canceledAt) : Date.now(),
   };
 },

Verify the cancellation timestamp field name in the test event:

Based on learnings about timestamp handling in webhook sources.


🏁 Script executed:

#!/bin/bash
# Check the test event structure for timestamp fields
cat components/xola/sources/purchase-canceled-instant/test-event.mjs | grep -E "(canceledAt|cancelled|canceled|updatedAt|createdAt)" -i

Length of output: 2024



---

🏁 Script executed:

```shell
#!/bin/bash
# Check for other Xola sources to verify timestamp handling patterns
find components/xola/sources -name "*.mjs" -type f | head -5 | while read file; do
  echo "=== $file ==="
  grep -A 10 "generateMeta" "$file" | head -15
done

Length of output: 1164


Add id field and use the correct updatedAt timestamp field from payload.

The generateMeta method needs corrections:

  1. Missing id field: Other Xola sources include composite IDs for event identification
  2. Incorrect timestamp reference: The original suggestion to use data.canceledAt is wrong—this field doesn't exist in the test event. Use data.updatedAt instead (ISO 8601 format: "2025-10-29T07:37:32+00:00"), which reflects when the purchase was canceled
  3. Timestamp conversion: The ISO 8601 updatedAt value needs conversion to milliseconds using Date.parse()

Apply this diff:

 generateMeta(body) {
   const { data } = body;
+  if (!data?.id) {
+    throw new Error("Invalid webhook payload: missing data.id");
+  }
   return {
+    id: `${data.id}-${Date.parse(data.updatedAt)}`,
     summary: `Purchase Canceled ${data.id}`,
-    ts: Date.now(),
+    ts: data.updatedAt ? Date.parse(data.updatedAt) : Date.now(),
   };
 },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
generateMeta(body) {
const { data } = body;
return {
summary: `Purchase Canceled ${data.id}`,
ts: Date.now(),
};
},
generateMeta(body) {
const { data } = body;
if (!data?.id) {
throw new Error("Invalid webhook payload: missing data.id");
}
return {
id: `${data.id}-${Date.parse(data.updatedAt)}`,
summary: `Purchase Canceled ${data.id}`,
ts: data.updatedAt ? Date.parse(data.updatedAt) : Date.now(),
};
},
🤖 Prompt for AI Agents
In
components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs
around lines 16 to 22, generateMeta is missing an id field and uses the wrong
timestamp; update it to include a composite id (e.g.
`${data.id}:${data.updatedAt}` or follow existing Xola pattern) and set ts to
Date.parse(data.updatedAt) to convert the ISO 8601 updatedAt into milliseconds;
ensure you access data.updatedAt (not data.canceledAt) and handle parsing safely
(e.g. fallback or let invalid parse propagate per project convention).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add only the id as suggested here

Comment on lines +16 to +22
generateMeta(body) {
const { data } = body;
return {
summary: `Purchase Updated ${data.id}`,
ts: Date.now(),
};
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add id field, use payload timestamp, and add error handling.

The generateMeta method needs improvements:

  1. Missing id field: Even without deduplication, the id provides event identification and tracking
  2. Timestamp accuracy: Date.now() reflects processing time, not when the update occurred. The payload includes updatedAt which should be used instead
  3. Error handling: No validation for body.data or data.id could cause runtime errors

Apply this diff:

 generateMeta(body) {
   const { data } = body;
+  if (!data?.id) {
+    throw new Error("Invalid webhook payload: missing data.id");
+  }
   return {
+    id: data.id,
     summary: `Purchase Updated ${data.id}`,
-    ts: Date.now(),
+    ts: data.updatedAt ? Date.parse(data.updatedAt) : Date.now(),
   };
 },

Based on learnings about timestamp handling in webhook sources.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
generateMeta(body) {
const { data } = body;
return {
summary: `Purchase Updated ${data.id}`,
ts: Date.now(),
};
},
generateMeta(body) {
const { data } = body;
if (!data?.id) {
throw new Error("Invalid webhook payload: missing data.id");
}
return {
id: data.id,
summary: `Purchase Updated ${data.id}`,
ts: data.updatedAt ? Date.parse(data.updatedAt) : Date.now(),
};
},
🤖 Prompt for AI Agents
In components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs
around lines 16 to 22, update generateMeta to (1) validate that body and
body.data exist and that data.id is present, throwing or returning a clear error
if missing to avoid runtime exceptions; (2) add an id field to the returned meta
using data.id; and (3) use the payload timestamp (data.updatedAt) for ts by
parsing it to a numeric millisecond epoch (with a safe fallback if parsing
fails), rather than Date.now().

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add the id combined with the updatedAt timestamp as the id metadata

Copy link
Collaborator

@jcortes jcortes left a comment

Choose a reason for hiding this comment

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

Hi @anush thanks for this great contribution. Just make sure you increase the version in package.json to 0.2.0 and fix the minor changes I pointed out in the comments other than that it is looking great. Thanks

Comment on lines +4 to +10
export default {
...common,
key: "xola-new-purchase-created-instant",
name: "New Purchase Created (Instant)",
description: "Emit new event when a new purchase is created.",
version: "0.0.1",
type: "source",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add this suggestion!

Comment on lines +16 to +22
generateMeta(body) {
const { data } = body;
return {
summary: `Purchase Canceled ${data.id}`,
ts: Date.now(),
};
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add only the id as suggested here


export default {
...common,
key: "xola-new-purchase-created-instant",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
key: "xola-new-purchase-created-instant",
key: "xola-purchase-created-instant",

Comment on lines +16 to +22
generateMeta(body) {
const { data } = body;
return {
summary: `Purchase Updated ${data.id}`,
ts: Date.now(),
};
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add the id combined with the updatedAt timestamp as the id metadata

@jcortes jcortes moved this from Ready for PR Review to Changes Required in Component (Source and Action) Backlog Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

User submitted Submitted by a user

Projects

Development

Successfully merging this pull request may close these issues.

4 participants