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.

Use different schemas for leads and sales

Tim Wilsone880027a5b52
diff --git a/apps/web/lib/analytics/get-events.ts b/apps/web/lib/analytics/get-events.ts
index 3952cdff73..bbe67f2467 100644
--- a/apps/web/lib/analytics/get-events.ts
+++ b/apps/web/lib/analytics/get-events.ts
@@ -2,6 +2,8 @@ import { tb } from "@/lib/tinybird";
import { tbDemo } from "../tinybird/demo-client";
import { eventsFilterTB } from "../zod/schemas/analytics";
import { clickEventEnrichedSchema } from "../zod/schemas/clicks";
+import { leadEventEnrichedSchema } from "../zod/schemas/leads";
+import { saleEventEnrichedSchema } from "../zod/schemas/sales";
import { INTERVAL_DATA } from "./constants";
import { EventsFilters } from "./types";
@@ -27,7 +29,12 @@ export const getEvents = async (params: EventsFilters) => {
const pipe = (isDemo ? tbDemo : tb).buildPipe({
pipe: `v1_events`,
parameters: eventsFilterTB,
- data: clickEventEnrichedSchema,
+ data:
+ {
+ clicks: clickEventEnrichedSchema,
+ leads: leadEventEnrichedSchema,
+ sales: saleEventEnrichedSchema,
+ }[event] ?? clickEventEnrichedSchema,
});
const response = await pipe({
diff --git a/apps/web/ui/analytics/events/events-tabs.tsx b/apps/web/ui/analytics/events/events-tabs.tsx
index 548a65b80e..81023a9a0d 100644
--- a/apps/web/ui/analytics/events/events-tabs.tsx
+++ b/apps/web/ui/analytics/events/events-tabs.tsx
@@ -6,7 +6,7 @@ import { AnalyticsContext } from "../analytics-provider";
export default function EventsTabs() {
const { searchParams, queryParams } = useRouterStuff();
- const tab = searchParams.get("tab");
+ const tab = searchParams.get("tab") || "clicks";
const { totalEvents } = useContext(AnalyticsContext);
return (