From 6b02edd753d506f2c33f0faf109de486191d3376 Mon Sep 17 00:00:00 2001 From: jsun969 Date: Sun, 8 Dec 2024 14:18:40 +1030 Subject: [PATCH] feat: track adding course --- package.json | 1 + pnpm-lock.yaml | 8 ++++++++ src/components/SearchForm.tsx | 4 +++- tsconfig.app.json | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ee723f0..667d107 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", + "@types/umami": "^2.10.0", "@vitejs/plugin-react": "^4.3.1", "autoprefixer": "^10.4.19", "eslint": "^9.10.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2e35c49..0a9624a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -84,6 +84,9 @@ importers: '@types/react-dom': specifier: ^18.3.0 version: 18.3.0 + '@types/umami': + specifier: ^2.10.0 + version: 2.10.0 '@vitejs/plugin-react': specifier: ^4.3.1 version: 4.3.1(vite@5.4.8(@types/node@20.14.10)(terser@5.34.1)) @@ -2410,6 +2413,9 @@ packages: '@types/trusted-types@2.0.7': resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==} + '@types/umami@2.10.0': + resolution: {integrity: sha512-iWcs1KkcO3ooIi2rR9M5drmpQzlsT+sFiyWElIGmVwjdGlp+vQmy/VYIChYnF5ETqx7KrL80JfSkroS6dm37Hg==} + '@types/wrap-ansi@3.0.0': resolution: {integrity: sha512-ltIpx+kM7g/MLRZfkbL7EsCEjfzCcScLpkg37eXEtx5kmrAKBkTJwd1GIAjDSL8wTpM6Hzn5YO4pSb91BEwu1g==} @@ -8048,6 +8054,8 @@ snapshots: '@types/trusted-types@2.0.7': {} + '@types/umami@2.10.0': {} + '@types/wrap-ansi@3.0.0': {} '@typescript-eslint/eslint-plugin@8.6.0(@typescript-eslint/parser@8.6.0(eslint@9.10.0(jiti@1.21.6))(typescript@5.5.2))(eslint@9.10.0(jiti@1.21.6))(typescript@5.5.2)': diff --git a/src/components/SearchForm.tsx b/src/components/SearchForm.tsx index ec0a1b3..ca5a123 100644 --- a/src/components/SearchForm.tsx +++ b/src/components/SearchForm.tsx @@ -74,8 +74,10 @@ export const SearchForm = () => { e.preventDefault(); const course = courses?.find((c) => c.id === selectedCourseId); if (!course) return; + const name = `${course.name.subject} ${course.name.code}`; + umami.track('Add course', { subject: course.name.subject, name }); enrolledCourses.addCourse({ - name: `${course.name.subject} ${course.name.code}`, + name, id: course.id, }); setSelectedCourseId(null); diff --git a/tsconfig.app.json b/tsconfig.app.json index 2300062..22679e6 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -24,7 +24,7 @@ "noFallthroughCasesInSwitch": true, /* Testing */ - "types": ["vitest/globals"] + "types": ["vitest/globals", "umami"] }, "include": ["src", "__tests__"] }