From c45da8c3347e9d402f9a962aa889d67a647b50d1 Mon Sep 17 00:00:00 2001 From: mantikoros <95266179+mantikoros@users.noreply.github.com> Date: Wed, 15 Jun 2022 16:34:34 -0500 Subject: [PATCH] Tracking (#511) * tracking helper functions * track everything * remove extraneous code --- web/components/add-funds-button.tsx | 2 +- web/components/answers/answer-bet-panel.tsx | 9 ++------- web/components/answers/create-answer-panel.tsx | 5 +++-- web/components/contract-search.tsx | 11 ++++++++++- web/components/contract/contract-card.tsx | 14 +++++++++++++- web/components/copy-link-button.tsx | 7 ++++++- web/components/feed/category-selector.tsx | 6 +++++- web/components/feed/feed-comments.tsx | 2 ++ web/components/follow-button.tsx | 5 +++-- web/components/following-button.tsx | 7 ++++++- web/components/liquidity-panel.tsx | 7 ++++++- web/components/nav/nav-bar.tsx | 2 ++ web/components/nav/profile-menu.tsx | 7 ++++++- web/components/nav/sidebar.tsx | 15 ++++++++++++--- web/components/share-embed-button.tsx | 7 ++++++- web/components/sign-up-prompt.tsx | 3 ++- web/components/tags-input.tsx | 2 ++ web/components/tweet-button.tsx | 2 ++ web/hooks/use-tracking.ts | 8 ++++++++ web/lib/service/analytics.ts | 15 ++++++++++++--- web/pages/[username]/[contractSlug].tsx | 7 +++++++ web/pages/[username]/index.tsx | 4 ++++ web/pages/add-funds.tsx | 5 +++++ web/pages/charity/index.tsx | 3 +++ web/pages/create.tsx | 3 +++ web/pages/home.tsx | 9 ++++++++- web/pages/leaderboards.tsx | 3 +++ 27 files changed, 142 insertions(+), 28 deletions(-) create mode 100644 web/hooks/use-tracking.ts diff --git a/web/components/add-funds-button.tsx b/web/components/add-funds-button.tsx index 14c9b063..90b24b2c 100644 --- a/web/components/add-funds-button.tsx +++ b/web/components/add-funds-button.tsx @@ -61,7 +61,7 @@ export function AddFundsButton(props: { className?: string }) { > diff --git a/web/components/answers/answer-bet-panel.tsx b/web/components/answers/answer-bet-panel.tsx index c483345c..705433b1 100644 --- a/web/components/answers/answer-bet-panel.tsx +++ b/web/components/answers/answer-bet-panel.tsx @@ -22,9 +22,9 @@ import { calculateDpmPayoutAfterCorrectBet, getDpmOutcomeProbabilityAfterBet, } from 'common/calculate-dpm' -import { firebaseLogin } from 'web/lib/firebase/users' import { Bet } from 'common/bet' import { track } from 'web/lib/service/analytics' +import { SignUpPrompt } from '../sign-up-prompt' export function AnswerBetPanel(props: { answer: Answer @@ -183,12 +183,7 @@ export function AnswerBetPanel(props: { {isSubmitting ? 'Submitting...' : 'Submit trade'} ) : ( - + )} ) diff --git a/web/components/answers/create-answer-panel.tsx b/web/components/answers/create-answer-panel.tsx index 6d9739cc..2a089f50 100644 --- a/web/components/answers/create-answer-panel.tsx +++ b/web/components/answers/create-answer-panel.tsx @@ -22,6 +22,7 @@ import { import { firebaseLogin } from 'web/lib/firebase/users' import { Bet } from 'common/bet' import { MAX_ANSWER_LENGTH } from 'common/answer' +import { withTracking } from 'web/lib/service/analytics' export function CreateAnswerPanel(props: { contract: FreeResponseContract }) { const { contract } = props @@ -143,7 +144,7 @@ export function CreateAnswerPanel(props: { contract: FreeResponseContract }) { isSubmitting && 'loading' )} disabled={!canSubmit} - onClick={submitAnswer} + onClick={withTracking(submitAnswer, 'submit answer')} > Submit answer & buy @@ -151,7 +152,7 @@ export function CreateAnswerPanel(props: { contract: FreeResponseContract }) { text && ( diff --git a/web/components/contract-search.tsx b/web/components/contract-search.tsx index e56be8b8..d9aee48a 100644 --- a/web/components/contract-search.tsx +++ b/web/components/contract-search.tsx @@ -26,6 +26,8 @@ import { EditCategoriesButton } from './feed/category-selector' import { CATEGORIES } from 'common/categories' import { Tabs } from './layout/tabs' import { EditFollowingButton } from './following-button' +import { track } from '@amplitude/analytics-browser' +import { trackCallback } from 'web/lib/service/analytics' const searchClient = algoliasearch( 'GJQPAYENIF', @@ -129,11 +131,13 @@ export function ContractSearch(props: { input: '!pl-10 !input !input-bordered shadow-none w-[100px]', resetIcon: 'mt-2 hidden sm:flex', }} + onBlur={trackCallback('search')} />