Skip to content

Commit

Permalink
Feat/2413810886 gtm (#2305)
Browse files Browse the repository at this point in the history
* feat: remove react-ga

* fix: hash wallet address when sending to intercom

* feat: missing data-action-ids for Spot/Swap/Margin page dialog buttons (#2273)

* chore: ensure yield farm data-action-id's consistently named

* feat: update borrow button data-action-id (#2295)

* fix: zusd pricefeed console errors (#2293)

* feat: replace analytics opt-out link

* feat: pull GTM id from env vars

* feat: PT_BR localisations from #2308
  • Loading branch information
soulBit authored Jul 4, 2022
1 parent 42c5699 commit e0fd149
Show file tree
Hide file tree
Showing 22 changed files with 60 additions and 169 deletions.
2 changes: 1 addition & 1 deletion .env.local
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ REACT_APP_MAILCHIMP=https://gmail.us17.list-manage.com/subscribe/post?u=e66850f0
REACT_APP_TRANSAK_API_KEY=a2d23229-58f9-4ca5-a3d4-2c3d2b1b9a81
REACT_APP_TRANSAK_ENV=STAGING

REACT_APP_GOOGLE_ANALYTICS=UA-192081564-2
REACT_APP_GOOGLE_ANALYTICS=GTM-KTSX2PL

REACT_APP_INFURA_KEY=12b606df88b3420aad7828acd0f11902

Expand Down
2 changes: 1 addition & 1 deletion .env.mainnet.local
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ REACT_APP_MAILCHIMP=https://gmail.us17.list-manage.com/subscribe/post?u=e66850f0
REACT_APP_TRANSAK_API_KEY=fadc5140-4d8f-4eda-ab37-5999dfedf353
REACT_APP_TRANSAK_ENV=PRODUCTION

REACT_APP_GOOGLE_ANALYTICS=UA-192081564-2
REACT_APP_GOOGLE_ANALYTICS=GTM-KTSX2PL
REACT_APP_INFURA_KEY=12b606df88b3420aad7828acd0f11902

REACT_APP_BYPASS_MAINTENANCE=1
Expand Down
2 changes: 1 addition & 1 deletion .env.testnet
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ REACT_APP_WHITELIST=false
REACT_APP_TRANSAK_API_KEY=a2d23229-58f9-4ca5-a3d4-2c3d2b1b9a81
REACT_APP_TRANSAK_ENV=STAGING

REACT_APP_GOOGLE_ANALYTICS=UA-192081564-2
REACT_APP_GOOGLE_ANALYTICS=GTM-KTSX2PL

REACT_APP_INFURA_KEY=12b606df88b3420aad7828acd0f11902

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
"react-countdown": "2.3.1",
"react-dev-utils": "^11.0.4",
"react-dom": "16.13.0",
"react-ga": "3.3.0",
"react-helmet-async": "1.0.4",
"react-i18next": "11.3.4",
"react-mailchimp-subscribe": "2.1.0",
Expand Down
30 changes: 30 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Crypto Margin Trading with Sovryn" />
<!-- Google Tag Manager -->
<script>
(function (w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(
window,
document,
'script',
'dataLayer',
'%REACT_APP_GOOGLE_ANALYTICS%',
);
</script>
<!-- End Google Tag Manager -->
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
Expand Down Expand Up @@ -158,6 +178,16 @@
<!-- End Perpetuals Competition Info Popup -->
</head>
<body>
<!-- Google Tag Manager (noscript) -->
<noscript
><iframe
src="https://www.googletagmanager.com/ns.html?id=%REACT_APP_GOOGLE_ANALYTICS%"
height="0"
width="0"
style="display: none; visibility: hidden;"
></iframe
></noscript>
<!-- End Google Tag Manager (noscript) -->
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root">
<div class="sv-container">
Expand Down
3 changes: 0 additions & 3 deletions src/app/components/HeaderLabs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from 'react';
import { Link } from 'react-router-dom';

import { usePageViews } from 'app/hooks/useAnalytics';

import WalletConnector from '../../containers/WalletConnector';
import { LanguageToggle } from '../LanguageToggle';
import styles from './index.module.scss';
Expand All @@ -17,7 +15,6 @@ export type HeaderLabsProps = {

export const HeaderLabs: React.FC<HeaderLabsProps> = ({ helpLink }) => {
const { t } = useTranslation();
usePageViews();

return (
<header className={styles.header}>
Expand Down
69 changes: 0 additions & 69 deletions src/app/components/OptOutDialog/index.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions src/app/containers/PageContainer/PageContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
PageContextState,
PageOptions,
} from './types';
import { usePageViews } from 'app/hooks/useAnalytics';
import { DefaultHeaderComponent } from './components/DefaultHeaderComponent/DefaultHeaderComponent';
import { Footer } from './components/DefaultFooterComponent/DefaultFooterComponent';
import { FastBtcHeader } from 'app/pages/FastBtcPage/components/FastBtcHeader';
Expand Down Expand Up @@ -89,8 +88,6 @@ export const PageContainer: React.FC<Partial<HeaderContainerProps>> = ({
}
}, [options.footer, options.footerProps]);

usePageViews();

return (
<PageContext.Provider value={{ state: memoizedState, actions }}>
{maybeRenderHeader}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import React, { useState } from 'react';
import React from 'react';
import { Trans } from 'react-i18next';
import { translations } from 'locales/i18n';
import { useTranslation } from 'react-i18next';
import { discordInvite } from 'utils/classifiers';
import OptOutDialog from 'app/components/OptOutDialog';
import footerLogo from 'assets/images/footer-logo.svg';

export const Footer: React.FC = () => {
const { t } = useTranslation();
const commitHash = process.env.REACT_APP_GIT_COMMIT_ID || '';
const [optDialogOpen, setOptDialogOpen] = useState<boolean>(false);

return (
<footer className="tw-mt-4 tw-bg-gray-2 tw-text-sov-white tw-pt-5">
Expand Down Expand Up @@ -63,14 +61,15 @@ export const Footer: React.FC = () => {
</p>
</div>
</div>
<div className="tw-text-base">
<div
className="tw-cursor-pointer hover:tw-underline tw-font-base tw-text-primary tw-underline tw-mt-3 md:tw-mt-6 tw-mb-3 md:tw-mb-0"
onClick={e => setOptDialogOpen(true)}
<div className="tw-mt-3">
<a
href="https://tools.google.com/dlpage/gaoptout"
target="_blank"
rel="noopener noreferrer"
data-action-id="footer-analytics-optout"
>
{t(translations.footer.optOut)}
</div>
</a>
</div>
</div>
<div className="tw-flex tw-flex-col tw-justify-end tw-relative">
Expand Down Expand Up @@ -106,10 +105,6 @@ export const Footer: React.FC = () => {
</div>
</div>
</div>
<OptOutDialog
open={optDialogOpen}
onClose={() => setOptDialogOpen(false)}
/>
</footer>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export const ReviewDialog: React.FC<IReviewDialogProps> = ({
confirmLabel={t(translations.common.confirm)}
onConfirm={submit}
disabled={swapDialogLocked}
data-action-id="swap-reviewDialog-confirm"
/>
</div>
</Dialog>
Expand Down
17 changes: 5 additions & 12 deletions src/app/containers/WalletProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { detectWeb3Wallet } from 'utils/helpers';
import { TxRequestDialog } from 'app/components/TransactionDialog/TxRequestDialog';
import { currentChainId } from '../../../utils/classifiers';
import { actions } from './slice';
import { useEvent } from 'app/hooks/useAnalytics';
import { selectWalletProvider } from './selectors';

interface Props {
Expand Down Expand Up @@ -75,28 +74,22 @@ export function WalletProvider(props: Props) {
function WalletWatcher() {
const dispatch = useDispatch();
const { wallet, address, chainId } = useWalletContext();
const setEvent = useEvent();

useEffect(() => {
if (address) {
setEvent({
category: 'Wallet',
action: 'Engaged',
label: `${
wallet?.wallet?.getWalletType() || 'unknown'
}:${crypto.createHash('md5').update(address).digest('hex')}`,
});

intercomUpdate({
'Wallet address': address,
'Wallet address': crypto
.createHash('md5')
.update(address)
.digest('hex'),
'Wallet type': detectWeb3Wallet(),
'Wallet network': wallet?.wallet?.chainId?.toString() || 'unknown',
Environment: currentChainId,
});
}

dispatch(actions.accountChanged(address || ''));
}, [dispatch, address, setEvent, wallet?.wallet]);
}, [dispatch, address, wallet?.wallet]);

useEffect(() => {
dispatch(actions.chainChanged({ chainId, networkId: chainId }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const assetsWithoutOracle: Asset[] = [
Asset.ZUSD,
];

const excludeAssets: Asset[] = [Asset.CSOV, Asset.RDOC, Asset.MYNT];
const excludeAssets: Asset[] = [Asset.CSOV, Asset.RDOC, Asset.MYNT, Asset.ZUSD];

/**
* use this only once
Expand Down
51 changes: 0 additions & 51 deletions src/app/hooks/useAnalytics.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/pages/BorrowPage/BorrowingContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ const InnerBorrowContainer: React.FC<Props> = ({ currency }) => {
<>{t(translations.maintenance.startBorrow)}</>
) : undefined
}
dataActionId={`borrow-borrowButton-${tokenToCollarate}`}
dataActionId={`borrow-borrowButton-${currency}`}
/>
</div>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const AddLiquidityDialog: React.FC<IAddLiquidityDialogProps> = ({
tx.loading || !valid || !canInteract || addliquidityLocked
}
className="tw-rounded-lg"
data-action-id="yieldFarm-liquidityModal-confirm"
data-action-id={`yieldFarm-deposit-confirmButton-${pool.assetA}`}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export const RemoveLiquidityDialogV1: React.FC<IRemoveLiquidityDialogV1Props> =
disabled={
tx.loading || !valid || !canInteract || removeliquidityLocked
}
dataActionId={`yieldFarm-deposit-confirmButton-${pool.assetA}`}
dataActionId={`yieldFarm-withdraw-confirmButton-${pool.assetA}`}
className="tw-w-full tw-mt-2"
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export const RemoveLiquidityDialog: React.FC<IRemoveLiquidityDialogProps> = ({
tx.loading || !valid || !canInteract || removeLiquidityLocked
}
className="tw-rounded-lg"
data-action-id="yieldFarm-liquidityModal-confirm"
data-action-id={`yieldFarm-withdraw-confirmButton-${pool.assetA}`}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,9 @@ export const TradeDialogContent: React.FC<ITradeDialogContentProps> = ({
confirmLabel={t(translations.common.confirm)}
onConfirm={onSubmit}
disabled={openTradesLocked || disableButtonAfterSimulatorError}
data-action-id="margin-reviewTransaction-button-confirm"
data-action-id={`margin-reviewTransaction-${
position === TradingPosition.LONG ? 'long' : 'short'
}-confirm`}
/>
</div>
</div>
Expand Down
Loading

0 comments on commit e0fd149

Please sign in to comment.