diff --git a/website/src/components/Entry.tsx b/website/src/components/Entry.tsx index 68c1ff8..aacf165 100644 --- a/website/src/components/Entry.tsx +++ b/website/src/components/Entry.tsx @@ -25,7 +25,7 @@ function Entry({ e: React.MouseEvent ) { e.stopPropagation(); - playStorageAudio(entry.ts, () => null); + playStorageAudio(entry.ts, entry.p, () => null); } return (
@@ -21,6 +34,7 @@ export function EntryAudioDisplay({ controlsList="nofullscreen" src={getAudioPath(entry.ts)} preload="auto" + onPlay={handlePlay} > Download audio for{" "} diff --git a/website/src/components/PlayStorageAudio.tsx b/website/src/components/PlayStorageAudio.tsx index de8d62c..4b14c0b 100644 --- a/website/src/components/PlayStorageAudio.tsx +++ b/website/src/components/PlayStorageAudio.tsx @@ -1,9 +1,19 @@ +import ReactGA from "react-ga4"; + export function getAudioPath(ts: number): string { return `https://storage.lingdocs.com/audio/${ts}.mp3`; } -export default function playStorageAudio(ts: number, callback: () => void) { +export default function playStorageAudio( + ts: number, + p: string, + callback: () => void +) { if (!ts) return; + ReactGA.event({ + category: "sounds", + action: `play ${ts} - ${p}`, + }); let audio = new Audio(getAudioPath(ts)); audio.addEventListener("ended", () => { callback(); diff --git a/website/src/screens/IsolatedEntry.tsx b/website/src/screens/IsolatedEntry.tsx index cae45dc..d0df49f 100644 --- a/website/src/screens/IsolatedEntry.tsx +++ b/website/src/screens/IsolatedEntry.tsx @@ -227,7 +227,7 @@ function IsolatedEntry({
- + {wordlistWord && ( <> {hasAttachment(wordlistWord, "audio") && (