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.

add userId

Steven Tey9527aee01ad7
diff --git a/apps/web/app/api/analytics/share/route.ts b/apps/web/app/api/analytics/share/route.ts
index b8d040eb88..ca5e50552a 100644
--- a/apps/web/app/api/analytics/share/route.ts
+++ b/apps/web/app/api/analytics/share/route.ts
@@ -37,8 +37,9 @@ export const POST = withWorkspace(
const response = await prisma.sharedDashboard.create({
data: {
id: createId({ prefix: "dsh_" }),
- link: { connect: { id: link.id } },
- project: { connect: { id: workspace.id } },
+ linkId: link.id,
+ projectId: workspace.id,
+ userId: link.userId,
showConversions: link.trackConversion,
},
});
diff --git a/apps/web/lib/api/links/create-link.ts b/apps/web/lib/api/links/create-link.ts
index 5615902058..41f6e9f56e 100644
--- a/apps/web/lib/api/links/create-link.ts
+++ b/apps/web/lib/api/links/create-link.ts
@@ -102,6 +102,9 @@ export async function createLink(link: ProcessedLinkProps) {
sharedDashboard: {
create: {
id: createId({ prefix: "dsh_" }),
+ showConversions: link.trackConversion,
+ projectId: link.projectId,
+ userId: link.userId,
},
},
}),
diff --git a/apps/web/lib/api/links/update-link.ts b/apps/web/lib/api/links/update-link.ts
index 4985ae7b1c..eebd3a0def 100644
--- a/apps/web/lib/api/links/update-link.ts
+++ b/apps/web/lib/api/links/update-link.ts
@@ -131,6 +131,9 @@ export async function updateLink({
sharedDashboard: {
create: {
id: createId({ prefix: "dsh_" }),
+ showConversions: updatedLink.trackConversion,
+ projectId: updatedLink.projectId,
+ userId: updatedLink.userId,
},
},
}),
diff --git a/apps/web/prisma/schema/link.prisma b/apps/web/prisma/schema/link.prisma
index aa1461b5bc..60bd169aa9 100644
--- a/apps/web/prisma/schema/link.prisma
+++ b/apps/web/prisma/schema/link.prisma
@@ -91,13 +91,19 @@ model SharedDashboard {
project Project? @relation(fields: [projectId], references: [id], onUpdate: Cascade, onDelete: Cascade)
projectId String?
+ // User who created the shared dashboard
+ user User? @relation(fields: [userId], references: [id], onUpdate: Cascade, onDelete: Cascade)
+ userId String?
+
+ // additional link configurations
doIndex Boolean @default(false) // whether to index the share link on Google or not
- password String?
- showConversions Boolean @default(false)
+ password String? // password to access the share link
+ showConversions Boolean @default(false) // ideally this should just be synced to trackConversion on the link
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
- @@index(projectId)
@@index(linkId)
+ @@index(projectId)
+ @@index(userId)
}
diff --git a/apps/web/prisma/schema/schema.prisma b/apps/web/prisma/schema/schema.prisma
index d2633e1976..631b95cd3c 100644
--- a/apps/web/prisma/schema/schema.prisma
+++ b/apps/web/prisma/schema/schema.prisma
@@ -34,6 +34,7 @@ model User {
sessions Session[]
projects ProjectUsers[]
links Link[]
+ sharedDashboards SharedDashboard[]
tokens Token[]
restrictedTokens RestrictedToken[]
oAuthCodes OAuthCode[]