Skip to content

Commit

Permalink
Add Plausible analytics (#779)
Browse files Browse the repository at this point in the history
* Add Plausible analytics

* Update src/routes/+layout.svelte

Co-authored-by: Eliott C. <[email protected]>

* fix vars for plausible analytics

* Update .env.template

Co-authored-by: Eliott C. <[email protected]>

* revert change to PUBLIC_PLAUSIBLE_SCRIPT_URL

---------

Co-authored-by: Eliott C. <[email protected]>
  • Loading branch information
nsarrazin and coyotte508 authored Feb 5, 2024
1 parent 25a7ba5 commit dddb85f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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! 🦙",
Expand Down
1 change: 1 addition & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -152,6 +156,14 @@
rel="manifest"
href="{PUBLIC_ORIGIN || $page.url.origin}{base}/{PUBLIC_APP_ASSETS}/manifest.json"
/>

{#if PUBLIC_PLAUSIBLE_SCRIPT_URL}
<script
defer
data-domain={new URL(PUBLIC_ORIGIN).hostname}
src={PUBLIC_PLAUSIBLE_SCRIPT_URL}
></script>
{/if}
</svelte:head>

{#if !$settings.ethicsModalAccepted}
Expand Down

0 comments on commit dddb85f

Please sign in to comment.