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