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.

Track free trials lead events via Stripe integration (#3383)

Steven Tey438c2b137476
diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/customer-subscription-created.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/customer-subscription-created.ts
new file mode 100644
index 0000000000..ea283199c2
--- /dev/null
+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/customer-subscription-created.ts
@@ -0,0 +1,116 @@
+import { trackLead } from "@/lib/api/conversions/track-lead";
+import { stripeIntegrationSettingsSchema } from "@/lib/integrations/stripe/schema";
+import { StripeMode } from "@/lib/types";
+import { prisma } from "@dub/prisma";
+import { Customer } from "@dub/prisma/client";
+import { pick, STRIPE_INTEGRATION_ID } from "@dub/utils";
+import type Stripe from "stripe";
+import { getConnectedCustomer } from "./utils/get-connected-customer";
+
+// Handle event "customer.subscription.created"
+// only used for recording free trial creations
+export async function customerSubscriptionCreated(
+ event: Stripe.Event,
+ mode: StripeMode,
+) {
+ const createdSubscription = event.data.object as Stripe.Subscription;
+
+ if (createdSubscription.status !== "trialing") {
+ return "Subscription is not in trialing status, skipping...";
+ }
+
+ const stripeAccountId = event.account as string;
+ const stripeCustomerId = createdSubscription.customer as string;
+
+ const workspace = await prisma.project.findUnique({
+ where: {
+ stripeConnectId: stripeAccountId,
+ },
+ select: {
+ id: true,
+ slug: true,
+ stripeConnectId: true,
+ defaultProgramId: true,
+ webhookEnabled: true,
+ installedIntegrations: {
+ where: {
+ integrationId: STRIPE_INTEGRATION_ID,
+ },
+ },
+ },
+ });
+
+ if (!workspace) {
+ return `Workspace with stripeConnectId ${stripeAccountId} not found, skipping...`;
+ }
+
+ if (!workspace.installedIntegrations.length) {
+ return `Workspace ${workspace.slug} has no Stripe integration installed, skipping...`;
+ }
+
+ const stripeIntegrationSettings = stripeIntegrationSettingsSchema.parse(
+ workspace.installedIntegrations[0].settings ?? {},
+ );
+
+ if (!stripeIntegrationSettings?.freeTrials?.enabled) {
+ return `Stripe free trial tracking is not enabled for workspace ${workspace.slug}, skipping...`;
+ }
+
+ let customer: Customer | null = null;
+
+ // find customer by stripeCustomerId or email
+ customer = await prisma.customer.findUnique({
+ where: {
+ stripeCustomerId,
+ },
+ });
+
+ if (!customer) {
+ const stripeCustomer = await getConnectedCustomer({
+ stripeCustomerId,
+ stripeAccountId,
+ mode,
+ });
+
+ if (stripeCustomer?.email) {
+ customer = await prisma.customer.findFirst({
+ where: {
+ projectId: workspace.id,
+ email: stripeCustomer.email,
+ },
+ });
+
+ if (!customer) {
+ // this should never happen, but just in case
+ return `Customer ${stripeCustomer.id} with email ${stripeCustomer.email} has not been tracked yet, skipping...`;
+ }
+ } else {
+ // this should never happen, but just in case
+ return `Customer with stripeCustomerId ${stripeCustomerId} not found, skipping...`;
+ }
+ }
+
+ if (!customer.clickId || !customer.externalId) {
+ return `Customer ${customer.id} has no clickId or externalId, skipping...`;
+ }
+
+ // if trackQuantity is enabled, use the quantity from the main subscription item
+ // (e.g. for a 3-seat free trial, the event quantity will be 3)
+ const eventQuantity = stripeIntegrationSettings.freeTrials.trackQuantity
+ ? createdSubscription.items.data[0].quantity
+ : 1;
+
+ await trackLead({
+ clickId: customer.clickId,
+ eventName: "Started Trial",
+ customerExternalId: customer.externalId,
+ customerName: customer.name,
+ customerEmail: customer.email,
+ eventQuantity,
+ rawBody: {},
+ workspace: pick(workspace, ["id", "stripeConnectId", "webhookEnabled"]),
+ source: "trial",
+ });
+
+ return `Customer subscription created for customer ${customer.id} with stripeCustomerId ${stripeCustomerId} and workspace ${workspace.slug}`;
+}
diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/route.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/route.ts
index 000198a107..ddc1c1091d 100644
--- a/apps/web/app/(ee)/api/stripe/integration/webhook/route.ts
+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/route.ts
@@ -8,6 +8,7 @@ import { chargeRefunded } from "./charge-refunded";
import { checkoutSessionCompleted } from "./checkout-session-completed";
import { couponDeleted } from "./coupon-deleted";
import { customerCreated } from "./customer-created";
+import { customerSubscriptionCreated } from "./customer-subscription-created";
import { customerSubscriptionDeleted } from "./customer-subscription-deleted";
import { customerUpdated } from "./customer-updated";
import { invoicePaid } from "./invoice-paid";
@@ -20,6 +21,7 @@ const relevantEvents = new Set([
"coupon.deleted",
"customer.created",
"customer.updated",
+ "customer.subscription.created",
"customer.subscription.deleted",
"invoice.paid",
"promotion_code.updated",
@@ -100,6 +102,9 @@ export const POST = withAxiom(async (req: Request) => {
case "customer.updated":
response = await customerUpdated(event);
break;
+ case "customer.subscription.created":
+ response = await customerSubscriptionCreated(event, mode);
+ break;
case "customer.subscription.deleted":
response = await customerSubscriptionDeleted(event);
break;
diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/utils/create-new-customer.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/utils/create-new-customer.ts
index 890e9e3b3c..23134e9a04 100644
--- a/apps/web/app/(ee)/api/stripe/integration/webhook/utils/create-new-customer.ts
+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/utils/create-new-customer.ts
@@ -1,16 +1,14 @@
import { createId } from "@/lib/api/create-id";
-import { detectAndRecordFraudEvent } from "@/lib/api/fraud/detect-record-fraud-event";
import { includeTags } from "@/lib/api/links/include-tags";
import { syncPartnerLinksStats } from "@/lib/api/partners/sync-partner-links-stats";
import { executeWorkflows } from "@/lib/api/workflows/execute-workflows";
import { generateRandomName } from "@/lib/names";
-import { createPartnerCommission } from "@/lib/partners/create-partner-commission";
import { getClickEvent, recordLead } from "@/lib/tinybird";
import { sendWorkspaceWebhook } from "@/lib/webhook/publish";
import { transformLeadEventData } from "@/lib/webhook/transform";
import { prisma } from "@dub/prisma";
import { WorkflowTrigger } from "@dub/prisma/client";
-import { nanoid, pick } from "@dub/utils";
+import { nanoid } from "@dub/utils";
import { waitUntil } from "@vercel/functions";
import type Stripe from "stripe";
@@ -105,28 +103,7 @@ export async function createNewCustomer(event: Stripe.Event) {
}),
]);
- let createdCommission:
- | Awaited<ReturnType<typeof createPartnerCommission>>
- | undefined = undefined;
-
if (link.programId && link.partnerId) {
- createdCommission = await createPartnerCommission({
- event: "lead",
- programId: link.programId,
- partnerId: link.partnerId,
- linkId: link.id,
- eventId: leadData.event_id,
- customerId: customer.id,
- quantity: 1,
- context: {
- customer: {
- country: customer.country,
- },
- },
- });
-
- const { webhookPartner, programEnrollment } = createdCommission;
-
waitUntil(
Promise.allSettled([
executeWorkflows({
@@ -145,17 +122,6 @@ export async function createNewCustomer(event: Stripe.Event) {
programId: link.programId,
eventType: "lead",
}),
-
- webhookPartner &&
- detectAndRecordFraudEvent({
- program: { id: link.programId },
- partner: pick(webhookPartner, ["id", "email", "name"]),
- programEnrollment: pick(programEnrollment, ["status"]),
- customer: pick(customer, ["id", "email", "name"]),
- link: pick(link, ["id"]),
- click: pick(leadData, ["url", "referer"]),
- event: { id: leadData.event_id },
- }),
]),
);
}
@@ -170,7 +136,6 @@ export async function createNewCustomer(event: Stripe.Event) {
eventName,
link: linkUpdated,
customer,
- partner: createdCommission?.webhookPartner,
metadata: null,
}),
}),
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/[integrationSlug]/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/[integrationSlug]/page-client.tsx
index a852fbf782..e508bf9add 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/[integrationSlug]/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/[integrationSlug]/page-client.tsx
@@ -5,6 +5,7 @@ import { clientAccessCheck } from "@/lib/client-access-check";
import { HubSpotSettings } from "@/lib/integrations/hubspot/ui/settings";
import { SegmentSettings } from "@/lib/integrations/segment/ui/settings";
import { SlackSettings } from "@/lib/integrations/slack/ui/settings";
+import { StripeIntegrationSettings } from "@/lib/integrations/stripe/ui/settings";
import { ZapierSettings } from "@/lib/integrations/zapier/ui/settings";
import useWorkspace from "@/lib/swr/use-workspace";
import { InstalledIntegrationInfoProps } from "@/lib/types";
@@ -46,6 +47,7 @@ import {
getDomainWithoutWWW,
SEGMENT_INTEGRATION_ID,
SLACK_INTEGRATION_ID,
+ STRIPE_INTEGRATION_ID,
ZAPIER_INTEGRATION_ID,
} from "@dub/utils";
import { HUBSPOT_INTEGRATION_ID } from "@dub/utils/src/constants/integrations";
@@ -59,6 +61,7 @@ const integrationSettings = {
[SLACK_INTEGRATION_ID]: SlackSettings,
[SEGMENT_INTEGRATION_ID]: SegmentSettings,
[HUBSPOT_INTEGRATION_ID]: HubSpotSettings,
+ [STRIPE_INTEGRATION_ID]: StripeIntegrationSettings,
};
export default function IntegrationPageClient({
diff --git a/apps/web/lib/integrations/stripe/schema.ts b/apps/web/lib/integrations/stripe/schema.ts
new file mode 100644
index 0000000000..0c2fd3adcb
--- /dev/null
+++ b/apps/web/lib/integrations/stripe/schema.ts
@@ -0,0 +1,18 @@
+import * as z from "zod/v4";
+
+export const stripeIntegrationSettingsSchema = z.object({
+ freeTrials: z
+ .object({
+ enabled: z
+ .boolean()
+ .default(false)
+ .describe("Whether to track subscription free trials as lead events."),
+ trackQuantity: z
+ .boolean()
+ .default(false)
+ .describe(
+ "Whether to track the provisioned quantity in the subscription as separate lead events.",
+ ),
+ })
+ .nullish(),
+});
diff --git a/apps/web/lib/integrations/stripe/ui/settings.tsx b/apps/web/lib/integrations/stripe/ui/settings.tsx
new file mode 100644
index 0000000000..b4499209e0
--- /dev/null
+++ b/apps/web/lib/integrations/stripe/ui/settings.tsx
@@ -0,0 +1,161 @@
+"use client";
+
+import useWorkspace from "@/lib/swr/use-workspace";
+import { InstalledIntegrationInfoProps } from "@/lib/types";
+import { MarkdownDescription } from "@/ui/shared/markdown-description";
+import { AnimatedSizeContainer, Button, Switch } from "@dub/ui";
+import { useAction } from "next-safe-action/hooks";
+import { useMemo, useState } from "react";
+import { toast } from "sonner";
+import * as z from "zod/v4";
+import { stripeIntegrationSettingsSchema } from "../schema";
+import { updateStripeSettingsAction } from "../update-stripe-settings";
+
+const STRIPE_DEFAULT_SETTINGS = {
+ freeTrials: {
+ enabled: false,
+ trackQuantity: false,
+ },
+};
+
+export const StripeIntegrationSettings = ({
+ installed,
+ settings,
+}: InstalledIntegrationInfoProps) => {
+ const { id: workspaceId } = useWorkspace();
+
+ const stripeSettings = stripeIntegrationSettingsSchema.parse({
+ ...STRIPE_DEFAULT_SETTINGS,
+ ...(settings as z.infer<typeof stripeIntegrationSettingsSchema>),
+ });
+
+ const initialFreeTrialsEnabled = stripeSettings?.freeTrials?.enabled ?? false;
+ const initialTrackQuantity =
+ stripeSettings?.freeTrials?.trackQuantity ?? false;
+
+ // Track saved values that can be updated after successful save
+ const [savedFreeTrialsEnabled, setSavedFreeTrialsEnabled] = useState(
+ initialFreeTrialsEnabled,
+ );
+ const [savedTrackQuantity, setSavedTrackQuantity] =
+ useState(initialTrackQuantity);
+
+ const [freeTrialsEnabled, setFreeTrialsEnabled] = useState(
+ initialFreeTrialsEnabled,
+ );
+
+ const [trackQuantity, setTrackQuantity] = useState(initialTrackQuantity);
+
+ const isDirty = useMemo(() => {
+ return (
+ freeTrialsEnabled !== savedFreeTrialsEnabled ||
+ trackQuantity !== savedTrackQuantity
+ );
+ }, [
+ freeTrialsEnabled,
+ savedFreeTrialsEnabled,
+ trackQuantity,
+ savedTrackQuantity,
+ ]);
+
+ const { executeAsync, isPending } = useAction(updateStripeSettingsAction, {
+ async onSuccess() {
+ // Update saved values to match current values after successful save
+ setSavedFreeTrialsEnabled(freeTrialsEnabled);
+ setSavedTrackQuantity(freeTrialsEnabled ? trackQuantity : false);
+ toast.success("Stripe settings updated successfully.");
+ },
+ onError({ error }) {
+ toast.error(error.serverError || "Failed to update Stripe settings.");
+ },
+ });
+
+ const onSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
+ e.preventDefault();
+
+ if (!workspaceId) {
+ return;
+ }
+
+ await executeAsync({
+ workspaceId,
+ freeTrials: {
+ enabled: freeTrialsEnabled,
+ trackQuantity: freeTrialsEnabled ? trackQuantity : false,
+ },
+ });
+ };
+
+ if (!installed) {
+ return null;
+ }
+
+ return (
+ <form className="mt-4 space-y-4" onSubmit={onSubmit}>
+ <div className="rounded-lg border border-neutral-200 bg-white">
+ <div className="flex items-center gap-x-2 border-b border-neutral-200 px-4 py-4">
+ <p className="text-sm font-medium text-neutral-700">
+ Stripe Integration Settings
+ </p>
+ </div>
+
+ <div className="space-y-0">
+ <div className="flex items-center justify-between gap-4 p-5">
+ <div className="min-w-0 flex-1">
+ <label className="mb-1 block text-sm font-semibold text-neutral-900">
+ Track Free Trials
+ </label>
+ <MarkdownDescription className="text-sm text-neutral-600">
+ Whether to track [subscription free
+ trials](https://docs.stripe.com/billing/subscriptions/trials) as
+ lead events.
+ </MarkdownDescription>
+ </div>
+ <Switch
+ checked={freeTrialsEnabled}
+ fn={setFreeTrialsEnabled}
+ disabled={isPending}
+ />
+ </div>
+
+ <AnimatedSizeContainer height>
+ {freeTrialsEnabled && (
+ <div className="border-t border-neutral-200">
+ <div className="flex items-center justify-between gap-4 p-5">
+ <div className="min-w-0 flex-1">
+ <label className="mb-1 block text-sm font-semibold text-neutral-900">
+ Track Provisioned Quantity
+ </label>
+ <MarkdownDescription className="text-sm text-neutral-600">
+ Whether to track the [provisioned
+ quantity](https://docs.stripe.com/billing/subscriptions/quantities)
+ in the subscription as separate lead events.
+ </MarkdownDescription>
+ </div>
+ <Switch
+ checked={trackQuantity}
+ fn={setTrackQuantity}
+ disabled={isPending}
+ />
+ </div>
+ </div>
+ )}
+ </AnimatedSizeContainer>
+ </div>
+
+ <div className="flex items-center justify-end rounded-b-lg border-t border-neutral-200 bg-neutral-50 px-4 py-3">
+ <div className="shrink-0">
+ <Button
+ type="submit"
+ variant="primary"
+ text="Save changes"
+ className="h-8 w-fit"
+ loading={isPending}
+ disabled={!isDirty || isPending}
+ />
+ </div>
+ </div>
+ </div>
+ </form>
+ );
+};
diff --git a/apps/web/lib/integrations/stripe/update-stripe-settings.ts b/apps/web/lib/integrations/stripe/update-stripe-settings.ts
new file mode 100644
index 0000000000..4dcf7640b7
--- /dev/null
+++ b/apps/web/lib/integrations/stripe/update-stripe-settings.ts
@@ -0,0 +1,46 @@
+"use server";
+
+import { authActionClient } from "@/lib/actions/safe-action";
+import { prisma } from "@dub/prisma";
+import { STRIPE_INTEGRATION_ID } from "@dub/utils";
+import { revalidatePath } from "next/cache";
+import * as z from "zod/v4";
+import { stripeIntegrationSettingsSchema } from "./schema";
+
+const schema = stripeIntegrationSettingsSchema.extend({
+ workspaceId: z.string(),
+});
+
+export const updateStripeSettingsAction = authActionClient
+ .inputSchema(schema)
+ .action(async ({ parsedInput, ctx }) => {
+ const { workspace } = ctx;
+ const { freeTrials } = parsedInput;
+
+ const installedIntegration = await prisma.installedIntegration.findFirst({
+ where: {
+ integrationId: STRIPE_INTEGRATION_ID,
+ projectId: workspace.id,
+ },
+ });
+
+ if (!installedIntegration) {
+ throw new Error("Stripe integration is not installed on your workspace.");
+ }
+
+ const current = (installedIntegration.settings as any) ?? {};
+
+ await prisma.installedIntegration.update({
+ where: {
+ id: installedIntegration.id,
+ },
+ data: {
+ settings: {
+ ...current,
+ freeTrials,
+ },
+ },
+ });
+
+ revalidatePath(`/${workspace.slug}/settings/integrations/stripe`);
+ });
diff --git a/apps/web/lib/zod/schemas/rewards.ts b/apps/web/lib/zod/schemas/rewards.ts
index 0b05de0cb2..6fe907412e 100644
--- a/apps/web/lib/zod/schemas/rewards.ts
+++ b/apps/web/lib/zod/schemas/rewards.ts
@@ -113,6 +113,10 @@ export const REWARD_CONDITIONS: Record<
id: "submitted",
label: "qualified lead",
},
+ {
+ id: "trial",
+ label: "free trial",
+ },
],
},
],
@@ -206,9 +210,6 @@ export const NUMBER_CONDITION_OPERATORS: (typeof CONDITION_OPERATORS)[number][]
"less_than_or_equal",
];
-export const SOURCE_CONDITION_OPERATORS: (typeof CONDITION_OPERATORS)[number][] =
- ["equals_to", "not_equals"];
-
export const CONDITION_OPERATOR_LABELS = {
equals_to: "is",
not_equals: "is not",
@@ -337,7 +338,7 @@ export const REWARD_EVENT_COLUMN_MAPPING = Object.freeze({
sale: "saleRewardId",
});
-export const CUSTOMER_SOURCES = ["tracked", "submitted"] as const;
+export const CUSTOMER_SOURCES = ["tracked", "submitted", "trial"] as const;
export const rewardContextSchema = z.object({
customer: z
diff --git a/apps/web/ui/partners/rewards/rewards-logic.tsx b/apps/web/ui/partners/rewards/rewards-logic.tsx
index 5a81648e3b..122ea85d43 100644
--- a/apps/web/ui/partners/rewards/rewards-logic.tsx
+++ b/apps/web/ui/partners/rewards/rewards-logic.tsx
@@ -11,7 +11,6 @@ import {
NUMBER_CONDITION_OPERATORS,
REWARD_CONDITIONS,
RewardConditionEntityAttribute,
- SOURCE_CONDITION_OPERATORS,
STRING_CONDITION_OPERATORS,
} from "@/lib/zod/schemas/rewards";
import { X } from "@/ui/shared/icons";
@@ -303,6 +302,31 @@ function ConditionLogic({
const [displayProductLabel, setDisplayProductLabel] = useState(false);
+ // Auto-set operator to "equals_to" for customer.source
+ const isCustomerSourceCondition =
+ condition.entity === "customer" && condition.attribute === "source";
+
+ useEffect(() => {
+ if (isCustomerSourceCondition && condition.operator !== "equals_to") {
+ setValue(
+ conditionKey,
+ {
+ ...condition,
+ operator: "equals_to",
+ },
+ {
+ shouldDirty: true,
+ },
+ );
+ }
+ }, [
+ isCustomerSourceCondition,
+ condition.operator,
+ condition,
+ conditionKey,
+ setValue,
+ ]);
+
return (
<div className="flex w-full flex-col">
<div className="flex items-center justify-between p-2.5">
@@ -369,53 +393,54 @@ function ConditionLogic({
}))}
/>
</InlineBadgePopover>{" "}
- <InlineBadgePopover
- text={
- condition.operator
- ? CONDITION_OPERATOR_LABELS[condition.operator]
- : "Condition"
- }
- invalid={!condition.operator}
- >
- <InlineBadgePopoverMenu
- selectedValue={condition.operator}
- onSelect={(value) =>
- setValue(
- conditionKey,
- {
- ...condition,
- operator:
- value as (typeof CONDITION_OPERATORS)[number],
- // Update value to array / string / number if needed
- ...(["in", "not_in"].includes(value)
- ? !Array.isArray(condition.value)
- ? { value: [] }
- : null
- : ["number", "currency"].includes(attributeType)
- ? typeof condition.value !== "number"
- ? { value: "" }
- : null
- : typeof condition.value !== "string"
- ? { value: "" }
- : null),
- },
- {
- shouldDirty: true,
- },
- )
+ {isCustomerSourceCondition ? (
+ <span className="text-content-emphasis font-medium">is </span>
+ ) : (
+ <InlineBadgePopover
+ text={
+ condition.operator
+ ? CONDITION_OPERATOR_LABELS[condition.operator]
+ : "Condition"
}
- items={(condition.entity === "customer" &&
- condition.attribute === "source"
- ? SOURCE_CONDITION_OPERATORS
- : ["number", "currency"].includes(attributeType)
+ invalid={!condition.operator}
+ >
+ <InlineBadgePopoverMenu
+ selectedValue={condition.operator}
+ onSelect={(value) =>
+ setValue(
+ conditionKey,
+ {
+ ...condition,
+ operator:
+ value as (typeof CONDITION_OPERATORS)[number],
+ // Update value to array / string / number if needed
+ ...(["in", "not_in"].includes(value)
+ ? !Array.isArray(condition.value)
+ ? { value: [] }
+ : null
+ : ["number", "currency"].includes(attributeType)
+ ? typeof condition.value !== "number"
+ ? { value: "" }
+ : null
+ : typeof condition.value !== "string"
+ ? { value: "" }
+ : null),
+ },
+ {
+ shouldDirty: true,
+ },
+ )
+ }
+ items={(["number", "currency"].includes(attributeType)
? NUMBER_CONDITION_OPERATORS
: STRING_CONDITION_OPERATORS
- ).map((operator) => ({
- text: CONDITION_OPERATOR_LABELS[operator],
- value: operator,
- }))}
- />
- </InlineBadgePopover>{" "}
+ ).map((operator) => ({
+ text: CONDITION_OPERATOR_LABELS[operator],
+ value: operator,
+ }))}
+ />
+ </InlineBadgePopover>
+ )}{" "}
{condition.operator && (
<>
<InlineBadgePopover
diff --git a/packages/email/src/templates/partner-application-approved.tsx b/packages/email/src/templates/partner-application-approved.tsx
index 2c6a017f64..de89eddb7d 100644
--- a/packages/email/src/templates/partner-application-approved.tsx
+++ b/packages/email/src/templates/partner-application-approved.tsx
@@ -28,8 +28,26 @@ export default function PartnerApplicationApproved({
payoutsEnabled: false,
},
- rewards = null,
- bounties = null,
+ rewards = [
+ {
+ icon: "https://assets.dub.co/email-assets/icons/invoice-dollar.png",
+ label: "Earn up to 65% per sale for 1 year",
+ },
+ {
+ icon: "https://assets.dub.co/email-assets/icons/gift.png",
+ label: "New users get 20% off for 3 months",
+ },
+ ],
+ bounties = [
+ {
+ icon: "https://assets.dub.co/email-assets/icons/heart.png",
+ label: "Create a YouTube video about Acme",
+ },
+ {
+ icon: "https://assets.dub.co/email-assets/icons/trophy.png",
+ label: "Earn $100 after generating $1,000 in revenue",
+ },
+ ],
}: {
program: {
name: string;
@@ -68,58 +86,53 @@ export default function PartnerApplicationApproved({
<Text className="text-sm leading-6 text-neutral-600">
Your application to join <strong>{program.name}'s</strong> partner
- program has been approved. You can now start promoting their
- products and earning commissions.
+ program has been approved. You can now promote their products and
+ earn commissions.
</Text>
{Boolean(rewards?.length || bounties?.length) && (
- <>
- <Text className="text-sm leading-6 text-neutral-600">
- You're immediately eligible for the following:
- </Text>
- <Section className="my-4 rounded-xl border border-solid border-neutral-200 bg-neutral-50 px-5 py-4">
- {rewards && Boolean(rewards.length) && (
- <>
- <Text className="my-0 text-base font-semibold text-black">
- Rewards
- </Text>
- {rewards.map((reward) => (
- <Row key={reward.label} className="mb-0 mt-2">
- <Column className="align-center">
- <Img src={reward.icon} height="16" alt="" />
- </Column>
- <Column className="w-full pl-2">
- <Text className="my-0 text-sm font-medium text-neutral-600">
- {reward.label}
- </Text>
- </Column>
- </Row>
- ))}
- </>
- )}
- {bounties && Boolean(bounties.length) && (
- <>
- <Text
- className={`mb-0 text-base font-semibold text-black ${rewards?.length ? "mt-5" : "mt-0"}`}
- >
- Bounties
- </Text>
- {bounties.map((bounty) => (
- <Row key={bounty.label} className="mb-0 mt-2">
- <Column className="align-center">
- <Img src={bounty.icon} height="16" alt="" />
- </Column>
- <Column className="w-full pl-2">
- <Text className="my-0 text-sm font-medium text-neutral-600">
- {bounty.label}
- </Text>
- </Column>
- </Row>
- ))}
- </>
- )}
- </Section>
- </>
+ <Section className="my-4 rounded-xl border border-solid border-neutral-200 bg-neutral-50 px-5 py-4">
+ {rewards && Boolean(rewards.length) && (
+ <>
+ <Text className="my-0 text-base font-semibold text-black">
+ Rewards
+ </Text>
+ {rewards.map((reward) => (
+ <Row key={reward.label} className="mb-0 mt-2">
+ <Column className="align-center">
+ <Img src={reward.icon} height="16" alt="" />
+ </Column>
+ <Column className="w-full pl-2">
+ <Text className="my-0 text-sm font-medium text-neutral-600">
+ {reward.label}
+ </Text>
+ </Column>
+ </Row>
+ ))}
+ </>
+ )}
+ {bounties && Boolean(bounties.length) && (
+ <>
+ <Text
+ className={`mb-0 text-base font-semibold text-black ${rewards?.length ? "mt-5" : "mt-0"}`}
+ >
+ Bounties
+ </Text>
+ {bounties.map((bounty) => (
+ <Row key={bounty.label} className="mb-0 mt-2">
+ <Column className="align-center">
+ <Img src={bounty.icon} height="16" alt="" />
+ </Column>
+ <Column className="w-full pl-2">
+ <Text className="my-0 text-sm font-medium text-neutral-600">
+ {bounty.label}
+ </Text>
+ </Column>
+ </Row>
+ ))}
+ </>
+ )}
+ </Section>
)}
<Hr className="my-6 border-neutral-200" />