diff --git a/public/index.html b/public/index.html index b826c41..44dc2d0 100644 --- a/public/index.html +++ b/public/index.html @@ -13,11 +13,8 @@
- - - - - + + 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} diff --git a/src/components/common/LanguageSwitcher.tsx b/src/components/common/LanguageSwitcher.tsx index 4ce6bff..d8a01b9 100644 --- a/src/components/common/LanguageSwitcher.tsx +++ b/src/components/common/LanguageSwitcher.tsx @@ -2,6 +2,8 @@ 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"; +import i18n from "i18next"; export function LanguageSwitcher() { const [, setLanguage] = React.useState(defaultLanguage); @@ -12,7 +14,8 @@ export function LanguageSwitcher() { const handleChange = (lang: string) => { setCookie("i18next", lang, {path: "/"}); setLanguage(lang); - window.location.reload(); + i18n.changeLanguage(lang); + umamiTrack("Language Switch", {language: lang}); }; return ( diff --git a/src/components/social/SocialItem.tsx b/src/components/social/SocialItem.tsx index 9f02e97..fa10029 100644 --- a/src/components/social/SocialItem.tsx +++ b/src/components/social/SocialItem.tsx @@ -1,5 +1,6 @@ import { Box } from "@mui/material"; import { SocialItem as SMI } from "../../type/social"; +import umamiTrack from "../../tools/umamiTrack"; type Props = { item: SMI @@ -7,7 +8,7 @@ type Props = { export default function SocialItem({item}: Props) { return ( - + {umamiTrack("Social", {name: item.name});}}> {item.icon} 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..2fe4ee4 --- /dev/null +++ b/src/tools/umamiTrack.ts @@ -0,0 +1,5 @@ +export default function umamiTrack(name: string, options: unknown) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + window.umami.track(name, {...options}); +} \ No newline at end of file diff --git a/vercel.json b/vercel.json index 074023d..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:; 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;" - }, { "key": "Permissions-Policy", "value": "battery=(), camera=(), geolocation=(), microphone=()"