Skip to content

πŸ“ˆ Open source, privacy-first web analytics β€” a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Add trial-ending sequence to improve conversion rate

Blue Mouse7bd992bfcc6d
diff --git a/backend/apps/cloud/src/common/templates/en/customer_sign-up.html b/backend/apps/cloud/src/common/templates/en/customer_sign-up.html
index c57d4aa8d..3a914c22a 100644
--- a/backend/apps/cloud/src/common/templates/en/customer_sign-up.html
+++ b/backend/apps/cloud/src/common/templates/en/customer_sign-up.html
@@ -11,7 +11,9 @@ details. You won't be charged today. Here's what happens next:<br />
charge today.
</li>
<li><b>Days 1-14</b>: Use all Swetrix Cloud features.</li>
- <li><b>Day 12</b>: We'll remind you before the trial ends.</li>
+ <li><b>Day 3</b>: We'll point you to the first traffic patterns to check.</li>
+ <li><b>Day 7</b>: We'll show you useful features, including GA4 import.</li>
+ <li><b>Days 11 and 13</b>: We'll remind you before billing starts.</li>
<li>
<b>Day 14</b>: Your subscription starts automatically unless you cancel
first.
diff --git a/backend/apps/cloud/src/common/templates/en/subscribe-reminder.html b/backend/apps/cloud/src/common/templates/en/subscribe-reminder.html
index 7eededcba..0cf096303 100644
--- a/backend/apps/cloud/src/common/templates/en/subscribe-reminder.html
+++ b/backend/apps/cloud/src/common/templates/en/subscribe-reminder.html
@@ -2,8 +2,9 @@ Hi,<br /><br />
You created a Swetrix project, but your free trial hasn't started yet.<br /><br />
-The trial lasts 14 days, requires no credit card, and gives your account access
-to all Swetrix Cloud features.<br /><br />
+The trial lasts 14 days, starts after you choose a plan and add payment details,
+and gives your account access to all Swetrix Cloud features. You won't be
+charged today.<br /><br />
<a href="{{subscribeUrl}}" target="_blank">Start free trial</a><br /><br />
diff --git a/backend/apps/cloud/src/common/templates/en/trial-ending-cancelled.html b/backend/apps/cloud/src/common/templates/en/trial-ending-cancelled.html
index ee868cef5..23b565d12 100644
--- a/backend/apps/cloud/src/common/templates/en/trial-ending-cancelled.html
+++ b/backend/apps/cloud/src/common/templates/en/trial-ending-cancelled.html
@@ -1,15 +1,15 @@
Hi,<br /><br />
-Your Swetrix trial ends in about 48 hours. Since you cancelled, your
-subscription will not start automatically.<br /><br />
+Your Swetrix trial access ends tomorrow. Since you cancelled, your subscription
+will not start automatically.<br /><br />
When the trial ends, your dashboard will be locked. Your projects and data will
be kept, but you won't be able to view analytics until you subscribe to a
plan.<br /><br />
-If you've changed your mind, you can
-<a href="{{url}}" target="_blank">subscribe from your billing page</a> before
-the trial ends to keep access.<br /><br />
+If Swetrix is proving useful, you can
+<a href="{{billingUrl}}" target="_blank">review billing</a> before the trial
+ends to keep access.<br /><br />
Questions? Reply to this email and we'll help.<br /><br />
diff --git a/backend/apps/cloud/src/common/templates/en/trial-ends-in-3-days-cancelled.html b/backend/apps/cloud/src/common/templates/en/trial-ends-in-3-days-cancelled.html
new file mode 100644
index 000000000..1eedb2410
--- /dev/null
+++ b/backend/apps/cloud/src/common/templates/en/trial-ends-in-3-days-cancelled.html
@@ -0,0 +1,17 @@
+Hi,<br /><br />
+
+Your Swetrix trial access ends in 3 days. Since you cancelled, your subscription
+will not start automatically.<br /><br />
+
+Your projects and data will be kept, but dashboards lock when the trial ends
+unless there is an active plan.<br /><br />
+
+If Swetrix is proving useful, you can review billing before access ends.<br /><br />
+
+<a href="{{billingUrl}}" target="_blank">Review billing</a><br />
+<a href="{{dashboardUrl}}" target="_blank">Open dashboard</a><br /><br />
+
+Questions? Reply to this email and we'll help.<br /><br />
+
+Andrii Romasiun<br />
+Founder, Swetrix
diff --git a/backend/apps/cloud/src/common/templates/en/trial-ends-in-3-days.html b/backend/apps/cloud/src/common/templates/en/trial-ends-in-3-days.html
new file mode 100644
index 000000000..f78da869e
--- /dev/null
+++ b/backend/apps/cloud/src/common/templates/en/trial-ends-in-3-days.html
@@ -0,0 +1,17 @@
+Hi,<br /><br />
+
+Your Swetrix trial ends in 3 days.<br /><br />
+
+This is a good time to review the projects, traffic volume, and plan you picked.
+If everything looks right, no action is needed: your subscription starts when
+the trial ends and dashboards keep running.<br /><br />
+
+If you want to change course, you can manage billing before the trial ends.<br /><br />
+
+<a href="{{billingUrl}}" target="_blank">Review billing</a><br />
+<a href="{{dashboardUrl}}" target="_blank">Open dashboard</a><br /><br />
+
+Questions about the plan or usage? Reply to this email and we'll help.<br /><br />
+
+Andrii Romasiun<br />
+Founder, Swetrix
diff --git a/backend/apps/cloud/src/common/templates/en/trial-ends-tomorrow.html b/backend/apps/cloud/src/common/templates/en/trial-ends-tomorrow.html
index f103ce1e5..17d57eee0 100644
--- a/backend/apps/cloud/src/common/templates/en/trial-ends-tomorrow.html
+++ b/backend/apps/cloud/src/common/templates/en/trial-ends-tomorrow.html
@@ -1,13 +1,13 @@
Hi,<br /><br />
-Your free Swetrix trial ends in about 48 hours.<br /><br />
+Your Swetrix trial ends tomorrow.<br /><br />
-If you want to keep using Swetrix, no action is needed. Your subscription will
-start automatically when the trial ends, and analytics access will continue.<br /><br />
+If you want to keep using Swetrix, no action is needed. Your subscription starts
+when the trial ends, and analytics access continues without interruption.<br /><br />
-If you don't want to continue, you can
-<a href="{{url}}" target="_blank">cancel from your billing page</a> before the
-trial ends and you won't be charged.<br /><br />
+If you do not want to continue, you can
+<a href="{{billingUrl}}" target="_blank">cancel from your billing page</a>
+before the trial ends.<br /><br />
Questions about your plan or billing? Reply to this email and we'll help.<br /><br />
diff --git a/backend/apps/cloud/src/common/templates/en/trial-feature-highlight.html b/backend/apps/cloud/src/common/templates/en/trial-feature-highlight.html
new file mode 100644
index 000000000..61dbb930c
--- /dev/null
+++ b/backend/apps/cloud/src/common/templates/en/trial-feature-highlight.html
@@ -0,0 +1,19 @@
+Hi,<br /><br />
+
+A week into the trial is a good time to add historical context.<br /><br />
+
+If you are moving from Google Analytics, Swetrix can import GA4 history into a
+project. That lets you keep older reports available while new traffic is
+measured with cookieless Swetrix analytics.<br /><br />
+
+This is also a useful point to try goals, funnels, alerts, and error tracking on
+the same project so the dashboard reflects real decisions, not just page
+views.<br /><br />
+
+<a href="{{dataImportDocsUrl}}" target="_blank">Read data import docs</a><br />
+<a href="{{dashboardUrl}}" target="_blank">Open dashboard</a><br /><br />
+
+Questions? Reply to this email and we'll help.<br /><br />
+
+Andrii Romasiun<br />
+Founder, Swetrix
diff --git a/backend/apps/cloud/src/common/templates/en/trial-value-check-in.html b/backend/apps/cloud/src/common/templates/en/trial-value-check-in.html
new file mode 100644
index 000000000..d5205c5b5
--- /dev/null
+++ b/backend/apps/cloud/src/common/templates/en/trial-value-check-in.html
@@ -0,0 +1,22 @@
+Hi,<br /><br />
+
+Three days in, Swetrix should start showing the first useful patterns from your
+site.<br /><br />
+
+Good checks for today:<br />
+<ul>
+ <li>Which pages bring visitors in?</li>
+ <li>Which sources and countries are already visible?</li>
+ <li>Are errors or slow pages shaping the experience?</li>
+</ul>
+
+If a project still has no events, it is usually an install or domain mismatch.
+The setup guide covers the quick checks.<br /><br />
+
+<a href="{{dashboardUrl}}" target="_blank">Open dashboard</a><br />
+<a href="{{setupGuideUrl}}" target="_blank">Check setup guide</a><br /><br />
+
+Questions? Reply to this email and we'll help.<br /><br />
+
+Andrii Romasiun<br />
+Founder, Swetrix
diff --git a/backend/apps/cloud/src/common/templates/en/trial-welcome.html b/backend/apps/cloud/src/common/templates/en/trial-welcome.html
new file mode 100644
index 000000000..d6dd59e88
--- /dev/null
+++ b/backend/apps/cloud/src/common/templates/en/trial-welcome.html
@@ -0,0 +1,20 @@
+Hi,<br /><br />
+
+Your 14-day Swetrix trial is active. The useful part starts now: connect one
+real project, confirm events are arriving, and keep the dashboard nearby while
+traffic comes in.<br /><br />
+
+During the trial you can use Swetrix Cloud features across analytics, custom
+events, goals, funnels, error tracking, performance metrics, alerts, and data
+import.<br /><br />
+
+Best first step: install the tracking snippet on one live site and check that
+events arrive today.<br /><br />
+
+<a href="{{dashboardUrl}}" target="_blank">Open dashboard</a><br />
+<a href="{{setupGuideUrl}}" target="_blank">Open setup guide</a><br /><br />
+
+Questions? Reply to this email and we'll help.<br /><br />
+
+Andrii Romasiun<br />
+Founder, Swetrix
diff --git a/backend/apps/cloud/src/mailer/letter.ts b/backend/apps/cloud/src/mailer/letter.ts
index ce1e69f42..75e4db6c3 100644
--- a/backend/apps/cloud/src/mailer/letter.ts
+++ b/backend/apps/cloud/src/mailer/letter.ts
@@ -10,6 +10,11 @@ export enum LetterTemplate {
ProjectInvitation = 'customer_project-invitation',
TwoFAOn = '2fa-turned-on',
TwoFAOff = '2fa-turned-off',
+ TrialWelcome = 'trial-welcome',
+ TrialValueCheckIn = 'trial-value-check-in',
+ TrialFeatureHighlight = 'trial-feature-highlight',
+ TrialEndsIn3Days = 'trial-ends-in-3-days',
+ TrialEndsIn3DaysCancelled = 'trial-ends-in-3-days-cancelled',
TrialExpired = 'trial-expired',
TrialEndsTomorrow = 'trial-ends-tomorrow',
TrialEndingCancelled = 'trial-ending-cancelled',
diff --git a/backend/apps/cloud/src/mailer/mailer.service.ts b/backend/apps/cloud/src/mailer/mailer.service.ts
index 6f1b53c98..8f1114586 100644
--- a/backend/apps/cloud/src/mailer/mailer.service.ts
+++ b/backend/apps/cloud/src/mailer/mailer.service.ts
@@ -81,6 +81,31 @@ const metaInfoJson = {
en: () => '2FA has been disabled on your Swetrix account',
},
},
+ [LetterTemplate.TrialWelcome]: {
+ subject: {
+ en: () => 'Your Swetrix trial is active',
+ },
+ },
+ [LetterTemplate.TrialValueCheckIn]: {
+ subject: {
+ en: () => 'Three checks for your Swetrix trial',
+ },
+ },
+ [LetterTemplate.TrialFeatureHighlight]: {
+ subject: {
+ en: () => 'Bring your GA4 history into Swetrix',
+ },
+ },
+ [LetterTemplate.TrialEndsIn3Days]: {
+ subject: {
+ en: () => 'Your Swetrix trial ends in 3 days',
+ },
+ },
+ [LetterTemplate.TrialEndsIn3DaysCancelled]: {
+ subject: {
+ en: () => 'Your Swetrix trial access ends in 3 days',
+ },
+ },
[LetterTemplate.TrialExpired]: {
subject: {
en: () => 'Your free Swetrix trial has ended',
@@ -88,12 +113,12 @@ const metaInfoJson = {
},
[LetterTemplate.TrialEndsTomorrow]: {
subject: {
- en: () => 'Your Swetrix trial ends in 48 hours',
+ en: () => 'Your Swetrix trial ends tomorrow',
},
},
[LetterTemplate.TrialEndingCancelled]: {
subject: {
- en: () => 'Your Swetrix trial ends in 48 hours β€” action needed',
+ en: () => 'Your Swetrix trial access ends tomorrow',
},
},
[LetterTemplate.ProjectSubscriberInvitation]: {
diff --git a/backend/apps/cloud/src/task-manager/task-manager.service.ts b/backend/apps/cloud/src/task-manager/task-manager.service.ts
index 38d633695..d82b16421 100644
--- a/backend/apps/cloud/src/task-manager/task-manager.service.ts
+++ b/backend/apps/cloud/src/task-manager/task-manager.service.ts
@@ -1,6 +1,15 @@
import { Injectable } from '@nestjs/common'
import { Cron, CronExpression } from '@nestjs/schedule'
-import { IsNull, LessThan, Not, Between } from 'typeorm'
+import {
+ And,
+ Between,
+ In,
+ IsNull,
+ LessThan,
+ LessThanOrEqual,
+ MoreThan,
+ Not,
+} from 'typeorm'
import { ConfigService } from '@nestjs/config'
import dayjs from 'dayjs'
import utc from 'dayjs/plugin/utc'
@@ -119,10 +128,67 @@ const CHUNK_SIZE = 5000
const REPORTS_USERS_CONCURRENCY = 3
const REPORTS_PROJECTS_CONCURRENCY = 5
const NO_EVENTS_REMINDER_DELAY_DAYS = 2
+const TRIAL_LIFECYCLE_EMAIL_URLS = {
+ dashboardUrl: 'https://swetrix.com/dashboard',
+ billingUrl: 'https://swetrix.com/user-settings?tab=billing',
+ setupGuideUrl: 'https://swetrix.com/docs',
+ dataImportDocsUrl: 'https://swetrix.com/docs/data-import',
+}
const CAPTCHA_PASS_CONDITION =
"type = 'captcha' AND if(indexOf(`meta.key`, 'captcha_event') = 0, 'pass', arrayElement(`meta.value`, indexOf(`meta.key`, 'captcha_event'))) = 'pass'"
const TELEGRAM_MARKDOWN_URL_KEYS = new Set(['dashboard_url', 'errors_url'])
+enum TrialLifecycleEmailKey {
+ Welcome = 'welcome',
+ ValueCheckIn = 'value_check_in',
+ FeatureHighlight = 'feature_highlight',
+ EndsIn3Days = 'ends_in_3_days',
+ EndsTomorrow = 'ends_tomorrow',
+}
+
+interface TrialLifecycleEmailStep {
+ key: TrialLifecycleEmailKey
+ afterDays: number
+ nextAfterDays: number
+ template: LetterTemplate
+ cancelledTemplate?: LetterTemplate
+}
+
+const TRIAL_LIFECYCLE_EMAIL_STEPS: TrialLifecycleEmailStep[] = [
+ {
+ key: TrialLifecycleEmailKey.Welcome,
+ afterDays: 0,
+ nextAfterDays: 3,
+ template: LetterTemplate.TrialWelcome,
+ },
+ {
+ key: TrialLifecycleEmailKey.ValueCheckIn,
+ afterDays: 3,
+ nextAfterDays: 7,
+ template: LetterTemplate.TrialValueCheckIn,
+ },
+ {
+ key: TrialLifecycleEmailKey.FeatureHighlight,
+ afterDays: 7,
+ nextAfterDays: 11,
+ template: LetterTemplate.TrialFeatureHighlight,
+ },
+ {
+ key: TrialLifecycleEmailKey.EndsIn3Days,
+ afterDays: 11,
+ nextAfterDays: 13,
+ template: LetterTemplate.TrialEndsIn3Days,
+ cancelledTemplate: LetterTemplate.TrialEndsIn3DaysCancelled,
+ },
+ {
+ key: TrialLifecycleEmailKey.EndsTomorrow,
+ afterDays: 13,
+ nextAfterDays: TRIAL_DURATION,
+ template: LetterTemplate.TrialEndsTomorrow,
+ cancelledTemplate: LetterTemplate.TrialEndingCancelled,
+ },
+]
+
const mapLimit = async <T, R>(
items: T[],
limit: number,
@@ -1508,36 +1574,85 @@ export class TaskManagerService {
@Cron(CronExpression.EVERY_4_HOURS)
async trialReminder() {
+ const now = dayjs.utc()
+ const promises = _map(TRIAL_LIFECYCLE_EMAIL_STEPS, (step) =>
+ this.sendTrialLifecycleEmails(step, now),
+ )
+
+ const results = await Promise.allSettled(promises)
+
+ results.forEach((result) => {
+ if (result.status === 'rejected') {
+ this.logger.error(
+ `[CRON WORKER](trialReminder) Error occured: ${result.reason}`,
+ )
+ }
+ })
+ }
+
+ private async sendTrialLifecycleEmails(
+ step: TrialLifecycleEmailStep,
+ now: dayjs.Dayjs,
+ ) {
+ const lowerDaysBeforeEnd = TRIAL_DURATION - step.nextAfterDays
+ const upperDaysBeforeEnd = TRIAL_DURATION - step.afterDays
+ const lower = now.add(lowerDaysBeforeEnd, 'day')
+ const upper = now.add(upperDaysBeforeEnd, 'day')
+
const users = await this.userService.find({
where: {
- planCode: Not(PlanCode.none),
- trialEndDate: Between(
- new Date(),
- new Date(new Date().getTime() + 48 * 60 * 60 * 1000),
+ planCode: Not(In([PlanCode.none, PlanCode.free, PlanCode.trial])),
+ trialEndDate: And(
+ MoreThan(lower.toDate()),
+ LessThanOrEqual(upper.toDate()),
),
- trialReminderSent: false,
},
- select: ['id', 'email', 'cancellationEffectiveDate'],
+ select: [
+ 'id',
+ 'email',
+ 'cancellationEffectiveDate',
+ 'trialLifecycleEmailsSent',
+ ],
})
const promises = _map(users, async (user) => {
const { id, email, cancellationEffectiveDate } = user
+ const sent = user.trialLifecycleEmailsSent || {}
+
+ if (sent[step.key]) {
+ return
+ }
await this.userService.update(id, {
- trialReminderSent: true,
+ trialLifecycleEmailsSent: {
+ ...sent,
+ [step.key]: now.toISOString(),
+ },
+ ...(step.key === TrialLifecycleEmailKey.EndsTomorrow
+ ? { trialReminderSent: true }
+ : {}),
})
- const template = cancellationEffectiveDate
- ? LetterTemplate.TrialEndingCancelled
- : LetterTemplate.TrialEndsTomorrow
+ const template =
+ cancellationEffectiveDate && step.cancelledTemplate
+ ? step.cancelledTemplate
+ : step.template
- await this.mailerService.sendEmail(email, template, {
- url: 'https://swetrix.com/user-settings?tab=billing',
- })
+ await this.mailerService.sendEmail(
+ email,
+ template,
+ TRIAL_LIFECYCLE_EMAIL_URLS,
+ )
})
- await Promise.allSettled(promises).catch((reason) => {
- this.logger.error(`[CRON WORKER](trialReminder) Error occured: ${reason}`)
+ const results = await Promise.allSettled(promises)
+
+ results.forEach((result) => {
+ if (result.status === 'rejected') {
+ this.logger.error(
+ `[CRON WORKER](trialReminder:${step.key}) Error occured: ${result.reason}`,
+ )
+ }
})
}
diff --git a/backend/apps/cloud/src/user/entities/user.entity.ts b/backend/apps/cloud/src/user/entities/user.entity.ts
index 603357d4c..cf028d7a5 100644
--- a/backend/apps/cloud/src/user/entities/user.entity.ts
+++ b/backend/apps/cloud/src/user/entities/user.entity.ts
@@ -715,6 +715,9 @@ export class User {
@Column({ default: false })
trialReminderSent: boolean
+ @Column({ type: 'json', nullable: true })
+ trialLifecycleEmailsSent: Record<string, string> | null
+
@Column({ default: false })
showLiveVisitorsInTitle: boolean
diff --git a/backend/migrations/mysql/2026_06_17_trial_lifecycle_emails.sql b/backend/migrations/mysql/2026_06_17_trial_lifecycle_emails.sql
new file mode 100644
index 000000000..de742d781
--- /dev/null
+++ b/backend/migrations/mysql/2026_06_17_trial_lifecycle_emails.sql
@@ -0,0 +1,2 @@
+ALTER TABLE `user`
+ ADD COLUMN `trialLifecycleEmailsSent` json DEFAULT NULL AFTER `trialReminderSent`;
diff --git a/web/app/components/Header/banners.tsx b/web/app/components/Header/banners.tsx
index afc49a4bc..89f9e6d14 100644
--- a/web/app/components/Header/banners.tsx
+++ b/web/app/components/Header/banners.tsx
@@ -2,7 +2,6 @@ import { useEffect, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Link } from '~/ui/Link'
import dayjs from 'dayjs'
-import duration from 'dayjs/plugin/duration'
import utc from 'dayjs/plugin/utc'
import { SHOW_BANNER_AT_PERC, isSelfhosted, API_URL } from '~/lib/constants'
@@ -13,14 +12,6 @@ import { shouldShowLowEventsBanner } from '~/utils/auth'
import { DashboardBlockReason } from '~/lib/models/User'
dayjs.extend(utc)
-dayjs.extend(duration)
-
-const TRIAL_STATUS_MAPPING = {
- ENDED: 1,
- ENDS_TODAY: 2,
- ENDS_TOMORROW: 3,
- ENDS_IN_X_DAYS: 4,
-}
const EventsRunningOutBanner = () => {
const { t } = useTranslation('common')
@@ -58,27 +49,20 @@ const EventsRunningOutBanner = () => {
)
}
-interface TrialBannerProps {
- status: string | null
- rawStatus: number | null
-}
-
-const TrialBanner = ({ status, rawStatus }: TrialBannerProps) => {
+const TrialBanner = () => {
const { t } = useTranslation('common')
return (
<div className='header-banner w-full bg-slate-900 text-gray-100 dark:bg-slate-900/70'>
<div className='mx-auto max-w-7xl px-4 py-2 text-center text-sm sm:px-6 lg:px-8'>
- <span className='font-medium'>{status}</span>
+ <span className='font-medium'>
+ {t('header.trialBanner.endedTitle')}
+ </span>
<span className='mx-1.5'>β€”</span>
<Link to={routes.billing} className='font-semibold underline'>
- {t('header.trialBanner.pickAPlan')}
+ {t('header.trialBanner.reviewBilling')}
</Link>
- <span className='ml-1.5'>
- {rawStatus === TRIAL_STATUS_MAPPING.ENDED
- ? t('header.trialBanner.keepUsingEnded')
- : t('header.trialBanner.keepUsing')}
- </span>
+ <span className='ml-1.5'>{t('header.trialBanner.endedBody')}</span>
</div>
</div>
)
@@ -161,7 +145,6 @@ const SelfhostedCantReachAPIBanner = () => {
}
export const BannerManager = () => {
- const { t } = useTranslation('common')
const { user, isAuthenticated, totalMonthlyEvents } = useAuth()
const [
showSelfhostedCantReachAPIBanner,
@@ -183,61 +166,15 @@ export const BannerManager = () => {
checkApiUrl()
}, [])
- const [rawStatus, status] = useMemo(() => {
- const { trialEndDate } = user || {}
-
- if (!trialEndDate) {
- return [null, null]
- }
-
- const now = dayjs.utc()
- const future = dayjs.utc(trialEndDate)
- const diff = future.diff(now)
-
- if (diff < 0) {
- // trial has already ended
- return [TRIAL_STATUS_MAPPING.ENDED, t('header.trialBanner.ended')]
- }
-
- if (diff < dayjs.duration(1, 'day').asMilliseconds()) {
- // trial ends today or tomorrow
- const isToday = future.isSame(now, 'day')
- const isTomorrow = future.isSame(now.add(1, 'day'), 'day')
-
- if (isToday) {
- return [
- TRIAL_STATUS_MAPPING.ENDS_TODAY,
- t('header.trialBanner.endsToday'),
- ]
- }
- if (isTomorrow) {
- return [
- TRIAL_STATUS_MAPPING.ENDS_TOMORROW,
- t('header.trialBanner.endsTomorrow'),
- ]
- }
- }
-
- // trial ends in more than 1 day
- const amount = Math.round(dayjs.duration(diff).asDays())
- return [
- TRIAL_STATUS_MAPPING.ENDS_IN_X_DAYS,
- t('header.trialBanner.youHaveXDaysLeft', { amount }),
- ]
- }, [user, t])
-
- const trialBannerHidden = useMemo(() => {
- return (
- !status || isSelfhosted || !isAuthenticated || user?.planCode !== 'trial'
- )
- }, [status, isAuthenticated, user?.planCode])
-
const isExpiredTrialWithoutSubscription = useMemo(() => {
+ const trialEnded =
+ !!user?.trialEndDate && dayjs.utc(user.trialEndDate).isBefore(dayjs.utc())
+
return (
user?.dashboardBlockReason ===
DashboardBlockReason.subscription_cancelled &&
user?.planCode === 'none' &&
- !!user?.trialEndDate &&
+ trialEnded &&
!user?.subID
)
}, [
@@ -265,8 +202,8 @@ export const BannerManager = () => {
return <SelfhostedCantReachAPIBanner />
}
- if (!trialBannerHidden || (isExpiredTrialWithoutSubscription && status)) {
- return <TrialBanner status={status} rawStatus={rawStatus} />
+ if (!isSelfhosted && isAuthenticated && isExpiredTrialWithoutSubscription) {
+ return <TrialBanner />
}
if (user?.dashboardBlockReason) {
diff --git a/web/app/routes/_index.tsx b/web/app/routes/_index.tsx
index 89b972bb7..50771b512 100644
--- a/web/app/routes/_index.tsx
+++ b/web/app/routes/_index.tsx
@@ -36,7 +36,6 @@ import {
localisePath,
} from '~/lib/constants'
import { DEFAULT_METAINFO, Metainfo } from '~/lib/models/Metainfo'
-import { Stats } from '~/lib/models/Stats'
import { useTheme } from '~/providers/ThemeProvider'
import { cn } from '~/utils/generic'
import routesPath from '~/utils/routes'