From b2e46efc6840aac15b5e9c4a69b177a3ca636470 Mon Sep 17 00:00:00 2001 From: Levente Orban Date: Wed, 27 Aug 2025 16:54:28 +0200 Subject: [PATCH] fix: refactor analytics --- .env.example | 2 -- Dockerfile | 1 - docker-compose.yml | 1 - src/app.html | 9 ++++++++- src/hooks.server.ts | 27 --------------------------- 5 files changed, 8 insertions(+), 32 deletions(-) delete mode 100644 src/hooks.server.ts diff --git a/.env.example b/.env.example index 19aeca2..13bdeb3 100644 --- a/.env.example +++ b/.env.example @@ -8,7 +8,5 @@ DATABASE_URL="postgres://cactoide:cactoide_password@localhost:5432/cactoied_data # Application configuration APP_VERSION=latest -ANALYTICS=true PORT=3000 HOSTNAME=0.0.0.0 -NODE_ENV=production diff --git a/Dockerfile b/Dockerfile index 2f9a9f6..1f78765 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,5 +20,4 @@ EXPOSE 3000 ENV PORT 3000 ENV HOSTNAME "0.0.0.0" -ENV NODE_ENV production CMD [ "node", "build" ] diff --git a/docker-compose.yml b/docker-compose.yml index 1cabdfd..0a93ce6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,7 +34,6 @@ services: - '${PORT:-3000}:3000' environment: DATABASE_URL: postgres://${POSTGRES_USER:-cactoide}:${POSTGRES_PASSWORD:-cactoide_password}@postgres:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-cactoied_database} - NODE_ENV: ${NODE_ENV:-dev} PORT: 3000 HOSTNAME: ${HOSTNAME:-0.0.0.0} depends_on: diff --git a/src/app.html b/src/app.html index f930998..a8f821a 100644 --- a/src/app.html +++ b/src/app.html @@ -4,7 +4,14 @@ - %sveltekit.head% %ANALYTICS_SCRIPT% + %sveltekit.head% + + +
%sveltekit.body%
diff --git a/src/hooks.server.ts b/src/hooks.server.ts deleted file mode 100644 index 9cb3f4f..0000000 --- a/src/hooks.server.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { env } from '$env/dynamic/private'; - -export const handle = async ({ event, resolve }) => { - // Check if analytics is enabled - const analyticsEnabled = env.ANALYTICS === 'true'; - - // Define the analytics script HTML - const analyticsScript = analyticsEnabled - ? '' - : ''; - - // Replace the placeholder with the actual script or empty string - const response = await resolve(event); - - if (response.headers.get('content-type')?.includes('text/html')) { - const html = await response.text(); - const modifiedHtml = html.replace('%ANALYTICS_SCRIPT%', analyticsScript); - - return new Response(modifiedHtml, { - headers: response.headers, - status: response.status, - statusText: response.statusText - }); - } - - return response; -};