The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix events table link fields
Steven Tey42987ba1b8d4
diff --git a/apps/web/ui/analytics/events/events-table.tsx b/apps/web/ui/analytics/events/events-table.tsxindex 967376a20b..092c5b2de1 100644--- a/apps/web/ui/analytics/events/events-table.tsx+++ b/apps/web/ui/analytics/events/events-table.tsx@@ -17,6 +17,7 @@ import {useRouterStuff,useTable,} from "@dub/ui";+import { CopyText } from "@dub/ui/src";import {CursorRays,FilterBars,@@ -151,27 +152,22 @@ export default function EventsTable() {key: getValue().key,}),},- cell: ({ getValue }) => {- const path = getValue().key === "_root" ? "" : `/${getValue().key}`;-- return (- <div className="flex items-center gap-3">- <LinkLogo- apexDomain={getApexDomain(getValue().url)}- className="size-4 shrink-0 sm:size-4"- />- <span- className="truncate"- title={`${getValue().domain}${path}`}- >- <span className="font-medium text-gray-950">- {getValue().domain}- </span>- {path}+ cell: ({ getValue }) => (+ <div className="flex items-center gap-3">+ <LinkLogo+ apexDomain={getApexDomain(getValue().url)}+ className="size-4 shrink-0 sm:size-4"+ />+ <CopyText+ value={getValue().shortLink}+ successMessage="Copied link to clipboard!"+ >+ <span className="truncate" title={getValue().shortLink}>+ {getPrettyUrl(getValue().shortLink)}</span>- </div>- );- },+ </CopyText>+ </div>+ ),},{id: "customer",@@ -363,7 +359,7 @@ export default function EventsTable() {filterParams: ({ getValue }) => ({ refererUrl: getValue() }),},cell: ({ getValue }) => (- <div className="flex items-center gap-3" title={getValue()}>+ <div className="flex items-center gap-3">{getValue() === "(direct)" ? (<Link2 className="h-4 w-4" />) : (@@ -372,7 +368,14 @@ export default function EventsTable() {className="size-4 shrink-0 sm:size-4"/>)}- <span className="truncate">{getPrettyUrl(getValue())}</span>+ <CopyText+ value={getValue()}+ successMessage="Copied referer URL to clipboard!"+ >+ <span className="truncate" title={getValue()}>+ {getPrettyUrl(getValue())}+ </span>+ </CopyText></div>),},diff --git a/packages/ui/src/copy-button.tsx b/packages/ui/src/copy-button.tsxindex 57f7a4840f..bae4378e6e 100644--- a/packages/ui/src/copy-button.tsx+++ b/packages/ui/src/copy-button.tsx@@ -12,8 +12,7 @@ const copyButtonVariants = cva({variants: {variant: {- default:- "bg-gray-100 hover:scale-105 hover:bg-blue-100 active:scale-95 text-gray-700 hover:text-blue-800",+ default: "bg-transparent hover:bg-gray-100 active:bg-gray-200",neutral: "bg-transparent hover:bg-gray-100 active:bg-gray-200",},},diff --git a/packages/ui/src/copy-text.tsx b/packages/ui/src/copy-text.tsxnew file mode 100644index 0000000000..26f99ac2de--- /dev/null+++ b/packages/ui/src/copy-text.tsx@@ -0,0 +1,39 @@+"use client";++import { cn } from "@dub/utils";+import { ReactNode, useState } from "react";+import { toast } from "sonner";++export function CopyText({+ value,+ children,+ className,+ successMessage,+}: {+ value: string;+ children: ReactNode;+ className?: string;+ successMessage?: string;+}) {+ const [copied, setCopied] = useState(false);+ return (+ <button+ onClick={(e) => {+ e.stopPropagation();+ setCopied(true);+ navigator.clipboard.writeText(value).then(() => {+ toast.success(successMessage || "Copied to clipboard!");+ });+ setTimeout(() => setCopied(false), 3000);+ }}+ type="button"+ className={cn(+ "cursor-copy text-sm text-gray-700 decoration-dotted hover:underline",+ copied && "cursor-default",+ className,+ )}+ >+ {children}+ </button>+ );+}diff --git a/packages/ui/src/index.tsx b/packages/ui/src/index.tsxindex 88b8083a1e..79a7df5469 100644--- a/packages/ui/src/index.tsx+++ b/packages/ui/src/index.tsx@@ -51,6 +51,7 @@ export * from "./animated-size-container";export * from "./blur-image";export * from "./client-only";export * from "./copy-button";+export * from "./copy-text";export * from "./counting-numbers";export * from "./icon-menu";export * from "./inline-snippet";diff --git a/packages/ui/src/tooltip.tsx b/packages/ui/src/tooltip.tsxindex 18c294d40c..013875beb8 100644--- a/packages/ui/src/tooltip.tsx+++ b/packages/ui/src/tooltip.tsx@@ -11,7 +11,7 @@ import { Button, ButtonProps, buttonVariants } from "./button";export function TooltipProvider({ children }: { children: ReactNode }) {return (- <TooltipPrimitive.Provider delayDuration={100}>+ <TooltipPrimitive.Provider delayDuration={150}>{children}</TooltipPrimitive.Provider>);