From d2a1af7c1524b62addfa2c217c2c94dd3f093ffc Mon Sep 17 00:00:00 2001 From: mantikoros Date: Thu, 16 Jun 2022 11:49:57 -0500 Subject: [PATCH] track search, track charity donation --- web/hooks/use-sort-and-query-params.tsx | 2 ++ web/pages/charity/[charitySlug].tsx | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/web/hooks/use-sort-and-query-params.tsx b/web/hooks/use-sort-and-query-params.tsx index 4430795e..672d75c5 100644 --- a/web/hooks/use-sort-and-query-params.tsx +++ b/web/hooks/use-sort-and-query-params.tsx @@ -2,6 +2,7 @@ import { defaults, debounce } from 'lodash' import { useRouter } from 'next/router' import { useEffect, useMemo, useState } from 'react' import { useSearchBox } from 'react-instantsearch-hooks-web' +import { track } from 'web/lib/service/analytics' const MARKETS_SORT = 'markets_sort' @@ -86,6 +87,7 @@ export function useUpdateQueryAndSort(props: { delete router.query.q } router.push(router, undefined, { shallow: true }) + track('search', { query }) }, 500), [router] ) diff --git a/web/pages/charity/[charitySlug].tsx b/web/pages/charity/[charitySlug].tsx index 5277f208..7c3ce51b 100644 --- a/web/pages/charity/[charitySlug].tsx +++ b/web/pages/charity/[charitySlug].tsx @@ -20,6 +20,7 @@ import Confetti from 'react-confetti' import { Donation } from 'web/components/charity/feed-items' import Image from 'next/image' import { manaToUSD } from '../../../common/util/format' +import { track } from 'web/lib/service/analytics' export default function CharityPageWrapper() { const router = useRouter() @@ -179,6 +180,7 @@ function DonationBox(props: { e.preventDefault() setIsSubmitting(true) setError(undefined) + await transact({ amount, fromId: user.id, @@ -189,9 +191,11 @@ function DonationBox(props: { category: 'CHARITY', description: `${user.name} donated M$ ${amount} to ${charity.name}`, }).catch((err) => console.log('Error', err)) + setIsSubmitting(false) setAmount(undefined) setShowConfetti(true) + track('donation', { charityId: charity.id, amount }) } return (