From 67d456cb86fa81118316b6cec4ac52ac720457c9 Mon Sep 17 00:00:00 2001 From: Connor Yoh Date: Wed, 27 Aug 2025 12:43:42 +0100 Subject: [PATCH] PostHog --- frontend/package-lock.json | 65 ++++++++++++++++++++++++++++++++++++++ frontend/package.json | 1 + frontend/src/index.tsx | 12 +++++++ frontend/vite-env.d.ts | 10 ++++++ 4 files changed, 88 insertions(+) create mode 100644 frontend/vite-env.d.ts diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 817f7b17e..7e6d23d50 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -32,6 +32,7 @@ "jszip": "^3.10.1", "pdf-lib": "^1.17.1", "pdfjs-dist": "^3.11.174", + "posthog-js": "^1.261.0", "react": "^19.1.0", "react-dom": "^19.1.0", "react-i18next": "^15.5.2", @@ -1774,6 +1775,12 @@ "url": "https://opencollective.com/popperjs" } }, + "node_modules/@posthog/core": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@posthog/core/-/core-1.0.2.tgz", + "integrity": "sha512-hWk3rUtJl2crQK0WNmwg13n82hnTwB99BT99/XI5gZSvIlYZ1TPmMZE8H2dhJJ98J/rm9vYJ/UXNzw3RV5HTpQ==", + "license": "MIT" + }, "node_modules/@rolldown/pluginutils": { "version": "1.0.0-beta.9", "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.9.tgz", @@ -3813,6 +3820,17 @@ "node": ">=18" } }, + "node_modules/core-js": { + "version": "3.45.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.45.1.tgz", + "integrity": "sha512-L4NPsJlCfZsPeXukyzHFlg/i7IIVwHSItR0wg0FLNqYClJ4MQYTYLbC7EkjKYRLZF2iof2MUgN0EGy7MdQFChg==", + "hasInstallScript": true, + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", @@ -4614,6 +4632,12 @@ "reusify": "^1.0.4" } }, + "node_modules/fflate": { + "version": "0.4.8", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.4.8.tgz", + "integrity": "sha512-FJqqoDBR00Mdj9ppamLa/Y7vxm+PRmNWA67N846RvsoYVMKB4q3y/de5PA7gUmRMYK/8CMz2GDZQmCRN1wBcWA==", + "license": "MIT" + }, "node_modules/file-selector": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/file-selector/-/file-selector-2.1.2.tgz", @@ -7388,6 +7412,47 @@ "postcss": "^8.2.9" } }, + "node_modules/posthog-js": { + "version": "1.261.0", + "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.261.0.tgz", + "integrity": "sha512-jyiXqyrCU+VlpbNNVRA6OQYAVut0XZMYNELCZH+XvTd981VqbE4jXn4XCBreo7XCL2gdPgDVxUVOuzNvEuKcmw==", + "license": "SEE LICENSE IN LICENSE", + "dependencies": { + "@posthog/core": "1.0.2", + "core-js": "^3.38.1", + "fflate": "^0.4.8", + "preact": "^10.19.3", + "web-vitals": "^4.2.4" + }, + "peerDependencies": { + "@rrweb/types": "2.0.0-alpha.17", + "rrweb-snapshot": "2.0.0-alpha.17" + }, + "peerDependenciesMeta": { + "@rrweb/types": { + "optional": true + }, + "rrweb-snapshot": { + "optional": true + } + } + }, + "node_modules/posthog-js/node_modules/web-vitals": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-4.2.4.tgz", + "integrity": "sha512-r4DIlprAGwJ7YM11VZp4R884m0Vmgr6EAKe3P+kO0PPj3Unqyvv59rczf6UiGcb9Z8QxZVcqKNwv/g0WNdWwsw==", + "license": "Apache-2.0" + }, + "node_modules/preact": { + "version": "10.27.1", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.27.1.tgz", + "integrity": "sha512-V79raXEWch/rbqoNc7nT9E4ep7lu+mI3+sBmfRD4i1M73R3WLYcCtdI0ibxGVf4eQL8ZIz2nFacqEC+rmnOORQ==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/preact" + } + }, "node_modules/precinct": { "version": "12.2.0", "resolved": "https://registry.npmjs.org/precinct/-/precinct-12.2.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index eaa5f20d4..13c795fc2 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -28,6 +28,7 @@ "jszip": "^3.10.1", "pdf-lib": "^1.17.1", "pdfjs-dist": "^3.11.174", + "posthog-js": "^1.261.0", "react": "^19.1.0", "react-dom": "^19.1.0", "react-i18next": "^15.5.2", diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx index 740eec3dc..d11f0cb12 100644 --- a/frontend/src/index.tsx +++ b/frontend/src/index.tsx @@ -1,4 +1,5 @@ import '@mantine/core/styles.css'; +import '../vite-env.d.ts'; import './index.css'; // Import Tailwind CSS import React from 'react'; import ReactDOM from 'react-dom/client'; @@ -6,6 +7,7 @@ import { ColorSchemeScript } from '@mantine/core'; import { BrowserRouter } from 'react-router-dom'; import App from './App'; import './i18n'; // Initialize i18next +import { PostHogProvider } from 'posthog-js/react'; // Compute initial color scheme function getInitialScheme(): 'light' | 'dark' { @@ -27,9 +29,19 @@ const root = ReactDOM.createRoot(container); // Finds the root DOM element root.render( + + ); diff --git a/frontend/vite-env.d.ts b/frontend/vite-env.d.ts new file mode 100644 index 000000000..ca36e9027 --- /dev/null +++ b/frontend/vite-env.d.ts @@ -0,0 +1,10 @@ +/// + +interface ImportMetaEnv { + readonly VITE_PUBLIC_POSTHOG_KEY: string; + readonly VITE_PUBLIC_POSTHOG_HOST: string; +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +}