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!

Checkout redirects

Blue Mouse8f9ebd54bc6c
diff --git a/web/app/routes/dashboard.tsx b/web/app/routes/dashboard.tsx
index d41f4c47e..8764222ea 100644
--- a/web/app/routes/dashboard.tsx
+++ b/web/app/routes/dashboard.tsx
@@ -8,6 +8,7 @@ import { data, redirect } from 'react-router'
import type { SitemapFunction } from 'remix-sitemap'
import { getAuthenticatedUser, serverFetch } from '~/api/api.server'
+import { isSelfhosted } from '~/lib/constants'
import { Project } from '~/lib/models/Project'
import Dashboard from '~/pages/Dashboard'
import { getDescription, getPreviewImage, getTitle } from '~/utils/seo'
@@ -207,6 +208,20 @@ export async function loader({ request }: LoaderFunctionArgs) {
return redirect('/onboarding')
}
+ // If user is not subscribed (trial or real sub), and they're not past subscription (none tier, but have blocked dashboard), redirect to checkout
+ if (
+ !isSelfhosted &&
+ user?.planCode === 'none' &&
+ !user?.dashboardBlockReason
+ ) {
+ if (authCookies.length > 0) {
+ return redirect('/checkout', {
+ headers: createHeadersWithCookies(authCookies),
+ })
+ }
+ return redirect('/checkout')
+ }
+
const url = new URL(request.url)
const page = parseInt(url.searchParams.get('page') || '1', 10)
const pageSize = parseInt(url.searchParams.get('pageSize') || '12', 10)
diff --git a/web/app/routes/onboarding.tsx b/web/app/routes/onboarding.tsx
index 4ccd66956..319222a82 100644
--- a/web/app/routes/onboarding.tsx
+++ b/web/app/routes/onboarding.tsx
@@ -74,17 +74,6 @@ export async function loader({ request }: LoaderFunctionArgs) {
const allCookies = [...cookies, ...metainfoResult.cookies]
if (user?.user?.hasCompletedOnboarding) {
- // Redirect to checkout if user hasn't subscribed yet
- const userPlanCode = user.user.planCode
- if (!isSelfhosted && (!userPlanCode || userPlanCode === 'none')) {
- if (allCookies.length > 0) {
- return redirect('/checkout', {
- headers: createHeadersWithCookies(allCookies),
- })
- }
- return redirect('/checkout')
- }
-
if (allCookies.length > 0) {
return redirect('/dashboard', {
headers: createHeadersWithCookies(allCookies),