🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Upgrade Next.js and related dependencies to version 16.1.6, refactor … (#894)
Goldflag344ad71f194b
diff --git a/client/package-lock.json b/client/package-lock.jsonindex 5d068476e..ed51e5fdf 100644--- a/client/package-lock.json+++ b/client/package-lock.json@@ -62,9 +62,9 @@"lucide-react": "0.510.0","luxon": "3.6.1","mapbox-gl": "^3.15.0",- "next": "15.5.9",+ "next": "16.1.6","next-themes": "0.4.6",- "nuqs": "^2.7.3",+ "nuqs": "^2.8.8","ol": "^10.6.1","papaparse": "^5.5.3","react": "19.2.1",@@ -1840,9 +1840,9 @@}},"node_modules/@next/env": {- "version": "15.5.9",- "resolved": "https://registry.npmjs.org/@next/env/-/env-15.5.9.tgz",- "integrity": "sha512-4GlTZ+EJM7WaW2HEZcyU317tIQDjkQIyENDLxYJfSWlfqguN+dHkZgyQTV/7ykvobU7yEH5gKvreNrH4B6QgIg==",+ "version": "16.1.6",+ "resolved": "https://registry.npmjs.org/@next/env/-/env-16.1.6.tgz",+ "integrity": "sha512-N1ySLuZjnAtN3kFnwhAwPvZah8RJxKasD7x1f8shFqhncnWZn4JMfg37diLNuoHsLAlrDfM3g4mawVdtAG8XLQ==","license": "MIT"},"node_modules/@next/eslint-plugin-next": {@@ -1856,9 +1856,9 @@}},"node_modules/@next/swc-darwin-arm64": {- "version": "15.5.7",- "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-15.5.7.tgz",- "integrity": "sha512-IZwtxCEpI91HVU/rAUOOobWSZv4P2DeTtNaCdHqLcTJU4wdNXgAySvKa/qJCgR5m6KI8UsKDXtO2B31jcaw1Yw==",+ "version": "16.1.6",+ "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.1.6.tgz",+ "integrity": "sha512-wTzYulosJr/6nFnqGW7FrG3jfUUlEf8UjGA0/pyypJl42ExdVgC6xJgcXQ+V8QFn6niSG2Pb8+MIG1mZr2vczw==","cpu": ["arm64"],@@ -1872,9 +1872,9 @@}},"node_modules/@next/swc-darwin-x64": {- "version": "15.5.7",- "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-15.5.7.tgz",- "integrity": "sha512-UP6CaDBcqaCBuiq/gfCEJw7sPEoX1aIjZHnBWN9v9qYHQdMKvCKcAVs4OX1vIjeE+tC5EIuwDTVIoXpUes29lg==",+ "version": "16.1.6",+ "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.1.6.tgz",+ "integrity": "sha512-BLFPYPDO+MNJsiDWbeVzqvYd4NyuRrEYVB5k2N3JfWncuHAy2IVwMAOlVQDFjj+krkWzhY2apvmekMkfQR0CUQ==","cpu": ["x64"],@@ -1888,9 +1888,9 @@}},"node_modules/@next/swc-linux-arm64-gnu": {- "version": "15.5.7",- "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-15.5.7.tgz",- "integrity": "sha512-NCslw3GrNIw7OgmRBxHtdWFQYhexoUCq+0oS2ccjyYLtcn1SzGzeM54jpTFonIMUjNbHmpKpziXnpxhSWLcmBA==",+ "version": "16.1.6",+ "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.1.6.tgz",+ "integrity": "sha512-OJYkCd5pj/QloBvoEcJ2XiMnlJkRv9idWA/j0ugSuA34gMT6f5b7vOiCQHVRpvStoZUknhl6/UxOXL4OwtdaBw==","cpu": ["arm64"],@@ -1904,9 +1904,9 @@}},"node_modules/@next/swc-linux-arm64-musl": {- "version": "15.5.7",- "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-15.5.7.tgz",- "integrity": "sha512-nfymt+SE5cvtTrG9u1wdoxBr9bVB7mtKTcj0ltRn6gkP/2Nu1zM5ei8rwP9qKQP0Y//umK+TtkKgNtfboBxRrw==",+ "version": "16.1.6",+ "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.1.6.tgz",+ "integrity": "sha512-S4J2v+8tT3NIO9u2q+S0G5KdvNDjXfAv06OhfOzNDaBn5rw84DGXWndOEB7d5/x852A20sW1M56vhC/tRVbccQ==","cpu": ["arm64"],@@ -1920,9 +1920,9 @@}},"node_modules/@next/swc-linux-x64-gnu": {- "version": "15.5.7",- "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-15.5.7.tgz",- "integrity": "sha512-hvXcZvCaaEbCZcVzcY7E1uXN9xWZfFvkNHwbe/n4OkRhFWrs1J1QV+4U1BN06tXLdaS4DazEGXwgqnu/VMcmqw==",+ "version": "16.1.6",+ "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.1.6.tgz",+ "integrity": "sha512-2eEBDkFlMMNQnkTyPBhQOAyn2qMxyG2eE7GPH2WIDGEpEILcBPI/jdSv4t6xupSP+ot/jkfrCShLAa7+ZUPcJQ==","cpu": ["x64"],@@ -1936,9 +1936,9 @@}},"node_modules/@next/swc-linux-x64-musl": {- "version": "15.5.7",- "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-15.5.7.tgz",- "integrity": "sha512-4IUO539b8FmF0odY6/SqANJdgwn1xs1GkPO5doZugwZ3ETF6JUdckk7RGmsfSf7ws8Qb2YB5It33mvNL/0acqA==",+ "version": "16.1.6",+ "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.1.6.tgz",+ "integrity": "sha512-oicJwRlyOoZXVlxmIMaTq7f8pN9QNbdes0q2FXfRsPhfCi8n8JmOZJm5oo1pwDaFbnnD421rVU409M3evFbIqg==","cpu": ["x64"],@@ -1952,9 +1952,9 @@}},"node_modules/@next/swc-win32-arm64-msvc": {- "version": "15.5.7",- "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-15.5.7.tgz",- "integrity": "sha512-CpJVTkYI3ZajQkC5vajM7/ApKJUOlm6uP4BknM3XKvJ7VXAvCqSjSLmM0LKdYzn6nBJVSjdclx8nYJSa3xlTgQ==",+ "version": "16.1.6",+ "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.1.6.tgz",+ "integrity": "sha512-gQmm8izDTPgs+DCWH22kcDmuUp7NyiJgEl18bcr8irXA5N2m2O+JQIr6f3ct42GOs9c0h8QF3L5SzIxcYAAXXw==","cpu": ["arm64"],@@ -1968,9 +1968,9 @@}},"node_modules/@next/swc-win32-x64-msvc": {- "version": "15.5.7",- "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-15.5.7.tgz",- "integrity": "sha512-gMzgBX164I6DN+9/PGA+9dQiwmTkE4TloBNx8Kv9UiGARsr9Nba7IpcBRA1iTV9vwlYnrE3Uy6I7Aj6qLjQuqw==",+ "version": "16.1.6",+ "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.1.6.tgz",+ "integrity": "sha512-NRfO39AIrzBnixKbjuo2YiYhB6o9d8v/ymU9m/Xk8cyVk+k7XylniXkHwjs4s70wedVffc6bQNbufk5v0xEm0A==","cpu": ["x64"],@@ -10890,13 +10890,14 @@"license": "MIT"},"node_modules/next": {- "version": "15.5.9",- "resolved": "https://registry.npmjs.org/next/-/next-15.5.9.tgz",- "integrity": "sha512-agNLK89seZEtC5zUHwtut0+tNrc0Xw4FT/Dg+B/VLEo9pAcS9rtTKpek3V6kVcVwsB2YlqMaHdfZL4eLEVYuCg==",+ "version": "16.1.6",+ "resolved": "https://registry.npmjs.org/next/-/next-16.1.6.tgz",+ "integrity": "sha512-hkyRkcu5x/41KoqnROkfTm2pZVbKxvbZRuNvKXLRXxs3VfyO0WhY50TQS40EuKO9SW3rBj/sF3WbVwDACeMZyw==","license": "MIT","dependencies": {- "@next/env": "15.5.9",+ "@next/env": "16.1.6","@swc/helpers": "0.5.15",+ "baseline-browser-mapping": "^2.8.3","caniuse-lite": "^1.0.30001579","postcss": "8.4.31","styled-jsx": "5.1.6"@@ -10905,18 +10906,18 @@"next": "dist/bin/next"},"engines": {- "node": "^18.18.0 || ^19.8.0 || >= 20.0.0"+ "node": ">=20.9.0"},"optionalDependencies": {- "@next/swc-darwin-arm64": "15.5.7",- "@next/swc-darwin-x64": "15.5.7",- "@next/swc-linux-arm64-gnu": "15.5.7",- "@next/swc-linux-arm64-musl": "15.5.7",- "@next/swc-linux-x64-gnu": "15.5.7",- "@next/swc-linux-x64-musl": "15.5.7",- "@next/swc-win32-arm64-msvc": "15.5.7",- "@next/swc-win32-x64-msvc": "15.5.7",- "sharp": "^0.34.3"+ "@next/swc-darwin-arm64": "16.1.6",+ "@next/swc-darwin-x64": "16.1.6",+ "@next/swc-linux-arm64-gnu": "16.1.6",+ "@next/swc-linux-arm64-musl": "16.1.6",+ "@next/swc-linux-x64-gnu": "16.1.6",+ "@next/swc-linux-x64-musl": "16.1.6",+ "@next/swc-win32-arm64-msvc": "16.1.6",+ "@next/swc-win32-x64-msvc": "16.1.6",+ "sharp": "^0.34.4"},"peerDependencies": {"@opentelemetry/api": "^1.1.0",@@ -10995,9 +10996,9 @@}},"node_modules/nuqs": {- "version": "2.8.5",- "resolved": "https://registry.npmjs.org/nuqs/-/nuqs-2.8.5.tgz",- "integrity": "sha512-ndhnNB9eLX/bsiGFkBNsrfOWf3BCbzBMD+b5GkD5o2Q96Q+llHnoUlZsrO3tgJKZZV7LLlVCvFKdj+sjBITRzg==",+ "version": "2.8.8",+ "resolved": "https://registry.npmjs.org/nuqs/-/nuqs-2.8.8.tgz",+ "integrity": "sha512-LF5sw9nWpHyPWzMMu9oho3r9C5DvkpmBIg4LQN78sexIzGaeRx8DWr0uy3YiFx5i2QGZN1Qqcb+OAtEVRa2bnA==","license": "MIT","dependencies": {"@standard-schema/spec": "1.0.0"diff --git a/client/package.json b/client/package.jsonindex a0363c0b7..315e89242 100644--- a/client/package.json+++ b/client/package.json@@ -3,7 +3,7 @@"version": "2.4.0","private": true,"scripts": {- "dev": "next dev -p 3002 --turbopack",+ "dev": "next dev -p 3002","build": "next build","start": "next start -p 3002","lint": "eslint .",@@ -66,9 +66,9 @@"lucide-react": "0.510.0","luxon": "3.6.1","mapbox-gl": "^3.15.0",- "next": "15.5.9",+ "next": "16.1.6","next-themes": "0.4.6",- "nuqs": "^2.7.3",+ "nuqs": "^2.8.8","ol": "^10.6.1","papaparse": "^5.5.3","react": "19.2.1",@@ -76,7 +76,6 @@"react-dom": "19.2.1","react-hook-form": "7.56.3","react-hot-toast": "^2.6.0",- "react-scan": "^0.3.4","react-select": "5.10.2","react-syntax-highlighter": "^16.1.0","rrweb-player": "^2.0.0-alpha.11",diff --git a/client/src/app/Providers.tsx b/client/src/app/Providers.tsxnew file mode 100644index 000000000..b905a5a93--- /dev/null+++ b/client/src/app/Providers.tsx@@ -0,0 +1,49 @@+"use client";++import { useAppEnv } from "@/hooks/useIsProduction";+import { useStopImpersonation } from "@/hooks/useStopImpersonation";+import { IS_CLOUD } from "@/lib/const";+import QueryProvider from "@/providers/QueryProvider";+import { ThemeProvider } from "next-themes";+import Script from "next/script";+import { NuqsAdapter } from "nuqs/adapters/next/app";+import { AuthenticationGuard } from "../components/AuthenticationGuard";+import { OrganizationInitializer } from "../components/OrganizationInitializer";+import { Toaster } from "../components/ui/sonner";+import { VersionCheck } from "../components/VersionCheck";+import { TooltipProvider } from "../components/ui/tooltip";++export function Providers({ children }: { children: React.ReactNode }) {+ useStopImpersonation();+ const appEnv = useAppEnv();++ return (+ <NuqsAdapter>+ <ThemeProvider attribute="class" enableSystem={true} disableTransitionOnChange>+ <TooltipProvider>+ <QueryProvider>+ <OrganizationInitializer />+ <AuthenticationGuard />+ {children}+ </QueryProvider>+ <VersionCheck />+ <Toaster />+ </TooltipProvider>+ </ThemeProvider>+ {appEnv === "prod" && (+ <Script src="https://demo.rybbit.com/api/script.js" data-site-id="21" strategy="afterInteractive" />+ )}+ {appEnv === "demo" && (+ <Script src="https://demo.rybbit.com/api/script.js" data-site-id="22" strategy="afterInteractive" />+ )}+ {appEnv === "prod" && IS_CLOUD && (+ <>+ <Script id="rewardful-queue" strategy="beforeInteractive">+ {`(function(w,r){w._rwq=r;w[r]=w[r]||function(){(w[r].q=w[r].q||[]).push(arguments)})(window,'rewardful');`}+ </Script>+ <Script src="https://r.wdfl.co/rw.js" data-rewardful="fc3780" strategy="afterInteractive" />+ </>+ )}+ </NuqsAdapter>+ );+}diff --git a/client/src/app/ReactScan.tsx b/client/src/app/ReactScan.tsxdeleted file mode 100644index ab9307b9c..000000000--- a/client/src/app/ReactScan.tsx+++ /dev/null@@ -1,14 +0,0 @@-"use client";-// react-scan must be imported before react-import { scan } from "react-scan";-import { JSX, useEffect } from "react";--export function ReactScan(): JSX.Element {- useEffect(() => {- scan({- enabled: process.env.NODE_ENV === "development",- });- }, []);-- return <></>;-}diff --git a/client/src/app/layout.tsx b/client/src/app/layout.tsxindex f9d97b0e4..742cae70b 100644--- a/client/src/app/layout.tsx+++ b/client/src/app/layout.tsx@@ -1,62 +1,16 @@-"use client";--import { useAppEnv } from "@/hooks/useIsProduction";-import { useStopImpersonation } from "@/hooks/useStopImpersonation";-import { IS_CLOUD } from "@/lib/const";-import QueryProvider from "@/providers/QueryProvider";-import { ThemeProvider } from "next-themes";import { Inter } from "next/font/google";-import Script from "next/script";-import { NuqsAdapter } from "nuqs/adapters/next/app";-import { AuthenticationGuard } from "../components/AuthenticationGuard";-import { OrganizationInitializer } from "../components/OrganizationInitializer";-import { Toaster } from "../components/ui/sonner";-import { VersionCheck } from "../components/VersionCheck";-import { TooltipProvider } from "../components/ui/tooltip";import { cn } from "../lib/utils";import "./globals.css";-import { ReactScan } from "./ReactScan";+import { Providers } from "./Providers";const inter = Inter({ subsets: ["latin"] });export default function RootLayout({ children }: { children: React.ReactNode }) {- // Use the hook to expose stopImpersonating globally- useStopImpersonation();-- const appEnv = useAppEnv();-return (<html lang="en" suppressHydrationWarning>- <ReactScan />- <NuqsAdapter>- <body className={cn("bg-background text-foreground h-full", inter.className)} suppressHydrationWarning>- <ThemeProvider attribute="class" enableSystem={true} disableTransitionOnChange>- <TooltipProvider>- <QueryProvider>- <OrganizationInitializer />- <AuthenticationGuard />- {children}- </QueryProvider>- <VersionCheck />- <Toaster />- </TooltipProvider>- </ThemeProvider>- {appEnv === "prod" && (- <Script src="https://demo.rybbit.com/api/script.js" data-site-id="21" strategy="afterInteractive" />- )}- {appEnv === "demo" && (- <Script src="https://demo.rybbit.com/api/script.js" data-site-id="22" strategy="afterInteractive" />- )}- {appEnv === "prod" && IS_CLOUD && (- <>- <Script id="rewardful-queue" strategy="beforeInteractive">- {`(function(w,r){w._rwq=r;w[r]=w[r]||function(){(w[r].q=w[r].q||[]).push(arguments)}})(window,'rewardful');`}- </Script>- <Script src="https://r.wdfl.co/rw.js" data-rewardful="fc3780" strategy="afterInteractive" />- </>- )}- </body>- </NuqsAdapter>+ <body className={cn("bg-background text-foreground h-full", inter.className)} suppressHydrationWarning>+ <Providers>{children}</Providers>+ </body></html>);}diff --git a/client/src/lib/urlParams.ts b/client/src/lib/urlParams.tsindex 72189732f..8a8440991 100644--- a/client/src/lib/urlParams.ts+++ b/client/src/lib/urlParams.ts@@ -132,9 +132,14 @@ export const useSyncStateWithUrl = () => {const initializedFromUrlRef = React.useRef(false);// Check if we're on a path where we should sync URL params- const shouldSyncUrl = () => {- if (!pathname) return false;- const pathParts = pathname.split("/");+ // Use a ref so this check doesn't trigger effects on navigation+ const pathnameRef = React.useRef(pathname);+ pathnameRef.current = pathname;++ const shouldSyncUrl = React.useCallback(() => {+ const p = pathnameRef.current;+ if (!p) return false;+ const pathParts = p.split("/");if (pathParts.length < 3) return false;return ["main",@@ -149,7 +154,7 @@ export const useSyncStateWithUrl = () => {"errors","pages",].includes(pathParts[2]);- };+ }, []);// Get URL params using nuqsconst [urlParams, setUrlParams] = useQueryStates(analyticsParsers, {@@ -219,7 +224,8 @@ export const useSyncStateWithUrl = () => {// Mark that we've initialized from URLinitializedFromUrlRef.current = true;- }, [urlParams, site, setTime, setBucket, setSelectedStat, setFilters, shouldSyncUrl, pathname]);+ // eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally omit pathname; initializedFromUrlRef guards re-runs+ }, [urlParams, site, setTime, setBucket, setSelectedStat, setFilters, shouldSyncUrl]);// Update URL when state changesuseEffect(() => {@@ -267,5 +273,6 @@ export const useSyncStateWithUrl = () => {// Note: embed param is automatically preserved by nuqssetUrlParams(newParams);- }, [time, bucket, selectedStat, filters, site, setUrlParams, shouldSyncUrl, pathname]);+ // eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally omit pathname to avoid interfering with soft navigation+ }, [time, bucket, selectedStat, filters, site, setUrlParams, shouldSyncUrl]);};diff --git a/client/src/middleware.ts b/client/src/proxy.tssimilarity index 97%rename from client/src/middleware.tsrename to client/src/proxy.tsindex 6ec3bb26d..a001f4f0c 100644--- a/client/src/middleware.ts+++ b/client/src/proxy.ts@@ -1,7 +1,7 @@import { NextResponse } from "next/server";import type { NextRequest } from "next/server";-export async function middleware(request: NextRequest) {+export async function proxy(request: NextRequest) {const url = request.nextUrl.clone();const path = url.pathname;diff --git a/client/tsconfig.json b/client/tsconfig.jsonindex 5d606a9f0..b575f7dac 100644--- a/client/tsconfig.json+++ b/client/tsconfig.json@@ -15,7 +15,7 @@"moduleResolution": "bundler","resolveJsonModule": true,"isolatedModules": true,- "jsx": "preserve",+ "jsx": "react-jsx","incremental": true,"plugins": [{