diff --git a/CHANGELOG.md b/CHANGELOG.md index 9da4f7f..af1a162 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ As this project is a user-facing application, the places in the semantic version ### Added -- Track some events to Matomo (run/abort annotation) [#166](https://github.com/spraakbanken/mink-frontend/issues/166) +- Track some events to Matomo [#166](https://github.com/spraakbanken/mink-frontend/issues/166) ### Fixed diff --git a/src/corpus/analysis/AnalysisPanel.vue b/src/corpus/analysis/AnalysisPanel.vue index df562ff..45ded7e 100644 --- a/src/corpus/analysis/AnalysisPanel.vue +++ b/src/corpus/analysis/AnalysisPanel.vue @@ -6,7 +6,6 @@ import useExports from "../exports/exports.composable"; import useJob from "../job/job.composable"; import ActionButton from "@/components/ActionButton.vue"; import PendingContent from "@/spin/PendingContent.vue"; -import { useMatomo } from "@/matomo"; const corpusId = useCorpusIdParam(); const { runJob, jobState, isJobRunning } = useJob(corpusId); @@ -14,7 +13,6 @@ const { canBeReady } = useCorpusState(corpusId); const { exports, loadExports, downloadResult, getDownloadFilename } = useExports(corpusId); const { isDone } = useCorpusState(corpusId); -const matomo = useMatomo(); const isPending = ref(false); const canRun = computed( @@ -25,7 +23,6 @@ loadExports(); async function doRunJob() { isPending.value = true; - matomo?.trackEvent("Corpus", "Run annotation", corpusId); await runJob(); isPending.value = false; } diff --git a/src/corpus/exports/exports.composable.ts b/src/corpus/exports/exports.composable.ts index e7e5da6..8aad440 100644 --- a/src/corpus/exports/exports.composable.ts +++ b/src/corpus/exports/exports.composable.ts @@ -1,11 +1,16 @@ import { computed } from "vue"; import { downloadFile } from "@/util"; +import { useMatomo } from "@/matomo"; import useMinkBackend from "@/api/backend.composable"; import { useResourceStore } from "@/store/resource.store"; import useMessenger from "@/message/messenger.composable"; export default function useExports(corpusId: string) { const resourceStore = useResourceStore(); + const mink = useMinkBackend(); + const { alertError } = useMessenger(); + const matomo = useMatomo(); + const corpus = computed(() => resourceStore.corpora[corpusId]); /** Exports sorted alphabetically by path, but "stats_*" first. */ const exports = computed(() => @@ -14,8 +19,6 @@ export default function useExports(corpusId: string) { ?.sort((a, b) => a.path.localeCompare(b.path)) .sort((a, b) => b.path.indexOf("stats_") - a.path.indexOf("stats_")), ); - const mink = useMinkBackend(); - const { alertError } = useMessenger(); async function loadExports() { const exports = await mink.loadExports(corpusId).catch(alertError); @@ -23,6 +26,7 @@ export default function useExports(corpusId: string) { } async function downloadResult() { + matomo?.trackEvent("Corpus result", "Download export archive", corpusId); const data = await mink.downloadExports(corpusId).catch(alertError); if (!data) return; downloadFile(data, getDownloadFilename()); @@ -33,11 +37,12 @@ export default function useExports(corpusId: string) { } async function downloadResultFile(path: string) { + const filename = path.split("/").pop()!; + matomo?.trackEvent("Corpus result", "Download export file", filename); const data = await mink .downloadExportFiles(corpusId, path) .catch(alertError); if (!data) return; - const filename = path.split("/").pop()!; downloadFile(data, filename); } diff --git a/src/corpus/job/JobStatus.vue b/src/corpus/job/JobStatus.vue index 65a28f8..64c75a9 100644 --- a/src/corpus/job/JobStatus.vue +++ b/src/corpus/job/JobStatus.vue @@ -1,6 +1,5 @@