diff options
author | Stefan Malzner <stefan@adlk.io> | 2019-04-15 17:41:44 +0200 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2019-04-15 17:41:44 +0200 |
commit | 365e22d671613725699ecad0183efff07419e005 (patch) | |
tree | 9936ee23f14c9b53d807751b7a5ba5c13bac96da | |
parent | Add services empty state (diff) | |
download | ferdium-app-365e22d671613725699ecad0183efff07419e005.tar.gz ferdium-app-365e22d671613725699ecad0183efff07419e005.tar.zst ferdium-app-365e22d671613725699ecad0183efff07419e005.zip |
Add stats api
-rw-r--r-- | src/config.js | 1 | ||||
-rw-r--r-- | src/lib/analytics.js | 20 | ||||
-rw-r--r-- | src/stores/ServicesStore.js | 4 |
3 files changed, 23 insertions, 2 deletions
diff --git a/src/config.js b/src/config.js index e7745b61d..3b5ce7dda 100644 --- a/src/config.js +++ b/src/config.js | |||
@@ -12,6 +12,7 @@ export const CHECK_INTERVAL = ms('1h'); // How often should we perform checks | |||
12 | export const LOCAL_API = 'http://localhost:3000'; | 12 | export const LOCAL_API = 'http://localhost:3000'; |
13 | export const DEV_API = 'https://dev.franzinfra.com'; | 13 | export const DEV_API = 'https://dev.franzinfra.com'; |
14 | export const LIVE_API = 'https://api.franzinfra.com'; | 14 | export const LIVE_API = 'https://api.franzinfra.com'; |
15 | export const STATS_API = 'https://stats.franzinfra.com'; | ||
15 | export const GA_ID = !isDevMode ? 'UA-74126766-10' : 'UA-74126766-12'; | 16 | export const GA_ID = !isDevMode ? 'UA-74126766-10' : 'UA-74126766-12'; |
16 | 17 | ||
17 | export const DEFAULT_APP_SETTINGS = { | 18 | export const DEFAULT_APP_SETTINGS = { |
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 | } | ||
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index d04fdd0c5..13f929c2f 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -11,7 +11,7 @@ import Store from './lib/Store'; | |||
11 | import Request from './lib/Request'; | 11 | import Request from './lib/Request'; |
12 | import CachedRequest from './lib/CachedRequest'; | 12 | import CachedRequest from './lib/CachedRequest'; |
13 | import { matchRoute } from '../helpers/routing-helpers'; | 13 | import { matchRoute } from '../helpers/routing-helpers'; |
14 | import { gaEvent } from '../lib/analytics'; | 14 | import { gaEvent, statsEvent } from '../lib/analytics'; |
15 | import { workspaceStore } from '../features/workspaces'; | 15 | import { workspaceStore } from '../features/workspaces'; |
16 | 16 | ||
17 | const debug = require('debug')('Franz:ServiceStore'); | 17 | const debug = require('debug')('Franz:ServiceStore'); |
@@ -299,6 +299,8 @@ export default class ServicesStore extends Store { | |||
299 | }); | 299 | }); |
300 | service.isActive = true; | 300 | service.isActive = true; |
301 | 301 | ||
302 | statsEvent('activate-service', service.recipe.id); | ||
303 | |||
302 | this._focusActiveService(); | 304 | this._focusActiveService(); |
303 | } | 305 | } |
304 | 306 | ||