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 columns + show LTV

Steven Teye6909653fa96
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page.tsx
index 6e3ad8d4d3..bab2f49044 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page.tsx
@@ -69,12 +69,12 @@ export default function PartnerProgramCustomersPage() {
"country",
"link",
"createdAt",
- "firstSaleAt",
...(CUSTOMER_LTV_EXCLUDED_PROGRAM_IDS.includes(
programEnrollment?.programId ?? "",
)
? []
: ["saleAmount"]),
+ "firstSaleAt",
"subscriptionCanceledAt",
],
defaultVisible: [
@@ -82,12 +82,12 @@ export default function PartnerProgramCustomersPage() {
"country",
"link",
"createdAt",
- "firstSaleAt",
...(CUSTOMER_LTV_EXCLUDED_PROGRAM_IDS.includes(
programEnrollment?.programId ?? "",
)
? []
: ["saleAmount"]),
+ "firstSaleAt",
"subscriptionCanceledAt",
],
};
@@ -175,6 +175,24 @@ export default function PartnerProgramCustomersPage() {
</TimestampTooltip>
),
},
+ ...(CUSTOMER_LTV_EXCLUDED_PROGRAM_IDS.includes(
+ programEnrollment?.programId ?? "",
+ )
+ ? []
+ : [
+ {
+ id: "saleAmount",
+ header: "LTV",
+ meta: {
+ headerTooltip:
+ "The customer's lifetime value (how much revenue the customer has generated over their lifetime).",
+ },
+ accessorKey: "saleAmount",
+ cell: ({ row }) => (
+ <span>{currencyFormatter(row.original.saleAmount)}</span>
+ ),
+ },
+ ]),
{
id: "firstSaleAt",
header: "Paid",
@@ -197,24 +215,6 @@ export default function PartnerProgramCustomersPage() {
"-"
),
},
- ...(CUSTOMER_LTV_EXCLUDED_PROGRAM_IDS.includes(
- programEnrollment?.programId ?? "",
- )
- ? []
- : [
- {
- id: "saleAmount",
- header: "LTV",
- meta: {
- headerTooltip:
- "The customer's lifetime value (how much revenue the customer has generated over their lifetime).",
- },
- accessorKey: "saleAmount",
- cell: ({ row }) => (
- <span>{currencyFormatter(row.original.saleAmount)}</span>
- ),
- },
- ]),
{
id: "subscriptionCanceledAt",
header: "Canceled",
diff --git a/apps/web/lib/zod/schemas/partner-profile.ts b/apps/web/lib/zod/schemas/partner-profile.ts
index 234e680690..0767d140c6 100644
--- a/apps/web/lib/zod/schemas/partner-profile.ts
+++ b/apps/web/lib/zod/schemas/partner-profile.ts
@@ -106,8 +106,8 @@ export const PartnerProfileCustomerSchema = CustomerEnrichedSchema.pick({
email: true,
country: true,
createdAt: true,
- firstSaleAt: true,
saleAmount: true,
+ firstSaleAt: true,
subscriptionCanceledAt: true,
}).extend({
activity: customerActivityResponseSchema,
@@ -267,8 +267,8 @@ export const getPartnerCustomersQuerySchema = z
sortBy: z
.enum([
"createdAt",
- "firstSaleAt",
"saleAmount",
+ "firstSaleAt",
"subscriptionCanceledAt",
])
.optional()
diff --git a/apps/web/ui/customers/customer-details-column.tsx b/apps/web/ui/customers/customer-details-column.tsx
index 5d6a2134f4..3183f17dcf 100644
--- a/apps/web/ui/customers/customer-details-column.tsx
+++ b/apps/web/ui/customers/customer-details-column.tsx
@@ -7,6 +7,7 @@ import {
Envelope,
Globe,
Hyperlink,
+ MoneyBill2,
TimestampTooltip,
Tooltip,
useCurrentProduct,
@@ -16,6 +17,7 @@ import {
capitalize,
cn,
COUNTRIES,
+ currencyFormatter,
getParamsFromURL,
getPrettyUrl,
} from "@dub/utils";
@@ -97,6 +99,21 @@ export function CustomerDetailsColumn({
),
}
: null,
+
+ customer?.saleAmount != null
+ ? {
+ id: "ltv",
+ icon: <MoneyBill2 className="size-3.5 shrink-0" />,
+ text: (
+ <span>
+ LTV:{" "}
+ {currencyFormatter(customer.saleAmount, {
+ trailingZeroDisplay: "stripIfInteger",
+ })}
+ </span>
+ ),
+ }
+ : null,
].filter((field): field is NonNullable<typeof field> => field !== null);
const partner = customer?.partner;