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 ProgramMarketplaceAnnouncement to email templates map

Steven Tey6be70072a8c7
diff --git a/apps/web/app/(ee)/api/cron/year-in-review/route.ts b/apps/web/app/(ee)/api/cron/year-in-review/route.ts
deleted file mode 100644
index 9793df836d..0000000000
--- a/apps/web/app/(ee)/api/cron/year-in-review/route.ts
+++ /dev/null
@@ -1,154 +0,0 @@
-import { handleAndReturnErrorResponse } from "@/lib/api/errors";
-import { qstash } from "@/lib/cron";
-import { sendBatchEmail } from "@dub/email";
-import DubWrapped from "@dub/email/templates/dub-wrapped";
-import { prisma } from "@dub/prisma";
-import { APP_DOMAIN_WITH_NGROK } from "@dub/utils";
-
-export const dynamic = "force-dynamic";
-
-const BATCH_SIZE = 100;
-
-// POST /api/cron/year-in-review
-export async function POST() {
- try {
- if (process.env.VERCEL === "1") {
- return new Response("Not available in production.");
- }
-
- const yearInReviews = await prisma.yearInReview.findMany({
- where: {
- sentAt: null,
- year: 2024,
- },
- select: {
- id: true,
- workspaceId: true,
- topCountries: true,
- topLinks: true,
- totalClicks: true,
- totalLinks: true,
- workspace: {
- select: {
- id: true,
- name: true,
- slug: true,
- logo: true,
- users: {
- select: {
- user: {
- select: {
- email: true,
- },
- },
- },
- },
- },
- },
- },
- take: 100,
- });
-
- if (yearInReviews.length === 0) {
- return new Response("No jobs found. Skipping...");
- }
-
- const emailData = yearInReviews.flatMap(
- ({ workspace, totalClicks, totalLinks, topCountries, topLinks }) =>
- workspace.users
- .map(({ user }) => {
- if (!user.email) {
- return null;
- }
-
- return {
- workspaceId: workspace.id,
- email: {
- from: "Steven from Dub <[email protected]>",
- to: user.email,
- reply_to: "[email protected]",
- subject: "Dub Year in Review 🎊",
- text: "Thank you for your support and here's to another year of your activity on Dub! Here's a look back at your activity in 2024.",
- react: DubWrapped({
- email: user.email,
- workspace: {
- logo: workspace.logo,
- name: workspace.name,
- slug: workspace.slug,
- },
- stats: {
- "Total Links": totalLinks,
- "Total Clicks": totalClicks,
- },
- // @ts-ignore
- topLinks,
- // @ts-ignore
- topCountries,
- }),
- },
- };
- })
- .filter((data) => data !== null),
- );
-
- if (emailData.length === 0) {
- return new Response("No email data found. Skipping...");
- }
-
- for (let i = 0; i < emailData.length; i += BATCH_SIZE) {
- const batch = emailData.slice(i, i + BATCH_SIZE);
-
- console.log(
- `\nπŸš€ Sending batch ${Math.floor(i / BATCH_SIZE) + 1} of ${Math.ceil(emailData.length / BATCH_SIZE)}`,
- );
-
- console.log(
- `πŸ“¨ Recipients:`,
- // @ts-ignore
- batch.map((b) => b.email.to),
- );
-
- if (batch.length === 0) {
- continue;
- }
-
- const { data, error } = await sendBatchEmail(
- // @ts-ignore
- batch.map((b) => b.email),
- );
-
- console.log("πŸš€ ~ data:", data);
- if (error) {
- console.log("πŸš€ ~ error:", error);
- }
- }
-
- await prisma.yearInReview.updateMany({
- where: {
- id: {
- in: yearInReviews.map(({ id }) => id),
- },
- },
- data: {
- sentAt: new Date(),
- },
- });
-
- console.log(
- `Sent ${emailData.length} emails to ${yearInReviews.length} workspaces!`,
- );
-
- await qstash.publishJSON({
- url: `${APP_DOMAIN_WITH_NGROK}/api/cron/year-in-review`,
- delay: 3,
- method: "POST",
- body: {},
- });
-
- return new Response(
- `Sent ${emailData.length} emails to ${yearInReviews.length} workspaces!`,
- );
- } catch (error) {
- return handleAndReturnErrorResponse(error);
- }
-}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/[programSlug]/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/[programSlug]/page.tsx
index b21709a5d6..e8817aae4f 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/[programSlug]/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/[programSlug]/page.tsx
@@ -56,7 +56,13 @@ export default async function MarketplaceProgramPage(props: {
controls={<MarketplaceProgramHeaderControls program={program} />}
>
<PageWidthWrapper className="pb-20">
- <div className="border-border-subtle relative overflow-hidden rounded-xl border">
+ <div
+ className={cn(
+ "relative",
+ program.featuredOnMarketplaceAt &&
+ "border-border-subtle overflow-hidden rounded-xl border",
+ )}
+ >
{program.featuredOnMarketplaceAt &&
program.marketplaceHeaderImage && (
<>
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/use-program-network-filters.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/use-program-network-filters.tsx
index 5edf910360..5d2ef0a02b 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/use-program-network-filters.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/use-program-network-filters.tsx
@@ -70,23 +70,6 @@ export function useProgramNetworkFilters() {
const filters = useMemo(
() => [
- {
- key: "category",
- icon: Suitcase,
- label: "Category",
- getOptionIcon: (value) => {
- const Icon = PROGRAM_CATEGORIES_MAP[value]?.icon || Suitcase;
- return <Icon className="size-4" />;
- },
- getOptionLabel: (value) =>
- PROGRAM_CATEGORIES_MAP[value]?.label || value.replace("_", " "),
- options:
- categoriesCount?.map(({ category, _count }) => ({
- value: category,
- label: category,
- right: nFormatter(_count, { full: true }),
- })) ?? [],
- },
{
key: "rewardType",
multiple: true,
@@ -104,6 +87,23 @@ export function useProgramNetworkFilters() {
}),
),
},
+ {
+ key: "category",
+ icon: Suitcase,
+ label: "Category",
+ getOptionIcon: (value) => {
+ const Icon = PROGRAM_CATEGORIES_MAP[value]?.icon || Suitcase;
+ return <Icon className="size-4" />;
+ },
+ getOptionLabel: (value) =>
+ PROGRAM_CATEGORIES_MAP[value]?.label || value.replace("_", " "),
+ options:
+ categoriesCount?.map(({ category, _count }) => ({
+ value: category,
+ label: category,
+ right: nFormatter(_count, { full: true }),
+ })) ?? [],
+ },
{
key: "status",
icon: CircleDotted,
diff --git a/apps/web/lib/email/email-templates-map.ts b/apps/web/lib/email/email-templates-map.ts
index f771ebb18c..b40c3dd835 100644
--- a/apps/web/lib/email/email-templates-map.ts
+++ b/apps/web/lib/email/email-templates-map.ts
@@ -3,8 +3,8 @@ import PartnerBanned from "@dub/email/templates/partner-banned";
import PartnerDeactivated from "@dub/email/templates/partner-deactivated";
import PartnerPayoutConfirmed from "@dub/email/templates/partner-payout-confirmed";
import PartnerPayoutProcessed from "@dub/email/templates/partner-payout-processed";
+import ProgramMarketplaceAnnouncement from "@dub/email/templates/program-marketplace-announcement";
import ProgramPayoutThankYou from "@dub/email/templates/program-payout-thank-you";
-import UnresolvedFraudEventsSummary from "@dub/email/templates/unresolved-fraud-events-summary";
export const EMAIL_TEMPLATES_MAP = {
BountyApproved,
@@ -13,5 +13,5 @@ export const EMAIL_TEMPLATES_MAP = {
PartnerDeactivated,
PartnerBanned,
ProgramPayoutThankYou,
- UnresolvedFraudEventsSummary,
+ ProgramMarketplaceAnnouncement,
} as const;
diff --git a/apps/web/scripts/migrations/backfill-program-categories.ts b/apps/web/scripts/migrations/backfill-program-categories.ts
index cd183a6911..609317289a 100644
--- a/apps/web/scripts/migrations/backfill-program-categories.ts
+++ b/apps/web/scripts/migrations/backfill-program-categories.ts
@@ -104,7 +104,7 @@ Meta Description: ${description}
Website Content Preview: ${content.slice(0, 300)}...`;
const { object } = await generateObject({
- model: anthropic("claude-3-5-haiku-latest"),
+ model: anthropic("claude-sonnet-4-20250514"),
schema: categorizationSchema,
prompt,
});
@@ -145,10 +145,8 @@ async function main() {
categories: {
none: {},
},
- workspace: {
- plan: {
- in: ["advanced", "enterprise"],
- },
+ addedToMarketplaceAt: {
+ not: null,
},
},
take: 10,
diff --git a/apps/web/scripts/migrations/backfill-program-marketplace.ts b/apps/web/scripts/migrations/backfill-program-marketplace.ts
index ea641183b6..c4a69532f0 100644
--- a/apps/web/scripts/migrations/backfill-program-marketplace.ts
+++ b/apps/web/scripts/migrations/backfill-program-marketplace.ts
@@ -51,7 +51,6 @@ async function main() {
},
},
});
- console.table(programToAdd, ["id", "name", "slug", "url"]);
if (!programToAdd.url) {
throw new Error("Program URL is not set");
diff --git a/packages/email/src/templates/partner-marketplace-announcement.tsx b/packages/email/src/templates/program-marketplace-announcement.tsx
similarity index 98%
rename from packages/email/src/templates/partner-marketplace-announcement.tsx
rename to packages/email/src/templates/program-marketplace-announcement.tsx
index 571695230d..93282e48ac 100644
--- a/packages/email/src/templates/partner-marketplace-announcement.tsx
+++ b/packages/email/src/templates/program-marketplace-announcement.tsx
@@ -14,7 +14,7 @@ import {
} from "@react-email/components";
import { Footer } from "../components/footer";
-export default function PartnerMarketplaceAnnouncement({
+export default function ProgramMarketplaceAnnouncement({
email = "[email protected]",
}: {
email: string;