From ca04ef1acc63c890ba716287aa48a11bfc0f6a56 Mon Sep 17 00:00:00 2001 From: Nicholas Krebs Date: Fri, 24 May 2024 17:59:17 +0200 Subject: [PATCH 01/12] update CSP --- vercel.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vercel.json b/vercel.json index 074023d..53d6a2a 100644 --- a/vercel.json +++ b/vercel.json @@ -21,7 +21,7 @@ }, { "key": "Content-Security-Policy", - "value": "default-src 'self' https:; form-action 'self' script.google.com; script-src 'self' 'unsafe-inline' www.google-analytics.com vercel.live www.digistats.ch www.googletagmanager.com; img-src 'self' data:; font-src 'self' data: fonts.googleapis.com; style-src 'self' 'unsafe-inline' fonts.googleapis.com; connect-src 'self' vitals.vercel-insights.com *.google-analytics.com digistats.ch;" + "value": "default-src 'self' https:; script-src 'self' 'unsafe-inline' vercel.live www.digistats.ch umami.crabston.dev; img-src 'self' data:; connect-src 'self' vitals.vercel-insights.com digistats.ch;" }, { "key": "Permissions-Policy", From 23a95125f177ec4380afde011ce4373022b0cf8e Mon Sep 17 00:00:00 2001 From: Nicholas Krebs Date: Fri, 24 May 2024 18:02:04 +0200 Subject: [PATCH 02/12] remove CSP --- vercel.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/vercel.json b/vercel.json index 53d6a2a..dbca082 100644 --- a/vercel.json +++ b/vercel.json @@ -19,10 +19,6 @@ "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" }, - { - "key": "Content-Security-Policy", - "value": "default-src 'self' https:; script-src 'self' 'unsafe-inline' vercel.live www.digistats.ch umami.crabston.dev; img-src 'self' data:; connect-src 'self' vitals.vercel-insights.com digistats.ch;" - }, { "key": "Permissions-Policy", "value": "battery=(), camera=(), geolocation=(), microphone=()" From cedd0dc2455bc38264b474a5765f68c16a77554c Mon Sep 17 00:00:00 2001 From: Nicholas Krebs Date: Fri, 24 May 2024 18:12:23 +0200 Subject: [PATCH 03/12] strict to domain --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index b826c41..1686767 100644 --- a/public/index.html +++ b/public/index.html @@ -17,7 +17,7 @@ - + From 7fccc4ef0a61338244eb603e777764bbaa880833 Mon Sep 17 00:00:00 2001 From: Nicholas Krebs Date: Fri, 24 May 2024 20:56:06 +0200 Subject: [PATCH 04/12] add umami website hostname --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index 1686767..cbe117a 100644 --- a/public/index.html +++ b/public/index.html @@ -17,7 +17,7 @@ - + From 7bd6497834ca3ed78382c825b6ac00ab08871736 Mon Sep 17 00:00:00 2001 From: Nicholas Krebs Date: Mon, 9 Sep 2024 12:48:07 +0200 Subject: [PATCH 05/12] update umami host url --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index cbe117a..fafc3db 100644 --- a/public/index.html +++ b/public/index.html @@ -17,7 +17,7 @@ - + From 77ba07e37bde0eabd5bdc508477de41bcb948b86 Mon Sep 17 00:00:00 2001 From: Nicholas Krebs Date: Mon, 9 Sep 2024 13:12:34 +0200 Subject: [PATCH 06/12] track events: language switch, theme switch --- src/components/common/LanguageSwitcher.tsx | 2 ++ src/index.tsx | 4 +++- src/tools/umamiTrack.ts | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 src/tools/umamiTrack.ts diff --git a/src/components/common/LanguageSwitcher.tsx b/src/components/common/LanguageSwitcher.tsx index 4ce6bff..76db9e4 100644 --- a/src/components/common/LanguageSwitcher.tsx +++ b/src/components/common/LanguageSwitcher.tsx @@ -2,6 +2,7 @@ import React, { useEffect } from "react"; import { defaultLanguage } from "../../locales/_i18n"; import { useCookies } from "react-cookie"; import { Button, ButtonGroup } from "@mui/material"; +import umamiTrack from "../../tools/umamiTrack"; export function LanguageSwitcher() { const [, setLanguage] = React.useState(defaultLanguage); @@ -12,6 +13,7 @@ export function LanguageSwitcher() { const handleChange = (lang: string) => { setCookie("i18next", lang, {path: "/"}); setLanguage(lang); + umamiTrack("Language Switch", {language: lang}); window.location.reload(); }; diff --git a/src/index.tsx b/src/index.tsx index 2bc91b7..d816821 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -4,11 +4,12 @@ import { Box, Container, createTheme, CssBaseline, ThemeProvider, useMediaQuery import { useCookies } from "react-cookie"; import { inject } from "@vercel/analytics"; import { BrowserRouter, Route, Routes } from "react-router-dom"; +import { SpeedInsights } from "@vercel/speed-insights/react"; +import umamiTrack from "./tools/umamiTrack"; // styles import "bootstrap/dist/css/bootstrap.min.css"; import "./styles/main.sass"; -import { SpeedInsights } from "@vercel/speed-insights/react"; // components import Header from "./components/common/Header"; @@ -77,6 +78,7 @@ function App() { setCookie("colorScheme", newTheme, {path: "/", expires: expires}); setTheme(newTheme); setChecked(!checked); + umamiTrack("Theme Switch", {theme: newTheme}); }; inject(); diff --git a/src/tools/umamiTrack.ts b/src/tools/umamiTrack.ts new file mode 100644 index 0000000..ee3e41b --- /dev/null +++ b/src/tools/umamiTrack.ts @@ -0,0 +1,5 @@ +export default function umamiTrack(name: string, options: any) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + window.umami.track(name, {...options}); +} \ No newline at end of file From a7241cfb040478843a2115d3f9c03c5081b3c1a0 Mon Sep 17 00:00:00 2001 From: Nicholas Krebs Date: Mon, 9 Sep 2024 13:19:45 +0200 Subject: [PATCH 07/12] track navigation --- src/components/common/Header.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/common/Header.tsx b/src/components/common/Header.tsx index 803f8b4..a8cd3bd 100644 --- a/src/components/common/Header.tsx +++ b/src/components/common/Header.tsx @@ -8,6 +8,7 @@ import { Sections } from "../../type/page"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore import { Link } from "react-scroll"; +import umamiTrack from "../../tools/umamiTrack"; const sections = [ {key: Sections.About}, @@ -75,6 +76,7 @@ function NavLink({children, href}: NavLinkProps) { duration={500} style={{cursor: "pointer", textDecoration: "none"}} activeStyle={{color: "white"}} + onClick={() => {umamiTrack("Navigation", {href});}} > {children} From 653b23c338406dfdf62999a92b33493350823546 Mon Sep 17 00:00:00 2001 From: Nicholas Krebs Date: Mon, 9 Sep 2024 13:22:50 +0200 Subject: [PATCH 08/12] track socials --- src/components/social/SocialItem.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/social/SocialItem.tsx b/src/components/social/SocialItem.tsx index 9f02e97..04280ea 100644 --- a/src/components/social/SocialItem.tsx +++ b/src/components/social/SocialItem.tsx @@ -1,12 +1,13 @@ import { Box } from "@mui/material"; import { SocialItem as SMI } from "../../type/social"; +import umamiTrack from "../../tools/umamiTrack"; type Props = { item: SMI } export default function SocialItem({item}: Props) { return ( - + {umamiTrack("Social", {name: item.name});}}> {item.icon} From 9446bda951d891ecb04cc2348d44e88ea78b5e09 Mon Sep 17 00:00:00 2001 From: Nicholas Krebs Date: Mon, 9 Sep 2024 13:24:31 +0200 Subject: [PATCH 09/12] remove digistats analytics --- public/index.html | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/public/index.html b/public/index.html index fafc3db..44dc2d0 100644 --- a/public/index.html +++ b/public/index.html @@ -13,10 +13,7 @@
- - - - + From 7f272f1dfd53f8359f63cdb80f28093f9af8f65e Mon Sep 17 00:00:00 2001 From: Nicholas Krebs Date: Mon, 9 Sep 2024 13:32:40 +0200 Subject: [PATCH 10/12] move track to anchor in socials --- src/components/social/SocialItem.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/social/SocialItem.tsx b/src/components/social/SocialItem.tsx index 04280ea..fa10029 100644 --- a/src/components/social/SocialItem.tsx +++ b/src/components/social/SocialItem.tsx @@ -7,8 +7,8 @@ type Props = { } export default function SocialItem({item}: Props) { return ( - {umamiTrack("Social", {name: item.name});}}> -
+ + {umamiTrack("Social", {name: item.name});}}> {item.icon} From dc42424f5dea56de369812019e0fe1d4b273df9b Mon Sep 17 00:00:00 2001 From: Nicholas Krebs Date: Mon, 9 Sep 2024 13:36:06 +0200 Subject: [PATCH 11/12] fix: switching language doesn't reload page --- src/components/common/LanguageSwitcher.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/common/LanguageSwitcher.tsx b/src/components/common/LanguageSwitcher.tsx index 76db9e4..d8a01b9 100644 --- a/src/components/common/LanguageSwitcher.tsx +++ b/src/components/common/LanguageSwitcher.tsx @@ -3,6 +3,7 @@ import { defaultLanguage } from "../../locales/_i18n"; import { useCookies } from "react-cookie"; import { Button, ButtonGroup } from "@mui/material"; import umamiTrack from "../../tools/umamiTrack"; +import i18n from "i18next"; export function LanguageSwitcher() { const [, setLanguage] = React.useState(defaultLanguage); @@ -13,8 +14,8 @@ export function LanguageSwitcher() { const handleChange = (lang: string) => { setCookie("i18next", lang, {path: "/"}); setLanguage(lang); + i18n.changeLanguage(lang); umamiTrack("Language Switch", {language: lang}); - window.location.reload(); }; return ( From db8df2e3ab2cec38a58a6e1898d5180c53df4074 Mon Sep 17 00:00:00 2001 From: Nicholas Krebs Date: Mon, 9 Sep 2024 13:38:00 +0200 Subject: [PATCH 12/12] fix umami options type --- src/tools/umamiTrack.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/umamiTrack.ts b/src/tools/umamiTrack.ts index ee3e41b..2fe4ee4 100644 --- a/src/tools/umamiTrack.ts +++ b/src/tools/umamiTrack.ts @@ -1,4 +1,4 @@ -export default function umamiTrack(name: string, options: any) { +export default function umamiTrack(name: string, options: unknown) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore window.umami.track(name, {...options});