The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
add region support to events table
Steven Teye630bd2465bc
diff --git a/apps/web/lib/zod/schemas/clicks.ts b/apps/web/lib/zod/schemas/clicks.tsindex cd1c7be5ee..d04170e23d 100644--- a/apps/web/lib/zod/schemas/clicks.ts+++ b/apps/web/lib/zod/schemas/clicks.ts@@ -37,9 +37,10 @@ export const clickEventSchemaTBEndpoint = z.object({click_id: z.string(),link_id: z.string(),url: z.string(),- continent: z.string().nullable(),country: z.string().nullable(),city: z.string().nullable(),+ region: z.string().nullable(),+ continent: z.string().nullable(),device: z.string().nullable(),browser: z.string().nullable(),os: z.string().nullable(),@@ -53,9 +54,10 @@ export const clickEventSchemaTBEndpoint = z.object({export const clickEventSchema = z.object({id: z.string(),url: z.string(),- continent: z.string(),country: z.string(),city: z.string(),+ region: z.string(),+ continent: z.string(),device: z.string(),browser: z.string(),os: z.string(),diff --git a/apps/web/ui/analytics/events/events-table.tsx b/apps/web/ui/analytics/events/events-table.tsxindex 49aafb8028..872c98e769 100644--- a/apps/web/ui/analytics/events/events-table.tsx+++ b/apps/web/ui/analytics/events/events-table.tsx@@ -21,6 +21,7 @@ import { CursorRays, Globe, Magnifier, QRCode } from "@dub/ui/src/icons";import {CONTINENTS,COUNTRIES,+ REGIONS,capitalize,currencyFormatter,fetcher,@@ -205,25 +206,6 @@ export default function EventsTable({);},},- {- id: "continent",- header: "Continent",- accessorKey: "click.continent",- meta: {- filterParams: ({ getValue }) => ({ continent: getValue() }),- },- cell: ({ getValue }) => (- <div- className="flex items-center gap-3"- title={CONTINENTS[getValue()] ?? "Unknown"}- >- <ContinentIcon display={getValue()} className="size-4 shrink-0" />- <span className="truncate">- {CONTINENTS[getValue()] ?? "Unknown"}- </span>- </div>- ),- },{id: "country",header: "Country",@@ -271,6 +253,47 @@ export default function EventsTable({</div>),},+ {+ id: "region",+ header: "Region",+ accessorKey: "click.region",+ minSize: 160,+ cell: ({ getValue, row }) => (+ <div className="flex items-center gap-3" title={getValue()}>+ {!row.original.country || row.original.country === "Unknown" ? (+ <Globe className="size-4 shrink-0" />+ ) : (+ <img+ alt={row.original.country}+ src={`https://hatscripts.github.io/circle-flags/flags/${row.original.country.toLowerCase()}.svg`}+ className="size-4 shrink-0"+ />+ )}+ <span className="truncate">+ {REGIONS[`${row.original.country}-${getValue()}`] || getValue()}+ </span>+ </div>+ ),+ },+ {+ id: "continent",+ header: "Continent",+ accessorKey: "click.continent",+ meta: {+ filterParams: ({ getValue }) => ({ continent: getValue() }),+ },+ cell: ({ getValue }) => (+ <div+ className="flex items-center gap-3"+ title={CONTINENTS[getValue()] ?? "Unknown"}+ >+ <ContinentIcon display={getValue()} className="size-4 shrink-0" />+ <span className="truncate">+ {CONTINENTS[getValue()] ?? "Unknown"}+ </span>+ </div>+ ),+ },{id: "device",header: "Device",diff --git a/apps/web/ui/analytics/events/use-column-visibility.ts b/apps/web/ui/analytics/events/use-column-visibility.tsindex 3110e35f4b..2c0856ef30 100644--- a/apps/web/ui/analytics/events/use-column-visibility.ts+++ b/apps/web/ui/analytics/events/use-column-visibility.ts@@ -11,9 +11,10 @@ export const getEventColumns: (all: ["trigger",...(!partners ? ["link"] : []),- "continent","country","city",+ "region",+ "continent","device","browser","os",@@ -36,9 +37,10 @@ export const getEventColumns: ("event",...(!partners ? ["link"] : []),"customer",- "continent","country","city",+ "region",+ "continent","device","browser","os",@@ -61,9 +63,10 @@ export const getEventColumns: ("event","customer",...(!partners ? ["link", "invoiceId"] : []),- "continent","country","city",+ "region",+ "continent","device","browser","os",diff --git a/apps/web/ui/analytics/locations.tsx b/apps/web/ui/analytics/locations.tsxindex 89c22a8a91..0174d40ba3 100644--- a/apps/web/ui/analytics/locations.tsx+++ b/apps/web/ui/analytics/locations.tsx@@ -62,9 +62,7 @@ export default function Locations() {: tab === "countries"? COUNTRIES[d.country]: tab === "regions"- ? REGIONS[- `${d.country}-${d.region}`.toUpperCase()- ] || d.region+ ? REGIONS[`${d.country}-${d.region}`] || d.region: d.city,href: queryParams({...(searchParams.has(singularTabName)