Add Plausible Analytics (#391)

* Add PLAUSIBLE_URL and PLAUSIBLE_DATA_DOMAIN

Plausible's tags look like this:
<script defer data-domain="domain.com"
src="https://plausible.io/js/script.js"></script>

If you are using their hosted version the PLAUSIBLE_URL=plausible.io, otherwise you can use your self-hosted url here.

* Add Plausible script tag

* Added PLAUSIBLE_DATA_API

* Remove "/script.js" hardcoded path and add PLAUSIBLE_DATA_API

* lint fix

---------

Co-authored-by: Techno Tim <timothystewart6@gmail.com>
This commit is contained in:
Joe DePumpo 2023-05-12 12:43:39 -04:00 committed by GitHub
parent e684a5411b
commit ab2b06c5af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20748 additions and 0 deletions

20726
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -125,6 +125,9 @@ export const runtimeConfig =
MYANIMELIST: window?.env?.MYANIMELIST,
MATOMO_URL: window?.env?.MATOMO_URL,
MATOMO_SITE_ID: window?.env?.MATOMO_SITE_ID,
PLAUSIBLE_URL: window?.env?.PLAUSIBLE_URL,
PLAUSIBLE_DATA_API: window?.env?.PLAUSIBLE_DATA_API,
PLAUSIBLE_DATA_DOMAIN: window?.env?.PLAUSIBLE_DATA_DOMAIN,
SHARE: window?.env?.SHARE,
DROP_SHADOW: window?.env?.DROP_SHADOW,
FIVEHUNDREDPX: window?.env?.FIVEHUNDREDPX,
@ -456,6 +459,15 @@ export const runtimeConfig =
MATOMO_SITE_ID: nodeIsProduction
? process.env.MATOMO_SITE_ID
: process.env.RAZZLE_MATOMO_SITE_ID,
PLAUSIBLE_URL: nodeIsProduction
? process.env.PLAUSIBLE_URL
: process.env.RAZZLE_PLAUSIBLE_URL,
PLAUSIBLE_DATA_API: nodeIsProduction
? process.env.PLAUSIBLE_DATA_API
: process.env.RAZZLE_PLAUSIBLE_DATA_API,
PLAUSIBLE_DATA_DOMAIN: nodeIsProduction
? process.env.PLAUSIBLE_DATA_DOMAIN
: process.env.RAZZLE_PLAUSIBLE_DATA_DOMAIN,
SHARE: nodeIsProduction ? process.env.SHARE : process.env.RAZZLE_SHARE,
DROP_SHADOW: nodeIsProduction
? process.env.DROP_SHADOW

View File

@ -227,6 +227,16 @@ server
<!-- Matomo End -->`
: ''
}
${
runtimeConfig.PLAUSIBLE_DATA_DOMAIN &&
runtimeConfig.PLAUSIBLE_DATA_API &&
runtimeConfig.PLAUSIBLE_URL
? `
<!-- Plausible Analytics -->
<script async defer data-domain="${runtimeConfig.PLAUSIBLE_DATA_DOMAIN}" data-api="${runtimeConfig.PLAUSIBLE_DATA_API}" src="${runtimeConfig.PLAUSIBLE_URL}">
</script>`
: ''
}
</head>
<body>