The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix eventIntervals
Steven Tey3e560eb5e79f
diff --git a/apps/web/lib/analytics/constants.ts b/apps/web/lib/analytics/constants.tsindex 9356afaa2a..501067032e 100644--- a/apps/web/lib/analytics/constants.ts+++ b/apps/web/lib/analytics/constants.ts@@ -11,6 +11,16 @@ export const intervals = ["all_unfiltered",] as const;+export const eventIntervals = [+ "24h",+ "7d",+ "30d",+ "90d",+ "ytd",+ "1y",+ "all",+] as const;+export const INTERVAL_DISPLAYS = [{display: "Last 24 hours",diff --git a/apps/web/lib/zod/schemas/analytics.ts b/apps/web/lib/zod/schemas/analytics.tsindex 9b4575f296..3e1fbd49d0 100644--- a/apps/web/lib/zod/schemas/analytics.ts+++ b/apps/web/lib/zod/schemas/analytics.ts@@ -3,6 +3,7 @@ import {OLD_ANALYTICS_ENDPOINTS,OLD_TO_NEW_ANALYTICS_ENDPOINTS,VALID_ANALYTICS_ENDPOINTS,+ eventIntervals,intervals,} from "@/lib/analytics/constants";import z from "@/lib/zod";@@ -207,9 +208,15 @@ export const eventsFilterTB = analyticsFilterTB);export const eventsQuerySchema = analyticsQuerySchema- .omit({ groupBy: true })+ .omit({ groupBy: true, interval: true }).merge(z.object({+ interval: z+ .enum(eventIntervals)+ .default("24h")+ .describe(+ "The interval to retrieve events for. Takes precedence over start and end. If undefined, defaults to 24h.",+ ),page: z.coerce.number().default(0),limit: z.coerce.number().default(PAGINATION_LIMIT),order: z.enum(["asc", "desc"]).default("desc"),