The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Omit sale amounts from partner-facing APIs and UI when revenue sharing is disabled.
Kiran K3eeccfd4341d
diff --git a/apps/web/app/(ee)/api/embed/referrals/analytics/route.ts b/apps/web/app/(ee)/api/embed/referrals/analytics/route.tsindex 2dea1d3212..84d1869eef 100644--- a/apps/web/app/(ee)/api/embed/referrals/analytics/route.ts+++ b/apps/web/app/(ee)/api/embed/referrals/analytics/route.ts@@ -1,5 +1,7 @@import { getAnalytics } from "@/lib/analytics/get-analytics";import { withReferralsEmbedToken } from "@/lib/embed/referrals/auth";+import { omitSaleAmount } from "@/lib/partners/hide-partner-revenue";+import { isPartnerRevenueHidden } from "@/lib/partners/is-partner-revenue-hidden";import { partnerProfileAnalyticsQuerySchema } from "@/lib/zod/schemas/partner-profile";import { parseFilterValue } from "@dub/utils";import { NextResponse } from "next/server";@@ -15,7 +17,7 @@ const querySchema = partnerProfileAnalyticsQuerySchema.pick({// GET /api/embed/referrals/analytics – get analytics for a partnerexport const GET = withReferralsEmbedToken(- async ({ links, program, searchParams }) => {+ async ({ links, program, group, searchParams }) => {if (links.length === 0) {return NextResponse.json([]);}@@ -29,6 +31,28 @@ export const GET = withReferralsEmbedToken(dataAvailableFrom: program.startedAt ?? program.createdAt,});+ if (!isPartnerRevenueHidden(group)) {+ return NextResponse.json(analytics);+ }++ if (Array.isArray(analytics)) {+ return NextResponse.json(+ analytics.map((row) =>+ row && typeof row === "object" && "saleAmount" in row+ ? omitSaleAmount(row)+ : row,+ ),+ );+ }++ if (+ analytics &&+ typeof analytics === "object" &&+ "saleAmount" in analytics+ ) {+ return NextResponse.json(omitSaleAmount(analytics));+ }+return NextResponse.json(analytics);},);diff --git a/apps/web/app/(ee)/api/partner-profile/bounties/route.ts b/apps/web/app/(ee)/api/partner-profile/bounties/route.tsindex c1692a0beb..688bb4a609 100644--- a/apps/web/app/(ee)/api/partner-profile/bounties/route.ts+++ b/apps/web/app/(ee)/api/partner-profile/bounties/route.ts@@ -5,6 +5,7 @@ import { programEnrollmentEligibilityIncludes } from "@/lib/bounty/api/bounty-avimport { getBountiesForPartnerEnrollments } from "@/lib/bounty/api/get-bounties-for-partner";import { aggregatePartnerLinksStats } from "@/lib/partners/aggregate-partner-links-stats";import { getPartnerLinksStatsByProgram } from "@/lib/partners/get-partner-links-stats-by-program";+import { hidePartnerTotalSaleAmount } from "@/lib/partners/hide-partner-revenue";import { prisma } from "@/lib/prisma";import {partnerProfileBountiesQuerySchema,@@ -25,6 +26,11 @@ const programEnrollmentInclude = {defaultGroupId: true,},},+ partnerGroup: {+ select: {+ revenueDataSharingDisabledAt: true,+ },+ },...programEnrollmentEligibilityIncludes,} satisfies Prisma.ProgramEnrollmentInclude;@@ -53,11 +59,22 @@ export const GET = withPartnerProfile(async ({ partner, searchParams }) => {programEnrollments.map(({ program }) => [program.id, program]),);+ const groupsByProgramId = new Map(+ programEnrollments.map(({ programId, partnerGroup }) => [+ programId,+ partnerGroup,+ ]),+ );+return NextResponse.json(z.array(PartnerProfileBountySchema).parse(bounties.map((bounty) => ({...bounty,program: programsById.get(bounty.programId),+ partner: hidePartnerTotalSaleAmount(+ bounty.partner,+ groupsByProgramId.get(bounty.programId),+ ),})),),);diff --git a/apps/web/app/(ee)/api/partner-profile/programs/[programId]/analytics/export/route.ts b/apps/web/app/(ee)/api/partner-profile/programs/[programId]/analytics/export/route.tsindex 012f12d60c..873bc26946 100644--- a/apps/web/app/(ee)/api/partner-profile/programs/[programId]/analytics/export/route.ts+++ b/apps/web/app/(ee)/api/partner-profile/programs/[programId]/analytics/export/route.ts@@ -15,6 +15,8 @@ import {LARGE_PROGRAM_MIN_TOTAL_COMMISSIONS_CENTS,MAX_PARTNER_LINKS_FOR_LOCAL_FILTERING,} from "@/lib/constants/partner-profile";+import { omitSaleAmount } from "@/lib/partners/hide-partner-revenue";+import { isPartnerRevenueHidden } from "@/lib/partners/is-partner-revenue-hidden";import { assertRateLimit } from "@/lib/upstash/assert-rate-limit";import { RATELIMIT_POLICIES } from "@/lib/upstash/ratelimit-policies";import { partnerProfileAnalyticsQuerySchema } from "@/lib/zod/schemas/partner-profile";@@ -30,13 +32,31 @@ export const GET = withPartnerProfile(identifier: [partner.id, params.programId],});- const { program, links, totalCommissions } =+ const { program, links, totalCommissions, partnerGroup } =await getProgramEnrollmentOrThrow({partnerId: partner.id,programId: params.programId,include: {- program: true,- links: true,+ program: {+ select: {+ id: true,+ workspaceId: true,+ startedAt: true,+ createdAt: true,+ },+ },+ links: {+ select: {+ id: true,+ domain: true,+ key: true,+ },+ },+ partnerGroup: {+ select: {+ revenueDataSharingDisabledAt: true,+ },+ },},});@@ -117,7 +137,19 @@ export const GET = withPartnerProfile(useComposite: true,skipEndpoints: PARTNER_PROFILE_SKIP_ENDPOINTS,skipTopLinksForSingleLink: hasExactlyOneLinkIdFilter(parsedParams.linkId),- formatRows: formatPartnerAnalyticsForExport,+ formatRows: (rows) => {+ const formatted = formatPartnerAnalyticsForExport(rows);++ if (!isPartnerRevenueHidden(partnerGroup)) {+ return formatted;+ }++ return formatted.map((row) =>+ row && typeof row === "object" && "saleAmount" in row+ ? omitSaleAmount(row)+ : row,+ );+ },getAnalyticsParams: () =>parsedParams.linkId? { linkId: parsedParams.linkId }diff --git a/apps/web/app/(ee)/api/partner-profile/programs/[programId]/bounties/[bountyId]/route.ts b/apps/web/app/(ee)/api/partner-profile/programs/[programId]/bounties/[bountyId]/route.tsindex b86306c8a6..89e5afa1a1 100644--- a/apps/web/app/(ee)/api/partner-profile/programs/[programId]/bounties/[bountyId]/route.ts+++ b/apps/web/app/(ee)/api/partner-profile/programs/[programId]/bounties/[bountyId]/route.ts@@ -12,6 +12,7 @@ import {aggregatePartnerLinksStats,partnerLinkStatsSelect,} from "@/lib/partners/aggregate-partner-links-stats";+import { hidePartnerTotalSaleAmount } from "@/lib/partners/hide-partner-revenue";import { PartnerBountySchema } from "@/lib/zod/schemas/partner-profile";import { NextResponse } from "next/server";@@ -19,7 +20,7 @@ import { NextResponse } from "next/server";export const GET = withPartnerProfile(async ({ partner, params }) => {const { programId, bountyId } = params;- const { program, links, ...programEnrollment } =+ const { program, links, partnerGroup, ...programEnrollment } =await getProgramEnrollmentOrThrow({partnerId: partner.id,programId,@@ -33,6 +34,11 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {links: {select: partnerLinkStatsSelect,},+ partnerGroup: {+ select: {+ revenueDataSharingDisabledAt: true,+ },+ },...programEnrollmentEligibilityIncludes,},});@@ -82,13 +88,16 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {});}+ const partnerBounty = toPartnerBounty({+ bounty,+ programEnrollment,+ partnerLinksStats: aggregatePartnerLinksStats(links),+ });+return NextResponse.json(- PartnerBountySchema.parse(- toPartnerBounty({- bounty,- programEnrollment,- partnerLinksStats: aggregatePartnerLinksStats(links),- }),- ),+ PartnerBountySchema.parse({+ ...partnerBounty,+ partner: hidePartnerTotalSaleAmount(partnerBounty.partner, partnerGroup),+ }),);});diff --git a/apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/[customerId]/route.ts b/apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/[customerId]/route.tsindex 91bdd8d062..f88a58076b 100644--- a/apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/[customerId]/route.ts+++ b/apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/[customerId]/route.ts@@ -10,6 +10,8 @@ import {LARGE_PROGRAM_MIN_TOTAL_COMMISSIONS_CENTS,} from "@/lib/constants/partner-profile";import { generateRandomName } from "@/lib/names";+import { omitSaleAmount } from "@/lib/partners/hide-partner-revenue";+import { isPartnerRevenueHidden } from "@/lib/partners/is-partner-revenue-hidden";import { prisma } from "@/lib/prisma";import { PartnerProfileCustomerSchema } from "@/lib/zod/schemas/partner-profile";import { toCentsNumber } from "@dub/utils";@@ -21,15 +23,37 @@ import * as z from "zod/v4";export const GET = withPartnerProfile(async ({ partner, params }) => {const { customerId, programId } = params;- const { program, links, totalCommissions, customerDataSharingEnabledAt } =- await getProgramEnrollmentOrThrow({- partnerId: partner.id,- programId: programId,- include: {- program: true,- links: true,+ const {+ program,+ links,+ totalCommissions,+ customerDataSharingEnabledAt,+ partnerGroup,+ } = await getProgramEnrollmentOrThrow({+ partnerId: partner.id,+ programId: programId,+ include: {+ program: {+ select: {+ id: true,+ workspaceId: true,+ },},- });+ links: {+ select: {+ id: true,+ domain: true,+ key: true,+ shortLink: true,+ },+ },+ partnerGroup: {+ select: {+ revenueDataSharingDisabledAt: true,+ },+ },+ },+ });if (LARGE_PROGRAM_IDS.includes(program.id) &&@@ -95,12 +119,17 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {// get the partner link that this customer interacted withconst link = links.find((link) => link.id === attributedPartnerLinkId);+ const hidePartnerRevenue = isPartnerRevenueHidden(partnerGroup);+ const ltvExcluded =+ CUSTOMER_LTV_EXCLUDED_PROGRAM_IDS.includes(program.id) ||+ hidePartnerRevenue;+return NextResponse.json(PartnerProfileCustomerSchema.extend({...(customerDataSharingEnabledAt && { name: z.string().nullish() }),}).omit({- ...(CUSTOMER_LTV_EXCLUDED_PROGRAM_IDS.includes(program.id) && {+ ...(ltvExcluded && {saleAmount: true,}),})@@ -116,7 +145,25 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {}),activity: {...customer,- events,+ events: hidePartnerRevenue+ ? events.map((event) => {+ if (event.event === "sale") {+ const { saleAmount: _, sale, link, ...rest } = event;+ const { amount: __, ...saleRest } = sale;++ return {+ ...rest,+ sale: saleRest,+ link: link ? omitSaleAmount(link) : link,+ };+ }++ return {+ ...event,+ link: event.link ? omitSaleAmount(event.link) : event.link,+ };+ })+ : events,link,},}),diff --git a/apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/export/route.ts b/apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/export/route.tsindex 6519dbff5f..229da0ebd7 100644--- a/apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/export/route.ts+++ b/apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/export/route.ts@@ -9,6 +9,7 @@ import {} from "@/lib/constants/partner-profile";import { qstash } from "@/lib/cron";import { formatPartnerCustomersForExport } from "@/lib/customers/api/format-partner-customers-export";+import { isPartnerRevenueHidden } from "@/lib/partners/is-partner-revenue-hidden";import { prisma, sanitizeFullTextSearch } from "@/lib/prisma";import { partnerCustomersExportQuerySchema } from "@/lib/zod/schemas/partner-profile";import { APP_DOMAIN_WITH_NGROK, toCentsNumber } from "@dub/utils";@@ -23,14 +24,28 @@ export const GET = withPartnerProfile(const filters = partnerCustomersExportQuerySchema.parse(searchParams);const { search, country, linkId, sortBy, sortOrder, columns } = filters;- const { program, totalCommissions, customerDataSharingEnabledAt } =- await getProgramEnrollmentOrThrow({- partnerId: partner.id,- programId: params.programId,- include: {- program: true,+ const {+ program,+ totalCommissions,+ customerDataSharingEnabledAt,+ partnerGroup,+ } = await getProgramEnrollmentOrThrow({+ partnerId: partner.id,+ programId: params.programId,+ include: {+ program: {+ select: {+ id: true,+ workspaceId: true,+ },},- });+ partnerGroup: {+ select: {+ revenueDataSharingDisabledAt: true,+ },+ },+ },+ });if (LARGE_PROGRAM_IDS.includes(program.id) &&@@ -43,7 +58,9 @@ export const GET = withPartnerProfile(});}- const ltvExcluded = CUSTOMER_LTV_EXCLUDED_PROGRAM_IDS.includes(program.id);+ const ltvExcluded =+ CUSTOMER_LTV_EXCLUDED_PROGRAM_IDS.includes(program.id) ||+ isPartnerRevenueHidden(partnerGroup);if (sortBy === "saleAmount" && ltvExcluded) {throw new DubApiError({diff --git a/apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/route.ts b/apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/route.tsindex 7171e2a7ef..3948dd9a9e 100644--- a/apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/route.ts+++ b/apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/route.ts@@ -9,6 +9,7 @@ import {LARGE_PROGRAM_MIN_TOTAL_COMMISSIONS_CENTS,} from "@/lib/constants/partner-profile";import { generateRandomName } from "@/lib/names";+import { isPartnerRevenueHidden } from "@/lib/partners/is-partner-revenue-hidden";import { prisma, sanitizeFullTextSearch } from "@/lib/prisma";import {PartnerProfileCustomerSchema,@@ -33,14 +34,28 @@ export const GET = withPartnerProfile(pageSize,} = getPartnerCustomersQuerySchema.parse(searchParams);- const { program, totalCommissions, customerDataSharingEnabledAt } =- await getProgramEnrollmentOrThrow({- partnerId: partner.id,- programId: programId,- include: {- program: true,+ const {+ program,+ totalCommissions,+ customerDataSharingEnabledAt,+ partnerGroup,+ } = await getProgramEnrollmentOrThrow({+ partnerId: partner.id,+ programId: programId,+ include: {+ program: {+ select: {+ id: true,+ workspaceId: true,+ },},- });+ partnerGroup: {+ select: {+ revenueDataSharingDisabledAt: true,+ },+ },+ },+ });if (LARGE_PROGRAM_IDS.includes(program.id) &&@@ -53,10 +68,11 @@ export const GET = withPartnerProfile(});}- if (- sortBy === "saleAmount" &&- CUSTOMER_LTV_EXCLUDED_PROGRAM_IDS.includes(program.id)- ) {+ const ltvExcluded =+ CUSTOMER_LTV_EXCLUDED_PROGRAM_IDS.includes(program.id) ||+ isPartnerRevenueHidden(partnerGroup);++ if (sortBy === "saleAmount" && ltvExcluded) {throw new DubApiError({code: "bad_request",message: "This feature is not available for your program.",@@ -107,7 +123,7 @@ export const GET = withPartnerProfile(...(customerDataSharingEnabledAt && { name: z.string().nullish() }),}).omit({- ...(CUSTOMER_LTV_EXCLUDED_PROGRAM_IDS.includes(program.id) && {+ ...(ltvExcluded && {saleAmount: true,}),})diff --git a/apps/web/app/(ee)/api/partner-profile/programs/[programId]/events/export/route.ts b/apps/web/app/(ee)/api/partner-profile/programs/[programId]/events/export/route.tsindex c004073f05..8e4350ddca 100644--- a/apps/web/app/(ee)/api/partner-profile/programs/[programId]/events/export/route.ts+++ b/apps/web/app/(ee)/api/partner-profile/programs/[programId]/events/export/route.ts@@ -17,6 +17,7 @@ import {} from "@/lib/constants/partner-profile";import { qstash } from "@/lib/cron";import { generateRandomName } from "@/lib/names";+import { isPartnerRevenueHidden } from "@/lib/partners/is-partner-revenue-hidden";import {PartnerProfileLinkSchema,partnerProfileEventsQuerySchema,@@ -35,15 +36,38 @@ const MAX_EVENTS_TO_EXPORT = 1000;// GET /api/partner-profile/programs/[programId]/events/export – get export data for partner profile eventsexport const GET = withPartnerProfile(async ({ partner, params, searchParams, session }) => {- const { program, links, totalCommissions, customerDataSharingEnabledAt } =- await getProgramEnrollmentOrThrow({- partnerId: partner.id,- programId: params.programId,- include: {- program: true,- links: true,+ const {+ program,+ links,+ totalCommissions,+ customerDataSharingEnabledAt,+ partnerGroup,+ } = await getProgramEnrollmentOrThrow({+ partnerId: partner.id,+ programId: params.programId,+ include: {+ program: {+ select: {+ id: true,+ workspaceId: true,+ startedAt: true,+ createdAt: true,+ },},- });+ links: {+ select: {+ id: true,+ domain: true,+ key: true,+ },+ },+ partnerGroup: {+ select: {+ revenueDataSharingDisabledAt: true,+ },+ },+ },+ });if (LARGE_PROGRAM_IDS.includes(program.id) &&@@ -76,13 +100,15 @@ export const GET = withPartnerProfile(const { event, columns: columnsParam } = parsedParams;+ const hidePartnerRevenue = isPartnerRevenueHidden(partnerGroup);+// Default columns based on event type if not providedconst defaultColumns: Record<string, string[]> = {clicks: ["timestamp", "link", "referer", "country", "device"],leads: ["timestamp", "event", "link", "customer", "referer"],sales: ["timestamp",- "saleAmount",+ ...(hidePartnerRevenue ? [] : ["saleAmount"]),"event","customer","referer",@@ -90,10 +116,11 @@ export const GET = withPartnerProfile(],};- const columns =+ const columns = (columnsParam.length > 0? columnsParam- : defaultColumns[event] || defaultColumns.clicks;+ : defaultColumns[event] || defaultColumns.clicks+ ).filter((c) => !(hidePartnerRevenue && c === "saleAmount"));const { linkId, domain, key } = parsedParams;diff --git a/apps/web/app/(ee)/app.dub.co/embed/referrals/earnings.tsx b/apps/web/app/(ee)/app.dub.co/embed/referrals/earnings.tsxindex bc51fae969..516ae112ef 100644--- a/apps/web/app/(ee)/app.dub.co/embed/referrals/earnings.tsx+++ b/apps/web/app/(ee)/app.dub.co/embed/referrals/earnings.tsx@@ -1,4 +1,5 @@import { REFERRALS_EMBED_EARNINGS_LIMIT } from "@/lib/constants/misc";+import { isPartnerRevenueHidden } from "@/lib/partners/is-partner-revenue-hidden";import { PartnerEarningsResponse } from "@/lib/types";import { CommissionStatusBadges } from "@/ui/partners/commission-status-badges";import {@@ -16,6 +17,7 @@ import {formatDateTime,} from "@dub/utils";import { motion } from "motion/react";+import { useMemo } from "react";import useSWR from "swr";import { useEmbedToken } from "../../embed/use-embed-token";import { useReferralsEmbedData } from "./page-client";@@ -24,7 +26,9 @@ export function ReferralsEmbedEarnings() {const token = useEmbedToken();const {earnings: { totalCount: earningsCount },+ group,} = useReferralsEmbedData();+ const hidePartnerRevenue = isPartnerRevenueHidden(group);const { pagination, setPagination } = usePagination(REFERRALS_EMBED_EARNINGS_LIMIT,@@ -42,10 +46,8 @@ export function ReferralsEmbedEarnings() {},);- const { table, ...tableProps } = useTable({- data: earnings || [],- loading: isLoading,- columns: [+ const columns = useMemo(+ () => [{id: "customer",header: "Customer",@@ -62,13 +64,17 @@ export function ReferralsEmbedEarnings() {</p>),},- {- id: "amount",- header: "Amount",- cell: ({ row }) => {- return currencyFormatter(row.original.amount);- },- },+ ...(!hidePartnerRevenue+ ? [+ {+ id: "amount",+ header: "Amount",+ cell: ({ row }) => {+ return currencyFormatter(row.original.amount);+ },+ },+ ]+ : []),{id: "earnings",header: "Earnings",@@ -77,6 +83,15 @@ export function ReferralsEmbedEarnings() {return currencyFormatter(row.original.earnings);},},+ ],+ [hidePartnerRevenue],+ );++ const { table, ...tableProps } = useTable({+ data: earnings || [],+ loading: isLoading,+ columns: [+ ...columns,{header: "Status",cell: ({ row }) => {diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/messages/[programSlug]/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/messages/[programSlug]/page.tsxindex 9ce3353557..b13824d14b 100644--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/messages/[programSlug]/page.tsx+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/messages/[programSlug]/page.tsx@@ -6,6 +6,7 @@ import { markProgramMessagesReadAction } from "@/lib/messages/mark-program-messaimport { messageProgramAction } from "@/lib/messages/message-program";import { uploadPartnerMessageAttachmentAction } from "@/lib/messages/upload-partner-message-attachment";import { constructPartnerLink } from "@/lib/partners/construct-partner-link";+import { isPartnerRevenueHidden } from "@/lib/partners/is-partner-revenue-hidden";import { UPLOAD_POLICIES } from "@/lib/storage/upload-policies";import { mutatePrefix } from "@/lib/swr/mutate";import usePartnerAnalytics from "@/lib/swr/use-partner-analytics";@@ -463,6 +464,7 @@ function ProgramInfoPanel({const isActiveEnrollment = COMMISSION_ELIGIBLE_ENROLLMENT_STATUSES.includes(programEnrollment.status,);+ const hidePartnerRevenue = isPartnerRevenueHidden(programEnrollment.group);return (<>@@ -570,9 +572,16 @@ function ProgramInfoPanel({</div>))}</div>- <div className="divide-border-subtle grid grid-cols-2 divide-x">+ <div+ className={cn(+ "divide-border-subtle grid divide-x",+ hidePartnerRevenue ? "grid-cols-1" : "grid-cols-2",+ )}+ >{[- { label: "Revenue", value: statsTotals?.saleAmount },+ ...(!hidePartnerRevenue+ ? [{ label: "Revenue", value: statsTotals?.saleAmount }]+ : []),{ label: "Earnings", value: programEnrollment.totalCommissions },].map(({ label, value }) => (<div key={label} className="flex flex-col px-3 py-2.5">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.tsxindex c755d704c3..d6e8cc4e5b 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@@ -4,6 +4,7 @@ import {CUSTOMER_LTV_EXCLUDED_PROGRAM_IDS,PARTNER_CUSTOMERS_MAX_PAGE_SIZE,} from "@/lib/constants/partner-profile";+import { isPartnerRevenueHidden } from "@/lib/partners/is-partner-revenue-hidden";import usePartnerCustomers from "@/lib/swr/use-partner-customers";import usePartnerCustomersCount from "@/lib/swr/use-partner-customers-count";import useProgramEnrollment from "@/lib/swr/use-program-enrollment";@@ -66,17 +67,18 @@ export default function PartnerProgramCustomersPage() {setSelectedFilter,} = usePartnerCustomerFilters();+ const ltvExcluded =+ CUSTOMER_LTV_EXCLUDED_PROGRAM_IDS.includes(+ programEnrollment?.programId ?? "",+ ) || isPartnerRevenueHidden(programEnrollment?.group);+const customersColumns = {all: ["customer","country","link","createdAt",- ...(CUSTOMER_LTV_EXCLUDED_PROGRAM_IDS.includes(- programEnrollment?.programId ?? "",- )- ? []- : ["saleAmount"]),+ ...(ltvExcluded ? [] : ["saleAmount"]),"firstSaleAt","subscriptionCanceledAt",],@@ -85,11 +87,7 @@ export default function PartnerProgramCustomersPage() {"country","link","createdAt",- ...(CUSTOMER_LTV_EXCLUDED_PROGRAM_IDS.includes(- programEnrollment?.programId ?? "",- )- ? []- : ["saleAmount"]),+ ...(ltvExcluded ? [] : ["saleAmount"]),"firstSaleAt","subscriptionCanceledAt",],@@ -178,9 +176,7 @@ export default function PartnerProgramCustomersPage() {</TimestampTooltip>),},- ...(CUSTOMER_LTV_EXCLUDED_PROGRAM_IDS.includes(- programEnrollment?.programId ?? "",- )+ ...(ltvExcluded? []: [{@@ -249,7 +245,7 @@ export default function PartnerProgramCustomersPage() {header: () => <EditColumnsButton table={table} />,},].filter((c) => c.id === "menu" || customersColumns.all.includes(c.id)),- [programSlug],+ [programSlug, ltvExcluded],);const { table, ...tableProps } = useTable({diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsxindex 717e5c6f0f..36105e8484 100644--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx@@ -1,5 +1,6 @@import { formatDateTooltip } from "@/lib/analytics/format-date-tooltip";import { constructPartnerLink } from "@/lib/partners/construct-partner-link";+import { isPartnerRevenueHidden } from "@/lib/partners/is-partner-revenue-hidden";import { QueryLinkStructureHelpText } from "@/lib/partners/query-link-structure-help-text";import usePartnerAnalytics from "@/lib/swr/use-partner-analytics";import useProgramEnrollment from "@/lib/swr/use-program-enrollment";@@ -51,7 +52,7 @@ import {usePartnerLinkRewardsState,} from "./partner-link-rewards";-const CHARTS = [+const getCharts = (hidePartnerRevenue: boolean) => [{key: "clicks",icon: CursorRays,@@ -65,11 +66,11 @@ const CHARTS = [colorClassName: "text-purple-500",},{- key: "saleAmount",+ key: hidePartnerRevenue ? "sales" : "saleAmount",icon: InvoiceDollar,label: "Sales",colorClassName: "text-teal-500",- currency: true,+ currency: !hidePartnerRevenue,},];@@ -236,6 +237,7 @@ export function PartnerLinkCard({ link }: { link: PartnerProfileLinkProps }) {const StatsBadge = memo(({ link }: { link: PartnerProfileLinkProps }) => {const { programEnrollment, showDetailedAnalytics } = useProgramEnrollment();+ const hidePartnerRevenue = isPartnerRevenueHidden(programEnrollment?.group);const As = showDetailedAnalytics ? Link : "div";return (<As@@ -259,31 +261,41 @@ const StatsBadge = memo(({ link }: { link: PartnerProfileLinkProps }) => {{id: "sales",icon: InvoiceDollar,- value: link.saleAmount,+ value: hidePartnerRevenue ? link.sales : link.saleAmount,className: "hidden sm:flex",iconClassName: "data-[active=true]:text-teal-500",+ currency: !hidePartnerRevenue,},- ].map(({ id: tab, icon: Icon, value, className, iconClassName }) => (- <div- key={tab}- className={cn(- "flex items-center gap-1.5 whitespace-nowrap rounded px-[5px] py-[3px] transition-colors",- className,- )}- >- <Icon- data-active={value > 0}- className={cn("h-4 w-4 shrink-0", iconClassName)}- />- <span>- {tab === "sales"- ? currencyFormatter(value, {- trailingZeroDisplay: "stripIfInteger",- })- : nFormatter(value)}- </span>- </div>- ))}+ ].map(+ ({+ id: tab,+ icon: Icon,+ value,+ className,+ iconClassName,+ currency,+ }) => (+ <div+ key={tab}+ className={cn(+ "flex items-center gap-1.5 whitespace-nowrap rounded px-[5px] py-[3px] transition-colors",+ className,+ )}+ >+ <Icon+ data-active={value > 0}+ className={cn("h-4 w-4 shrink-0", iconClassName)}+ />+ <span>+ {currency+ ? currencyFormatter(value, {+ trailingZeroDisplay: "stripIfInteger",+ })+ : nFormatter(value)}+ </span>+ </div>+ ),+ )}</As>);});@@ -292,12 +304,15 @@ const StatsCharts = memo(({ link }: { link: PartnerProfileLinkProps }) => {const { getQueryString } = useRouterStuff();const { start, end, interval } = usePartnerLinksContext();const { programEnrollment } = useProgramEnrollment();+ const hidePartnerRevenue = isPartnerRevenueHidden(programEnrollment?.group);+ const charts = getCharts(hidePartnerRevenue);const ref = useRef<HTMLDivElement>(null);const isVisible = useInViewport(ref);const lastValidTotals = useRef<{clicks: number;leads: number;+ sales: number;saleAmount: number;} | null>(null);@@ -318,12 +333,13 @@ const StatsCharts = memo(({ link }: { link: PartnerProfileLinkProps }) => {const totals = useMemo(() => {const newTotals = timeseries?.reduce(- (acc, { clicks, leads, saleAmount }) => ({+ (acc, { clicks, leads, sales, saleAmount }) => ({clicks: acc.clicks + clicks,leads: acc.leads + leads,+ sales: acc.sales + (sales ?? 0),saleAmount: acc.saleAmount + saleAmount,}),- { clicks: 0, leads: 0, saleAmount: 0 },+ { clicks: 0, leads: 0, sales: 0, saleAmount: 0 },);if (newTotals) {@@ -331,13 +347,25 @@ const StatsCharts = memo(({ link }: { link: PartnerProfileLinkProps }) => {return newTotals;}- return lastValidTotals.current ?? { clicks: 0, leads: 0, saleAmount: 0 };+ return (+ lastValidTotals.current ?? {+ clicks: 0,+ leads: 0,+ sales: 0,+ saleAmount: 0,+ }+ );}, [timeseries]);const chartData = useMemo(() => {- return timeseries?.map(({ start, clicks, leads, saleAmount }) => ({+ return timeseries?.map(({ start, clicks, leads, sales, saleAmount }) => ({date: new Date(start),- values: { clicks, leads, saleAmount: saleAmount },+ values: {+ clicks,+ leads,+ sales: sales ?? 0,+ saleAmount,+ },}));}, [timeseries]);@@ -346,7 +374,7 @@ const StatsCharts = memo(({ link }: { link: PartnerProfileLinkProps }) => {ref={ref}className="grid grid-cols-1 gap-4 p-4 pt-0 sm:grid-cols-3 sm:gap-5 sm:px-[18px] sm:pb-5">- {CHARTS.map((chart) => (+ {charts.map((chart) => (<Linkkey={chart.key}href={`/programs/${programEnrollment?.program.slug}/analytics${getQueryString(diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/group-additional-settings.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/group-additional-settings.tsxindex fce3df1dae..cea0df83b4 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/group-additional-settings.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/group-additional-settings.tsx@@ -64,13 +64,13 @@ function GroupAdditionalSettingsForm({}}, [group]);- const handleHideRevenueToggle = async () => {+ const handleRevenueDataSharingToggle = async () => {if (!group) return;- const currentValue = Boolean(group.hideRevenueFromPartnersAt);+ const currentValue = Boolean(group.revenueDataSharingDisabledAt);await updateGroup(`/api/groups/${group.id}`, {method: "PATCH",body: {- hideRevenueFromPartners: !currentValue,+ revenueDataSharingDisabled: !currentValue,},onSuccess: async () => {await mutatePrefix(`/api/groups/${group.slug}`);@@ -277,8 +277,8 @@ function GroupAdditionalSettingsForm({<label><div className="flex select-none items-center gap-2"><Switch- checked={Boolean(group!.hideRevenueFromPartnersAt)}- fn={handleHideRevenueToggle}+ checked={Boolean(group!.revenueDataSharingDisabledAt)}+ fn={handleRevenueDataSharingToggle}disabled={isSubmitting}trackDimensions="radix-state-checked:bg-black focus-visible:ring-black/20"/>