The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
final fixes to show the right data for partners
Steven Tey4fa1955bf78c
diff --git a/apps/web/app/api/partner-profile/programs/[programId]/customers/[customerId]/activity/route.ts b/apps/web/app/api/partner-profile/programs/[programId]/customers/[customerId]/activity/route.tsindex 518b636ea6..27e1086095 100644--- a/apps/web/app/api/partner-profile/programs/[programId]/customers/[customerId]/activity/route.ts+++ b/apps/web/app/api/partner-profile/programs/[programId]/customers/[customerId]/activity/route.ts@@ -1,6 +1,5 @@import { getCustomerEvents } from "@/lib/analytics/get-customer-events";import { DubApiError } from "@/lib/api/errors";-import { decodeLinkIfCaseSensitive } from "@/lib/api/links/case-sensitivity";import { getProgramEnrollmentOrThrow } from "@/lib/api/programs/get-program-enrollment-or-throw";import { withPartnerProfile } from "@/lib/auth/partner";import { customerActivityResponseSchema } from "@/lib/zod/schemas/customer-activity";@@ -16,38 +15,13 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {programId: programId,});- if (program.slug === "framer") {- throw new DubApiError({- code: "forbidden",- message: "Framer program does not support customer activity",- });- }-const customer = await prisma.customer.findUnique({where: {id: customerId,},- include: {- link: {- include: {- programEnrollment: {- include: {- partner: true,- program: true,- },- },- },- },- },});- if (- !customer ||- ![- customer?.link?.programEnrollment?.programId,- customer?.link?.programEnrollment?.program.slug,- ].includes(program.id)- ) {+ if (!customer || customer?.projectId !== program.workspaceId) {throw new DubApiError({code: "not_found",message:@@ -68,33 +42,20 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {);}- let [events, link] = await Promise.all([- getCustomerEvents(- {- customerId: customer.id,- clickId: customer.clickId,- linkIds: links.map((link) => link.id),- },- {- sortOrder: "desc",- interval: "1y",- },- ),-- prisma.link.findUniqueOrThrow({- where: {- id: customer.linkId,- },- select: {- id: true,- domain: true,- key: true,- shortLink: true,- },- }),- ]);+ const events = await getCustomerEvents(+ {+ customerId: customer.id,+ linkIds: links.map((link) => link.id),+ },+ {+ sortOrder: "desc",+ interval: "1y",+ },+ );- link = decodeLinkIfCaseSensitive(link);+ // get the first partner link that this customer interacted with+ const firstLinkId = events[0].link_id;+ const link = links.find((link) => link.id === firstLinkId);// Find the LTV of the customer// TODO: Calculate this from all events, not limiteddiff --git a/apps/web/app/api/partner-profile/programs/[programId]/customers/[customerId]/route.ts b/apps/web/app/api/partner-profile/programs/[programId]/customers/[customerId]/route.tsindex 39b2e6ba44..8278f79f78 100644--- a/apps/web/app/api/partner-profile/programs/[programId]/customers/[customerId]/route.ts+++ b/apps/web/app/api/partner-profile/programs/[programId]/customers/[customerId]/route.ts@@ -16,13 +16,6 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {programId: programId,});- if (program.slug === "framer") {- throw new DubApiError({- code: "forbidden",- message: "Framer program does not support customer profile",- });- }-const customer = await prisma.customer.findUnique({where: {id: customerId,diff --git a/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page.tsx b/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page.tsxindex 67a7a9e209..4982498f9d 100644--- a/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page.tsx+++ b/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page.tsx@@ -1,16 +1,8 @@import { PageContent } from "@/ui/layout/page-content";import { MaxWidthWrapper } from "@dub/ui";-import { redirect } from "next/navigation";import { ProgramCustomerPageClient } from "./page-client";-export default function ProgramCustomer({- params,-}: {- params: { programSlug: string; customerId: string };-}) {- if (params.programSlug === "framer") {- redirect("/programs/framer");- }+export default function ProgramCustomer() {return (<PageContent hideReferButton><MaxWidthWrapper className="flex flex-col gap-6">