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.

update launch week email

Steven Tey274de170a459
diff --git a/apps/web/lib/email/email-templates-map.ts b/apps/web/lib/email/email-templates-map.ts
index 0c0e561b63..a2994f7064 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 DubLaunchWeekDay4 from "@dub/email/templates/broadcasts/launch-week-day-4";
+import DubLaunchWeekDay5 from "@dub/email/templates/broadcasts/launch-week-day-5";
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";
@@ -32,5 +32,5 @@ export const EMAIL_TEMPLATES_MAP = {
// PayoutAutoWithdrawals,
// ProgramMarketplaceAnnouncement,
// StablecoinPayoutsAnnouncement,
- DubLaunchWeekDay4,
+ DubLaunchWeekDay5,
} as const;
diff --git a/apps/web/scripts/send-batch-emails.ts b/apps/web/scripts/send-batch-emails.ts
index 3b6976c033..d078dd7ced 100644
--- a/apps/web/scripts/send-batch-emails.ts
+++ b/apps/web/scripts/send-batch-emails.ts
@@ -1,4 +1,5 @@
-import DubLaunchWeekDay4 from "@dub/email/templates/broadcasts/launch-week-day-4";
+import { EXCLUDED_PROGRAM_IDS } from "@/lib/constants/partner-profile";
+import DubLaunchWeekDay5 from "@dub/email/templates/broadcasts/launch-week-day-5";
import { prisma } from "@dub/prisma";
import { chunk } from "@dub/utils";
import "dotenv-flow/config";
@@ -7,48 +8,83 @@ import { generateUnsubscribeToken } from "../lib/email/unsubscribe-token";
async function main() {
while (true) {
- const usersToNotify = await prisma.user.findMany({
+ const usersWithPartners = await prisma.user.findMany({
where: {
sentMail: false,
- projects: {
- some: {
- project: {
- OR: [
- {
- defaultProgramId: {
- not: null,
- },
- },
- {
- plan: {
- not: "free",
- },
- },
- ],
- },
- },
+ partners: {
+ some: {},
},
email: {
not: null,
},
notificationPreferences: {
- dubPartners: true,
+ partnerAccount: true,
+ },
+ },
+ take: 1000,
+ include: {
+ partners: {
+ select: {
+ partner: {
+ select: {
+ id: true,
+ programs: {
+ where: {
+ programId: {
+ in: EXCLUDED_PROGRAM_IDS,
+ },
+ },
+ },
+ },
+ },
+ },
},
},
- take: 10000,
});
- if (usersToNotify.length === 0) {
+ if (usersWithPartners.length === 0) {
console.log("No more users to notify");
break;
}
+
+ const programEnrollmentsByPartner = await prisma.programEnrollment.groupBy({
+ by: ["partnerId"],
+ where: {
+ partnerId: {
+ in: usersWithPartners.map((user) => user.defaultPartnerId!),
+ },
+ },
+ _count: {
+ programId: true,
+ },
+ });
+
+ const programEnrollmentCountsByPartnerId =
+ programEnrollmentsByPartner.reduce(
+ (acc, { partnerId, _count }) => {
+ acc[partnerId] = _count.programId;
+ return acc;
+ },
+ {} as Record<string, number>,
+ );
+
+ const usersToNotify = usersWithPartners.filter((user) =>
+ user.partners.every(
+ ({ partner }) =>
+ !(
+ partner.programs.length > 0 &&
+ programEnrollmentCountsByPartnerId[partner.id] === 1
+ ),
+ ),
+ );
+
console.log(`Found ${usersToNotify.length} users to notify`);
- const res = await queueBatchEmail<typeof DubLaunchWeekDay4>(
+ const res = await queueBatchEmail<typeof DubLaunchWeekDay5>(
usersToNotify.map((user) => ({
to: user.email!,
variant: "marketing",
- subject: "Dub Launch Week Day 4: Introducing the Dub MCP Server",
- templateName: "DubLaunchWeekDay4",
+ subject: "Introducing the Dub Network Referral Bonus",
+ templateName: "DubLaunchWeekDay5",
templateProps: {
email: user.email!,
unsubscribeUrl: `https://app.dub.co/unsubscribe/${generateUnsubscribeToken(user.email!)}`,
@@ -58,8 +94,8 @@ async function main() {
console.log(res);
- const chunkedUsers = chunk(usersToNotify, 1000);
- for (const cu of chunkedUsers) {
+ const chunkedUsersWithPartners = chunk(usersWithPartners, 1000);
+ for (const cu of chunkedUsersWithPartners) {
const res = await prisma.user.updateMany({
where: {
id: {
diff --git a/packages/email/src/templates/broadcasts/launch-week-day-5.tsx b/packages/email/src/templates/broadcasts/launch-week-day-5.tsx
new file mode 100644
index 0000000000..ed08dce810
--- /dev/null
+++ b/packages/email/src/templates/broadcasts/launch-week-day-5.tsx
@@ -0,0 +1,148 @@
+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 DubLaunchWeekDay5({
+ email = "[email protected]",
+ unsubscribeUrl = "https://app.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>
+ Refer other partners to join the Dub Partner Network and get rewarded
+ when they start earning on Dub.
+ </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 5
+ </Heading>
+
+ <Text className="mx-auto mb-8 mt-0 max-w-sm text-center text-base leading-6 text-neutral-600">
+ Introducing the Dub Network Referral Bonus
+ </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 5 of our Spring Launch Week</strong>, where
+ we'll be launching an exciting new feature for{" "}
+ <Link
+ href="http://ship.dub.co/partners"
+ className="font-medium text-black underline"
+ >
+ Dub Partners
+ </Link>{" "}
+ every day – for 5 days straight!
+ </Text>
+
+ <Section className="mb-8 text-center">
+ <Link
+ href="https://ship.dub.co/network-referral"
+ style={{ textDecoration: "none" }}
+ >
+ <Img
+ src="https://assets.dub.co/cms/network-referral-bonus.jpg"
+ width={560}
+ height={320}
+ alt="Dub Network Referral Bonus"
+ 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 the Dub Network Referral Bonus
+ </Heading>
+
+ <Text className="mx-0 mb-4 mt-0 text-sm leading-6 text-neutral-600">
+ You can now refer other affiliates/creators/publishers to join the
+ Dub Partner Network and get rewarded when they start earning on
+ Dub.
+ </Text>
+ <Text className="mx-0 mb-4 mt-0 text-sm leading-6 text-neutral-600">
+ When a partner you referred starts earning on Dub, you'll earn 50%
+ of their payout fees for up to 12 months.
+ </Text>
+ <Link
+ href="https://ship.dub.co/network-referral"
+ 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 the Dub Network Referral Bonus
+ </Link>
+
+ <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 our Spring Launch Week! Thanks for joining us for 5
+ days of exciting new features – please let us know if you have any
+ feedback or questions.
+ </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>
+ );
+}