mirror of
https://github.com/polaroi8d/cactoide.git
synced 2026-03-22 06:05:28 +00:00
fix: refactor analytics
This commit is contained in:
@@ -8,7 +8,5 @@ DATABASE_URL="postgres://cactoide:cactoide_password@localhost:5432/cactoied_data
|
|||||||
|
|
||||||
# Application configuration
|
# Application configuration
|
||||||
APP_VERSION=latest
|
APP_VERSION=latest
|
||||||
ANALYTICS=true
|
|
||||||
PORT=3000
|
PORT=3000
|
||||||
HOSTNAME=0.0.0.0
|
HOSTNAME=0.0.0.0
|
||||||
NODE_ENV=production
|
|
||||||
|
|||||||
@@ -20,5 +20,4 @@ EXPOSE 3000
|
|||||||
|
|
||||||
ENV PORT 3000
|
ENV PORT 3000
|
||||||
ENV HOSTNAME "0.0.0.0"
|
ENV HOSTNAME "0.0.0.0"
|
||||||
ENV NODE_ENV production
|
|
||||||
CMD [ "node", "build" ]
|
CMD [ "node", "build" ]
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ services:
|
|||||||
- '${PORT:-3000}:3000'
|
- '${PORT:-3000}:3000'
|
||||||
environment:
|
environment:
|
||||||
DATABASE_URL: postgres://${POSTGRES_USER:-cactoide}:${POSTGRES_PASSWORD:-cactoide_password}@postgres:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-cactoied_database}
|
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
|
PORT: 3000
|
||||||
HOSTNAME: ${HOSTNAME:-0.0.0.0}
|
HOSTNAME: ${HOSTNAME:-0.0.0.0}
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
@@ -4,7 +4,14 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||||
%sveltekit.head% %ANALYTICS_SCRIPT%
|
%sveltekit.head%
|
||||||
|
|
||||||
|
<!-- Remove if you don't want to use analytics -->
|
||||||
|
<script
|
||||||
|
defer
|
||||||
|
src="https://analytics.dalev.hu/script.js"
|
||||||
|
data-website-id="7425d098-e340-4464-bd03-c2e47b004cd9"
|
||||||
|
></script>
|
||||||
</head>
|
</head>
|
||||||
<body data-sveltekit-preload-data="hover">
|
<body data-sveltekit-preload-data="hover">
|
||||||
<div style="display: contents">%sveltekit.body%</div>
|
<div style="display: contents">%sveltekit.body%</div>
|
||||||
|
|||||||
@@ -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
|
|
||||||
? '<script defer src="https://analytics.dalev.hu/script.js" data-website-id="7425d098-e340-4464-bd03-c2e47b004cd9"></script>'
|
|
||||||
: '';
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user