From 0c12866b22176a3eb19641050c70b4accd47d4a6 Mon Sep 17 00:00:00 2001 From: MiniDigger | Martin Date: Mon, 23 Dec 2024 17:16:48 +0100 Subject: [PATCH] feat: add umami --- chart/templates/secret-hangar-frontend.yaml | 1 + chart/values.yaml | 1 + frontend/nuxt.config.ts | 2 + frontend/src/app.vue | 9 +++++ frontend/src/components/Homepage.vue | 1 + frontend/src/components/design/Steps.vue | 40 +++++++++++++++++-- frontend/src/components/layout/Header.vue | 24 +++++++---- .../components/projects/DownloadButton.vue | 5 +++ frontend/src/composables/useTracking.ts | 30 ++++++++++++++ .../pages/[user]/[project]/versions/new.vue | 2 +- frontend/src/pages/new.vue | 2 +- frontend/src/pages/privacy.vue | 7 +++- frontend/src/pages/tools/importer.vue | 2 +- frontend/src/types/globals.d.ts | 4 ++ 14 files changed, 116 insertions(+), 14 deletions(-) create mode 100644 frontend/src/composables/useTracking.ts diff --git a/chart/templates/secret-hangar-frontend.yaml b/chart/templates/secret-hangar-frontend.yaml index 944cd5fdb..fc50e4c28 100644 --- a/chart/templates/secret-hangar-frontend.yaml +++ b/chart/templates/secret-hangar-frontend.yaml @@ -14,3 +14,4 @@ stringData: #NITRO_CLUSTER_WORKERS: "4" SENTRY_ENV: "{{ .Values.backend.config.sentry.environment }}" NUXT_PUBLIC_TURNSTILE_SITE_KEY: "{{ .Values.frontend.config.turnstileSiteKey }}" + UMAMI_WEBSITE_ID: "{{ .Values.frontend.config.umamiWebsiteId }}" diff --git a/chart/values.yaml b/chart/values.yaml index 709199f43..61fb4812e 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -120,6 +120,7 @@ frontend: configEnv: "hangar.test" backendHost: "http://hangar-backend:8080" turnstileSiteKey: "todo" + umamiWebsiteId: "todo" backend: replicaCount: 1 diff --git a/frontend/nuxt.config.ts b/frontend/nuxt.config.ts index e226912c8..1e03fb80a 100644 --- a/frontend/nuxt.config.ts +++ b/frontend/nuxt.config.ts @@ -12,6 +12,7 @@ const backendDataHost = process.env.BACKEND_DATA_HOST || (local ? "http://localh const allowIndexing = process.env.HANGAR_ALLOW_INDEXING || "true"; const sentryDSN = process.env.SENTRY_DSN || "https://801c6e3ec217457e94b8d360e861242d@o4504989579804672.ingest.sentry.io/4504989584850944"; const sentryEnvironment = process.env.SENTRY_ENV || "local"; +const umamiWebsiteId = process.env.UMAMI_WEBSIDE_ID || "8530c6aa-8fb3-4421-8503-4e8de6bc19ef"; // hangar local; // https://v3.nuxtjs.org/api/configuration/nuxt.config export default defineNuxtConfig({ @@ -43,6 +44,7 @@ export default defineNuxtConfig({ backendHost, public: { allowIndexing, + umamiWebsiteId, sentry: { dsn: sentryDSN, environment: sentryEnvironment, diff --git a/frontend/src/app.vue b/frontend/src/app.vue index 043aa36e9..4258a17cc 100644 --- a/frontend/src/app.vue +++ b/frontend/src/app.vue @@ -3,6 +3,7 @@ import "./assets/css/main.css"; // popper needs this? import "regenerator-runtime/runtime"; import type { HangarNuxtError } from "~/types/components/error"; +import { identify } from "~/composables/useTracking"; // keep in sync with error.vue, cause reasons const runtimeConfig = useRuntimeConfig(); @@ -11,6 +12,7 @@ const settingsStore = useSettingsStore(); await settingsStore.loadSettingsClient(); useAccentColor(); settingsLog("render for user", authStore.user?.name, "with darkmode", settingsStore.darkMode); +identify(); // for some dum reason useHead will not always replace the "light" from server side with "dark" from client side so we just force it. if (import.meta.client) { @@ -31,6 +33,13 @@ useHead({ class: "background-body text-[#262626] dark:text-[#E0E6f0]", }, meta: [{ name: "robots", content: runtimeConfig.public.allowIndexing === "false" ? "noindex,nofollow" : "index,follow" }], + script: [ + { + src: "https://trk.papermc.io/api/init", + defer: true, + "data-website-id": useRuntimeConfig().public.umamiWebsiteId, + }, + ], }); onErrorCaptured((err) => { diff --git a/frontend/src/components/Homepage.vue b/frontend/src/components/Homepage.vue index 7c894a4ad..b54559b24 100644 --- a/frontend/src/components/Homepage.vue +++ b/frontend/src/components/Homepage.vue @@ -172,6 +172,7 @@ useSeo( class="rounded-l-md md:rounded-md p-4 basis-full min-w-0 dark:bg-gray-700" type="text" :placeholder="i18n.t('hangar.projectSearch.query', [projects?.pagination.count])" + v-on="useTracking('homepage-search', { platformName })" />
diff --git a/frontend/src/components/design/Steps.vue b/frontend/src/components/design/Steps.vue index bfd6263e5..63b61c306 100644 --- a/frontend/src/components/design/Steps.vue +++ b/frontend/src/components/design/Steps.vue @@ -1,5 +1,6 @@