aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/website/ts')
-rw-r--r--packages/website/ts/index.tsx8
-rw-r--r--packages/website/ts/utils/utils.ts31
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