Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

store the entire event as metadata

Kiran Ke97b6770f48b
diff --git a/apps/web/lib/integrations/shopify/create-sale.ts b/apps/web/lib/integrations/shopify/create-sale.ts
index 14c3c0dd98..0e2197ca79 100644
--- a/apps/web/lib/integrations/shopify/create-sale.ts
+++ b/apps/web/lib/integrations/shopify/create-sale.ts
@@ -13,17 +13,17 @@ import { waitUntil } from "@vercel/functions";
import { orderSchema } from "./schema";
export async function createShopifySale({
- order,
+ event,
customerId,
workspaceId,
leadData,
}: {
- order: any;
+ event: any;
customerId: string;
workspaceId: string;
leadData: z.infer<typeof leadEventSchemaTB>;
}) {
- const orderData = orderSchema.parse(order);
+ const orderData = orderSchema.parse(event);
const eventId = nanoid(16);
const paymentProcessor = "shopify";
@@ -55,7 +55,7 @@ export async function createShopifySale({
amount,
currency,
invoice_id: invoiceId,
- metadata: JSON.stringify(order),
+ metadata: JSON.stringify(event),
};
const [_sale, link, workspace, customer] = await Promise.all([
@@ -155,9 +155,7 @@ export async function createShopifySale({
eventId,
paymentProcessor,
},
- metadata: {
- ...order,
- },
+ metadata: event,
});
waitUntil(
diff --git a/apps/web/lib/integrations/shopify/process-order.ts b/apps/web/lib/integrations/shopify/process-order.ts
index 92f04d980d..a840173902 100644
--- a/apps/web/lib/integrations/shopify/process-order.ts
+++ b/apps/web/lib/integrations/shopify/process-order.ts
@@ -2,7 +2,6 @@ import { handleAndReturnErrorResponse } from "@/lib/api/errors";
import { getLeadEvent } from "@/lib/tinybird";
import { createShopifyLead } from "./create-lead";
import { createShopifySale } from "./create-sale";
-import { orderSchema } from "./schema";
// Process the order from Shopify webhook
export async function processOrder({
@@ -17,8 +16,6 @@ export async function processOrder({
clickId?: string; // ID of the click event from Shopify pixel
}) {
try {
- const order = orderSchema.parse(event);
-
// for existing customer
if (customerId) {
const leadEvent = await getLeadEvent({ customerId });
@@ -33,7 +30,7 @@ export async function processOrder({
await createShopifySale({
leadData,
- order,
+ event,
workspaceId,
customerId,
});
@@ -53,7 +50,7 @@ export async function processOrder({
await createShopifySale({
leadData,
- order,
+ event,
workspaceId,
customerId,
});