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.

add workspaceId

Steven Tey728030ea0371
diff --git a/apps/web/app/api/track/customer/route.ts b/apps/web/app/api/track/customer/route.ts
index 94d9df9e62..8adc003b1e 100644
--- a/apps/web/app/api/track/customer/route.ts
+++ b/apps/web/app/api/track/customer/route.ts
@@ -9,8 +9,13 @@ export const runtime = "edge";
// POST /api/track/customer – Track a customer object
export const POST = withSessionEdge(async ({ req }) => {
- const { customerId, customerName, customerEmail, customerAvatar } =
- trackCustomerRequestSchema.parse(await parseRequestBody(req));
+ const {
+ customerId,
+ customerName,
+ customerEmail,
+ customerAvatar,
+ workspaceId,
+ } = trackCustomerRequestSchema.parse(await parseRequestBody(req));
waitUntil(
recordCustomer({
@@ -19,7 +24,7 @@ export const POST = withSessionEdge(async ({ req }) => {
name: customerName,
email: customerEmail,
avatar: customerAvatar,
- project_id: "",
+ workspace_id: workspaceId,
}),
);
diff --git a/apps/web/app/api/track/lead/route.ts b/apps/web/app/api/track/lead/route.ts
index f43f8e62e0..d444e9262b 100644
--- a/apps/web/app/api/track/lead/route.ts
+++ b/apps/web/app/api/track/lead/route.ts
@@ -18,6 +18,7 @@ export const POST = withSessionEdge(async ({ req }) => {
customerName,
customerEmail,
customerAvatar,
+ workspaceId,
} = trackLeadRequestSchema.parse(await parseRequestBody(req));
waitUntil(
@@ -45,7 +46,7 @@ export const POST = withSessionEdge(async ({ req }) => {
name: customerName,
email: customerEmail,
avatar: customerAvatar,
- project_id: "",
+ workspace_id: workspaceId,
}),
]
: []),
diff --git a/apps/web/lib/zod/schemas/customers.ts b/apps/web/lib/zod/schemas/customers.ts
index 2fb8957a7e..9e8fb6a989 100644
--- a/apps/web/lib/zod/schemas/customers.ts
+++ b/apps/web/lib/zod/schemas/customers.ts
@@ -1,6 +1,7 @@
import z from "@/lib/zod";
export const trackCustomerRequestSchema = z.object({
+ workspaceId: z.string({ required_error: "workspaceId is required" }),
customerId: z.string({ required_error: "customerId is required" }),
customerName: z.string().nullish().default(""),
customerEmail: z.string().email().nullish().default(""),
@@ -13,6 +14,6 @@ export const customersMetadataSchema = z.object({
name: z.string().nullish().default(""),
email: z.string().email().nullish().default(""),
avatar: z.string().url().nullish().default(""),
- project_id: z.string(),
+ workspace_id: z.string(),
deleted: z.boolean().default(false),
});
diff --git a/apps/web/lib/zod/schemas/leads.ts b/apps/web/lib/zod/schemas/leads.ts
index 69e2935131..51d1648867 100644
--- a/apps/web/lib/zod/schemas/leads.ts
+++ b/apps/web/lib/zod/schemas/leads.ts
@@ -2,6 +2,7 @@ import z from "@/lib/zod";
import { clickEventSchemaTB } from "./clicks";
export const trackLeadRequestSchema = z.object({
+ workspaceId: z.string({ required_error: "workspaceId is required" }),
clickId: z.string({ required_error: "clickId is required" }),
eventName: z
.string({ required_error: "eventName is required" })
diff --git a/packages/tinybird/datasources/dub_customers_metadata.datasource b/packages/tinybird/datasources/dub_customers_metadata.datasource
index fdb66367b5..ca7932058a 100644
--- a/packages/tinybird/datasources/dub_customers_metadata.datasource
+++ b/packages/tinybird/datasources/dub_customers_metadata.datasource
@@ -4,8 +4,8 @@ SCHEMA >
`name` String `json:$.name`,
`email` String `json:$.email`,
`avatar` String `json:$.avatar`,
- `project_id` String `json:$.project_id`,
+ `workspace_id` String `json:$.workspace_id`,
`deleted` UInt8 `json:$.deleted`
ENGINE "MergeTree"
-ENGINE_SORTING_KEY "timestamp, customer_id, project_id, deleted"
\ No newline at end of file
+ENGINE_SORTING_KEY "timestamp, customer_id, workspace_id, deleted"
\ No newline at end of file