diff options
author | 2019-04-15 17:41:44 +0200 | |
---|---|---|
committer | 2019-04-15 17:41:44 +0200 | |
commit | 365e22d671613725699ecad0183efff07419e005 (patch) | |
tree | 9936ee23f14c9b53d807751b7a5ba5c13bac96da /src/lib | |
parent | Add services empty state (diff) | |
download | ferdium-app-365e22d671613725699ecad0183efff07419e005.tar.gz ferdium-app-365e22d671613725699ecad0183efff07419e005.tar.zst ferdium-app-365e22d671613725699ecad0183efff07419e005.zip |
Add stats api
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/analytics.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/lib/analytics.js b/src/lib/analytics.js index e7daa9d06..663aafe22 100644 --- a/src/lib/analytics.js +++ b/src/lib/analytics.js | |||
@@ -1,5 +1,8 @@ | |||
1 | import { remote } from 'electron'; | 1 | import { remote } from 'electron'; |
2 | import { GA_ID } from '../config'; | 2 | import querystring from 'querystring'; |
3 | |||
4 | import { GA_ID, STATS_API } from '../config'; | ||
5 | import { isDevMode } from '../environment'; | ||
3 | 6 | ||
4 | const debug = require('debug')('Franz:Analytics'); | 7 | const debug = require('debug')('Franz:Analytics'); |
5 | 8 | ||
@@ -35,3 +38,18 @@ export function gaEvent(category, action, label) { | |||
35 | ga('send', 'event', category, action, label); | 38 | ga('send', 'event', category, action, label); |
36 | debug('GA track event', category, action, label); | 39 | debug('GA track event', category, action, label); |
37 | } | 40 | } |
41 | |||
42 | export function statsEvent(key, value) { | ||
43 | const params = { | ||
44 | key, | ||
45 | value, | ||
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 | } | ||