The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
timezone fixes
Steven Teyae5198261230
diff --git a/apps/web/app/api/customers/[id]/activity/route.ts b/apps/web/app/api/customers/[id]/activity/route.tsindex 6d9abe0d95..8f62872bf6 100644--- a/apps/web/app/api/customers/[id]/activity/route.ts+++ b/apps/web/app/api/customers/[id]/activity/route.ts@@ -16,6 +16,19 @@ export const GET = withWorkspace(async ({ workspace, params }) => {id: customerId,});+ if (!customer.linkId) {+ return NextResponse.json(+ customerActivityResponseSchema.parse({+ customer,+ activity: [],+ ltv: 0,+ timeToLead: null,+ timeToSale: null,+ link: null,+ }),+ );+ }+const [events, link] = await Promise.all([getEvents({customerId: customer.id,@@ -95,15 +108,6 @@ export const GET = withWorkspace(async ({ workspace, params }) => {? new Date(firstSale.timestamp).getTime() - customer.createdAt.getTime(): null;- console.log({- ltv,- timeToLead,- timeToSale,- customer,- activity,- link,- });-return NextResponse.json(customerActivityResponseSchema.parse({ltv,diff --git a/apps/web/app/api/stripe/integration/webhook/customer-created.ts b/apps/web/app/api/stripe/integration/webhook/customer-created.tsindex c77a80f0d3..96cf728d44 100644--- a/apps/web/app/api/stripe/integration/webhook/customer-created.ts+++ b/apps/web/app/api/stripe/integration/webhook/customer-created.ts@@ -64,7 +64,7 @@ export async function customerCreated(event: Stripe.Event) {externalId,linkId,clickId,- clickedAt: new Date(clickData.timestamp),+ clickedAt: new Date(clickData.timestamp + "Z"),country: clickData.country,project: {connect: {diff --git a/apps/web/app/api/track/lead/route.ts b/apps/web/app/api/track/lead/route.tsindex 08f82766fb..97dadb2838 100644--- a/apps/web/app/api/track/lead/route.ts+++ b/apps/web/app/api/track/lead/route.ts@@ -98,7 +98,7 @@ export const POST = withWorkspaceEdge(clickId: clickData.click_id,linkId: clickData.link_id,country: clickData.country,- clickedAt: new Date(clickData.timestamp),+ clickedAt: new Date(clickData.timestamp + "Z"),},});diff --git a/apps/web/lib/zod/schemas/customers.ts b/apps/web/lib/zod/schemas/customers.tsindex 2918d8fa03..139f2f9be1 100644--- a/apps/web/lib/zod/schemas/customers.ts+++ b/apps/web/lib/zod/schemas/customers.ts@@ -111,7 +111,7 @@ export const customerActivitySchema = z.object({export const customerActivityResponseSchema = z.object({ltv: z.number(),- timeToLead: z.number(),+ timeToLead: z.number().nullable(),timeToSale: z.number().nullable(),activity: z.array(customerActivitySchema),customer: CustomerSchema.merge(diff --git a/apps/web/scripts/backfill-customers.ts b/apps/web/scripts/backfill-customers.tsindex e0df1b9d2d..5bec8e6b0a 100644--- a/apps/web/scripts/backfill-customers.ts+++ b/apps/web/scripts/backfill-customers.ts@@ -28,8 +28,9 @@ async function main() {},select: {id: true,+ createdAt: true,},- take: 2,+ take: 100,orderBy: {createdAt: "desc",},@@ -57,8 +58,6 @@ async function main() {(res) => res.data,);- console.log({ leadEvents, clickEvents });-// Update customersconst result = await Promise.all(customers.map(async (customer) => {@@ -80,7 +79,7 @@ async function main() {linkId: clickEvent.link_id,clickId: clickEvent.click_id,country: clickEvent.country,- clickedAt: new Date(clickEvent.timestamp),+ clickedAt: new Date(clickEvent.timestamp + "Z"),},select: {id: true,@@ -90,17 +89,24 @@ async function main() {clickedAt: true,},});+ // return {+ // linkId: clickEvent.link_id,+ // clickId: clickEvent.click_id,+ // country: clickEvent.country,+ // clickedAt: new Date(clickEvent.timestamp + "Z"),+ // createdAt: customer.createdAt,+ // };}),);- const remaining = await prisma.customer.count({- where: {- linkId: null,- },- });+ // const remaining = await prisma.customer.count({+ // where: {+ // linkId: null,+ // },+ // });console.table(result);- console.log(`${remaining} remaining`);+ // console.log(`${remaining} remaining`);}main();