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 button

Steven Teyf4894b68e1ee
diff --git a/apps/web/ui/analytics/bar-list.tsx b/apps/web/ui/analytics/bar-list.tsx
index 72b678683f..add0ef0ace 100644
--- a/apps/web/ui/analytics/bar-list.tsx
+++ b/apps/web/ui/analytics/bar-list.tsx
@@ -7,15 +7,7 @@ import { cn, nFormatter, truncate } from "@dub/utils";
import { motion } from "framer-motion";
import { Search } from "lucide-react";
import Link from "next/link";
-import {
- Dispatch,
- ReactNode,
- SetStateAction,
- useContext,
- useMemo,
- useState,
-} from "react";
-import { AnalyticsContext } from "./analytics-provider";
+import { Dispatch, ReactNode, SetStateAction, useMemo, useState } from "react";
import LinkPreviewTooltip from "./link-preview";
export default function BarList({
@@ -43,8 +35,6 @@ export default function BarList({
}) {
const [search, setSearch] = useState("");
- const { selectedTab } = useContext(AnalyticsContext);
-
// TODO: mock pagination for better perf in React
// TODO: fix for top links since it's technically link IDs
const filteredData = useMemo(() => {
diff --git a/apps/web/ui/analytics/events/events-table.tsx b/apps/web/ui/analytics/events/events-table.tsx
index 616481530b..081af8cf0f 100644
--- a/apps/web/ui/analytics/events/events-table.tsx
+++ b/apps/web/ui/analytics/events/events-table.tsx
@@ -4,6 +4,7 @@ import { editQueryString } from "@/lib/analytics/utils";
import { clickEventEnrichedSchema } from "@/lib/zod/schemas/clicks";
import { leadEventEnrichedSchema } from "@/lib/zod/schemas/leads";
import { saleEventEnrichedSchema } from "@/lib/zod/schemas/sales";
+import { Filter } from "@/ui/shared/icons";
import {
Button,
CursorRays,
@@ -30,6 +31,7 @@ import {
useReactTable,
} from "@tanstack/react-table";
import { AnimatePresence, motion } from "framer-motion";
+import Link from "next/link";
import { useContext, useEffect, useMemo } from "react";
import useSWR from "swr";
import z from "zod";
@@ -37,7 +39,7 @@ import { AnalyticsContext } from "../analytics-provider";
import DeviceIcon from "../device-icon";
import usePagination from "./use-pagination";
-const PAGE_SIZE = 500;
+const PAGE_SIZE = 100;
const tableCellClassName =
"border-r border-b border-gray-200 px-4 py-2.5 text-left text-sm leading-6 whitespace-nowrap overflow-hidden [&>.flex]:pr-4";
@@ -81,6 +83,13 @@ const eventColumns: Record<
},
};
+const FilterButton = () => (
+ <div className="group-hover:animate-slide-left-fade absolute right-0 rounded-lg border border-gray-200 bg-white p-1 opacity-0 shadow-lg group-hover:opacity-100">
+ <span className="sr-only">Filter</span>
+ <Filter className="h-3 w-3 text-black" />
+ </div>
+);
+
export default function EventsTable() {
const { searchParams, queryParams } = useRouterStuff();
const tab = searchParams.get("tab") || "clicks";
@@ -135,7 +144,18 @@ export default function EventsTable() {
header: "Link",
accessorKey: "link",
cell: ({ getValue }) => (
- <div className="flex items-center gap-3">
+ <Link
+ href={
+ queryParams({
+ set: {
+ domain: getValue().domain,
+ key: getValue().key,
+ },
+ getNewPath: true,
+ }) as string
+ }
+ className="group relative flex items-center gap-3"
+ >
<LinkLogo
apexDomain={getApexDomain(getValue().url)}
className="h-4 w-4 sm:h-4 sm:w-4"
@@ -146,7 +166,8 @@ export default function EventsTable() {
</span>
{getValue().key === "_root" ? "" : `/${getValue().key}`}
</span>
- </div>
+ <FilterButton />
+ </Link>
),
},
{
@@ -173,14 +194,25 @@ export default function EventsTable() {
header: "Country",
accessorKey: "country",
cell: ({ getValue }) => (
- <div className="flex items-center gap-3">
+ <Link
+ href={
+ queryParams({
+ set: {
+ country: getValue(),
+ },
+ getNewPath: true,
+ }) as string
+ }
+ className="group relative flex items-center gap-3"
+ >
<img
alt={getValue()}
src={`https://hatscripts.github.io/circle-flags/flags/${getValue().toLowerCase()}.svg`}
className="h-4 w-4"
/>
<span>{COUNTRIES[getValue()] ?? getValue()}</span>
- </div>
+ <FilterButton />
+ </Link>
),
},
{
@@ -188,14 +220,25 @@ export default function EventsTable() {
header: "Device",
accessorKey: "device",
cell: ({ getValue }) => (
- <div className="flex items-center gap-3">
+ <Link
+ href={
+ queryParams({
+ set: {
+ device: getValue(),
+ },
+ getNewPath: true,
+ }) as string
+ }
+ className="group relative flex items-center gap-3"
+ >
<DeviceIcon
display={capitalize(getValue()) ?? getValue()}
tab="devices"
className="h-4 w-4"
/>
<span>{getValue()}</span>
- </div>
+ <FilterButton />
+ </Link>
),
},
// Date