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.

Added thank you email for Pro/Enterprise subscribers

Steven Teybf5da476c7f4
diff --git a/components/layout/meta.tsx b/components/layout/meta.tsx
index c0cc13e3d5..4ec596121b 100644
--- a/components/layout/meta.tsx
+++ b/components/layout/meta.tsx
@@ -4,7 +4,7 @@ import { FAVICON_FOLDER } from "#/lib/constants";
export default function Meta({
title = "Dub - Link Management for Modern Marketing Teams",
description = "Dub is an open-source link management tool for modern marketing teams to create, share, and track short links.",
- image = "https://dub.sh/_static/thumbnail.png",
+ image = "https://public.blob.vercel-storage.com/kmKY9FhOzDRAX28c/4aNzmdW-S93Bh3Z3AJMLU90iSwq7SCLuuwIrcB.png",
}: {
title?: string;
description?: string;
@@ -47,7 +47,10 @@ export default function Meta({
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta itemProp="image" content={image} />
- <meta property="og:logo" content="https://dub.sh/_static/logo.png"></meta>
+ <meta
+ property="og:logo"
+ content="https://public.blob.vercel-storage.com/kmKY9FhOzDRAX28c/diIX27B-vli9jFicKhqvO4Dzb2IrgHbaOdRLcT.png"
+ ></meta>
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:image" content={image} />
diff --git a/emails/clicks-summary.tsx b/emails/clicks-summary.tsx
new file mode 100644
index 0000000000..c23f34fca8
--- /dev/null
+++ b/emails/clicks-summary.tsx
@@ -0,0 +1,158 @@
+import {
+ Body,
+ Link,
+ Container,
+ Head,
+ Heading,
+ Hr,
+ Html,
+ Img,
+ Preview,
+ Row,
+ Column,
+ Section,
+ Tailwind,
+ Text,
+} from "@react-email/components";
+import { Link2, MousePointerClick } from "lucide-react";
+import { DUB_LOGO } from "../lib/constants";
+import { nFormatter, truncate } from "../lib/utils";
+
+export default function ClicksSummary({
+ email = "[email protected]",
+ projectName = "Acme",
+ projectSlug = "acme",
+ totalClicks = 63689,
+ createdLinks = 25,
+ bestPerformingLinks = [
+ {
+ link: "acme.com/sales",
+ clicks: 2187,
+ },
+ {
+ link: "acme.com/instagram",
+ clicks: 1820,
+ },
+ {
+ link: "acme.com/facebook",
+ clicks: 1552,
+ },
+ {
+ link: "acme.com/twitter",
+ clicks: 1229,
+ },
+ {
+ link: "acme.com/linkedin",
+ clicks: 1055,
+ },
+ ],
+}: {
+ email: string;
+ projectName: string;
+ projectSlug: string;
+ totalClicks: number;
+ createdLinks: number;
+ bestPerformingLinks: {
+ link: string;
+ clicks: number;
+ }[];
+}) {
+ return (
+ <Html>
+ <Head />
+ <Preview>Your 30-day Dub summary</Preview>
+ <Tailwind>
+ <Body className="mx-auto my-auto bg-white font-sans">
+ <Container className="mx-auto my-10 max-w-[500px] rounded border border-solid border-gray-200 px-10 py-5">
+ <Section className="mt-8">
+ <Img
+ src={DUB_LOGO}
+ width="40"
+ height="40"
+ alt="Dub"
+ className="mx-auto my-0"
+ />
+ </Section>
+ <Heading className="mx-0 my-7 p-0 text-center text-xl font-semibold text-black">
+ Your 30-day Dub summary
+ </Heading>
+ <Text className="text-sm leading-6 text-black">
+ In the last 30 days, your Dub project,{" "}
+ <strong>{projectName}</strong> received{" "}
+ <strong>{nFormatter(totalClicks)} link clicks</strong>. You also
+ created <strong>{createdLinks} new links</strong> during that
+ time.
+ </Text>
+ <Section>
+ <Row>
+ <Column align="center">
+ <div className="flex h-12 w-12 items-center justify-center rounded-full bg-blue-200">
+ <MousePointerClick className="h-5 w-5 text-blue-600" />
+ </div>
+ <p className="text-sm font-semibold text-black">
+ {nFormatter(totalClicks)} clicks
+ </p>
+ </Column>
+ <Column align="center">
+ <div className="flex h-12 w-12 items-center justify-center rounded-full bg-green-200">
+ <Link2 className="h-5 w-5 text-green-600" />
+ </div>
+ <p className="text-sm font-semibold text-black">
+ {nFormatter(createdLinks)} new links
+ </p>
+ </Column>
+ </Row>
+ </Section>
+ <Text className="text-sm leading-6 text-black">
+ Here are your top 5 best performing links:
+ </Text>
+ <Section>
+ <Row className="pb-2">
+ <Column align="left" className="text-sm text-gray-500">
+ Link
+ </Column>
+ <Column align="right" className="text-sm text-gray-500">
+ Clicks
+ </Column>
+ </Row>
+ {bestPerformingLinks.map(({ link, clicks }, index) => (
+ <div key={index}>
+ <Row>
+ <Column align="left" className="text-sm font-medium">
+ {truncate(link, 30)}
+ </Column>
+ <Column align="right" className="text-sm text-gray-600">
+ {nFormatter(clicks)}
+ </Column>
+ </Row>
+ {index !== bestPerformingLinks.length - 1 && (
+ <Hr className="my-2 w-full border border-gray-200" />
+ )}
+ </div>
+ ))}
+ </Section>
+ <Text className="mt-10 text-sm leading-6 text-black">
+ You can view your full stats by clicking the button below.
+ </Text>
+ <Section className="my-8 text-center">
+ <Link
+ className="rounded-full bg-black px-6 py-3 text-center text-[12px] font-semibold text-white no-underline"
+ href={`https://app.dub.sh/${projectSlug}/settings/billing`}
+ >
+ View my stats
+ </Link>
+ </Section>
+ <Hr className="mx-0 my-6 w-full border border-gray-200" />
+ <Text className="text-[12px] leading-6 text-gray-500">
+ This invitation was intended for{" "}
+ <span className="text-black">{email}</span>. If you were not
+ expecting this invitation, you can ignore this email. If you are
+ concerned about your account's safety, please reply to this email
+ to get in touch with us.
+ </Text>
+ </Container>
+ </Body>
+ </Tailwind>
+ </Html>
+ );
+}
diff --git a/emails/domain-deleted.tsx b/emails/domain-deleted.tsx
index 1146fc8af4..eea3fc58d7 100644
--- a/emails/domain-deleted.tsx
+++ b/emails/domain-deleted.tsx
@@ -12,7 +12,7 @@ import {
Tailwind,
Text,
} from "@react-email/components";
-import * as React from "react";
+import { DUB_LOGO } from "../lib/constants";
export default function DomainDeleted({
email = "[email protected]",
@@ -32,7 +32,7 @@ export default function DomainDeleted({
<Container className="mx-auto my-10 max-w-[500px] rounded border border-solid border-gray-200 px-10 py-5">
<Section className="mt-8">
<Img
- src="https://dub.sh/_static/logo.png"
+ src={DUB_LOGO}
width="40"
height="40"
alt="Dub"
@@ -45,13 +45,12 @@ export default function DomainDeleted({
<Text className="text-sm leading-6 text-black">
Your domain <code className="text-purple-600">{domain}</code> for
your Dub project{" "}
- <a
+ <Link
href={`https://app.dub.sh/${projectSlug}`}
- target="_blank"
className="font-medium text-blue-600 no-underline"
>
{projectSlug}↗
- </a>{" "}
+ </Link>{" "}
has been invalid for 30 days. As a result, it has been deleted
from Dub.
</Text>
diff --git a/emails/feedback-email.tsx b/emails/feedback-email.tsx
index 3a6c73dec4..eca15b5e9e 100644
--- a/emails/feedback-email.tsx
+++ b/emails/feedback-email.tsx
@@ -10,6 +10,7 @@ import {
Tailwind,
Text,
} from "@react-email/components";
+import { DUB_LOGO } from "../lib/constants";
export default function FeedbackEmail({
email = "[email protected]",
@@ -27,7 +28,7 @@ export default function FeedbackEmail({
<Container className="mx-auto my-10 max-w-[500px] rounded border border-solid border-gray-200 px-10 py-5">
<Section className="mt-8">
<Img
- src="https://dub.sh/_static/logo.png"
+ src={DUB_LOGO}
width="40"
height="40"
alt="Dub"
diff --git a/emails/invalid-domain.tsx b/emails/invalid-domain.tsx
index 5e1976c4e0..f293246ce7 100644
--- a/emails/invalid-domain.tsx
+++ b/emails/invalid-domain.tsx
@@ -1,4 +1,3 @@
-import { capitalize, nFormatter } from "../lib/utils";
import {
Body,
Link,
@@ -13,7 +12,7 @@ import {
Tailwind,
Text,
} from "@react-email/components";
-import * as React from "react";
+import { DUB_LOGO } from "../lib/constants";
export default function InvalidDomain({
email = "[email protected]",
@@ -35,7 +34,7 @@ export default function InvalidDomain({
<Container className="mx-auto my-10 max-w-[500px] rounded border border-solid border-gray-200 px-10 py-5">
<Section className="mt-8">
<Img
- src="https://dub.sh/_static/logo.png"
+ src={DUB_LOGO}
width="40"
height="40"
alt="Dub"
@@ -48,13 +47,12 @@ export default function InvalidDomain({
<Text className="text-sm leading-6 text-black">
Your domain <code className="text-purple-600">{domain}</code> for
your Dub project{" "}
- <a
+ <Link
href={`https://app.dub.sh/${projectSlug}`}
- target="_blank"
className="font-medium text-blue-600 no-underline"
>
{projectSlug}↗
- </a>{" "}
+ </Link>{" "}
has been invalid for {invalidDays} days.
</Text>
<Text className="text-sm leading-6 text-black">
@@ -72,13 +70,12 @@ export default function InvalidDomain({
</Section>
<Text className="text-sm leading-6 text-black">
If you do not want to keep this domain on Dub, you can{" "}
- <a
+ <Link
href={`https://app.dub.sh/${projectSlug}/domains`}
- target="_blank"
className="font-medium text-blue-600 no-underline"
>
delete it
- </a>{" "}
+ </Link>{" "}
or simply ignore this email. To respect your inbox,{" "}
{invalidDays < 28
? `we will only send you one more email about this in ${
diff --git a/emails/login-link.tsx b/emails/login-link.tsx
index e0510facb3..696e98b190 100644
--- a/emails/login-link.tsx
+++ b/emails/login-link.tsx
@@ -12,7 +12,7 @@ import {
Tailwind,
Text,
} from "@react-email/components";
-import * as React from "react";
+import { DUB_LOGO } from "../lib/constants";
export default function LoginLink({
email = "[email protected]",
@@ -30,7 +30,7 @@ export default function LoginLink({
<Container className="mx-auto my-10 max-w-[500px] rounded border border-solid border-gray-200 px-10 py-5">
<Section className="mt-8">
<Img
- src="https://dub.sh/_static/logo.png"
+ src={DUB_LOGO}
width="40"
height="40"
alt="Dub"
diff --git a/emails/project-invite.tsx b/emails/project-invite.tsx
index 4c5b397ffb..0594d08e43 100644
--- a/emails/project-invite.tsx
+++ b/emails/project-invite.tsx
@@ -12,7 +12,7 @@ import {
Tailwind,
Text,
} from "@react-email/components";
-import * as React from "react";
+import { DUB_LOGO } from "../lib/constants";
export default function ProjectInvite({
email = "[email protected]",
@@ -36,7 +36,7 @@ export default function ProjectInvite({
<Container className="mx-auto my-10 max-w-[500px] rounded border border-solid border-gray-200 px-10 py-5">
<Section className="mt-8">
<Img
- src="https://dub.sh/_static/logo.png"
+ src={DUB_LOGO}
width="40"
height="40"
alt="Dub"
@@ -48,12 +48,12 @@ export default function ProjectInvite({
</Heading>
<Text className="text-sm leading-6 text-black">
<strong>{projectUser}</strong> (
- <a
+ <Link
className="text-blue-600 no-underline"
href={`mailto:${projectUserEmail}`}
>
{projectUserEmail}
- </a>
+ </Link>
) has invited you to join the <strong>{projectName}</strong>{" "}
project on Dub!
</Text>
diff --git a/emails/upgrade-email.tsx b/emails/upgrade-email.tsx
index 504b9dd0ff..7ea76ab959 100644
--- a/emails/upgrade-email.tsx
+++ b/emails/upgrade-email.tsx
@@ -1,36 +1,38 @@
import {
Body,
- Link,
Container,
Head,
Heading,
Hr,
Html,
Img,
+ Link,
Preview,
Section,
Tailwind,
Text,
} from "@react-email/components";
-import * as React from "react";
+import { DUB_LOGO } from "../lib/constants";
export default function UpgradeEmail({
name = "Brendon Urie",
- email = "panic@thedisco",
+ email = "[email protected]",
+ plan = "Pro",
}: {
name: string | null;
email: string;
+ plan: string;
}) {
return (
<Html>
<Head />
- <Preview>Thank you for upgrading!</Preview>
+ <Preview>Thank you for upgrading to Dub {plan}!</Preview>
<Tailwind>
<Body className="mx-auto my-auto bg-white font-sans">
<Container className="mx-auto my-10 max-w-[500px] rounded border border-solid border-gray-200 px-10 py-5">
<Section className="mt-8">
<Img
- src="https://dub.sh/_static/logo.png"
+ src={DUB_LOGO}
width="40"
height="40"
alt="Dub"
@@ -38,54 +40,70 @@ export default function UpgradeEmail({
/>
</Section>
<Heading className="mx-0 my-7 p-0 text-center text-xl font-semibold text-black">
- Thank you for upgrading!
+ Thank you for upgrading to Dub {plan}!
</Heading>
<Section className="my-8">
<Img
- src="https://dub.sh/_static/thumbnail.png"
- alt="Dub"
+ src="https://public.blob.vercel-storage.com/kmKY9FhOzDRAX28c/thank-you-PCJDehD1yOJdagchd7TuDCI0JnXVo7.png"
+ alt="Thank you"
className="max-w-[500px]"
/>
</Section>
<Text className="text-sm leading-6 text-black">
- Thanks for signing up{name && `, ${name}`}!
+ Hey{name && ` ${name}`}!
</Text>
<Text className="text-sm leading-6 text-black">
- My name is Steven, and I'm the creator of Dub - the link
- management tool for modern marketing teams. I'm excited to have
- you on board!
+ My name is Steven, and I'm the founder of Dub. I wanted to
+ personally reach out to thank you for upgrading to Dub {plan}!
</Text>
<Text className="text-sm leading-6 text-black">
- Here are a few things you can do:
- </Text>
- <Text className="ml-1 text-sm leading-4 text-black">
- ◆ Create a{" "}
- <a
- href="https://app.dub.sh/links"
+ As you might already know, we are a{" "}
+ <Link
+ href="https://dub.sh/mission"
className="font-medium text-blue-600 no-underline"
>
- Dub.sh short link
- </a>
- </Text>
- <Text className="ml-1 text-sm leading-4 text-black">
- ◆ Create a{" "}
- <a
- href="https://app.dub.sh"
+ 100% bootstrapped
+ </Link>{" "}
+ and{" "}
+ <Link
+ href="https://dub.sh/github"
className="font-medium text-blue-600 no-underline"
>
- new project
- </a>{" "}
- and add your custom domain
+ open-source
+ </Link>{" "}
+ business. Your support means the world to us and helps us continue
+ to build and improve Dub.
+ </Text>
+ <Text className="text-sm leading-6 text-black">
+ On the {plan} plan, you now have access to:
</Text>
<Text className="ml-1 text-sm leading-4 text-black">
- ◆ Follow us on{" "}
- <a
- href="https://twitter.com/dubdotsh"
- className="font-medium text-blue-600 no-underline"
- >
- Twitter
- </a>
+ ◆ {plan === "Enterprise" ? "Unlimited" : "Up to 50K"} link clicks
+ per month
+ </Text>
+ <Text className="ml-1 text-sm leading-4 text-black">
+ ◆ Custom branding for your QR codes
+ </Text>
+ <Text className="ml-1 text-sm leading-4 text-black">
+ ◆ Redirect your root domain to the URL of your choice
+ </Text>
+ <Text className="ml-1 text-sm leading-4 text-black">
+ ◆ Unlimited teammates
+ </Text>
+ <Text className="ml-1 text-sm leading-4 text-black">
+ ◆ Unlimited link history
+ </Text>
+ <Text className="ml-1 text-sm leading-4 text-black">
+ ◆ Unlimited tags
+ </Text>
+ <Text className="ml-1 text-sm leading-4 text-black">
+ ◆ API access (coming soon)
</Text>
+ {plan === "Enterprise" && (
+ <Text className="ml-1 text-sm leading-4 text-black">
+ ◆ Priority support
+ </Text>
+ )}
<Text className="text-sm leading-6 text-black">
Let me know if you have any questions or feedback. I'm always
happy to help!
diff --git a/emails/usage-exceeded.tsx b/emails/usage-exceeded.tsx
index 66c38f4812..4d62d7c4b0 100644
--- a/emails/usage-exceeded.tsx
+++ b/emails/usage-exceeded.tsx
@@ -1,5 +1,3 @@
-import { ProjectProps } from "../lib/types";
-import { capitalize, nFormatter } from "../lib/utils";
import {
Body,
Link,
@@ -14,10 +12,12 @@ import {
Tailwind,
Text,
} from "@react-email/components";
-import * as React from "react";
+import { DUB_LOGO } from "../lib/constants";
+import { ProjectProps } from "../lib/types";
+import { capitalize, nFormatter } from "../lib/utils";
export default function UsageExceeded({
- email = "panic@thedisco",
+ email = "[email protected]",
project = {
id: "ckqf1q3xw0000gk5u2q1q2q1q",
name: "Acme",
@@ -42,7 +42,7 @@ export default function UsageExceeded({
<Container className="mx-auto my-10 max-w-[500px] rounded border border-solid border-gray-200 px-10 py-5">
<Section className="mt-8">
<Img
- src="https://dub.sh/_static/logo.png"
+ src={DUB_LOGO}
width="40"
height="40"
alt="Dub"
diff --git a/emails/welcome-email.tsx b/emails/welcome-email.tsx
index a5a1bdadfc..5f2f11f08b 100644
--- a/emails/welcome-email.tsx
+++ b/emails/welcome-email.tsx
@@ -12,11 +12,11 @@ import {
Tailwind,
Text,
} from "@react-email/components";
-import * as React from "react";
+import { DUB_LOGO, DUB_THUMBNAIL } from "../lib/constants";
export default function WelcomeEmail({
name = "Brendon Urie",
- email = "panic@thedisco",
+ email = "[email protected]",
}: {
name: string | null;
email: string;
@@ -30,7 +30,7 @@ export default function WelcomeEmail({
<Container className="mx-auto my-10 max-w-[500px] rounded border border-solid border-gray-200 px-10 py-5">
<Section className="mt-8">
<Img
- src="https://dub.sh/_static/logo.png"
+ src={DUB_LOGO}
width="40"
height="40"
alt="Dub"
@@ -41,17 +41,13 @@ export default function WelcomeEmail({
Welcome to Dub
</Heading>
<Section className="my-8">
- <Img
- src="https://dub.sh/_static/thumbnail.png"
- alt="Dub"
- className="max-w-[500px]"
- />
+ <Img src={DUB_THUMBNAIL} alt="Dub" className="max-w-[500px]" />
</Section>
<Text className="text-sm leading-6 text-black">
Thanks for signing up{name && `, ${name}`}!
</Text>
<Text className="text-sm leading-6 text-black">
- My name is Steven, and I'm the creator of Dub - the link
+ My name is Steven, and I'm the founder of Dub - the link
management tool for modern marketing teams. I'm excited to have
you on board!
</Text>
@@ -60,31 +56,31 @@ export default function WelcomeEmail({
</Text>
<Text className="ml-1 text-sm leading-4 text-black">
◆ Create a{" "}
- <a
+ <Link
href="https://app.dub.sh/links"
className="font-medium text-blue-600 no-underline"
>
Dub.sh short link
- </a>
+ </Link>
</Text>
<Text className="ml-1 text-sm leading-4 text-black">
◆ Create a{" "}
- <a
+ <Link
href="https://app.dub.sh"
className="font-medium text-blue-600 no-underline"
>
new project
- </a>{" "}
+ </Link>{" "}
and add your custom domain
</Text>
<Text className="ml-1 text-sm leading-4 text-black">
◆ Follow us on{" "}
- <a
+ <Link
href="https://twitter.com/dubdotsh"
className="font-medium text-blue-600 no-underline"
>
Twitter
- </a>
+ </Link>
</Text>
<Text className="text-sm leading-6 text-black">
Let me know if you have any questions or feedback. I'm always
diff --git a/lib/constants/index.ts b/lib/constants/index.ts
index 8dbaa12c54..cc7d22de3c 100644
--- a/lib/constants/index.ts
+++ b/lib/constants/index.ts
@@ -70,6 +70,12 @@ export const REDIRECT_HEADERS = {
export const FAVICON_FOLDER = "/_static/favicons";
export const GOOGLE_FAVICON_URL =
"https://www.google.com/s2/favicons?sz=64&domain_url=";
+
+export const DUB_LOGO =
+ "https://public.blob.vercel-storage.com/kmKY9FhOzDRAX28c/logo-1Y8NV0x4Wsy7LzPAYjBmkytJYTMJi0.png";
+export const DUB_THUMBNAIL =
+ "https://public.blob.vercel-storage.com/kmKY9FhOzDRAX28c/thumbnail-wU82A4LTeJMXrygW1ZR6O36k3edeJf.png";
+
export { default as COUNTRIES } from "./countries";
export { default as ccTLDs } from "./cctlds";
diff --git a/lib/utils.ts b/lib/utils.ts
index 7ffdd6df4d..df40e4eafb 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -19,7 +19,7 @@ export function cn(...inputs: ClassValue[]) {
export function constructMetadata({
title = "Dub - Link Management for Modern Marketing Teams",
description = "Dub is an open-source link management tool for modern marketing teams to create, share, and track short links.",
- image = "https://dub.sh/_static/thumbnail.png",
+ image = "https://public.blob.vercel-storage.com/kmKY9FhOzDRAX28c/4aNzmdW-S93Bh3Z3AJMLU90iSwq7SCLuuwIrcB.png",
}: {
title?: string;
description?: string;
diff --git a/pages/api/og/stats.tsx b/pages/api/og/stats.tsx
index d7b6434626..950131a287 100644
--- a/pages/api/og/stats.tsx
+++ b/pages/api/og/stats.tsx
@@ -54,7 +54,7 @@ export default async function handler(req: NextRequest) {
}}
>
<img
- src="https://dub.sh/_static/logo.png"
+ src="https://public.blob.vercel-storage.com/kmKY9FhOzDRAX28c/diIX27B-vli9jFicKhqvO4Dzb2IrgHbaOdRLcT.png"
style={{
width: "80px",
height: "80px",
diff --git a/pages/api/stripe/webhook.ts b/pages/api/stripe/webhook.ts
index 6484a4b0f5..29cdb9cd85 100644
--- a/pages/api/stripe/webhook.ts
+++ b/pages/api/stripe/webhook.ts
@@ -6,6 +6,8 @@ import { stripe } from "#/lib/stripe";
import { PLANS } from "#/lib/stripe/constants";
import { redis } from "#/lib/upstash";
import { log } from "#/lib/utils";
+import { sendEmail } from "emails";
+import UpgradeEmail from "emails/upgrade-email";
// Stripe requires the raw body to construct the event.
export const config = {
@@ -75,9 +77,6 @@ export default async function webhookHandler(
billingCycleStart: new Date().getDate(),
},
});
-
- // TODO - send thank you email to project owner
- //
} else if (event.type === "customer.subscription.updated") {
const subscriptionUpdated = event.data.object as Stripe.Subscription;
const newPriceId = subscriptionUpdated.items.data[0].price.id;
@@ -94,7 +93,7 @@ export default async function webhookHandler(
const stripeId = subscriptionUpdated.customer.toString();
// If a project upgrades/downgrades their subscription, update their usage limit in the database.
- await prisma.project.update({
+ const data = await prisma.project.update({
where: {
stripeId,
},
@@ -102,7 +101,38 @@ export default async function webhookHandler(
usageLimit,
plan: plan.slug,
},
+ select: {
+ users: {
+ where: {
+ role: "owner",
+ },
+ select: {
+ user: {
+ select: {
+ name: true,
+ email: true,
+ },
+ },
+ },
+ },
+ },
});
+
+ const owner = data.users[0].user;
+
+ // send thank you email to project owner
+ await sendEmail({
+ email: owner.email as string,
+ subject: `Thank you for upgrading to Dub ${plan.name}!`,
+ react: UpgradeEmail({
+ name: owner.name,
+ email: owner.email as string,
+ plan: plan.name,
+ }),
+ marketing: true,
+ });
+
+ // If project cancels their subscription
} else if (event.type === "customer.subscription.deleted") {
const subscriptionDeleted = event.data.object as Stripe.Subscription;