The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
filter events by customer id
Kiran K7888aba3f04d
diff --git a/apps/web/app/api/customers/[id]/activities/route.ts b/apps/web/app/api/customers/[id]/activities/route.tsindex a63d8f20e5..95cd0c7375 100644--- a/apps/web/app/api/customers/[id]/activities/route.ts+++ b/apps/web/app/api/customers/[id]/activities/route.ts@@ -29,14 +29,11 @@ export const GET = withWorkspace(async ({ workspace, params }) => {id: customerId,});- // TODO:- // We need to add a new filter clickId/customerId to `getEvents` or add a new pipe to get sales by clickId/customerIdconst events = await getEvents({+ customerId: customer.id,event: "sales",order: "desc",sortBy: "timestamp",- linkId: customer.linkId!, // FIX ME- workspaceId: workspace.id,interval: "1y",page: 1,limit: 50,diff --git a/apps/web/lib/analytics/types.ts b/apps/web/lib/analytics/types.tsindex db7d309c16..1abe0528f3 100644--- a/apps/web/lib/analytics/types.ts+++ b/apps/web/lib/analytics/types.ts@@ -37,6 +37,7 @@ export type AnalyticsFilters = z.infer<typeof analyticsQuerySchema> & {export type EventsFilters = z.infer<typeof eventsQuerySchema> & {workspaceId?: string;isDemo?: boolean;+ customerId?: string;};const partnerAnalyticsSchema = analyticsQuerySchemadiff --git a/apps/web/lib/zod/schemas/analytics.ts b/apps/web/lib/zod/schemas/analytics.tsindex 541b7e453f..b2f37e9a4f 100644--- a/apps/web/lib/zod/schemas/analytics.ts+++ b/apps/web/lib/zod/schemas/analytics.ts@@ -205,6 +205,7 @@ export const analyticsFilterTB = z}}),programId: z.string().optional(),+ customerId: z.string().optional(),root: z.boolean().optional(),qr: z.boolean().optional(),start: z.string(),diff --git a/packages/tinybird/pipes/v2_events.pipe b/packages/tinybird/pipes/v2_events.pipeindex ae0476cf1b..b3d017295a 100644--- a/packages/tinybird/pipes/v2_events.pipe+++ b/packages/tinybird/pipes/v2_events.pipe@@ -111,6 +111,7 @@ SQL >timestamp >= {{ DateTime(start, '2024-06-01 00:00:00') }}AND timestamp < {{ DateTime(end, '2024-06-07 00:00:00') }}{% if defined(linkId) %} AND link_id = {{ String(linkId) }}+ {% elif defined(customerId) %} AND customer_id = {{ String(customerId) }}{% elif defined(workspaceId) %} AND link_id IN (SELECT link_id FROM workspace_links){% end %}{% if defined(qr) %} AND qr = {{ Boolean(qr) }} {% end %}