The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
CustomerRowItem
Steven Teyfcdec37f34cf
diff --git a/apps/web/ui/analytics/events/customer-row-item.tsx b/apps/web/ui/analytics/events/customer-row-item.tsxnew file mode 100644index 0000000000..3190f8cd2b--- /dev/null+++ b/apps/web/ui/analytics/events/customer-row-item.tsx@@ -0,0 +1,33 @@+import { generateRandomName } from "@/lib/names";+import { Customer } from "@/lib/types";+import { useCustomerDetailsSheet } from "@/ui/partners/customer-details-sheet";+import { ChartActivity2 } from "@dub/ui";++export function CustomerRowItem({ customer }: { customer: Customer }) {+ const { customerDetailsSheet, setIsOpen: setShowCustomerDetailsSheet } =+ useCustomerDetailsSheet({+ customer,+ });++ const display = customer.name || customer.email || generateRandomName();++ return (+ <>+ {customerDetailsSheet}+ <button+ className="flex w-full items-center justify-between transition-colors hover:bg-stone-100"+ onClick={() => setShowCustomerDetailsSheet(true)}+ >+ <div className="flex items-center gap-3" title={display}>+ <img+ alt={display}+ src={customer.avatar || ""}+ className="size-4 shrink-0 rounded-full border border-neutral-200"+ />+ <span className="truncate">{display}</span>+ </div>+ <ChartActivity2 className="size-3.5" />+ </button>+ </>+ );+}diff --git a/apps/web/ui/analytics/events/events-table.tsx b/apps/web/ui/analytics/events/events-table.tsxindex 4dff7c6b4b..ccebe3d5a4 100644--- a/apps/web/ui/analytics/events/events-table.tsx+++ b/apps/web/ui/analytics/events/events-table.tsx@@ -1,12 +1,9 @@"use client";import { editQueryString } from "@/lib/analytics/utils";-import { generateRandomName } from "@/lib/names";import { ClickEvent, LeadEvent, SaleEvent } from "@/lib/types";import EmptyState from "@/ui/shared/empty-state";import {- Avatar,- CopyButton,CopyText,LinkLogo,Table,@@ -33,6 +30,7 @@ import useSWR from "swr";import { AnalyticsContext } from "../analytics-provider";import ContinentIcon from "../continent-icon";import DeviceIcon from "../device-icon";+import { CustomerRowItem } from "./customer-row-item";import EditColumnsButton from "./edit-columns-button";import { EventsContext } from "./events-provider";import { exampleData } from "./example-data";@@ -63,6 +61,7 @@ export default function EventsTable({eventsApiPath,totalEvents,} = useContext(AnalyticsContext);+const { columnVisibility, setColumnVisibility } = useColumnVisibility();const sortBy = searchParams.get("sort") || "timestamp";@@ -113,7 +112,7 @@ export default function EventsTable({<span className="truncate" title={getValue()}>{getValue()}</span>- ) || <span className="text-gray-400">-</span>,+ ) || <span className="text-neutral-400">-</span>,},{id: "link",@@ -148,50 +147,7 @@ export default function EventsTable({id: "customer",header: "Customer",accessorKey: "customer",- cell: ({ getValue }) => {- const customer = getValue();- const display =- customer.name || customer.email || generateRandomName();- return (- <Tooltip- content={- <div className="w-full p-3">- <Avatar- user={{- name: customer.name,- email: customer.email || customer.externalId,- image: customer.avatar,- }}- className="h-8 w-8"- />- <p className="mt-2 text-sm font-semibold text-gray-700">- {display}- </p>- <div className="flex items-center gap-1 text-xs text-gray-500">- <p className="max-w-[12rem] truncate">- {customer.email || customer.externalId}- </p>- <CopyButton- value={customer.email || customer.externalId}- variant="neutral"- className="p-1 [&>*]:h-3 [&>*]:w-3"- successMessage="Copied email to clipboard!"- />- </div>- </div>- }- >- <div className="flex items-center gap-3" title={display}>- <img- alt={display}- src={customer.avatar}- className="size-4 shrink-0 rounded-full border border-gray-200"- />- <span className="truncate">{display}</span>- </div>- </Tooltip>- );- },+ cell: ({ getValue }) => <CustomerRowItem customer={getValue()} />,},{id: "country",@@ -410,7 +366,7 @@ export default function EventsTable({cell: ({ getValue }) => (<div className="flex items-center gap-2"><span>${nFormatter(getValue() / 100)}</span>- <span className="text-gray-400">USD</span>+ <span className="text-neutral-400">USD</span></div>),},@@ -425,7 +381,7 @@ export default function EventsTable({<span className="truncate" title={getValue()}>{getValue()}</span>- ) || <span className="text-gray-400">-</span>,+ ) || <span className="text-neutral-400">-</span>,},// Date{diff --git a/apps/web/ui/analytics/events/filter-button.tsx b/apps/web/ui/analytics/events/filter-button.tsxindex d745f32fbf..8401793169 100644--- a/apps/web/ui/analytics/events/filter-button.tsx+++ b/apps/web/ui/analytics/events/filter-button.tsx@@ -18,7 +18,7 @@ export default function FilterButton({ set }: { set: Record<string, any> }) {className="block rounded-md border border-transparent bg-white p-0.5 text-gray-600 transition-colors hover:border-gray-200 hover:bg-gray-100 hover:text-gray-950"><span className="sr-only">Filter</span>- <FilterBars className="h-3.5 w-3.5" />+ <FilterBars className="size-3.5" /></Link></div>);diff --git a/apps/web/ui/analytics/events/row-menu-button.tsx b/apps/web/ui/analytics/events/row-menu-button.tsxindex 55ede8f5ed..b53f0be9e4 100644--- a/apps/web/ui/analytics/events/row-menu-button.tsx+++ b/apps/web/ui/analytics/events/row-menu-button.tsx@@ -1,6 +1,5 @@-import { useCustomerDetailsSheet } from "@/ui/partners/customer-details-sheet";import { Button, Icon, Popover, useCopyToClipboard } from "@dub/ui";-import { ChartActivity2, Copy, Dots } from "@dub/ui/icons";+import { Copy, Dots } from "@dub/ui/icons";import { cn } from "@dub/utils";import { Row } from "@tanstack/react-table";import { Command } from "cmdk";@@ -11,71 +10,50 @@ import { EventDatum } from "./events-table";export function RowMenuButton({ row }: { row: Row<EventDatum> }) {const [isOpen, setIsOpen] = useState(false);const [, copyToClipboard] = useCopyToClipboard();-- const { customerDetailsSheet, setIsOpen: setShowCustomerDetailsSheet } =- useCustomerDetailsSheet({- // @ts-expect-error- customer: row.original.customer,- });-return (- <>- {customerDetailsSheet}- <Popover- openPopover={isOpen}- setOpenPopover={setIsOpen}- content={- <Command tabIndex={0} loop className="focus:outline-none">- <Command.List className="flex w-screen flex-col gap-1 p-1 text-sm sm:w-auto sm:min-w-[130px]">- {"eventId" in row.original && (- <MenuItem- icon={Copy}- label="Copy event ID"- onSelect={() => {- if (!("eventId" in row.original)) return;- const eventId = row.original.eventId as string;- toast.promise(copyToClipboard(eventId), {- success: "Copied to clipboard",- });- setIsOpen(false);- }}- />- )}+ <Popover+ openPopover={isOpen}+ setOpenPopover={setIsOpen}+ content={+ <Command tabIndex={0} loop className="focus:outline-none">+ <Command.List className="flex w-screen flex-col gap-1 p-1 text-sm sm:w-auto sm:min-w-[130px]">+ {"eventId" in row.original && (<MenuItemicon={Copy}- label="Copy click ID"+ label="Copy event ID"onSelect={() => {- const clickId = row.original.click_id as string;- toast.promise(copyToClipboard(clickId), {+ if (!("eventId" in row.original)) return;+ const eventId = row.original.eventId as string;+ toast.promise(copyToClipboard(eventId), {success: "Copied to clipboard",});setIsOpen(false);}}/>-- {"customer" in row.original && (- <MenuItem- icon={ChartActivity2}- label="View activity"- onSelect={() => {- setShowCustomerDetailsSheet(true);- setIsOpen(false);- }}- />- )}- </Command.List>- </Command>- }- align="end"- >- <Button- type="button"- className="h-8 whitespace-nowrap px-2"- variant="outline"- icon={<Dots className="h-4 w-4 shrink-0" />}- />- </Popover>- </>+ )}+ <MenuItem+ icon={Copy}+ label="Copy click ID"+ onSelect={() => {+ const clickId = row.original.click_id as string;+ toast.promise(copyToClipboard(clickId), {+ success: "Copied to clipboard",+ });+ setIsOpen(false);+ }}+ />+ </Command.List>+ </Command>+ }+ align="end"+ >+ <Button+ type="button"+ className="h-8 whitespace-nowrap px-2"+ variant="outline"+ icon={<Dots className="h-4 w-4 shrink-0" />}+ />+ </Popover>);}