mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
feat(web): migrate from pages to workers and add posthog analytics
This commit is contained in:
5
apps/web/.gitignore
vendored
5
apps/web/.gitignore
vendored
@@ -12,6 +12,7 @@
|
||||
/out/
|
||||
/build
|
||||
*.tsbuildinfo
|
||||
.open-next
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
@@ -19,7 +20,7 @@
|
||||
/.pnp
|
||||
.pnp.js
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# others
|
||||
@@ -27,4 +28,4 @@ yarn-error.log*
|
||||
.vercel
|
||||
next-env.d.ts
|
||||
|
||||
analytics-data.json
|
||||
analytics-data.json
|
||||
|
||||
9
apps/web/instrumentation-client.ts
Normal file
9
apps/web/instrumentation-client.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import posthog from "posthog-js"
|
||||
|
||||
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
|
||||
api_host: "/ingest",
|
||||
ui_host: "https://us.posthog.com",
|
||||
defaults: '2025-05-24',
|
||||
capture_exceptions: true, // This enables capturing exceptions using Error Tracking
|
||||
debug: process.env.NODE_ENV === "development",
|
||||
});
|
||||
@@ -5,10 +5,27 @@ const withMDX = createMDX();
|
||||
/** @type {import('next').NextConfig} */
|
||||
const config = {
|
||||
reactStrictMode: true,
|
||||
output: "export",
|
||||
// This is required to support PostHog trailing slash API requests
|
||||
skipTrailingSlashRedirect: true,
|
||||
experimental: {
|
||||
reactCompiler: true,
|
||||
},
|
||||
async rewrites() {
|
||||
return [
|
||||
{
|
||||
source: "/ingest/static/:path*",
|
||||
destination: "https://us-assets.i.posthog.com/static/:path*",
|
||||
},
|
||||
{
|
||||
source: "/ingest/:path*",
|
||||
destination: "https://us.i.posthog.com/:path*",
|
||||
},
|
||||
{
|
||||
source: "/ingest/decide",
|
||||
destination: "https://us.i.posthog.com/decide",
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
export default withMDX(config);
|
||||
|
||||
3
apps/web/open-next.config.ts
Normal file
3
apps/web/open-next.config.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
|
||||
|
||||
export default defineCloudflareConfig();
|
||||
@@ -9,43 +9,49 @@
|
||||
"start": "next start",
|
||||
"check": "biome check --write .",
|
||||
"postinstall": "fumadocs-mdx",
|
||||
"preview": "opennextjs-cloudflare build && opennextjs-cloudflare preview",
|
||||
"deploy": "opennextjs-cloudflare build && opennextjs-cloudflare deploy",
|
||||
"cf-typegen": "wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts",
|
||||
"generate-analytics": "bun scripts/generate-analytics.ts",
|
||||
"generate-schema": "bun scripts/generate-schema.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@opennextjs/cloudflare": "^1.5.1",
|
||||
"babel-plugin-react-compiler": "^19.1.0-rc.2",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"date-fns": "^4.1.0",
|
||||
"fumadocs-core": "15.5.1",
|
||||
"fumadocs-mdx": "11.6.7",
|
||||
"fumadocs-ui": "15.5.1",
|
||||
"lucide-react": "^0.513.0",
|
||||
"motion": "^12.18.1",
|
||||
"next": "15.3.3",
|
||||
"fumadocs-core": "15.6.3",
|
||||
"fumadocs-mdx": "11.6.11",
|
||||
"fumadocs-ui": "15.6.3",
|
||||
"lucide-react": "^0.525.0",
|
||||
"motion": "^12.23.3",
|
||||
"next": "15.3.5",
|
||||
"next-themes": "^0.4.6",
|
||||
"nuqs": "^2.4.3",
|
||||
"papaparse": "^5.5.3",
|
||||
"posthog-js": "^1.257.0",
|
||||
"radix-ui": "^1.4.2",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"react-tweet": "^3.2.2",
|
||||
"recharts": "^2.15.4",
|
||||
"sonner": "^2.0.5",
|
||||
"recharts": "^3.1.0",
|
||||
"sonner": "^2.0.6",
|
||||
"tailwind-merge": "^3.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4.1.10",
|
||||
"@tailwindcss/postcss": "^4.1.11",
|
||||
"@types/mdx": "^2.0.13",
|
||||
"@types/node": "24.0.0",
|
||||
"@types/node": "24.0.13",
|
||||
"@types/papaparse": "^5.3.16",
|
||||
"@types/react": "^19.1.8",
|
||||
"@types/react-dom": "^19.1.6",
|
||||
"eslint": "^9.29.0",
|
||||
"eslint-config-next": "15.3.3",
|
||||
"eslint": "^9.31.0",
|
||||
"eslint-config-next": "15.3.5",
|
||||
"postcss": "^8.5.6",
|
||||
"tailwindcss": "^4.1.10",
|
||||
"tw-animate-css": "^1.3.4",
|
||||
"typescript": "^5.8.3"
|
||||
"tailwindcss": "^4.1.11",
|
||||
"tw-animate-css": "^1.3.5",
|
||||
"typescript": "^5.8.3",
|
||||
"wrangler": "^4.24.3"
|
||||
}
|
||||
}
|
||||
|
||||
10
apps/web/wrangler.jsonc
Normal file
10
apps/web/wrangler.jsonc
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"main": ".open-next/worker.js",
|
||||
"name": "better-t-stack",
|
||||
"compatibility_date": "2025-07-13",
|
||||
"compatibility_flags": ["nodejs_compat"],
|
||||
"assets": {
|
||||
"directory": ".open-next/assets",
|
||||
"binding": "ASSETS"
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,7 @@
|
||||
"check": "turbo check",
|
||||
"format": "biome check --write .",
|
||||
"publish-packages": "turbo run build --filter=create-better-t-stack && changeset publish",
|
||||
"build:web:cloudflare": "bun install && bun run build:web",
|
||||
"deploy:web": "bun run build:web:cloudflare && bunx wrangler pages deploy ./apps/web/out"
|
||||
"deploy:web": "bun run --filter=web deploy"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^2.0.2",
|
||||
|
||||
Reference in New Issue
Block a user