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.

update table

Kiran K035b1451dcb1
diff --git a/apps/web/app/api/campaigns/webhooks/stripe/route.ts b/apps/web/app/api/campaigns/webhooks/stripe/route.ts
index 7090de9029..5f5fd8d8a3 100644
--- a/apps/web/app/api/campaigns/webhooks/stripe/route.ts
+++ b/apps/web/app/api/campaigns/webhooks/stripe/route.ts
@@ -20,8 +20,8 @@ export const POST = async (req: Request) => {
try {
const event = stripe.webhooks.constructEvent(buf, sig, webhookSecret);
+ // Ignore unsupported events
if (!SUPPORTED_STRIPE_EVENTS.includes(event.type)) {
- // Ignore unsupported events
return new Response("OK", {
status: 200,
});
@@ -38,6 +38,10 @@ export const POST = async (req: Request) => {
});
} catch (error: any) {
console.log("Stripe webhook error:", error);
+
+ return new Response("Error", {
+ status: 400,
+ });
}
};
@@ -55,15 +59,16 @@ async function handleChargeSucceeded(event: Stripe.Event) {
const customer = (await stripe.customers.retrieve(
charge.customer as string,
)) as Stripe.Customer;
- const customerKey = customer.metadata?.customerKey || null;
- if (!customerKey) {
+ const customerId = customer.metadata?.customerId || null;
+
+ if (!customerId) {
return;
}
console.log("customer", customer);
- // Check customerKey exists in TB
+ // Check customerId exists in TB
// TODO: Update clickId
const clickEvent = await getClickEvent({ clickId: "jlNZlZKVa2X6ZCcZ" });
@@ -77,7 +82,7 @@ async function handleChargeSucceeded(event: Stripe.Event) {
event_name: "",
event_type: "sale",
event_metadata: "",
- customer_id: customerKey,
+ customer_id: customerId,
timestamp: new Date(Date.now()).toISOString(),
});
}
diff --git a/packages/tinybird/datasources/dub_conversion_events.datasource b/packages/tinybird/datasources/dub_conversion_events.datasource
index 9fb696f888..ca965356be 100644
--- a/packages/tinybird/datasources/dub_conversion_events.datasource
+++ b/packages/tinybird/datasources/dub_conversion_events.datasource
@@ -5,8 +5,8 @@ SCHEMA >
`click_id` String `json:$.click_id`,
`event_name` LowCardinality(String) `json:$.event_name`,
`event_type` LowCardinality(String) `json:$.event_type`,
- `metadata` String `json:$.metadata`,
- `customer_key` String `json:$.customer_key`,
+ `event_metadata` String `json:$.event_metadata`,
+ `customer_id` String `json:$.customer_id`,
`country` LowCardinality(String) `json:$.country`,
`city` String `json:$.city`,
`region` String `json:$.region`,
@@ -29,4 +29,4 @@ SCHEMA >
ENGINE "MergeTree"
ENGINE_PARTITION_KEY "toYYYYMM(timestamp)"
-ENGINE_SORTING_KEY "timestamp, link_id, click_id, customer_key"
\ No newline at end of file
+ENGINE_SORTING_KEY "timestamp, link_id, click_id, customer_id"
\ No newline at end of file