From b5cc0ade2ecaeb2cb0687bd6bbfb41abfde86158 Mon Sep 17 00:00:00 2001 From: Ronald Moesbergen Date: Fri, 3 May 2024 13:55:42 +0200 Subject: [PATCH] feat: track robot selection and upload events in matomo (#10) --- .github/workflows/pull-request.yml | 1 - src/lib/components/core/header/Header.svelte | 1 + src/lib/components/start/RobotSelector.svelte | 2 ++ src/lib/matomo.ts | 3 ++- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 21ee016..0bd2541 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -14,7 +14,6 @@ jobs: with: node-version: "20.x" registry-url: "https://registry.npmjs.org" - cache: yarn - name: Install node modules run: yarn --frozen-lockfile --prefer-offline - name: Run Biome diff --git a/src/lib/components/core/header/Header.svelte b/src/lib/components/core/header/Header.svelte index 7bbafb8..595f028 100644 --- a/src/lib/components/core/header/Header.svelte +++ b/src/lib/components/core/header/Header.svelte @@ -53,6 +53,7 @@ import Uploader from "../popups/popups/Uploader.svelte"; import Warning from "../popups/popups/Warning.svelte"; async function upload() { + window._paq.push(["trackEvent", "Main", "UploadClicked"]); popups.open({ component: Uploader, data: { diff --git a/src/lib/components/start/RobotSelector.svelte b/src/lib/components/start/RobotSelector.svelte index f19e653..bd4d366 100644 --- a/src/lib/components/start/RobotSelector.svelte +++ b/src/lib/components/start/RobotSelector.svelte @@ -10,6 +10,8 @@ interface Props { const { robots, secondary }: Props = $props(); function select(type: Robot) { + window._paq.push(["trackEvent", "SelectRobot", type.name]); + if ("variants" in type) return selected.set(type); if ("mode" in type) { code.set(type.defaultProgram); diff --git a/src/lib/matomo.ts b/src/lib/matomo.ts index 57eec87..af3374a 100644 --- a/src/lib/matomo.ts +++ b/src/lib/matomo.ts @@ -5,10 +5,11 @@ declare global { } function initMatomo() { + // Always create the _paq array so dev code works + const _paq = (window._paq = window._paq || []); // Only track prod builds if (!import.meta.env.PROD) return; - const _paq = (window._paq = window._paq || []); const u = import.meta.env.VITE_MATOMO_URL; _paq.push(["trackPageView"]); _paq.push(["enableLinkTracking"]);