Replace Plausible CE with Umami

This commit is contained in:
Ethan Yoo 2024-11-12 21:09:28 -05:00
parent 5de3c7cd35
commit 5742b7c1f9
Signed by: ethan
GPG Key ID: 70596474C5D20F85
4 changed files with 7 additions and 5 deletions

View File

@ -5,7 +5,7 @@ layout: permalink
description: "You should always try to understand the privacy policy." description: "You should always try to understand the privacy policy."
--- ---
This website uses the self-hosted version of [Plausible Analytics](https://github.com/plausible/analytics#readme) on a subdomain; I run Plausible Community Edition on a [Hetzner Cloud](https://www.hetzner.com/cloud/) server located in Virginia. This website uses [a self-hosted version](https://github.com/umami-software/umami#readme) of [Umami](https://umami.is/) for analytics; I run Umami on a [Hetzner Cloud](https://www.hetzner.com/cloud/) server located in Virginia.
There are no other external dependencies or resources, including Google Fonts or social media (e.g., Facebook, Twitter, and embedded YouTube videos). If JavaScript is disabled (typically a conscious decision) or the search script fails to load, however, search queries will instead be sent to DuckDuckGo. There are no other external dependencies or resources, including Google Fonts or social media (e.g., Facebook, Twitter, and embedded YouTube videos). If JavaScript is disabled (typically a conscious decision) or the search script fails to load, however, search queries will instead be sent to DuckDuckGo.
@ -23,5 +23,6 @@ If you do contact me, you're not required to use a real name or a permanent emai
*Updated on **December 11, 2020** after disabling access logs*\ *Updated on **December 11, 2020** after disabling access logs*\
*Updated on **December 29, 2022** after adding the website's search function*\ *Updated on **December 29, 2022** after adding the website's search function*\
*Updated on **March 12, 2023** to move a sentence describing the website's search function*\ *Updated on **March 12, 2023** to move a sentence describing the website's search function*\
*Updated on **June 2, 2024** to reflect the use of Plausible Community Edition and to change some wording* *Updated on **June 2, 2024** to reflect the use of Plausible Community Edition and to change some wording*\
*Updated on **July 8, 2024** to replace the link to Mozilla Observatory ([deprecated](https://developer.mozilla.org/en-US/blog/mdn-http-observatory-launch/)) with a link to the [MDN HTTP Observatory](https://developer.mozilla.org/en-US/observatory)* *Updated on **July 8, 2024** to replace the link to Mozilla Observatory ([deprecated](https://developer.mozilla.org/en-US/blog/mdn-http-observatory-launch/)) with a link to the [MDN HTTP Observatory](https://developer.mozilla.org/en-US/observatory)*\
*Updated on **November 12, 2024** to replace Plausible Community Edition with Umami*

View File

@ -6,7 +6,7 @@ Header always set X-Content-Type-Options "nosniff"
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" "expr=%{req_novary:X-Forwarded-Proto}=='https'" Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" "expr=%{req_novary:X-Forwarded-Proto}=='https'"
Header always set Referrer-Policy "no-referrer" Header always set Referrer-Policy "no-referrer"
Header always set Permissions-Policy "accelerometer=(), ambient-light-sensor=(), autoplay=(), battery=(), camera=(), cross-origin-isolated=(), display-capture=(), document-domain=(), encrypted-media=(), execution-while-not-rendered=(), execution-while-out-of-viewport=(), fullscreen=(), geolocation=(), gyroscope=(), keyboard-map=(), magnetometer=(), microphone=(), midi=(), navigation-override=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), sync-xhr=(), usb=(), web-share=(), xr-spatial-tracking=()" Header always set Permissions-Policy "accelerometer=(), ambient-light-sensor=(), autoplay=(), battery=(), camera=(), cross-origin-isolated=(), display-capture=(), document-domain=(), encrypted-media=(), execution-while-not-rendered=(), execution-while-out-of-viewport=(), fullscreen=(), geolocation=(), gyroscope=(), keyboard-map=(), magnetometer=(), microphone=(), midi=(), navigation-override=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), sync-xhr=(), usb=(), web-share=(), xr-spatial-tracking=()"
Header always set Content-Security-Policy "default-src 'none'; img-src 'self'; style-src 'self' 'sha256-LjAT7bhFv1zP58aCXKasCTIJMEOvFjjXkmhr/ekDANM='; base-uri 'self'; connect-src https://analytics.ethanyoo.com/ 'self'; form-action https://duckduckgo.com; frame-ancestors 'none'; script-src-elem https://analytics.ethanyoo.com/ 'self' 'sha256-RzxOh5mdjWlyRcbdPibUQG7O7WXZSthwslaZe52R7jE='; worker-src 'self'; upgrade-insecure-requests;" Header always set Content-Security-Policy "default-src 'none'; img-src 'self'; style-src 'self' 'sha256-LjAT7bhFv1zP58aCXKasCTIJMEOvFjjXkmhr/ekDANM='; base-uri 'self'; connect-src https://analytics.ethanyoo.com/ 'self'; form-action https://duckduckgo.com; frame-ancestors 'none'; script-src 'self' 'sha256-RzxOh5mdjWlyRcbdPibUQG7O7WXZSthwslaZe52R7jE='; script-src-elem 'self' 'https://analytics.ethanyoo.com'; worker-src 'self'; upgrade-insecure-requests;"
# Set custom error page: https://faq.nearlyfreespeech.net/full/error # Set custom error page: https://faq.nearlyfreespeech.net/full/error
ErrorDocument 404 /404.html ErrorDocument 404 /404.html

1
static/js/script.js Normal file
View File

@ -0,0 +1 @@
!function(){"use strict";(t=>{const{screen:{width:e,height:a},navigator:{language:r},location:n,localStorage:i,document:c,history:o}=t,{hostname:s,href:u}=n,{currentScript:l,referrer:d}=c;if(!l)return;const f="data-",m=l.getAttribute.bind(l),h=m(f+"website-id"),p=m(f+"host-url"),g=m(f+"tag"),y="false"!==m(f+"auto-track"),b="true"===m(f+"exclude-search"),v=m(f+"domains")||"",S=v.split(",").map((t=>t.trim())),w=`${(p||""||l.src.split("/").slice(0,-1).join("/")).replace(/\/$/,"")}/api/ethanyoo`,N=`${e}x${a}`,T=/data-umami-event-([\w-_]+)/,A=f+"umami-event",x=300,O=t=>{if(t){try{const e=decodeURI(t);if(e!==t)return e}catch(e){return t}return encodeURI(t)}},U=t=>{try{const{pathname:e,search:a}=new URL(t);t=e+a}catch(t){}return b?t.split("?")[0]:t},j=()=>({website:h,hostname:s,screen:N,language:r,title:O(q),url:O(D),referrer:O(_),tag:g||void 0}),k=(t,e,a)=>{a&&(_=D,D=U(a.toString()),D!==_&&setTimeout(I,x))},E=()=>!h||i&&i.getItem("umami.disabled")||v&&!S.includes(s),L=async(t,e="event")=>{if(E())return;const a={"Content-Type":"application/json"};void 0!==R&&(a["x-umami-cache"]=R);try{const r=await fetch(w,{method:"POST",body:JSON.stringify({type:e,payload:t}),headers:a}),n=await r.text();return R=n}catch(t){}},$=()=>{B||(I(),(()=>{const t=(t,e,a)=>{const r=t[e];return(...e)=>(a.apply(null,e),r.apply(t,e))};o.pushState=t(o,"pushState",k),o.replaceState=t(o,"replaceState",k)})(),(()=>{const t=new MutationObserver((([t])=>{q=t&&t.target?t.target.text:void 0})),e=c.querySelector("head > title");e&&t.observe(e,{subtree:!0,characterData:!0,childList:!0})})(),c.addEventListener("click",(async t=>{const e=t=>["BUTTON","A"].includes(t),a=async t=>{const e=t.getAttribute.bind(t),a=e(A);if(a){const r={};return t.getAttributeNames().forEach((t=>{const a=t.match(T);a&&(r[a[1]]=e(t))})),I(a,r)}},r=t.target,i=e(r.tagName)?r:((t,a)=>{let r=t;for(let t=0;t<a;t++){if(e(r.tagName))return r;if(r=r.parentElement,!r)return null}})(r,10);if(!i)return a(r);{const{href:e,target:r}=i,c=i.getAttribute(A);if(c)if("A"===i.tagName){const o="_blank"===r||t.ctrlKey||t.shiftKey||t.metaKey||t.button&&1===t.button;if(c&&e)return o||t.preventDefault(),a(i).then((()=>{o||(n.href=e)}))}else if("BUTTON"===i.tagName)return a(i)}}),!0),B=!0)},I=(t,e)=>L("string"==typeof t?{...j(),name:t,data:"object"==typeof e?e:void 0}:"object"==typeof t?t:"function"==typeof t?t(j()):j()),K=t=>L({...j(),data:t},"identify");t.umami||(t.umami={track:I,identify:K});let R,B,D=U(u),_=d!==s?d:"",q=c.title;y&&!E()&&("complete"===c.readyState?$():c.addEventListener("readystatechange",$,!0))})(window)}();

View File

@ -11,6 +11,7 @@
<link rel="openid.delegate" href="https://ethanyoo.com/"/><link rel="openid.server" href="https://openid.indieauth.com/openid"/><link rel="webmention" href="https://webmention.io/ethanyoo.com/webmention"/> <link rel="openid.delegate" href="https://ethanyoo.com/"/><link rel="openid.server" href="https://openid.indieauth.com/openid"/><link rel="webmention" href="https://webmention.io/ethanyoo.com/webmention"/>
{{- with .OutputFormats.Get "RSS" -}}{{ printf `<link rel="%s" type="%s" href="%s" title="%s">` .Rel .MediaType.Type .RelPermalink $.Site.Title | safeHTML }}{{ end }} {{- with .OutputFormats.Get "RSS" -}}{{ printf `<link rel="%s" type="%s" href="%s" title="%s">` .Rel .MediaType.Type .RelPermalink $.Site.Title | safeHTML }}{{ end }}
<link rel="stylesheet" href="/css/style.css?rnd={{ now.Unix }}"> <link rel="stylesheet" href="/css/style.css?rnd={{ now.Unix }}">
<script defer src="/js/script.js" data-website-id="ca92a149-4e82-46bf-9dc9-c85641315bff" data-host-url="https://analytics.ethanyoo.com"></script>
</head> </head>
<body> <body>
{{- if not .IsHome }}{{ partial "header" . }}{{ partialCached "search.html" . }}{{ end }} {{- if not .IsHome }}{{ partial "header" . }}{{ partialCached "search.html" . }}{{ end }}
@ -19,6 +20,5 @@
{{- block "main" . }}{{ end }} {{- block "main" . }}{{ end }}
{{ if not .IsHome }}{{ partial "footer" . }} {{ if not .IsHome }}{{ partial "footer" . }}
{{ end }} {{ end }}
<script defer data-domain="ethanyoo.com" src="https://analytics.ethanyoo.com/js/script.file-downloads.hash.outbound-links.js"></script>
</body> </body>
</html> </html>