aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts
diff options
context:
space:
mode:
authorTom Schmidt <imtomhschmidt@gmail.com>2018-03-09 08:06:44 +0800
committerTom Schmidt <imtomhschmidt@gmail.com>2018-03-09 08:06:44 +0800
commitc009e9979e8590701d10fbe5f623c6e618e86fc6 (patch)
tree9653f77afe99a623bcb5b30fec423215df201489 /packages/website/ts
parentf27e943258746fc61fbf8030e5b0e0c2c193bb76 (diff)
downloaddexon-sol-tools-c009e9979e8590701d10fbe5f623c6e618e86fc6.tar.gz
dexon-sol-tools-c009e9979e8590701d10fbe5f623c6e618e86fc6.tar.zst
dexon-sol-tools-c009e9979e8590701d10fbe5f623c6e618e86fc6.zip
Added web3 provider logging
Diffstat (limited to 'packages/website/ts')
-rw-r--r--packages/website/ts/index.tsx6
-rw-r--r--packages/website/ts/utils/utils.ts26
2 files changed, 15 insertions, 17 deletions
diff --git a/packages/website/ts/index.tsx b/packages/website/ts/index.tsx
index c0539c6d0..f3ec00e35 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,10 @@ 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 3d24cb1f4..bed818351 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, ZeroEx, ZeroExError, Web3Provider } from '0x.js';
import { BigNumber } from '@0xproject/utils';
import deepEqual = require('deep-equal');
import isMobile = require('is-mobile');
@@ -309,22 +309,14 @@ export const utils = {
containerId,
});
},
- web3ProviderNameToString(web3ProviderName: string): string {
- let parsedProviderName = "UNKNOWN";
- if(web3ProviderName === "MetamaskInpageProvider") {
- parsedProviderName = "METAMASK";
- }
- else if(web3ProviderName === "EthereumProvider") {
- parsedProviderName = "MIST";
- }
- else if(web3ProviderName === "o") {
- parsedProviderName = "PARITY";
- }
- else if(web3ProviderName.indexOf("infura") !== -1) {
- parsedProviderName = "INFURA";
- }
- else if(web3ProviderName.indexOf("localhost") !== -1) {
- parsedProviderName ="LOCALHOST";
+ 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.constructor.name === 'o') {
+ parsedProviderName = 'PARITY';
}
return parsedProviderName;
},