Skip to content

Commit e86da51

Browse files
committed
Add event tracking
1 parent cf0fbfc commit e86da51

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/components/FindWalletProductTable/hooks/useWalletFilters.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useRef } from "react"
12
import { useTranslation } from "next-i18next"
23

34
import { FilterOption } from "@/lib/types"
@@ -35,6 +36,7 @@ import { DEFAULT_LOCALE } from "@/lib/constants"
3536

3637
export const useWalletFilters = (): FilterOption[] => {
3738
const { t } = useTranslation("page-wallets-find-wallet")
39+
const prevNetworkArray = useRef<string[]>([])
3840
return [
3941
{
4042
title: t("page-find-wallet-device"),
@@ -452,7 +454,19 @@ export const useWalletFilters = (): FilterOption[] => {
452454
filterIndex={filterIndex}
453455
itemIndex={itemIndex}
454456
inputState={inputState}
455-
updateFilterState={updateFilterState}
457+
updateFilterState={(filterIndex, itemIndex, newInputState) => {
458+
const newArray = newInputState as string[]
459+
const oldArray = prevNetworkArray.current
460+
if (newArray.length > oldArray.length) {
461+
trackCustomEvent({
462+
eventCategory: "WalletFilterSidebar",
463+
eventAction: "network",
464+
eventName: newArray[newArray.length - 1],
465+
})
466+
}
467+
prevNetworkArray.current = newArray
468+
updateFilterState(filterIndex, itemIndex, newInputState)
469+
}}
456470
/>
457471
)
458472
},

0 commit comments

Comments
 (0)