From dddb85f2876932116b9977211e93999e7bb990b7 Mon Sep 17 00:00:00 2001 From: Nathan Sarrazin Date: Mon, 5 Feb 2024 14:01:05 +0100 Subject: [PATCH] Add Plausible analytics (#779) * Add Plausible analytics * Update src/routes/+layout.svelte Co-authored-by: Eliott C. * fix vars for plausible analytics * Update .env.template Co-authored-by: Eliott C. * revert change to PUBLIC_PLAUSIBLE_SCRIPT_URL --------- Co-authored-by: Eliott C. --- .env | 1 + .env.template | 1 + src/routes/+layout.svelte | 14 +++++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.env b/.env index f80d3018eec..8a385892bb5 100644 --- a/.env +++ b/.env @@ -97,6 +97,7 @@ TASK_MODEL= # name of the model used for tasks such as summarizing title, creati PUBLIC_ORIGIN=#https://huggingface.co PUBLIC_SHARE_PREFIX=#https://hf.co/chat PUBLIC_GOOGLE_ANALYTICS_ID=#G-XXXXXXXX / Leave empty to disable +PUBLIC_PLAUSIBLE_SCRIPT_URL=#/js/script.js / Leave empty to disable PUBLIC_ANNOUNCEMENT_BANNERS=`[ { "title": "Code Llama 70B is available! 🦙", diff --git a/.env.template b/.env.template index 3df2cc0982f..c9244c91e7c 100644 --- a/.env.template +++ b/.env.template @@ -235,6 +235,7 @@ RATE_LIMIT=16 MESSAGES_BEFORE_LOGIN=5# how many messages a user can send in a conversation before having to login. set to 0 to force login right away PUBLIC_GOOGLE_ANALYTICS_ID=G-8Q63TH4CSL +PUBLIC_PLAUSIBLE_SCRIPT_URL="/js/script.js" # Not part of the .env but set as other variables in the space # ADDRESS_HEADER=X-Forwarded-For diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 2f9aef10a38..15e93c74dbc 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -4,7 +4,11 @@ import { page } from "$app/stores"; import "../styles/main.css"; import { base } from "$app/paths"; - import { PUBLIC_APP_DESCRIPTION, PUBLIC_ORIGIN } from "$env/static/public"; + import { + PUBLIC_APP_DESCRIPTION, + PUBLIC_ORIGIN, + PUBLIC_PLAUSIBLE_SCRIPT_URL, + } from "$env/static/public"; import { shareConversation } from "$lib/shareConversation"; import { UrlDependency } from "$lib/types/UrlDependency"; @@ -152,6 +156,14 @@ rel="manifest" href="{PUBLIC_ORIGIN || $page.url.origin}{base}/{PUBLIC_APP_ASSETS}/manifest.json" /> + + {#if PUBLIC_PLAUSIBLE_SCRIPT_URL} + + {/if} {#if !$settings.ethicsModalAccepted}