From fdabb90f0e09335a2ffdde69ed97afa5f8c14ed5 Mon Sep 17 00:00:00 2001 From: Moody Salem Date: Tue, 1 Jun 2021 15:31:15 -0500 Subject: [PATCH] fix: fire a GA event when the locale is switched --- src/components/SwitchLocaleLink/index.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/components/SwitchLocaleLink/index.tsx b/src/components/SwitchLocaleLink/index.tsx index 59f39c8941..b4b9b23525 100644 --- a/src/components/SwitchLocaleLink/index.tsx +++ b/src/components/SwitchLocaleLink/index.tsx @@ -1,5 +1,6 @@ import { Trans } from '@lingui/macro' import React, { useMemo } from 'react' +import ReactGA from 'react-ga' import { useLocation } from 'react-router' import styled from 'styled-components/macro' import { DEFAULT_LOCALE, LOCALE_LABEL, SupportedLocale } from '../../constants/locales' @@ -38,7 +39,21 @@ export function SwitchLocaleLink() { return ( - Uniswap available in: {{LOCALE_LABEL[targetLocale]}} + Uniswap available in:{' '} + { + { + ReactGA.event({ + category: 'Localization', + action: 'Switch Locale', + label: `${activeLocale} -> ${targetLocale}`, + }) + }} + to={target} + > + {LOCALE_LABEL[targetLocale]} + + } )