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 filter by continent

Steven Tey00fa8b829597
diff --git a/apps/web/lib/zod/schemas/analytics.ts b/apps/web/lib/zod/schemas/analytics.ts
index d5c7f27a3e..c43841d009 100644
--- a/apps/web/lib/zod/schemas/analytics.ts
+++ b/apps/web/lib/zod/schemas/analytics.ts
@@ -7,6 +7,7 @@ import {
} from "@/lib/analytics/constants";
import z from "@/lib/zod";
import {
+ CONTINENT_CODES,
COUNTRY_CODES,
DUB_FOUNDING_DATE,
PAGINATION_LIMIT,
@@ -102,6 +103,11 @@ export const analyticsQuerySchema = z.object({
"The IANA time zone code for aligning timeseries granularity (e.g. America/New_York). Defaults to UTC.",
)
.openapi({ example: "America/New_York", default: "UTC" }),
+ continent: z
+ .enum(CONTINENT_CODES)
+ .optional()
+ .describe("The continent to retrieve analytics for.")
+ .openapi({ ref: "continentCode" }),
country: z
.enum(COUNTRY_CODES)
.optional()
@@ -178,6 +184,7 @@ export const analyticsFilterTB = z
browser: true,
city: true,
country: true,
+ continent: true,
device: true,
domain: true,
linkId: true,
diff --git a/apps/web/lib/zod/schemas/clicks.ts b/apps/web/lib/zod/schemas/clicks.ts
index 9a8c5f27a9..d9968289b0 100644
--- a/apps/web/lib/zod/schemas/clicks.ts
+++ b/apps/web/lib/zod/schemas/clicks.ts
@@ -36,6 +36,7 @@ export const clickEventEnrichedSchema = z.object({
domain: z.string(),
key: z.string(),
url: z.string(),
+ continent: z.string().nullable(),
country: z.string().nullable(),
city: z.string().nullable(),
device: z.string().nullable(),
diff --git a/apps/web/lib/zod/schemas/leads.ts b/apps/web/lib/zod/schemas/leads.ts
index 4e24808bf2..1827d0d755 100644
--- a/apps/web/lib/zod/schemas/leads.ts
+++ b/apps/web/lib/zod/schemas/leads.ts
@@ -82,6 +82,7 @@ export const leadEventEnrichedSchema = z.object({
domain: z.string(),
key: z.string(),
url: z.string(),
+ continent: z.string().nullable(),
country: z.string().nullable(),
city: z.string().nullable(),
device: z.string().nullable(),
diff --git a/apps/web/lib/zod/schemas/sales.ts b/apps/web/lib/zod/schemas/sales.ts
index 07e36bd31f..a400f4c431 100644
--- a/apps/web/lib/zod/schemas/sales.ts
+++ b/apps/web/lib/zod/schemas/sales.ts
@@ -87,6 +87,7 @@ export const saleEventEnrichedSchema = z.object({
domain: z.string(),
key: z.string(),
url: z.string(),
+ continent: z.string().nullable(),
country: z.string().nullable(),
city: z.string().nullable(),
device: z.string().nullable(),
diff --git a/apps/web/ui/analytics/events/events-table.tsx b/apps/web/ui/analytics/events/events-table.tsx
index 987656e89a..ae0e709788 100644
--- a/apps/web/ui/analytics/events/events-table.tsx
+++ b/apps/web/ui/analytics/events/events-table.tsx
@@ -15,6 +15,7 @@ import {
} from "@dub/ui";
import { FilterBars } from "@dub/ui/src/icons";
import {
+ CONTINENTS,
COUNTRIES,
capitalize,
fetcher,
@@ -27,6 +28,7 @@ import { useContext, useEffect, useMemo, useState } from "react";
import useSWR from "swr";
import z from "zod";
import { AnalyticsContext } from "../analytics-provider";
+import ContinentIcon from "../continent-icon";
import DeviceIcon from "../device-icon";
import EditColumnsButton from "./edit-columns-button";
import EmptyState from "./empty-state";
@@ -54,6 +56,7 @@ const eventColumns: Record<
all: [
"trigger",
"link",
+ "continent",
"country",
"city",
"device",
@@ -68,6 +71,7 @@ const eventColumns: Record<
"event",
"link",
"customer",
+ "continent",
"country",
"city",
"device",
@@ -90,6 +94,7 @@ const eventColumns: Record<
"customer",
"invoiceId",
"link",
+ "continent",
"country",
"city",
"device",
@@ -247,6 +252,22 @@ export default function EventsTable() {
);
},
},
+ {
+ id: "continent",
+ header: "Continent",
+ accessorKey: "continent",
+ meta: {
+ filterParams: ({ getValue }) => ({ continent: getValue() }),
+ },
+ cell: ({ getValue }) => (
+ <div className="flex items-center gap-3">
+ <ContinentIcon display={getValue()} className="size-4 shrink-0" />
+ <span className="truncate">
+ {CONTINENTS[getValue()] ?? "Unknown"}
+ </span>
+ </div>
+ ),
+ },
{
id: "country",
header: "Country",
diff --git a/apps/web/ui/analytics/toggle.tsx b/apps/web/ui/analytics/toggle.tsx
index 9e94d2eb07..34d984132f 100644
--- a/apps/web/ui/analytics/toggle.tsx
+++ b/apps/web/ui/analytics/toggle.tsx
@@ -28,6 +28,7 @@ import {
Globe2,
Hyperlink,
Magic,
+ MapPosition,
MobilePhone,
OfficeBuilding,
QRCode,
@@ -37,6 +38,7 @@ import {
} from "@dub/ui/src/icons";
import {
APP_DOMAIN,
+ CONTINENTS,
COUNTRIES,
DUB_DEMO_LINKS,
DUB_LOGO,
@@ -62,6 +64,7 @@ import useSWR from "swr";
import { COLORS_LIST } from "../links/tag-badge";
import AnalyticsOptions from "./analytics-options";
import { AnalyticsContext } from "./analytics-provider";
+import ContinentIcon from "./continent-icon";
import DeviceIcon from "./device-icon";
import RefererIcon from "./referer-icon";
import { useAnalyticsFilterOption } from "./utils";
@@ -100,6 +103,7 @@ export default function Toggle({
key,
tagId,
qr,
+ continent,
country,
city,
device,
@@ -120,6 +124,7 @@ export default function Toggle({
: []),
...(tagId ? [{ key: "tagId", value: tagId }] : []),
...(qr ? [{ key: "qr", value: qr === "true" }] : []),
+ ...(continent ? [{ key: "continent", value: continent }] : []),
...(country ? [{ key: "country", value: country }] : []),
...(city ? [{ key: "city", value: city }] : []),
...(device ? [{ key: "device", value: device }] : []),
@@ -146,6 +151,9 @@ export default function Toggle({
const cities = useAnalyticsFilterOption("cities", {
cacheOnly: !isRequested("city"),
});
+ const continents = useAnalyticsFilterOption("continents", {
+ cacheOnly: !isRequested("continent"),
+ });
const devices = useAnalyticsFilterOption("devices", {
cacheOnly: !isRequested("device"),
});
@@ -362,6 +370,21 @@ export default function Toggle({
right: nFormatter(count, { full: true }),
})) ?? null,
},
+ {
+ key: "continent",
+ icon: MapPosition,
+ label: "Continent",
+ getOptionIcon: (value) => (
+ <ContinentIcon display={value} className="size-2.5" />
+ ),
+ getOptionLabel: (value) => CONTINENTS[value],
+ options:
+ continents?.map(({ continent, count }) => ({
+ value: continent,
+ label: CONTINENTS[continent],
+ right: nFormatter(count, { full: true }),
+ })) ?? null,
+ },
{
key: "device",
icon: MobilePhone,
@@ -440,7 +463,7 @@ export default function Toggle({
return (
<>
<div
- className={cn("sticky top-11 z-10 bg-gray-50/80 py-3 md:py-3", {
+ className={cn("sticky top-11 z-10 bg-gray-50 py-3 md:py-3", {
"top-14": isPublicStatsPage,
"top-0": adminPage,
"top-16": demoPage,
diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.ts
index 7e1f7d0a2f..3b57a08719 100644
--- a/packages/ui/src/icons/nucleo/index.ts
+++ b/packages/ui/src/icons/nucleo/index.ts
@@ -41,6 +41,7 @@ export * from "./invoice-dollar";
export * from "./key";
export * from "./lines-y";
export * from "./magnifier";
+export * from "./map-position";
export * from "./mobile-phone";
export * from "./office-building";
export * from "./page2";
diff --git a/packages/ui/src/icons/nucleo/map-position.tsx b/packages/ui/src/icons/nucleo/map-position.tsx
new file mode 100644
index 0000000000..2ac730d741
--- /dev/null
+++ b/packages/ui/src/icons/nucleo/map-position.tsx
@@ -0,0 +1,45 @@
+import { SVGProps } from "react";
+
+export function MapPosition(props: SVGProps<SVGSVGElement>) {
+ return (
+ <svg
+ height="18"
+ width="18"
+ viewBox="0 0 18 18"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ >
+ <g fill="currentColor">
+ <circle
+ cx="15.25"
+ cy="12.75"
+ fill="none"
+ r="2"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M16.25,8.371v-3.374c0-.64-.592-1.115-1.217-.976l-2.998,.666c-.186,.041-.38,.029-.559-.036l-4.952-1.801c-.179-.065-.373-.078-.559-.036l-3.432,.763c-.458,.102-.783,.508-.783,.976V13.003c0,.64,.592,1.115,1.217,.976l2.998-.666c.186-.041,.38-.029,.559,.036l4.926,1.791"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="15.25"
+ x2="15.25"
+ y1="14.75"
+ y2="17.25"
+ />
+ </g>
+ </svg>
+ );
+}