The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix link sequence
Steven Tey23df1e361610
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 0f6441ffa1..06775cdcab 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@@ -29,26 +29,13 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {});}- if (!customer.linkId) {- return NextResponse.json(- customerActivityResponseSchema.parse({- customer,- events: [],- ltv: 0,- timeToLead: null,- timeToSale: null,- link: null,- }),- );- }-const events = await getCustomerEvents({customerId: customer.id,linkIds: links.map((link) => link.id),});// get the first partner link that this customer interacted with- const firstLinkId = events[0].link_id;+ const firstLinkId = events[events.length - 1].link_id;const link = links.find((link) => link.id === firstLinkId);// Find the LTV of the customerdiff --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 8278f79f78..0419d6961a 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@@ -20,27 +20,9 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {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:@@ -56,14 +38,6 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {transformCustomer({...customer,email: customer.email || customer.name || generateRandomName(),- link: customer.link- ? {- ...customer.link,- programEnrollment: customer.link.programEnrollment- ? { ...customer.link.programEnrollment, program: undefined }- : null,- }- : null,}),),);diff --git a/apps/web/lib/zod/schemas/partner-profile.ts b/apps/web/lib/zod/schemas/partner-profile.tsindex 391552322b..e0d2ead952 100644--- a/apps/web/lib/zod/schemas/partner-profile.ts+++ b/apps/web/lib/zod/schemas/partner-profile.ts@@ -82,7 +82,6 @@ export const PartnerProfileCustomerSchema = CustomerEnrichedSchema.pick({id: true,createdAt: true,country: true,- link: true,}).extend({email: z.string()