Skip to content

Commit dddb85f

Browse files
Add Plausible analytics (#779)
* Add Plausible analytics * Update src/routes/+layout.svelte Co-authored-by: Eliott C. <coyotte508@gmail.com> * fix vars for plausible analytics * Update .env.template Co-authored-by: Eliott C. <coyotte508@gmail.com> * revert change to PUBLIC_PLAUSIBLE_SCRIPT_URL --------- Co-authored-by: Eliott C. <coyotte508@gmail.com>
1 parent 25a7ba5 commit dddb85f

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ TASK_MODEL= # name of the model used for tasks such as summarizing title, creati
9797
PUBLIC_ORIGIN=#https://huggingface.co
9898
PUBLIC_SHARE_PREFIX=#https://hf.co/chat
9999
PUBLIC_GOOGLE_ANALYTICS_ID=#G-XXXXXXXX / Leave empty to disable
100+
PUBLIC_PLAUSIBLE_SCRIPT_URL=#/js/script.js / Leave empty to disable
100101
PUBLIC_ANNOUNCEMENT_BANNERS=`[
101102
{
102103
"title": "Code Llama 70B is available! 🦙",

.env.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ RATE_LIMIT=16
235235
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
236236

237237
PUBLIC_GOOGLE_ANALYTICS_ID=G-8Q63TH4CSL
238+
PUBLIC_PLAUSIBLE_SCRIPT_URL="/js/script.js"
238239

239240
# Not part of the .env but set as other variables in the space
240241
# ADDRESS_HEADER=X-Forwarded-For

src/routes/+layout.svelte

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
import { page } from "$app/stores";
55
import "../styles/main.css";
66
import { base } from "$app/paths";
7-
import { PUBLIC_APP_DESCRIPTION, PUBLIC_ORIGIN } from "$env/static/public";
7+
import {
8+
PUBLIC_APP_DESCRIPTION,
9+
PUBLIC_ORIGIN,
10+
PUBLIC_PLAUSIBLE_SCRIPT_URL,
11+
} from "$env/static/public";
812
913
import { shareConversation } from "$lib/shareConversation";
1014
import { UrlDependency } from "$lib/types/UrlDependency";
@@ -152,6 +156,14 @@
152156
rel="manifest"
153157
href="{PUBLIC_ORIGIN || $page.url.origin}{base}/{PUBLIC_APP_ASSETS}/manifest.json"
154158
/>
159+
160+
{#if PUBLIC_PLAUSIBLE_SCRIPT_URL}
161+
<script
162+
defer
163+
data-domain={new URL(PUBLIC_ORIGIN).hostname}
164+
src={PUBLIC_PLAUSIBLE_SCRIPT_URL}
165+
></script>
166+
{/if}
155167
</svelte:head>
156168

157169
{#if !$settings.ethicsModalAccepted}

0 commit comments

Comments
 (0)