From f046a3df911348a197725f4a42ee1a637670aa9a Mon Sep 17 00:00:00 2001
From: "wizard-ci-bot[bot]"
<254716194+wizard-ci-bot[bot]@users.noreply.github.com>
Date: Wed, 23 Sep 2026 22:23:00 +0000
Subject: [PATCH 1/3] wizard-ci: react-router/saas-template (1/3)
---
.../react-router/saas-template/.env.example | 4 ++
.../react-router/saas-template/.gitignore | 1 +
.../saas-template/app/entry.client.tsx | 43 ++++++++++++++++++-
.../saas-template/app/entry.server.tsx | 3 ++
...l-or-modify-subscription-modal-content.tsx | 12 +++++-
.../create-subscription-modal-content.tsx | 12 +++++-
.../create-organization-form-card.tsx | 15 ++++++-
.../organizations/layout/nav-user.tsx | 9 +++-
.../settings/general/danger-zone.tsx | 8 +++-
.../general/general-organization-settings.tsx | 9 ++--
.../team-members/invite-by-email-card.tsx | 8 +++-
.../team-members/invite-link-card.tsx | 16 ++++++-
.../settings/account/account-settings.tsx | 9 ++--
.../settings/account/danger-zone.tsx | 8 +++-
.../_authenticated-routes-layout.tsx | 32 +++++++++++++-
.../onboarding+/organization.tsx | 15 +++++--
.../onboarding+/user-account.tsx | 15 ++++++-
.../$organizationSlug+/pastes.tsx | 8 +++-
18 files changed, 204 insertions(+), 23 deletions(-)
diff --git a/apps/basic-integration/react-router/saas-template/.env.example b/apps/basic-integration/react-router/saas-template/.env.example
index 9222ce272..90e4c382c 100644
--- a/apps/basic-integration/react-router/saas-template/.env.example
+++ b/apps/basic-integration/react-router/saas-template/.env.example
@@ -12,6 +12,10 @@ VITE_SUPABASE_URL=https://abcdefghijklmnopqrst.supabase.co
VITE_SUPABASE_ANON_KEY="ey_mock-anon-key"
SUPABASE_SERVICE_ROLE_KEY="ey_mock-service-role"
+# PostHog
+VITE_PUBLIC_POSTHOG_PROJECT_TOKEN=
+VITE_PUBLIC_POSTHOG_HOST=
+
# App
APP_URL="http://localhost:3000"
COOKIE_SECRET=a-sufficiently-long-secret-ideally-32-characters-or-more
diff --git a/apps/basic-integration/react-router/saas-template/.gitignore b/apps/basic-integration/react-router/saas-template/.gitignore
index bf57516ba..a550c6444 100644
--- a/apps/basic-integration/react-router/saas-template/.gitignore
+++ b/apps/basic-integration/react-router/saas-template/.gitignore
@@ -28,3 +28,4 @@ stripe-events.txt
# Prisma
/app/generated/
+.env
diff --git a/apps/basic-integration/react-router/saas-template/app/entry.client.tsx b/apps/basic-integration/react-router/saas-template/app/entry.client.tsx
index 6508477e9..2b7d3abf4 100644
--- a/apps/basic-integration/react-router/saas-template/app/entry.client.tsx
+++ b/apps/basic-integration/react-router/saas-template/app/entry.client.tsx
@@ -1,11 +1,44 @@
+import { PostHogErrorBoundary, PostHogProvider } from "@posthog/react";
import i18next from "i18next";
import I18nextBrowserLanguageDetector from "i18next-browser-languagedetector";
import Fetch from "i18next-fetch-backend";
+import posthog from "posthog-js";
import { StrictMode, startTransition } from "react";
import { hydrateRoot } from "react-dom/client";
import { I18nextProvider, initReactI18next } from "react-i18next";
import { HydratedRouter } from "react-router/dom";
+const projectToken = import.meta.env.VITE_PUBLIC_POSTHOG_PROJECT_TOKEN;
+const host = import.meta.env.VITE_PUBLIC_POSTHOG_HOST;
+
+if (!projectToken) {
+ if (import.meta.env.DEV) {
+ throw new Error(
+ "VITE_PUBLIC_POSTHOG_PROJECT_TOKEN variable required by PostHog is missing or un-configured, this causes events to be silently missed. This error stops appearing once VITE_PUBLIC_POSTHOG_PROJECT_TOKEN is configured",
+ );
+ }
+} else if (!host) {
+ if (import.meta.env.DEV) {
+ throw new Error(
+ "VITE_PUBLIC_POSTHOG_HOST variable required by PostHog is missing or un-configured, this causes events to be silently missed. This error stops appearing once VITE_PUBLIC_POSTHOG_HOST is configured",
+ );
+ }
+} else {
+ posthog.init(projectToken, {
+ api_host: host,
+ capture_exceptions: {
+ capture_console_errors: false,
+ capture_unhandled_errors: true,
+ capture_unhandled_rejections: true,
+ },
+ defaults: "2026-05-30",
+ logs: {
+ environment: import.meta.env.MODE,
+ serviceName: "saas-template-web",
+ },
+ });
+}
+
async function hydrate() {
await i18next
.use(initReactI18next)
@@ -23,7 +56,15 @@ async function hydrate() {
document,