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.

fix bulk update bug

Steven Tey07e5165aa54e
diff --git a/apps/web/app/api/links/bulk/route.ts b/apps/web/app/api/links/bulk/route.ts
index 60202360ed..6a01903fcf 100644
--- a/apps/web/app/api/links/bulk/route.ts
+++ b/apps/web/app/api/links/bulk/route.ts
@@ -343,11 +343,9 @@ export const PATCH = withWorkspace(
}
if (checkIfLinksHaveFolders(links)) {
- const folderIds = [
- ...new Set(
- links.map((link) => link.folderId).filter(Boolean) as string[],
- ),
- ];
+ const folderIds = Array.from(
+ new Set(links.map((link) => link.folderId).filter(Boolean) as string[]),
+ );
const folderPermissions = await checkFolderPermissions({
workspaceId: workspace.id,
diff --git a/apps/web/lib/api/links/process-link.ts b/apps/web/lib/api/links/process-link.ts
index 38024bdd79..3f0d67d871 100644
--- a/apps/web/lib/api/links/process-link.ts
+++ b/apps/web/lib/api/links/process-link.ts
@@ -1,7 +1,7 @@
import { isBlacklistedDomain } from "@/lib/edge-config";
import { verifyFolderAccess } from "@/lib/folder/permissions";
import { checkIfUserExists, getRandomKey } from "@/lib/planetscale";
-import { isStored } from "@/lib/storage";
+import { isNotHostedImage } from "@/lib/storage";
import { NewLinkProps, ProcessedLinkProps, WorkspaceProps } from "@/lib/types";
import { prisma } from "@dub/prisma";
import {
@@ -299,10 +299,11 @@ export async function processLink<T extends Record<string, any>>({
}
if (bulk) {
- if (proxy && image && !isStored(image)) {
+ if (proxy && image && isNotHostedImage(image)) {
return {
link: payload,
- error: "You cannot set custom social cards with bulk link creation.",
+ error:
+ "You cannot upload custom link preview images with bulk link creation.",
code: "unprocessable_entity",
};
}
diff --git a/apps/web/scripts/conversion-customers.ts b/apps/web/scripts/conversion-customers.ts
new file mode 100644
index 0000000000..3d4e37e912
--- /dev/null
+++ b/apps/web/scripts/conversion-customers.ts
@@ -0,0 +1,76 @@
+import { prisma } from "@dub/prisma";
+import { chunk } from "@dub/utils";
+import "dotenv-flow/config";
+
+// one-time script to get all workspaces/users that used conversion tracking on Dub in the last 3 months
+async function main() {
+ const projectsByCustomerCount = await prisma.customer.groupBy({
+ by: ["projectId"],
+ where: {
+ createdAt: {
+ gte: new Date(Date.now() - 3 * 30 * 24 * 60 * 60 * 1000),
+ },
+ },
+ _count: {
+ id: true,
+ },
+ orderBy: {
+ _count: {
+ id: "desc",
+ },
+ },
+ });
+
+ const projectUserEmails = await prisma.project.findMany({
+ where: {
+ id: {
+ in: projectsByCustomerCount.map((project) => project.projectId),
+ },
+ },
+ select: {
+ id: true,
+ slug: true,
+ users: {
+ select: {
+ user: {
+ select: {
+ email: true,
+ },
+ },
+ },
+ where: {
+ user: {
+ email: {
+ not: null,
+ },
+ },
+ },
+ },
+ },
+ });
+
+ console.table(
+ projectsByCustomerCount.map((project) => {
+ const projectData = projectUserEmails.find(
+ (p) => p.id === project.projectId,
+ );
+
+ return {
+ id: project.projectId,
+ slug: projectData?.slug,
+ userEmails: projectData?.users.map((u) => u.user.email),
+ };
+ }),
+ );
+
+ const chunks = chunk(
+ projectUserEmails.flatMap((p) => p.users.map((u) => u.user.email)),
+ 49,
+ );
+
+ for (const chunk of chunks) {
+ console.log(chunk.join(", "));
+ }
+}
+
+main();
diff --git a/apps/web/ui/folders/move-link-form.tsx b/apps/web/ui/folders/move-link-form.tsx
index 37c00d7ae7..3f88e02222 100644
--- a/apps/web/ui/folders/move-link-form.tsx
+++ b/apps/web/ui/folders/move-link-form.tsx
@@ -60,7 +60,7 @@ export const MoveLinkForm = ({
{ revalidate: true },
);
- toast.success("Link moved successfully!");
+ toast.success(`${pluralize("Link", links.length)} moved successfully!`);
onSuccess(selectedFolderId === "unsorted" ? null : selectedFolderId);
};