-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Xola] Deprecated order.* sources and introduced purchase.* sources to replace them
#18963
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?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
order.* sources and introduced purchase.* sources to replace themorder.* sources and introduced purchase.* sources to replace them
|
Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified. |
WalkthroughThree 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
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: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 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.mjscomponents/xola/sources/purchase-created-instant/purchase-created-instant.mjscomponents/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.mjscomponents/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.
components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs
Show resolved
Hide resolved
components/xola/sources/purchase-updated-instant/purchase-updated-instant.mjs
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.
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: usedata.updatedAtfrom the webhook payload to ensure stable IDs across retries.components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs (1)
10-11: Missingdedupeproperty.The
dedupe: "unique"property should be defined betweentype: "source"andmethods: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
📒 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.mjscomponents/xola/sources/purchase-updated-instant/purchase-updated-instant.mjscomponents/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.mjscomponents/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-namepattern, the naming is clear, and the version is appropriate for a new component. This aligns with the PR objective of replacing deprecatedorder.*webhooks withpurchase.*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
sampleEmitfollows 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()andgenerateMeta()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
sampleEmitexport 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
sampleEmitreference follows the standard pattern for providing test event payloads in Pipedream sources.
| 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", |
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.
🧹 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.
| 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.
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.
Please add this suggestion!
| generateMeta(body) { | ||
| const { data } = body; | ||
| return { | ||
| id: data.id, | ||
| summary: `New Purchase ${data.id}`, | ||
| ts: Date.now(), | ||
| }; | ||
| }, |
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.
🧩 Analysis chain
Use webhook payload timestamp and add error handling.
The generateMeta method has two concerns:
-
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. -
Error handling: No validation for
body.dataorbody.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.mjsLength 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=jsLength 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.
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: 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: Addidfield and use payload timestamp.The
generateMetamethod has several issues:
- Missing
idfield: Required for deduplication to work properly- Timestamp accuracy: Using
Date.now()captures processing time, not event creation time- Error handling: No validation for
body.dataordata.idApply 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
📒 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.mjscomponents/xola/sources/purchase-created-instant/purchase-created-instant.mjscomponents/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.mjscomponents/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.mjscomponents/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)
| generateMeta(body) { | ||
| const { data } = body; | ||
| return { | ||
| summary: `Purchase Canceled ${data.id}`, | ||
| ts: Date.now(), | ||
| }; | ||
| }, |
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.
🧩 Analysis chain
Add id field, use payload timestamp, and add error handling.
The generateMeta method needs improvements:
- Missing
idfield: Provides event identification and tracking - Timestamp accuracy:
Date.now()reflects processing time, not cancellation time. The payload likely includes a cancellation timestamp that should be used instead - Error handling: No validation for
body.dataordata.idcould 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)" -iLength 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:
- Missing
idfield: Other Xola sources include composite IDs for event identification - Incorrect timestamp reference: The original suggestion to use
data.canceledAtis wrong—this field doesn't exist in the test event. Usedata.updatedAtinstead (ISO 8601 format: "2025-10-29T07:37:32+00:00"), which reflects when the purchase was canceled - Timestamp conversion: The ISO 8601
updatedAtvalue needs conversion to milliseconds usingDate.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.
| 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).
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.
Please add only the id as suggested here
| generateMeta(body) { | ||
| const { data } = body; | ||
| return { | ||
| summary: `Purchase Updated ${data.id}`, | ||
| ts: Date.now(), | ||
| }; | ||
| }, |
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.
Add id field, use payload timestamp, and add error handling.
The generateMeta method needs improvements:
- Missing
idfield: Even without deduplication, theidprovides event identification and tracking - Timestamp accuracy:
Date.now()reflects processing time, not when the update occurred. The payload includesupdatedAtwhich should be used instead - Error handling: No validation for
body.dataordata.idcould 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.
| 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().
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.
Please add the id combined with the updatedAt timestamp as the id metadata
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 @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
| 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", |
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.
Please add this suggestion!
| generateMeta(body) { | ||
| const { data } = body; | ||
| return { | ||
| summary: `Purchase Canceled ${data.id}`, | ||
| ts: Date.now(), | ||
| }; | ||
| }, |
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.
Please add only the id as suggested here
|
|
||
| export default { | ||
| ...common, | ||
| key: "xola-new-purchase-created-instant", |
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.
| key: "xola-new-purchase-created-instant", | |
| key: "xola-purchase-created-instant", |
| generateMeta(body) { | ||
| const { data } = body; | ||
| return { | ||
| summary: `Purchase Updated ${data.id}`, | ||
| ts: Date.now(), | ||
| }; | ||
| }, |
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.
Please add the id combined with the updatedAt timestamp as the id metadata
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
Chores