diff options
author | Tom Schmidt <imtomhschmidt@gmail.com> | 2018-03-10 07:31:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-10 07:31:21 +0800 |
commit | 824ee8a3dce2e3bd977edafec30dd9b84efc4280 (patch) | |
tree | abd75e02d19d7c2e9c7b8df1ebe7152e2d364a40 /packages/website | |
parent | 7116f100ee194f46d0e34782afa8f680791adc9c (diff) | |
parent | 47af38ecb8d59789af9db2079e18ee0b6e589786 (diff) | |
download | dexon-sol-tools-824ee8a3dce2e3bd977edafec30dd9b84efc4280.tar dexon-sol-tools-824ee8a3dce2e3bd977edafec30dd9b84efc4280.tar.gz dexon-sol-tools-824ee8a3dce2e3bd977edafec30dd9b84efc4280.tar.bz2 dexon-sol-tools-824ee8a3dce2e3bd977edafec30dd9b84efc4280.tar.lz dexon-sol-tools-824ee8a3dce2e3bd977edafec30dd9b84efc4280.tar.xz dexon-sol-tools-824ee8a3dce2e3bd977edafec30dd9b84efc4280.tar.zst dexon-sol-tools-824ee8a3dce2e3bd977edafec30dd9b84efc4280.zip |
Merge pull request #441 from 0xProject/feature/website/web3-logging
Add web3 provider logging to GA
Diffstat (limited to 'packages/website')
-rw-r--r-- | packages/website/ts/index.tsx | 8 | ||||
-rw-r--r-- | packages/website/ts/utils/utils.ts | 31 |
2 files changed, 38 insertions, 1 deletions
diff --git a/packages/website/ts/index.tsx b/packages/website/ts/index.tsx index c0539c6d0..1eaf6274b 100644 --- a/packages/website/ts/index.tsx +++ b/packages/website/ts/index.tsx @@ -18,6 +18,8 @@ import { tradeHistoryStorage } from 'ts/local_storage/trade_history_storage'; import { reducer, State } from 'ts/redux/reducer'; import { WebsitePaths } from 'ts/types'; import { muiTheme } from 'ts/utils/mui_theme'; +import { utils } from 'ts/utils/utils'; +import * as Web3 from 'web3'; import 'whatwg-fetch'; injectTapEventPlugin(); @@ -46,6 +48,12 @@ const LazyConnectDocumentation = createLazyComponent('Documentation', async () = ); ReactGA.initialize('UA-98720122-1'); +window.onload = () => { + const providerName = (window as any).web3 + ? utils.web3ProviderToString((window as any).web3.currentProvider) + : 'NONE'; + ReactGA.ga('set', 'dimension1', providerName); +}; const store: ReduxStore<State> = createStore(reducer); render( <Router> diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts index 308b4bb5c..82e5616e1 100644 --- a/packages/website/ts/utils/utils.ts +++ b/packages/website/ts/utils/utils.ts @@ -1,4 +1,4 @@ -import { ECSignature, ExchangeContractErrs, ZeroEx, ZeroExError } from '0x.js'; +import { ECSignature, ExchangeContractErrs, Web3Provider, ZeroEx, ZeroExError } from '0x.js'; import { constants as sharedConstants, EtherscanLinkSuffixes, Networks } from '@0xproject/react-shared'; import { BigNumber } from '@0xproject/utils'; import deepEqual = require('deep-equal'); @@ -262,6 +262,35 @@ export const utils = { ); return isTestNetwork; }, + getCurrentBaseUrl() { + const port = window.location.port; + const hasPort = !_.isUndefined(port); + const baseUrl = `https://${window.location.hostname}${hasPort ? `:${port}` : ''}`; + return baseUrl; + }, + scrollToHash(hash: string, containerId: string): void { + let finalHash = hash; + if (_.isEmpty(hash)) { + finalHash = configs.SCROLL_TOP_ID; // scroll to the top + } + + scroller.scrollTo(finalHash, { + duration: 0, + offset: 0, + containerId, + }); + }, + web3ProviderToString(provider: Web3Provider): string { + let parsedProviderName = provider.constructor.name; + if (provider.constructor.name === 'MetamaskInpageProvider') { + parsedProviderName = 'METAMASK'; + } else if (provider.constructor.name === 'EthereumProvider') { + parsedProviderName = 'MIST'; + } else if ((provider as any).isParity) { + parsedProviderName = 'PARITY'; + } + return parsedProviderName; + }, async onPageLoadAsync(): Promise<void> { if (document.readyState === 'complete') { return; // Already loaded |