simplify audio analytics
This commit is contained in:
parent
7b24fc381d
commit
3451115195
|
@ -15,7 +15,6 @@ function Entry({
|
|||
textOptions,
|
||||
nonClickable,
|
||||
isolateEntry,
|
||||
admin,
|
||||
}: {
|
||||
entry: T.DictionaryEntry;
|
||||
textOptions: T.TextOptions;
|
||||
|
@ -27,7 +26,7 @@ function Entry({
|
|||
e: React.MouseEvent<HTMLElement, MouseEvent>
|
||||
) {
|
||||
e.stopPropagation();
|
||||
playStorageAudio(entry.ts, entry.p, admin, () => null);
|
||||
playStorageAudio(entry.ts, entry.p, () => null);
|
||||
}
|
||||
return (
|
||||
<div
|
||||
|
|
|
@ -1,25 +1,19 @@
|
|||
import { Types as T, InlinePs } from "@lingdocs/ps-react";
|
||||
import { getAudioPath } from "./PlayStorageAudio";
|
||||
import { LingdocsUser } from "../types/account-types";
|
||||
import ReactGA from "react-ga4";
|
||||
|
||||
export function EntryAudioDisplay({
|
||||
entry,
|
||||
opts,
|
||||
user,
|
||||
}: {
|
||||
entry: T.DictionaryEntry;
|
||||
opts: T.TextOptions;
|
||||
user: LingdocsUser | undefined;
|
||||
}) {
|
||||
const audioPath = getAudioPath(entry.ts);
|
||||
if (!entry.a) {
|
||||
return null;
|
||||
}
|
||||
function handlePlay() {
|
||||
if (user && user.admin) {
|
||||
return;
|
||||
}
|
||||
ReactGA.event({
|
||||
category: "sounds",
|
||||
action: `play ${entry.p} - ${entry.ts}`,
|
||||
|
@ -27,12 +21,10 @@ export function EntryAudioDisplay({
|
|||
}
|
||||
|
||||
function handleDownload() {
|
||||
if (user && !user.admin) {
|
||||
ReactGA.event({
|
||||
category: "sounds",
|
||||
action: `download ${entry.p} - ${entry.ts}`,
|
||||
});
|
||||
}
|
||||
ReactGA.event({
|
||||
category: "sounds",
|
||||
action: `download ${entry.p} - ${entry.ts}`,
|
||||
});
|
||||
const documentName = `${entry.p}-${entry.ts}.mp3`;
|
||||
|
||||
fetch(audioPath)
|
||||
|
|
|
@ -7,16 +7,13 @@ export function getAudioPath(ts: number): string {
|
|||
export default function playStorageAudio(
|
||||
ts: number,
|
||||
p: string,
|
||||
admin: boolean,
|
||||
callback: () => void
|
||||
) {
|
||||
if (!ts) return;
|
||||
if (!admin) {
|
||||
ReactGA.event({
|
||||
category: "sounds",
|
||||
action: `quick play ${p} - ${ts}`,
|
||||
});
|
||||
}
|
||||
ReactGA.event({
|
||||
category: "sounds",
|
||||
action: `quick play ${p} - ${ts}`,
|
||||
});
|
||||
let audio = new Audio(getAudioPath(ts));
|
||||
audio.addEventListener("ended", () => {
|
||||
callback();
|
||||
|
|
|
@ -240,7 +240,7 @@ function IsolatedEntry({
|
|||
</div>
|
||||
</div>
|
||||
</dl>
|
||||
<EntryAudioDisplay entry={entry} opts={textOptions} user={state.user} />
|
||||
<EntryAudioDisplay entry={entry} opts={textOptions} />
|
||||
{wordlistWord && (
|
||||
<>
|
||||
{hasAttachment(wordlistWord, "audio") && (
|
||||
|
|
Loading…
Reference in New Issue