From 02e427a32353838ad38c46f4a857bdc803a82818 Mon Sep 17 00:00:00 2001 From: Nuno Miguel Date: Sun, 24 Nov 2024 23:46:29 +0000 Subject: [PATCH 1/5] feat: add analytics --- components/ClearSelectionButton/ClearSelectionButton.tsx | 2 ++ components/CustomToolbar/CustomToolbar.tsx | 6 ++++++ components/DarkModeToggler/DarkModeToggler.tsx | 2 ++ components/ExportButton/ExportButton.tsx | 2 ++ components/Install/Install.tsx | 1 + components/ShareButton/ShareButton.tsx | 2 ++ components/Sidebar/Sidebar.tsx | 1 + components/Themes/Themes.tsx | 4 ++++ pages/_document.tsx | 2 ++ pages/index.tsx | 2 ++ 10 files changed, 24 insertions(+) diff --git a/components/ClearSelectionButton/ClearSelectionButton.tsx b/components/ClearSelectionButton/ClearSelectionButton.tsx index 3a63875d..5d5ca7e3 100644 --- a/components/ClearSelectionButton/ClearSelectionButton.tsx +++ b/components/ClearSelectionButton/ClearSelectionButton.tsx @@ -30,6 +30,8 @@ const ClearSelectionButton = ({ type: "button", title: "Clear", className: classNameData, + "data-umami-event": "clear-selection-button", + "data-umami-event-type": isHome ? "events" : "shifts", }} > diff --git a/components/CustomToolbar/CustomToolbar.tsx b/components/CustomToolbar/CustomToolbar.tsx index 25917084..0c344ba6 100644 --- a/components/CustomToolbar/CustomToolbar.tsx +++ b/components/CustomToolbar/CustomToolbar.tsx @@ -37,6 +37,7 @@ const MobileToolbar = ({ view, onView }) => { view === "day" ? "rbc-active" : undefined } h-[2.1rem]`} onClick={() => onView("day")} + data-umami-event="day-view-button" > Day @@ -52,6 +53,7 @@ const MobileToolbar = ({ view, onView }) => { view === "week" ? "rbc-active" : undefined } h-[2.1rem]`} onClick={() => onView("week")} + data-umami-event="week-view-button" > Week @@ -67,6 +69,7 @@ const MobileToolbar = ({ view, onView }) => { view === "month" ? "rbc-active" : undefined } h-[2.1rem]`} onClick={() => onView("month")} + data-umami-event="month-view-button" > Month @@ -88,6 +91,7 @@ const DesktopToolbar = ({ view, onView }) => { // don't use condition && "result" -> className can't be a boolean className={`${view === "day" ? "rbc-active" : undefined} h-[2.1rem]`} onClick={() => onView("day")} + data-umami-event="day-view-button" > @@ -97,6 +101,7 @@ const DesktopToolbar = ({ view, onView }) => { // don't use condition && "result" -> className can't be a boolean className={`${view === "week" ? "rbc-active" : undefined} h-[2.1rem]`} onClick={() => onView("week")} + data-umami-event="week-view-button" > @@ -106,6 +111,7 @@ const DesktopToolbar = ({ view, onView }) => { // don't use condition && "result" -> className can't be a boolean className={`${view === "month" ? "rbc-active" : undefined} h-[2.1rem]`} onClick={() => onView("month")} + data-umami-event="month-view-button" > diff --git a/components/DarkModeToggler/DarkModeToggler.tsx b/components/DarkModeToggler/DarkModeToggler.tsx index 5c6f2968..b6f3fbaf 100644 --- a/components/DarkModeToggler/DarkModeToggler.tsx +++ b/components/DarkModeToggler/DarkModeToggler.tsx @@ -31,6 +31,8 @@ const DarkModeToggler = () => { : "system" ) } + data-umami-event="appearance-select" + data-umami-event-mode={theme} > diff --git a/components/ExportButton/ExportButton.tsx b/components/ExportButton/ExportButton.tsx index 0e5a4c27..cdc23e89 100644 --- a/components/ExportButton/ExportButton.tsx +++ b/components/ExportButton/ExportButton.tsx @@ -19,6 +19,8 @@ const ExportButton = ({ isHome, filters }: ExportButtonProps) => { onClick={() => setIsModalOpen(true)} title="Export" className="h-10 w-full rounded-xl p-2 font-medium leading-3 text-neutral-300 shadow-md ring-1 ring-neutral-200/50 transition-all duration-300 hover:text-neutral-900 hover:shadow-lg dark:bg-neutral-800/70 dark:text-neutral-500 dark:ring-neutral-400/20 dark:hover:text-neutral-200" + data-umami-event="export-button" + data-umami-event-type={isHome ? "events" : "shifts"} > Export diff --git a/components/Install/Install.tsx b/components/Install/Install.tsx index d3752562..21c19956 100644 --- a/components/Install/Install.tsx +++ b/components/Install/Install.tsx @@ -29,6 +29,7 @@ const Install = ({ installPwaPrompt }: InstallProps) => { diff --git a/components/ShareButton/ShareButton.tsx b/components/ShareButton/ShareButton.tsx index b09ba006..abdea1e7 100644 --- a/components/ShareButton/ShareButton.tsx +++ b/components/ShareButton/ShareButton.tsx @@ -27,6 +27,8 @@ const ShareButton = ({ className="h-10 w-10 rounded-xl p-2 font-medium leading-3 text-neutral-300 shadow-md ring-1 ring-neutral-200/50 transition-all duration-300 hover:text-neutral-900 hover:shadow-lg dark:bg-neutral-800/70 dark:text-neutral-500 dark:ring-neutral-400/20 dark:hover:text-neutral-200" title="Share" onClick={() => setIsModalOpen(true)} + data-umami-event="share-button" + data-umami-event-type={isHome ? "events" : "shifts"} > diff --git a/components/Sidebar/Sidebar.tsx b/components/Sidebar/Sidebar.tsx index 292caf79..9fc266d5 100644 --- a/components/Sidebar/Sidebar.tsx +++ b/components/Sidebar/Sidebar.tsx @@ -101,6 +101,7 @@ const Sidebar = ({ onClick={() => setIsSettings(!isSettings)} className="h-10 w-10 rounded-xl p-2 leading-3 text-neutral-300 shadow-md ring-1 ring-neutral-200/50 transition-all duration-300 hover:text-neutral-900 hover:shadow-lg focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-500 dark:bg-neutral-800/70 dark:text-neutral-500 dark:ring-neutral-400/20 dark:hover:text-neutral-200" title="Settings" + data-umami-event="settings-button" > {isSettings ? ( diff --git a/components/Themes/Themes.tsx b/components/Themes/Themes.tsx index eb78031e..913c404a 100644 --- a/components/Themes/Themes.tsx +++ b/components/Themes/Themes.tsx @@ -194,6 +194,8 @@ const Themes = ({ className="mt-2 block w-full rounded-md border-0 py-1.5 pl-3 pr-10 ring-1 ring-inset ring-neutral-300 focus:ring-2 focus:ring-cesium-900 dark:bg-neutral-800 dark:ring-neutral-400/20" value={theme} onChange={(e) => updateTheme(e.target.value)} + data-umami-event="theme-select" + data-umami-event-theme={theme} > @@ -213,6 +215,8 @@ const Themes = ({ className="block w-full rounded-md border-0 py-1.5 ring-1 ring-inset ring-neutral-300 focus:ring-2 focus:ring-cesium-900 dark:bg-neutral-800 dark:ring-neutral-400/20" value={customType} onChange={(e) => updateCustomType(e.target.value)} + data-umami-event="customize-by-select" + data-umami-event-customize-by={customType} > diff --git a/pages/_document.tsx b/pages/_document.tsx index 37fb83bb..c0ccb47b 100644 --- a/pages/_document.tsx +++ b/pages/_document.tsx @@ -1,4 +1,5 @@ import { Html, Head, Main, NextScript } from "next/document"; +import Script from "next/script"; export default function Document() { return ( @@ -70,6 +71,7 @@ export default function Document() { media="(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image" /> +