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 links

Tim Wilson0d059da2f3e7
diff --git a/apps/web/ui/customers/customer-details-column.tsx b/apps/web/ui/customers/customer-details-column.tsx
index 3521576df1..c857e23bda 100644
--- a/apps/web/ui/customers/customer-details-column.tsx
+++ b/apps/web/ui/customers/customer-details-column.tsx
@@ -1,5 +1,5 @@
import { CustomerActivityResponse, CustomerProps } from "@/lib/types";
-import { UTM_PARAMETERS } from "@dub/ui";
+import { ArrowUpRight, UTM_PARAMETERS } from "@dub/ui";
import {
capitalize,
cn,
@@ -47,14 +47,24 @@ export function CustomerDetailsColumn({
<DetailHeading>Details</DetailHeading>
{customer ? (
customer.country && (
- <span className="flex items-center gap-2">
- <img
- src={`https://hatscripts.github.io/circle-flags/flags/${customer.country.toLowerCase()}.svg`}
- alt=""
- className="size-3.5"
- />
- <span className="truncate">{COUNTRIES[customer.country]}</span>
- </span>
+ <ConditionalLink
+ href={
+ workspaceSlug
+ ? `/${workspaceSlug}/analytics?country=${encodeURIComponent(customer.country)}`
+ : undefined
+ }
+ target="_blank"
+ linkClassName="underline-offset-2 hover:text-neutral-950 hover:underline"
+ >
+ <div className="flex items-center gap-2">
+ <img
+ src={`https://hatscripts.github.io/circle-flags/flags/${customer.country.toLowerCase()}.svg`}
+ alt=""
+ className="size-3.5 shrink-0"
+ />
+ <span className="truncate">{COUNTRIES[customer.country]}</span>
+ </div>
+ </ConditionalLink>
)
) : (
<div className="h-5 w-24 animate-pulse rounded-md bg-neutral-100" />
@@ -62,6 +72,7 @@ export function CustomerDetailsColumn({
{click
? [
{
+ key: "os",
icon: (
<DeviceIcon
display={capitalize(click.os)!}
@@ -72,6 +83,7 @@ export function CustomerDetailsColumn({
value: click.os,
},
{
+ key: "device",
icon: (
<DeviceIcon
display={capitalize(click.device)!}
@@ -82,6 +94,7 @@ export function CustomerDetailsColumn({
value: click.device,
},
{
+ key: "browser",
icon: (
<DeviceIcon
display={capitalize(click.browser)!}
@@ -93,11 +106,21 @@ export function CustomerDetailsColumn({
},
]
.filter(({ value }) => value)
- .map(({ icon, value }, idx) => (
- <span className="flex items-center gap-2">
- {icon}
- <span className="truncate">{value}</span>
- </span>
+ .map(({ key, icon, value }, idx) => (
+ <ConditionalLink
+ href={
+ workspaceSlug
+ ? `/${workspaceSlug}/analytics?${key}=${encodeURIComponent(value)}`
+ : undefined
+ }
+ target="_blank"
+ linkClassName="underline-offset-2 hover:text-neutral-950 hover:underline"
+ >
+ <span key={key} className="flex items-center gap-2">
+ {icon}
+ <span className="truncate">{value}</span>
+ </span>
+ </ConditionalLink>
))
: (isCustomerActivityLoading || !customer) && (
<div className="h-5 w-12 animate-pulse rounded-md bg-neutral-100" />
@@ -147,7 +170,7 @@ export function CustomerDetailsColumn({
}
target="_blank"
className="min-w-0 overflow-hidden truncate"
- linkClassName="cursor-alias decoration-dotted underline-offset-2 hover:text-neutral-950 hover:underline"
+ linkClassName="underline-offset-2 hover:text-neutral-950 hover:underline"
>
{getPrettyUrl(link.shortLink)}
</ConditionalLink>
@@ -160,10 +183,20 @@ export function CustomerDetailsColumn({
<div className="flex flex-col gap-2">
<DetailHeading>UTM</DetailHeading>
<div className="grid w-full grid-cols-[min-content,minmax(0,1fr)] gap-x-4 gap-y-2 overflow-hidden">
- {utmParams.map(({ label, value }) => (
- <Fragment key={label}>
+ {utmParams.map(({ key, label, value }) => (
+ <Fragment key={key}>
<span className="truncate">{label}</span>
- <span className="truncate text-neutral-500">{value}</span>
+ <ConditionalLink
+ href={
+ workspaceSlug &&
+ `/${workspaceSlug}/analytics?${key}=${encodeURIComponent(value)}`
+ }
+ target="_blank"
+ className="truncate text-neutral-500"
+ linkClassName="underline-offset-2 hover:text-neutral-600 hover:underline"
+ >
+ {value}
+ </ConditionalLink>
</Fragment>
))}
</div>
@@ -192,10 +225,15 @@ const ConditionalLink = ({
...rest
}: HTMLProps<HTMLAnchorElement> & { linkClassName?: string }) => {
return href ? (
- <Link href={href} className={cn(className, linkClassName)} {...rest}>
- {children}
+ <Link
+ href={href}
+ className={cn("group flex items-center", className, linkClassName)}
+ {...rest}
+ >
+ <div className="min-w-0 truncate">{children}</div>
+ <ArrowUpRight className="ml-1 size-3 shrink-0 -translate-x-0.5 translate-y-0.5 opacity-0 transition-[transform,opacity] group-hover:translate-x-0 group-hover:translate-y-0 group-hover:opacity-100" />
</Link>
) : (
- <span className={className}>{children}</span>
+ <div className={className}>{children}</div>
);
};