-
Notifications
You must be signed in to change notification settings - Fork 3k
Free Trial #3644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Free Trial #3644
Changes from 40 commits
Commits
Show all changes
131 commits
Select commit
Hold shift + click to select a range
b9e6a40
initial free trial structure
pepeladeira 2fca55d
update trial limits
pepeladeira b445340
Merge branch 'main' into free-trial
pepeladeira 6e0fe71
trial layout improvements
pepeladeira 593ff86
feedback improvements
pepeladeira 7c825e1
cron trial emails
pepeladeira c0265fd
email flows tests
pepeladeira 4e9b097
Merge branch 'main' into free-trial
pepeladeira 9dde927
small tweaks
pepeladeira 3202ca2
advanced downgrade
pepeladeira 4c42633
hit trial limit modal
pepeladeira 7b46dec
Merge branch 'main' into free-trial
pepeladeira f832bec
subscriptionCancelAtPeriodEnd and planPeriod
pepeladeira 72bccff
plan-usage subscription canceled
pepeladeira f8eb8ee
Merge branch 'main' into free-trial
pepeladeira d718a93
billing trial playwright
pepeladeira bcb1ab1
playwright urls
pepeladeira 8a4d7e6
mock redirectToCheckout
pepeladeira d209ee0
Merge branch 'main' into free-trial
pepeladeira 1de7561
use serverless-redis-http for Upstash Redis in E2E
pepeladeira 457528e
Merge branch 'main' into free-trial
pepeladeira 715422d
fix build error
pepeladeira 6cead33
build errors
pepeladeira 6f7a3e7
fix broken tests
pepeladeira bc9b876
broken e2e tests
pepeladeira b9f02c7
fix broken tests
pepeladeira 650e671
Merge branch 'main' into free-trial
pepeladeira 24015e2
Merge branch 'main' into free-trial
pepeladeira 378791d
more billing e2e tests
pepeladeira 3961b7a
fix Stripe types, rename fields, add more PlanPeriod enums
steven-tey ea04070
Merge branch 'main' into free-trial
steven-tey 4f6b412
Update approve-partner-application-modal.tsx
steven-tey 96e65c3
move trial emails to folder
steven-tey 43dd9cf
limit → cap, kind → resource
steven-tey 7f3c6a5
Merge branch 'main' into free-trial
pepeladeira 52fc8c2
email cron improvements
pepeladeira c2cda11
stripe backfill script
pepeladeira 3ba1732
free trial behind feature-flag
pepeladeira cbd8820
Merge branch 'main' into free-trial
pepeladeira 2adcaf8
coderabbit improvements
pepeladeira 90b6c17
coderabbit improvements
pepeladeira d889114
codereview improvements
pepeladeira ccb74c6
codereview improvements
pepeladeira 87573f7
Merge branch 'main' into free-trial
pepeladeira fc633bf
Workspace onboarding updates
marcusljf eaccfca
Merge branch 'main' into free-trial
pepeladeira 4f347ec
remove free trial feature flag
pepeladeira 2d1ea5d
code improvements
pepeladeira 9eaa8d3
code improvements
pepeladeira 328b002
code improvements
pepeladeira 72a7bea
Merge branch 'main' into free-trial
pepeladeira 805b4c4
Merge branch 'main' into free-trial
pepeladeira e7af47e
Merge branch 'main' into free-trial
pepeladeira 4e07dda
code improvements
pepeladeira d75d29d
fix build error
pepeladeira 4e7b379
fix build error
pepeladeira cf38cb1
Merge branch 'main' into free-trial
steven-tey f75a33a
update onboarding copy
steven-tey 787e2c2
small touch-ups
steven-tey 4e29590
layout improvements
steven-tey 0a4f1a2
fix updateWorkspacePlan, rearrange AppSidebarNav
steven-tey d58ec63
Update product-selector.tsx
steven-tey e927340
dynamic NAV_GROUPS, fix ts error
steven-tey c85e7d5
add support for switching periods
steven-tey cb7e076
wouldLoseAdvancedFeatures
steven-tey f138943
losesPartnerAccess / losesAdvancedFeatures confirmation modals
steven-tey 3074a46
fix playwright, fix planPeriod
steven-tey 7d48d96
add Dub Partners onboarding tests, fix Go to Dub → View workspace
steven-tey 29c2312
fix playwright
steven-tey ec5c5d1
fix tests
steven-tey 681609e
Update onboarding-dub-partners.spec.ts
steven-tey 7f0e777
add useOnboardingTrialVariant + plausible tracking
steven-tey 050fb08
fix useOnboardingTrialVariant
steven-tey dce3f52
Update use-onboarding-trial-variant.ts
steven-tey e167f9e
fix playwright tests for Dub Partners onboarding
steven-tey 3719903
upgrade plausible
steven-tey 3d8e811
use custom properties for plausible tracking
steven-tey 5022c0d
move Started Onboarding tracking to NextButton
steven-tey 5880a76
use init.customProperties instead
steven-tey 01684fc
fix window build error
pepeladeira c9d878c
fix onboarding e2e tests
pepeladeira 44f6477
Merge branch 'main' into free-trial
pepeladeira 44aec60
Merge branch 'main' into free-trial
steven-tey 7974ee2
Update onboarding-dub-partners.spec.ts
steven-tey b1bfe3b
Merge branch 'main' into free-trial
steven-tey 21c3072
fix flaky tests
pepeladeira bb01fd0
Merge branch 'main' into free-trial
pepeladeira d389ee2
fix flaky dub links tests
pepeladeira 59422fa
change trial test cta expect
pepeladeira 5d17f94
add data-testid
pepeladeira ac9eded
Merge branch 'main' into free-trial
steven-tey 187bd22
remove planTier for now
steven-tey ecb51b4
fix CTA text
steven-tey ab43f00
update TRIAL_LIMITS
steven-tey 4aedf70
Update trial-limits.ts
steven-tey 4ff339a
Merge branch 'main' into free-trial
steven-tey cebc741
improve throwIfTrialProgramEnrollmentLimitExceeded
steven-tey 9234bfb
track program creation event
steven-tey b058d62
Merge branch 'main' into free-trial
steven-tey 18d05de
Update start-paid-plan-modal.tsx
steven-tey d0cf683
Merge branch 'main' into free-trial
steven-tey 5aa9603
fix trial emails – send TrialStartedEmail right away, send UpgradeEma…
steven-tey 7c060e3
fix email tests
steven-tey 949fb7c
simplify emails
steven-tey 4843873
fix tests
steven-tey 4dba3df
more changes
steven-tey c8071c8
Update create-program.ts
steven-tey 3dbf0a4
Merge branch 'main' into free-trial
steven-tey 1f2dd3c
update email flows
steven-tey 3fe6e6e
stash
steven-tey ec95387
Merge branch 'main' into free-trial
steven-tey b1eb50e
simplify Dub trial email
steven-tey 28cbfd2
Update checkout-session-completed.ts
steven-tey a57f790
address coderabbit feedback
steven-tey 71d6e00
address more coderabbit feedback
steven-tey 50c00a1
Update accept-program-invite.ts
steven-tey 3c39ac1
improve emails
steven-tey 54d53e8
update billingCycleEndsAt
steven-tey 0a37f61
final fixes
steven-tey 481e454
refactor email types: consolidate TrialMarketingEmailProps into a sin…
devkiran fa15c8f
Merge branch 'main' into free-trial
steven-tey 49793e6
add claim .dub.link subdomain feature
steven-tey 7369ccd
free-trial help article
steven-tey 962c090
simplify UpgradeEmail
steven-tey fe14cb2
improve stripe checkout portal, fix trial cancellation flow
steven-tey 7426993
avoid duplicate banner
steven-tey a85712c
remove payment_method_options
steven-tey 5c86262
fix updateWorkspacePlan
steven-tey 75de775
improve cancellation UX
steven-tey 56a4418
improve resubscribe UX
steven-tey 47ae6bf
revert to use current_period_end
steven-tey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import { qstash } from "@/lib/cron"; | ||
| import { withCron } from "@/lib/cron/with-cron"; | ||
| import { runTrialEmailCron } from "@/lib/email/run-trial-email-cron"; | ||
| import { prisma } from "@dub/prisma"; | ||
| import { APP_DOMAIN_WITH_NGROK } from "@dub/utils"; | ||
| import * as z from "zod/v4"; | ||
| import { logAndRespond } from "../utils"; | ||
|
|
||
| export const dynamic = "force-dynamic"; | ||
|
|
||
| const QSTASH_CONTINUATION_DELAY_SECONDS = 2; | ||
|
|
||
| const postBodySchema = z.object({ | ||
| startingAfter: z.string(), | ||
| }); | ||
|
|
||
| /** | ||
| * Sends the paid-plan trial marketing sequence (see `lib/email/trial-email-schedule.ts`). | ||
| * Runs on a schedule (cron). Eligibility is `trialEndsAt` in the future + `SentEmail` dedupe. | ||
| * | ||
| * Complements the generic welcome email (`/api/cron/welcome-user`): free-only signups get welcome only; | ||
| * users who start a trial get welcome (QStash) + these emails when due. | ||
| */ | ||
|
|
||
| async function executeTrialEmailCronPage(startingAfter?: string) { | ||
| const now = new Date(); | ||
| const result = await runTrialEmailCron({ | ||
| now, | ||
| prisma, | ||
| startingAfter, | ||
| }); | ||
|
|
||
| if (result.workspaceCount === 0) { | ||
| if (startingAfter) { | ||
| return logAndRespond( | ||
| "Trial email cron: no workspaces on continuation page (done).", | ||
| ); | ||
| } | ||
|
|
||
| return logAndRespond("No workspaces in active trial. Skipping."); | ||
| } | ||
|
|
||
| if (result.hasMore && result.nextStartingAfter) { | ||
| await qstash.publishJSON({ | ||
| url: `${APP_DOMAIN_WITH_NGROK}/api/cron/trial-emails`, | ||
| method: "POST", | ||
| delay: QSTASH_CONTINUATION_DELAY_SECONDS, | ||
| body: { | ||
| startingAfter: result.nextStartingAfter, | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| return logAndRespond( | ||
| `Trial email cron: sent ${result.sentCount} email(s) for ${result.workspaceCount} workspace(s)${result.hasMore ? "; next page enqueued." : "."}`, | ||
| ); | ||
| } | ||
|
|
||
| // GET /api/cron/trial-emails | ||
| export const GET = withCron(async () => executeTrialEmailCronPage(undefined)); | ||
|
|
||
| // POST /api/cron/trial-emails (QStash continuation) | ||
| export const POST = withCron(async ({ rawBody }) => { | ||
| const { startingAfter } = postBodySchema.parse(JSON.parse(rawBody)); | ||
| return await executeTrialEmailCronPage(startingAfter); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.