diff --git a/package-lock.json b/package-lock.json index 3b9bc4d..fe4bc1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,10 +14,12 @@ "@testing-library/user-event": "^13.5.0", "@types/he": "^1.2.3", "@types/jest": "^27.5.2", + "@types/mixpanel-browser": "^2.48.1", "@types/node": "^16.18.69", "@types/react": "^18.2.46", "@types/react-dom": "^18.2.18", "he": "^1.2.0", + "mixpanel-browser": "^2.48.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-scripts": "5.0.1", @@ -4289,6 +4291,11 @@ "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==" }, + "node_modules/@types/mixpanel-browser": { + "version": "2.48.1", + "resolved": "https://registry.npmjs.org/@types/mixpanel-browser/-/mixpanel-browser-2.48.1.tgz", + "integrity": "sha512-qcckCw9znV98KUkvImglkiVd303Fnn1NTpbKkboQS0bB1SbkNc0Qzz6M9AsS6MaKSzINN4e5z28qUBsK9Wzm5g==" + }, "node_modules/@types/node": { "version": "16.18.69", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.69.tgz", @@ -13459,6 +13466,11 @@ "node": ">=16 || 14 >=14.17" } }, + "node_modules/mixpanel-browser": { + "version": "2.48.1", + "resolved": "https://registry.npmjs.org/mixpanel-browser/-/mixpanel-browser-2.48.1.tgz", + "integrity": "sha512-vXTuUzZMg+ht7sRqyjtc3dUDy/81Z/H6FLFgFkUZJqKFaAqcx1JSXmOdY/2kmsxCkUdy5JN5zW9m9TMCk+rxGQ==" + }, "node_modules/mkdirp": { "version": "0.5.6", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", diff --git a/package.json b/package.json index ba58b60..cd0aaf1 100644 --- a/package.json +++ b/package.json @@ -9,10 +9,12 @@ "@testing-library/user-event": "^13.5.0", "@types/he": "^1.2.3", "@types/jest": "^27.5.2", + "@types/mixpanel-browser": "^2.48.1", "@types/node": "^16.18.69", "@types/react": "^18.2.46", "@types/react-dom": "^18.2.18", "he": "^1.2.0", + "mixpanel-browser": "^2.48.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-scripts": "5.0.1", @@ -48,4 +50,4 @@ "devDependencies": { "cypress": "^13.6.2" } -} \ No newline at end of file +} diff --git a/src/components/Article.tsx b/src/components/Article.tsx index 04b53a5..21d7443 100644 --- a/src/components/Article.tsx +++ b/src/components/Article.tsx @@ -3,6 +3,7 @@ import "./Article.css"; import { Link } from "./Link"; import { decode } from "he"; import React from "react"; +import mixpanel from "mixpanel-browser"; export type BentoBuzzArticle = { title: string; @@ -21,7 +22,13 @@ export const Article: FC = ({ source, }) => { return ( - + { + mixpanel.track("Article Clicked", { title, link }); + window.open(link, "_blank"); + }} + >
{source && pubDate && (
diff --git a/src/index.tsx b/src/index.tsx index 8f4e0e8..8b066ee 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -4,9 +4,17 @@ import "./index.css"; import App from "./App"; import reportWebVitals from "./reportWebVitals"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import mixpanel from "mixpanel-browser"; const queryClient = new QueryClient(); +// TODO: Move the token to an environment variable. +mixpanel.init("1bf77a736f8eda486012d28ecf258154", { + debug: true, + track_pageview: true, + persistence: "localStorage", +}); + const root = ReactDOM.createRoot( document.getElementById("root") as HTMLElement );