From d85ea6861c7110676fd403f3fffa59c0959f3e46 Mon Sep 17 00:00:00 2001
From: swve
Date: Sat, 8 Jun 2024 12:23:04 +0100
Subject: [PATCH] feat: init umami
---
apps/web/app/auth/options.ts | 2 +-
apps/web/app/layout.tsx | 3 +++
apps/web/middleware.ts | 3 ++-
apps/web/next.config.js | 17 ++++++++++++++---
4 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/apps/web/app/auth/options.ts b/apps/web/app/auth/options.ts
index 04553622..b953fd6a 100644
--- a/apps/web/app/auth/options.ts
+++ b/apps/web/app/auth/options.ts
@@ -9,7 +9,7 @@ import { getResponseMetadata } from '@services/utils/ts/requests'
import CredentialsProvider from 'next-auth/providers/credentials'
import GoogleProvider from 'next-auth/providers/google'
-const isDevEnv = LEARNHOUSE_TOP_DOMAIN == 'localhost' ? true : false
+export const isDevEnv = LEARNHOUSE_TOP_DOMAIN == 'localhost' ? true : false
export const nextAuthOptions = {
debug: true,
diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsx
index 93dcdc2d..2ae9dd48 100644
--- a/apps/web/app/layout.tsx
+++ b/apps/web/app/layout.tsx
@@ -4,6 +4,8 @@ import StyledComponentsRegistry from '../components/Utils/libs/styled-registry'
import { motion } from 'framer-motion'
import { SessionProvider } from 'next-auth/react'
import LHSessionProvider from '@components/Contexts/LHSessionContext'
+import { isDevEnv } from './auth/options'
+import Script from 'next/script'
export default function RootLayout({
children,
@@ -19,6 +21,7 @@ export default function RootLayout({
+ {isDevEnv ? '' : }
diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts
index 2234ca51..829a905a 100644
--- a/apps/web/middleware.ts
+++ b/apps/web/middleware.ts
@@ -16,10 +16,11 @@ export const config = {
* 1. /api routes
* 2. /_next (Next.js internals)
* 3. /fonts (inside /public)
+ * 4. Umami Analytics
* 4. /examples (inside /public)
* 5. all root files inside /public (e.g. /favicon.ico)
*/
- '/((?!api|_next|fonts|examples|[\\w-]+\\.\\w+).*)',
+ '/((?!api|_next|fonts|umami|examples|[\\w-]+\\.\\w+).*)',
],
}
diff --git a/apps/web/next.config.js b/apps/web/next.config.js
index 5fc07052..fcdab469 100644
--- a/apps/web/next.config.js
+++ b/apps/web/next.config.js
@@ -1,8 +1,19 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
- reactStrictMode: false,
- output: 'standalone',
+ async rewrites() {
+ return [
+ {
+ source: '/umami/script.js',
+ destination: `https://eu.umami.is/script.js`,
+ },
+ {
+ source: '/umami/api/send',
+ destination: `https://eu.umami.is/api/send`,
+ },
+ ]
+ },
+ reactStrictMode: false,
+ output: 'standalone',
}
module.exports = nextConfig
-