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/
|
/out/
|
||||||
/build
|
/build
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
|
.open-next
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
.DS_Store
|
.DS_Store
|
||||||
@@ -19,7 +20,7 @@
|
|||||||
/.pnp
|
/.pnp
|
||||||
.pnp.js
|
.pnp.js
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
|
||||||
# others
|
# others
|
||||||
@@ -27,4 +28,4 @@ yarn-error.log*
|
|||||||
.vercel
|
.vercel
|
||||||
next-env.d.ts
|
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} */
|
/** @type {import('next').NextConfig} */
|
||||||
const config = {
|
const config = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
output: "export",
|
// This is required to support PostHog trailing slash API requests
|
||||||
|
skipTrailingSlashRedirect: true,
|
||||||
experimental: {
|
experimental: {
|
||||||
reactCompiler: true,
|
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);
|
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",
|
"start": "next start",
|
||||||
"check": "biome check --write .",
|
"check": "biome check --write .",
|
||||||
"postinstall": "fumadocs-mdx",
|
"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-analytics": "bun scripts/generate-analytics.ts",
|
||||||
"generate-schema": "bun scripts/generate-schema.ts"
|
"generate-schema": "bun scripts/generate-schema.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@opennextjs/cloudflare": "^1.5.1",
|
||||||
"babel-plugin-react-compiler": "^19.1.0-rc.2",
|
"babel-plugin-react-compiler": "^19.1.0-rc.2",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"date-fns": "^4.1.0",
|
"date-fns": "^4.1.0",
|
||||||
"fumadocs-core": "15.5.1",
|
"fumadocs-core": "15.6.3",
|
||||||
"fumadocs-mdx": "11.6.7",
|
"fumadocs-mdx": "11.6.11",
|
||||||
"fumadocs-ui": "15.5.1",
|
"fumadocs-ui": "15.6.3",
|
||||||
"lucide-react": "^0.513.0",
|
"lucide-react": "^0.525.0",
|
||||||
"motion": "^12.18.1",
|
"motion": "^12.23.3",
|
||||||
"next": "15.3.3",
|
"next": "15.3.5",
|
||||||
"next-themes": "^0.4.6",
|
"next-themes": "^0.4.6",
|
||||||
"nuqs": "^2.4.3",
|
"nuqs": "^2.4.3",
|
||||||
"papaparse": "^5.5.3",
|
"papaparse": "^5.5.3",
|
||||||
|
"posthog-js": "^1.257.0",
|
||||||
"radix-ui": "^1.4.2",
|
"radix-ui": "^1.4.2",
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0",
|
"react-dom": "^19.1.0",
|
||||||
"react-tweet": "^3.2.2",
|
"react-tweet": "^3.2.2",
|
||||||
"recharts": "^2.15.4",
|
"recharts": "^3.1.0",
|
||||||
"sonner": "^2.0.5",
|
"sonner": "^2.0.6",
|
||||||
"tailwind-merge": "^3.3.1"
|
"tailwind-merge": "^3.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/postcss": "^4.1.10",
|
"@tailwindcss/postcss": "^4.1.11",
|
||||||
"@types/mdx": "^2.0.13",
|
"@types/mdx": "^2.0.13",
|
||||||
"@types/node": "24.0.0",
|
"@types/node": "24.0.13",
|
||||||
"@types/papaparse": "^5.3.16",
|
"@types/papaparse": "^5.3.16",
|
||||||
"@types/react": "^19.1.8",
|
"@types/react": "^19.1.8",
|
||||||
"@types/react-dom": "^19.1.6",
|
"@types/react-dom": "^19.1.6",
|
||||||
"eslint": "^9.29.0",
|
"eslint": "^9.31.0",
|
||||||
"eslint-config-next": "15.3.3",
|
"eslint-config-next": "15.3.5",
|
||||||
"postcss": "^8.5.6",
|
"postcss": "^8.5.6",
|
||||||
"tailwindcss": "^4.1.10",
|
"tailwindcss": "^4.1.11",
|
||||||
"tw-animate-css": "^1.3.4",
|
"tw-animate-css": "^1.3.5",
|
||||||
"typescript": "^5.8.3"
|
"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",
|
"check": "turbo check",
|
||||||
"format": "biome check --write .",
|
"format": "biome check --write .",
|
||||||
"publish-packages": "turbo run build --filter=create-better-t-stack && changeset publish",
|
"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 --filter=web deploy"
|
||||||
"deploy:web": "bun run build:web:cloudflare && bunx wrangler pages deploy ./apps/web/out"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "^2.0.2",
|
"@biomejs/biome": "^2.0.2",
|
||||||
|
|||||||
Reference in New Issue
Block a user