Skip to content

Commit

Permalink
feat: track robot selection and upload events in matomo (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmoesbergen authored May 3, 2024
1 parent fc70fb3 commit b5cc0ad
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 0 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/lib/components/core/header/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/components/start/RobotSelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/lib/matomo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
Expand Down

0 comments on commit b5cc0ad

Please sign in to comment.