diff options
Diffstat (limited to 'src/lib/analytics.js')
-rw-r--r-- | src/lib/analytics.js | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/src/lib/analytics.js b/src/lib/analytics.js deleted file mode 100644 index c305fdb00..000000000 --- a/src/lib/analytics.js +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | import { remote } from 'electron'; | ||
2 | import querystring from 'querystring'; | ||
3 | |||
4 | import { GA_ID, STATS_API } from '../config'; | ||
5 | import { isDevMode } from '../environment'; | ||
6 | |||
7 | const debug = require('debug')('Franz:Analytics'); | ||
8 | |||
9 | const { app } = remote; | ||
10 | |||
11 | /* eslint-disable */ | ||
12 | (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | ||
13 | (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | ||
14 | m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | ||
15 | })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); | ||
16 | /* eslint-enable */ | ||
17 | |||
18 | const GA_LOCAL_STORAGE_KEY = 'gaUid'; | ||
19 | |||
20 | ga('create', GA_ID, { | ||
21 | storage: 'none', | ||
22 | clientId: localStorage.getItem(GA_LOCAL_STORAGE_KEY), | ||
23 | }); | ||
24 | |||
25 | ga((tracker) => { | ||
26 | localStorage.setItem(GA_LOCAL_STORAGE_KEY, tracker.get('clientId')); | ||
27 | }); | ||
28 | ga('set', 'checkProtocolTask', null); | ||
29 | ga('set', 'version', app.getVersion()); | ||
30 | ga('send', 'App'); | ||
31 | |||
32 | export function gaPage(page) { | ||
33 | ga('send', 'pageview', page); | ||
34 | debug('GA track page', page); | ||
35 | } | ||
36 | |||
37 | export function gaEvent(category, action, label) { | ||
38 | ga('send', 'event', category, action, label); | ||
39 | debug('GA track event', category, action, label); | ||
40 | } | ||
41 | |||
42 | export function statsEvent(key, value) { | ||
43 | const params = { | ||
44 | key, | ||
45 | value: value || key, | ||
46 | platform: process.platform, | ||
47 | version: remote.app.getVersion(), | ||
48 | }; | ||
49 | |||
50 | debug('Send Franz stats event', params); | ||
51 | |||
52 | if (!isDevMode) { | ||
53 | window.fetch(`${STATS_API}/event/?${querystring.stringify(params)}`); | ||
54 | } | ||
55 | } | ||