The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
add launch week email + send batch email logic
Steven Tey44fe1d746bf7
diff --git a/apps/web/lib/email/email-templates-map.ts b/apps/web/lib/email/email-templates-map.tsindex 8e8bee323e..eb0edd887d 100644--- a/apps/web/lib/email/email-templates-map.ts+++ b/apps/web/lib/email/email-templates-map.ts@@ -1,6 +1,6 @@import BountyApproved from "@dub/email/templates/bounty-approved";import IdentityVerificationAnnouncement from "@dub/email/templates/broadcasts/identity-verification-announcement";-import StablecoinPayoutsAnnouncement from "@dub/email/templates/broadcasts/stablecoin-payouts-announcement";+import DubLaunchWeekDay1 from "@dub/email/templates/broadcasts/launch-week-day-1";import ConnectPayoutReminder from "@dub/email/templates/connect-payout-reminder";import ConnectPlatformsReminder from "@dub/email/templates/connect-platforms-reminder";import PartnerBanned from "@dub/email/templates/partner-banned";@@ -29,5 +29,6 @@ export const EMAIL_TEMPLATES_MAP = {IdentityVerificationAnnouncement,// PayoutAutoWithdrawals,// ProgramMarketplaceAnnouncement,- StablecoinPayoutsAnnouncement,+ // StablecoinPayoutsAnnouncement,+ DubLaunchWeekDay1,} as const;diff --git a/apps/web/scripts/reset-sent-mail.ts b/apps/web/scripts/reset-sent-mail.tsnew file mode 100644index 0000000000..99e5667815--- /dev/null+++ b/apps/web/scripts/reset-sent-mail.ts@@ -0,0 +1,30 @@+import { prisma } from "@dub/prisma";+import "dotenv-flow/config";++async function main() {+ while (true) {+ const usersToReset = await prisma.user.findMany({+ where: {+ sentMail: true,+ },+ });+ if (usersToReset.length === 0) {+ console.log("No more users to reset");+ break;+ }+ console.log(`Found ${usersToReset.length} users to reset`);+ const res = await prisma.user.updateMany({+ where: {+ id: {+ in: usersToReset.map((user) => user.id),+ },+ },+ data: {+ sentMail: false,+ },+ });+ console.log(`Reset ${res.count} users to sentMail: false`);+ }+}++main();diff --git a/apps/web/scripts/send-batch-emails.ts b/apps/web/scripts/send-batch-emails.tsindex edb2f37171..048c511747 100644--- a/apps/web/scripts/send-batch-emails.ts+++ b/apps/web/scripts/send-batch-emails.ts@@ -1,4 +1,5 @@-import IdentityVerificationAnnouncement from "@dub/email/templates/broadcasts/identity-verification-announcement";+import { generateUnsubscribeToken } from "@/lib/email/unsubscribe-token";+import DubLaunchWeekDay1 from "@dub/email/templates/broadcasts/launch-week-day-1";import { prisma } from "@dub/prisma";import { chunk } from "@dub/utils";import "dotenv-flow/config";@@ -9,18 +10,21 @@ async function main() {const usersToNotify = await prisma.user.findMany({where: {sentMail: false,- partners: {+ projects: {some: {- partner: {- identityVerifiedAt: null,- payouts: {- some: {- status: "completed",- amount: {- gt: 10000,+ project: {+ OR: [+ {+ defaultProgramId: {+ not: null,},},- },+ {+ plan: {+ not: "free",+ },+ },+ ],},},},@@ -36,13 +40,14 @@ async function main() {}console.log(`Found ${usersToNotify.length} users to notify`);- const res = await queueBatchEmail<typeof IdentityVerificationAnnouncement>(+ const res = await queueBatchEmail<typeof DubLaunchWeekDay1>(usersToNotify.map((user) => ({to: user.email!,- subject: "Action Required: Verify your identity on Dub",- templateName: "IdentityVerificationAnnouncement",+ subject: "Dub Launch Week Day 1: Introducing Partner Referrals",+ templateName: "DubLaunchWeekDay1",templateProps: {email: user.email!,+ unsubscribeUrl: `https://app.dub.co/unsubscribe/${generateUnsubscribeToken(user.email!)}`,},})),);diff --git a/packages/email/src/templates/broadcasts/launch-week-day-1.tsx b/packages/email/src/templates/broadcasts/launch-week-day-1.tsxnew file mode 100644index 0000000000..114a809fbc--- /dev/null+++ b/packages/email/src/templates/broadcasts/launch-week-day-1.tsx@@ -0,0 +1,200 @@+import { DUB_WORDMARK } from "@dub/utils";+import {+ Body,+ Container,+ Head,+ Heading,+ Hr,+ Html,+ Img,+ Link,+ Preview,+ Section,+ Tailwind,+ Text,+} from "@react-email/components";+import { Footer } from "../../components/footer";++export default function DubLaunchWeekDay1({+ email = "[email protected]",+ unsubscribeUrl = "https://partners.dub.co/account/settings",+}: {+ email: string;+ unsubscribeUrl: string;+}) {+ return (+ <Html>+ <Head>+ <style>{`+ @media only screen and (max-width: 600px) {+ .email-container {+ padding-left: 16px !important;+ padding-right: 16px !important;+ }+ }+ `}</style>+ </Head>+ <Preview>+ Reward partners for referring other partners, and see where your+ applications come from.+ </Preview>+ <Tailwind>+ <Body className="mx-auto my-auto bg-white font-sans">+ <Container className="email-container mx-auto my-10 max-w-[600px] px-10 py-5">+ <Section className="mt-2 text-center">+ <Img+ src={DUB_WORDMARK}+ width="65"+ height="32"+ alt="Dub"+ style={{ display: "block", margin: "0 auto" }}+ />+ </Section>++ <Heading className="mx-0 mb-2 mt-8 p-0 text-center text-2xl font-semibold text-black">+ Dub Launch Week Day 1+ </Heading>++ <Text className="mx-auto mb-8 mt-0 max-w-sm text-center text-base leading-6 text-neutral-600">+ Introducing Partner Referrals + Application Analytics+ </Text>++ <Text className="mx-0 mb-4 mt-0 text-sm leading-6 text-neutral-600">+ π Hey, it's Steven from Dub!+ </Text>+ <Text className="mx-0 mb-8 mt-0 text-sm leading-6 text-neutral-600">+ Today is <strong>Day 1 of our Spring Launch Week</strong>, where+ we'll be launching an exciting new feature for{" "}+ <a+ href="http://ship.dub.co/partners"+ className="font-medium text-black"+ >+ Dub Partners+ </a>{" "}+ every day β for 5 days straight!+ </Text>++ <Section className="mb-8 text-center">+ <Link+ href="https://ship.dub.co/partner-referrals"+ style={{ textDecoration: "none" }}+ >+ <Img+ src="https://assets.dub.co/cms/partner-referrals.jpg"+ width={560}+ height={320}+ alt="Partner Referrals"+ style={{+ display: "block",+ maxWidth: "100%",+ height: "auto",+ margin: "0 auto",+ borderRadius: "8px",+ }}+ />+ </Link>+ </Section>++ <Heading className="mx-0 mb-3 mt-0 p-0 text-lg font-semibold text-black">+ Introducing Partner Referrals+ </Heading>++ <Text className="mx-0 mb-4 mt-0 text-sm leading-6 text-neutral-600">+ You can now reward partners for referring other{" "}+ <strong>influencers, affiliates, and publishers</strong> to join+ your partner program.+ </Text>+ <Text className="mx-0 mb-4 mt-0 text-sm leading-6 text-neutral-600">+ There are two ways to reward partners for referrals: via a+ flat-fee or percentage commission.+ </Text>+ <Link+ href="https://ship.dub.co/partner-referrals"+ className="block w-full rounded-lg bg-neutral-900 py-2.5 text-center text-sm font-medium text-white no-underline"+ style={{+ backgroundColor: "#171717",+ color: "#ffffff",+ borderRadius: "8px",+ padding: "10px 16px",+ textDecoration: "none",+ fontWeight: "500",+ fontSize: "14px",+ width: "100%",+ boxSizing: "border-box",+ }}+ >+ Learn more about Partner Referrals+ </Link>++ <Hr className="mx-0 my-6 w-full border border-neutral-200" />++ <Section className="mb-8 text-center">+ <Link+ href="https://ship.dub.co/application-analytics"+ style={{ textDecoration: "none" }}+ >+ <Img+ src="https://assets.dub.co/cms/application-analytics-funnelchart.png"+ width={560}+ height={320}+ alt="Application Analytics Funnel Chart"+ style={{+ display: "block",+ maxWidth: "100%",+ height: "auto",+ margin: "0 auto",+ borderRadius: "8px",+ }}+ />+ </Link>+ </Section>++ <Heading className="mx-0 mb-3 mt-0 p-0 text-lg font-semibold text-black">+ Application Analytics+ </Heading>++ <Text className="mx-0 mb-4 mt-0 text-sm leading-6 text-neutral-600">+ On top of this, we're also unveiling a powerful new Application+ Analytics dashboard to give you real-time visibility into which+ channels are driving the most applications to your program.+ </Text>++ <Section className="mt-4 text-center">+ <Link+ href="https://ship.dub.co/application-analytics"+ className="block w-full rounded-lg bg-neutral-900 py-2.5 text-center text-sm font-medium text-white no-underline"+ style={{+ backgroundColor: "#171717",+ color: "#ffffff",+ borderRadius: "8px",+ padding: "10px 16px",+ textDecoration: "none",+ fontWeight: "500",+ fontSize: "14px",+ width: "100%",+ boxSizing: "border-box",+ }}+ >+ Learn more about Application Analytics+ </Link>+ </Section>++ <Hr className="mx-0 my-6 w-full border border-neutral-200" />++ <Text className="mx-0 mb-4 mt-0 text-sm leading-6 text-neutral-600">+ That's all for today! Stay tuned for the remaining days of our+ Spring Launch Week β see you tomorrow!+ </Text>+ <Text className="mx-0 mb-4 mt-0 text-sm leading-6 text-neutral-400">+ Steven from Dub.co+ </Text>++ <Section className="mx-auto max-w-[400px] text-center">+ <Footer email={email} marketing unsubscribeUrl={unsubscribeUrl} />+ </Section>+ </Container>+ </Body>+ </Tailwind>+ </Html>+ );+}