From 365e22d671613725699ecad0183efff07419e005 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Mon, 15 Apr 2019 17:41:44 +0200 Subject: Add stats api --- src/lib/analytics.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/lib/analytics.js') 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 @@ import { remote } from 'electron'; -import { GA_ID } from '../config'; +import querystring from 'querystring'; + +import { GA_ID, STATS_API } from '../config'; +import { isDevMode } from '../environment'; const debug = require('debug')('Franz:Analytics'); @@ -35,3 +38,18 @@ export function gaEvent(category, action, label) { ga('send', 'event', category, action, label); debug('GA track event', category, action, label); } + +export function statsEvent(key, value) { + const params = { + key, + value, + platform: process.platform, + version: remote.app.getVersion(), + }; + + debug('Send Franz stats event', params); + + if (!isDevMode) { + window.fetch(`${STATS_API}/event/?${querystring.stringify(params)}`); + } +} -- cgit v1.2.3-70-g09d2 From 68a03fc47b28ccadc30a0b6cf36b7b12d2d19847 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Tue, 23 Apr 2019 22:27:07 +0200 Subject: add appstart event --- src/lib/analytics.js | 2 +- src/stores/AppStore.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/lib/analytics.js') diff --git a/src/lib/analytics.js b/src/lib/analytics.js index 663aafe22..c305fdb00 100644 --- a/src/lib/analytics.js +++ b/src/lib/analytics.js @@ -42,7 +42,7 @@ export function gaEvent(category, action, label) { export function statsEvent(key, value) { const params = { key, - value, + value: value || key, platform: process.platform, version: remote.app.getVersion(), }; diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index e68e797ef..72c4b4d0b 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -14,7 +14,7 @@ import Request from './lib/Request'; import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config'; import { isMac } from '../environment'; import locales from '../i18n/translations'; -import { gaEvent, gaPage } from '../lib/analytics'; +import { gaEvent, gaPage, statsEvent } from '../lib/analytics'; import { onVisibilityChange } from '../helpers/visibility-helper'; import { getLocale } from '../helpers/i18n-helpers'; @@ -174,6 +174,8 @@ export default class AppStore extends Store { reaction(() => this.stores.router.location.pathname, (pathname) => { gaPage(pathname); }); + + statsEvent('app-start'); } @computed get cacheSize() { -- cgit v1.2.3-70-g09d2