aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils/analytics.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-12 18:28:34 +0800
committerGitHub <noreply@github.com>2018-03-12 18:28:34 +0800
commit76a31b6fd69038779166a2532d6d6ee677a91406 (patch)
tree85d37695519c18c9e66e53667c69eb5dd9c8c92b /packages/website/ts/utils/analytics.ts
parent0ad3d06ef969904ce1121b76ca129d25839af781 (diff)
parent8a58ffda86289d8126fa5ff56ea24f7b31f3757f (diff)
downloaddexon-sol-tools-76a31b6fd69038779166a2532d6d6ee677a91406.tar
dexon-sol-tools-76a31b6fd69038779166a2532d6d6ee677a91406.tar.gz
dexon-sol-tools-76a31b6fd69038779166a2532d6d6ee677a91406.tar.bz2
dexon-sol-tools-76a31b6fd69038779166a2532d6d6ee677a91406.tar.lz
dexon-sol-tools-76a31b6fd69038779166a2532d6d6ee677a91406.tar.xz
dexon-sol-tools-76a31b6fd69038779166a2532d6d6ee677a91406.tar.zst
dexon-sol-tools-76a31b6fd69038779166a2532d6d6ee677a91406.zip
Merge pull request #447 from 0xProject/refactorAnalytics
Refactor Website Analytics
Diffstat (limited to 'packages/website/ts/utils/analytics.ts')
-rw-r--r--packages/website/ts/utils/analytics.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/website/ts/utils/analytics.ts b/packages/website/ts/utils/analytics.ts
new file mode 100644
index 000000000..37c47c7b0
--- /dev/null
+++ b/packages/website/ts/utils/analytics.ts
@@ -0,0 +1,26 @@
+import * as _ from 'lodash';
+import * as ReactGA from 'react-ga';
+import { configs } from 'ts/utils/configs';
+import { utils } from 'ts/utils/utils';
+import * as Web3 from 'web3';
+
+export const analytics = {
+ init() {
+ ReactGA.initialize(configs.GOOGLE_ANALYTICS_ID);
+ },
+ logEvent(category: string, action: string, label: string, value?: any) {
+ ReactGA.event({
+ category,
+ action,
+ label,
+ value,
+ });
+ },
+ async logProviderAsync(web3IfExists: Web3) {
+ await utils.onPageLoadAsync();
+ const providerType = !_.isUndefined(web3IfExists)
+ ? utils.getProviderType(web3IfExists.currentProvider)
+ : 'NONE';
+ ReactGA.ga('set', 'dimension1', providerType);
+ },
+};