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.

more fixes

Steven Tey09ef7611fb19
diff --git a/apps/web/app/api/analytics/[endpoint]/route.ts b/apps/web/app/api/analytics/[endpoint]/route.ts
index 2a875287d6..b1e3246985 100644
--- a/apps/web/app/api/analytics/[endpoint]/route.ts
+++ b/apps/web/app/api/analytics/[endpoint]/route.ts
@@ -33,7 +33,7 @@ export const GET = withAuth(
: null;
const response = await getAnalytics({
- projectId: workspace.id,
+ workspaceId: workspace.id,
...(linkId && { linkId }),
endpoint,
...parsedParams,
diff --git a/apps/web/app/api/analytics/edge/[endpoint]/route.ts b/apps/web/app/api/analytics/edge/[endpoint]/route.ts
index 1a851016a3..b5a62315fd 100644
--- a/apps/web/app/api/analytics/edge/[endpoint]/route.ts
+++ b/apps/web/app/api/analytics/edge/[endpoint]/route.ts
@@ -86,8 +86,8 @@ export const GET = async (
}
const response = await getAnalytics({
- // projectId can be undefined (for public links that haven't been claimed/synced to a workspace)
- ...(link.projectId && { projectId: link.projectId }),
+ // workspaceId can be undefined (for public links that haven't been claimed/synced to a workspace)
+ ...(link.projectId && { workspaceId: link.projectId }),
linkId: link.id,
endpoint,
...parsedParams,
diff --git a/apps/web/app/api/cron/usage/utils.ts b/apps/web/app/api/cron/usage/utils.ts
index edb84baba0..9f592090bc 100644
--- a/apps/web/app/api/cron/usage/utils.ts
+++ b/apps/web/app/api/cron/usage/utils.ts
@@ -121,7 +121,7 @@ export const updateUsage = async (skip?: number) => {
const topLinks =
workspace.usage > 0
? await getAnalytics({
- projectId: workspace.id,
+ workspaceId: workspace.id,
endpoint: "top_links",
interval: "30d",
excludeRoot: true,
diff --git a/apps/web/app/api/og/analytics/route.tsx b/apps/web/app/api/og/analytics/route.tsx
index bb82bbe8bb..0c9309cee1 100644
--- a/apps/web/app/api/og/analytics/route.tsx
+++ b/apps/web/app/api/og/analytics/route.tsx
@@ -27,8 +27,8 @@ export async function GET(req: NextRequest) {
}
const data = await getAnalytics({
- // projectId can be undefined (for public links that haven't been claimed/synced to a workspace)
- ...(link.projectId && { projectId: link.projectId }),
+ // workspaceId can be undefined (for public links that haven't been claimed/synced to a workspace)
+ ...(link.projectId && { workspaceId: link.projectId }),
linkId: link.id,
endpoint: "timeseries",
interval: "24h",
diff --git a/apps/web/lib/analytics.ts b/apps/web/lib/analytics.ts
index ae556008ca..b6df68dc6f 100644
--- a/apps/web/lib/analytics.ts
+++ b/apps/web/lib/analytics.ts
@@ -93,14 +93,14 @@ export const VALID_ANALYTICS_FILTERS = [
];
export const getAnalytics = async ({
- projectId,
+ workspaceId,
linkId,
domain,
endpoint,
interval,
...rest
-}: Omit<z.infer<typeof getAnalyticsQuerySchema>, "projectSlug"> & {
- projectId?: string;
+}: z.infer<typeof getAnalyticsQuerySchema> & {
+ workspaceId?: string;
linkId?: string;
endpoint: (typeof VALID_TINYBIRD_ENDPOINTS)[number];
}) => {
@@ -138,8 +138,8 @@ export const getAnalytics = async ({
let url = new URL(
`${process.env.TINYBIRD_API_URL}/v0/pipes/${endpoint}.json`,
);
- if (projectId) {
- url.searchParams.append("projectId", projectId);
+ if (workspaceId) {
+ url.searchParams.append("projectId", workspaceId);
}
if (linkId) {
url.searchParams.append("linkId", linkId);
diff --git a/apps/web/lib/api/links.ts b/apps/web/lib/api/links.ts
index ace6dc6a86..2a97f51166 100644
--- a/apps/web/lib/api/links.ts
+++ b/apps/web/lib/api/links.ts
@@ -45,7 +45,7 @@ export async function getLinksForWorkspace({
userId,
showArchived,
withTags,
-}: Omit<z.infer<typeof getLinksQuerySchema>, "projectSlug"> & {
+}: z.infer<typeof getLinksQuerySchema> & {
workspaceId: string;
}) {
const combinedTagIds = combineTagIds({ tagId, tagIds });
diff --git a/apps/web/scripts/get-top-links-for-project.ts b/apps/web/scripts/get-top-links-for-workspace.ts
similarity index 90%
rename from apps/web/scripts/get-top-links-for-project.ts
rename to apps/web/scripts/get-top-links-for-workspace.ts
index a88f1ba35d..c732f249bf 100644
--- a/apps/web/scripts/get-top-links-for-project.ts
+++ b/apps/web/scripts/get-top-links-for-workspace.ts
@@ -4,7 +4,7 @@ import { linkConstructor } from "@dub/utils";
import "dotenv-flow/config";
async function main() {
- const project = await prisma.project.findUnique({
+ const workspace = await prisma.project.findUnique({
where: {
slug: "dub",
},
@@ -30,12 +30,12 @@ async function main() {
createdAt: true,
},
});
- if (!project) {
- console.log("No project found");
+ if (!workspace) {
+ console.log("No workspace found");
return;
}
const topLinks = await getAnalytics({
- projectId: project.id,
+ projectId: workspace.id,
endpoint: "top_links",
interval: "30d",
excludeRoot: true,
diff --git a/apps/web/scripts/get-projects-by-clicks.ts b/apps/web/scripts/get-workspaces-by-clicks.ts
similarity index 72%
rename from apps/web/scripts/get-projects-by-clicks.ts
rename to apps/web/scripts/get-workspaces-by-clicks.ts
index bcbb0046bb..ff7c3d90d0 100644
--- a/apps/web/scripts/get-projects-by-clicks.ts
+++ b/apps/web/scripts/get-workspaces-by-clicks.ts
@@ -2,7 +2,7 @@ import prisma from "@/lib/prisma";
import "dotenv-flow/config";
async function main() {
- const projects = await prisma.project.findMany({
+ const workspaces = await prisma.project.findMany({
select: {
slug: true,
plan: true,
@@ -18,7 +18,7 @@ async function main() {
},
take: 100,
});
- console.table(projects, ["slug", "plan", "usage", "_count"]);
+ console.table(workspaces, ["slug", "plan", "usage", "_count"]);
}
main();
diff --git a/apps/web/scripts/get-projects-by-links.ts b/apps/web/scripts/get-workspaces-by-links.ts
similarity index 68%
rename from apps/web/scripts/get-projects-by-links.ts
rename to apps/web/scripts/get-workspaces-by-links.ts
index e6057a17ae..499b14ddde 100644
--- a/apps/web/scripts/get-projects-by-links.ts
+++ b/apps/web/scripts/get-workspaces-by-links.ts
@@ -2,7 +2,7 @@ import prisma from "@/lib/prisma";
import "dotenv-flow/config";
async function main() {
- const projects = await prisma.project.findMany({
+ const workspaces = await prisma.project.findMany({
select: {
slug: true,
plan: true,
@@ -14,7 +14,7 @@ async function main() {
},
take: 100,
});
- console.table(projects, ["slug", "plan", "linksUsage", "linksLimit"]);
+ console.table(workspaces, ["slug", "plan", "linksUsage", "linksLimit"]);
}
main();