From 565177b76f22036b0d7d3bd91360a462ffc5d7d5 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Sun, 9 Oct 2022 17:02:28 -0500 Subject: [PATCH] track midterms, date docs --- web/components/usa-map/state-election-map.tsx | 10 ++++++++-- web/pages/date-docs/index.tsx | 2 ++ web/pages/midterms.tsx | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/web/components/usa-map/state-election-map.tsx b/web/components/usa-map/state-election-map.tsx index a9a53a91..1eb5915e 100644 --- a/web/components/usa-map/state-election-map.tsx +++ b/web/components/usa-map/state-election-map.tsx @@ -7,6 +7,7 @@ import { CPMMBinaryContract } from 'common/contract' import { Customize, USAMap } from './usa-map' import { listenForContract } from 'web/lib/firebase/contracts' import { interpolateColor } from 'common/util/color' +import { track } from 'web/lib/service/analytics' export interface StateElectionMarket { creatorUsername: string @@ -35,8 +36,13 @@ export function StateElectionMap(props: { market.state, { fill: probToColor(prob, market.isWinRepublican), - clickHandler: () => - Router.push(`/${market.creatorUsername}/${market.slug}`), + clickHandler: () => { + Router.push(`/${market.creatorUsername}/${market.slug}`) + track('state election map click', { + state: market.state, + slug: market.slug, + }) + }, }, ]) diff --git a/web/pages/date-docs/index.tsx b/web/pages/date-docs/index.tsx index f25746ee..64584c5e 100644 --- a/web/pages/date-docs/index.tsx +++ b/web/pages/date-docs/index.tsx @@ -14,6 +14,7 @@ import { getUser, User } from 'web/lib/firebase/users' import { DateDocPost } from './[username]' import { NoSEO } from 'web/components/NoSEO' import { useDateDocs } from 'web/hooks/use-post' +import { useTracking } from 'web/hooks/use-tracking' export async function getStaticProps() { const dateDocs = await getDateDocs() @@ -40,6 +41,7 @@ export default function DatePage(props: { const dateDocs = useDateDocs() ?? props.dateDocs const hasDoc = dateDocs.some((d) => d.creatorId === user?.id) + useTracking('view date docs page') return ( diff --git a/web/pages/midterms.tsx b/web/pages/midterms.tsx index d14f9d0f..d9566a13 100644 --- a/web/pages/midterms.tsx +++ b/web/pages/midterms.tsx @@ -8,6 +8,7 @@ import { StateElectionMarket, StateElectionMap, } from 'web/components/usa-map/state-election-map' +import { useTracking } from 'web/hooks/use-tracking' import { getContractFromSlug } from 'web/lib/firebase/contracts' const senateMidterms: StateElectionMarket[] = [ @@ -203,6 +204,8 @@ const App = (props: { }) => { const { senateContracts, governorContracts } = props + useTracking('view midterms 2022') + return (