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.

rearrange events columns

Steven Tey138adab1f27a
diff --git a/apps/web/ui/analytics/events/events-table.tsx b/apps/web/ui/analytics/events/events-table.tsx
index 10a1b5b085..e2784efa27 100644
--- a/apps/web/ui/analytics/events/events-table.tsx
+++ b/apps/web/ui/analytics/events/events-table.tsx
@@ -83,7 +83,7 @@ export default function EventsTable({
header: "Date",
accessorFn: (d: { timestamp: string }) => new Date(d.timestamp),
enableHiding: false,
- minSize: 100,
+ size: 160,
cell: ({ getValue }) => (
<Tooltip
content={getValue().toLocaleTimeString("en-US", {
@@ -108,6 +108,25 @@ export default function EventsTable({
</Tooltip>
),
},
+ // Sale amount
+ {
+ id: "saleAmount",
+ header: "Amount",
+ accessorKey: "sale.amount",
+ size: 120,
+ cell: ({ getValue }) => (
+ <div className="flex items-center gap-2">
+ <span>
+ {currencyFormatter(getValue() / 100, {
+ maximumFractionDigits: undefined,
+ // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated
+ trailingZeroDisplay: "stripIfInteger",
+ })}
+ </span>
+ <span className="text-neutral-400">USD</span>
+ </div>
+ ),
+ },
// Click trigger
{
id: "trigger",
@@ -152,6 +171,30 @@ export default function EventsTable({
<span className="text-neutral-400">-</span>
),
},
+ {
+ id: "customer",
+ header: "Customer",
+ accessorKey: "customer",
+ minSize: 300,
+ size: 300,
+ maxSize: 400,
+ cell: ({ getValue }) => (
+ <CustomerRowItem
+ customer={getValue()}
+ href={
+ partnerPage
+ ? `/programs/${programSlug}/customers/${getValue().id}`
+ : `/${slug}/customers/${getValue().id}`
+ }
+ className="px-4 py-2.5"
+ />
+ ),
+ meta: {
+ filterParams: ({ getValue }) => ({
+ customerId: getValue().id,
+ }),
+ },
+ },
{
id: "link",
header: "Link",
@@ -197,28 +240,53 @@ export default function EventsTable({
},
},
{
- id: "customer",
- header: "Customer",
- accessorKey: "customer",
- minSize: 300,
- size: 300,
- maxSize: 400,
+ id: "referer",
+ header: "Referer",
+ accessorKey: "click.referer",
+ meta: {
+ filterParams: ({ getValue }) => ({ referer: getValue() }),
+ },
cell: ({ getValue }) => (
- <CustomerRowItem
- customer={getValue()}
- href={
- partnerPage
- ? `/programs/${programSlug}/customers/${getValue().id}`
- : `/${slug}/customers/${getValue().id}`
- }
- className="px-4 py-2.5"
- />
+ <div className="flex items-center gap-3" title={getValue()}>
+ {getValue() === "(direct)" ? (
+ <Link2 className="h-4 w-4" />
+ ) : (
+ <LinkLogo
+ apexDomain={getValue()}
+ className="size-4 shrink-0 sm:size-4"
+ />
+ )}
+ <span className="truncate">{getValue()}</span>
+ </div>
),
+ },
+ {
+ id: "refererUrl",
+ header: "Referrer URL",
+ accessorKey: "click.refererUrl",
meta: {
- filterParams: ({ getValue }) => ({
- customerId: getValue().id,
- }),
+ filterParams: ({ getValue }) => ({ refererUrl: getValue() }),
},
+ cell: ({ getValue }) => (
+ <div className="flex items-center gap-3">
+ {getValue() === "(direct)" ? (
+ <Link2 className="h-4 w-4" />
+ ) : (
+ <LinkLogo
+ apexDomain={getApexDomain(getValue())}
+ className="size-4 shrink-0 sm:size-4"
+ />
+ )}
+ <CopyText
+ value={getValue()}
+ successMessage="Copied referrer URL to clipboard!"
+ >
+ <span className="truncate" title={getValue()}>
+ {getPrettyUrl(getValue())}
+ </span>
+ </CopyText>
+ </div>
+ ),
},
{
id: "country",
@@ -362,55 +430,6 @@ export default function EventsTable({
</div>
),
},
- {
- id: "referer",
- header: "Referer",
- accessorKey: "click.referer",
- meta: {
- filterParams: ({ getValue }) => ({ referer: getValue() }),
- },
- cell: ({ getValue }) => (
- <div className="flex items-center gap-3" title={getValue()}>
- {getValue() === "(direct)" ? (
- <Link2 className="h-4 w-4" />
- ) : (
- <LinkLogo
- apexDomain={getValue()}
- className="size-4 shrink-0 sm:size-4"
- />
- )}
- <span className="truncate">{getValue()}</span>
- </div>
- ),
- },
- {
- id: "refererUrl",
- header: "Referrer URL",
- accessorKey: "click.refererUrl",
- meta: {
- filterParams: ({ getValue }) => ({ refererUrl: getValue() }),
- },
- cell: ({ getValue }) => (
- <div className="flex items-center gap-3">
- {getValue() === "(direct)" ? (
- <Link2 className="h-4 w-4" />
- ) : (
- <LinkLogo
- apexDomain={getApexDomain(getValue())}
- className="size-4 shrink-0 sm:size-4"
- />
- )}
- <CopyText
- value={getValue()}
- successMessage="Copied referrer URL to clipboard!"
- >
- <span className="truncate" title={getValue()}>
- {getPrettyUrl(getValue())}
- </span>
- </CopyText>
- </div>
- ),
- },
{
id: "ip",
header: "IP Address",
@@ -428,25 +447,6 @@ export default function EventsTable({
</Tooltip>
),
},
- // Sale amount
- {
- id: "saleAmount",
- header: "Sale Amount",
- accessorKey: "sale.amount",
- minSize: 120,
- cell: ({ getValue }) => (
- <div className="flex items-center gap-2">
- <span>
- {currencyFormatter(getValue() / 100, {
- maximumFractionDigits: undefined,
- // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated
- trailingZeroDisplay: "stripIfInteger",
- })}
- </span>
- <span className="text-neutral-400">USD</span>
- </div>
- ),
- },
// Sale invoice ID
{
id: "invoiceId",
diff --git a/apps/web/ui/analytics/events/use-column-visibility.ts b/apps/web/ui/analytics/events/use-column-visibility.ts
index 45b1afd868..b37ebeb627 100644
--- a/apps/web/ui/analytics/events/use-column-visibility.ts
+++ b/apps/web/ui/analytics/events/use-column-visibility.ts
@@ -19,7 +19,7 @@ export const eventColumns = {
"ip",
"timestamp",
],
- defaultVisible: ["trigger", "link", "country", "device", "timestamp"],
+ defaultVisible: ["timestamp", "trigger", "link", "referer", "country"],
},
leads: {
all: [
@@ -38,14 +38,7 @@ export const eventColumns = {
"ip",
"timestamp",
],
- defaultVisible: [
- "event",
- "link",
- "customer",
- "country",
- "device",
- "timestamp",
- ],
+ defaultVisible: ["timestamp", "event", "link", "customer", "referer"],
},
sales: {
all: [
@@ -67,12 +60,12 @@ export const eventColumns = {
"saleAmount",
],
defaultVisible: [
+ "timestamp",
+ "saleAmount",
"event",
- "link",
"customer",
- "country",
- "saleAmount",
- "timestamp",
+ "referer",
+ "link",
],
},
};
diff --git a/apps/web/ui/analytics/index.tsx b/apps/web/ui/analytics/index.tsx
index 1e99f7bbbf..79f76761e5 100644
--- a/apps/web/ui/analytics/index.tsx
+++ b/apps/web/ui/analytics/index.tsx
@@ -59,9 +59,9 @@ function StatsGrid() {
return hide ? null : (
<div className="grid grid-cols-1 gap-5 md:grid-cols-2">
{!dashboardProps && <TopLinks />}
+ <Referer />
<Locations />
<Devices />
- <Referer />
{/* <Feedback /> */}
</div>
);