aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2019-04-15 17:41:44 +0200
committerLibravatar Stefan Malzner <stefan@adlk.io>2019-04-15 17:41:44 +0200
commit365e22d671613725699ecad0183efff07419e005 (patch)
tree9936ee23f14c9b53d807751b7a5ba5c13bac96da
parentAdd services empty state (diff)
downloadferdium-app-365e22d671613725699ecad0183efff07419e005.tar.gz
ferdium-app-365e22d671613725699ecad0183efff07419e005.tar.zst
ferdium-app-365e22d671613725699ecad0183efff07419e005.zip
Add stats api
-rw-r--r--src/config.js1
-rw-r--r--src/lib/analytics.js20
-rw-r--r--src/stores/ServicesStore.js4
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
12export const LOCAL_API = 'http://localhost:3000'; 12export const LOCAL_API = 'http://localhost:3000';
13export const DEV_API = 'https://dev.franzinfra.com'; 13export const DEV_API = 'https://dev.franzinfra.com';
14export const LIVE_API = 'https://api.franzinfra.com'; 14export const LIVE_API = 'https://api.franzinfra.com';
15export const STATS_API = 'https://stats.franzinfra.com';
15export const GA_ID = !isDevMode ? 'UA-74126766-10' : 'UA-74126766-12'; 16export const GA_ID = !isDevMode ? 'UA-74126766-10' : 'UA-74126766-12';
16 17
17export const DEFAULT_APP_SETTINGS = { 18export 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 @@
1import { remote } from 'electron'; 1import { remote } from 'electron';
2import { GA_ID } from '../config'; 2import querystring from 'querystring';
3
4import { GA_ID, STATS_API } from '../config';
5import { isDevMode } from '../environment';
3 6
4const debug = require('debug')('Franz:Analytics'); 7const 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
42export 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';
11import Request from './lib/Request'; 11import Request from './lib/Request';
12import CachedRequest from './lib/CachedRequest'; 12import CachedRequest from './lib/CachedRequest';
13import { matchRoute } from '../helpers/routing-helpers'; 13import { matchRoute } from '../helpers/routing-helpers';
14import { gaEvent } from '../lib/analytics'; 14import { gaEvent, statsEvent } from '../lib/analytics';
15import { workspaceStore } from '../features/workspaces'; 15import { workspaceStore } from '../features/workspaces';
16 16
17const debug = require('debug')('Franz:ServiceStore'); 17const 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