aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/AppStore.js20
-rw-r--r--src/stores/GlobalErrorStore.js5
-rw-r--r--src/stores/PaymentStore.js3
-rw-r--r--src/stores/RecipePreviewsStore.js10
-rw-r--r--src/stores/ServicesStore.js26
-rw-r--r--src/stores/SettingsStore.js2
-rw-r--r--src/stores/UserStore.js26
7 files changed, 21 insertions, 71 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index 315235ba4..61b63d52e 100644
--- a/src/stores/AppStore.js
+++ b/src/stores/AppStore.js
@@ -1,6 +1,6 @@
1import { remote, ipcRenderer, shell } from 'electron'; 1import { remote, ipcRenderer, shell } from 'electron';
2import { 2import {
3 action, computed, observable, reaction, 3 action, computed, observable,
4} from 'mobx'; 4} from 'mobx';
5import moment from 'moment'; 5import moment from 'moment';
6import { getDoNotDisturb } from '@meetfranz/electron-notification-state'; 6import { getDoNotDisturb } from '@meetfranz/electron-notification-state';
@@ -17,7 +17,6 @@ import Request from './lib/Request';
17import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config'; 17import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config';
18import { isMac } from '../environment'; 18import { isMac } from '../environment';
19import locales from '../i18n/translations'; 19import locales from '../i18n/translations';
20import { gaEvent, gaPage, statsEvent } from '../lib/analytics';
21import { onVisibilityChange } from '../helpers/visibility-helper'; 20import { onVisibilityChange } from '../helpers/visibility-helper';
22import { getLocale } from '../helpers/i18n-helpers'; 21import { getLocale } from '../helpers/i18n-helpers';
23 22
@@ -54,6 +53,8 @@ export default class AppStore extends Store {
54 53
55 @observable isOnline = navigator.onLine; 54 @observable isOnline = navigator.onLine;
56 55
56 @observable authRequestFailed = false;
57
57 @observable timeOfflineStart; 58 @observable timeOfflineStart;
58 59
59 @observable updateStatus = null; 60 @observable updateStatus = null;
@@ -113,7 +114,7 @@ export default class AppStore extends Store {
113 114
114 this.isOnline = navigator.onLine; 115 this.isOnline = navigator.onLine;
115 116
116 // Check if Franz should launch on start 117 // Check if Ferdi should launch on start
117 // Needs to be delayed a bit 118 // Needs to be delayed a bit
118 this._autoStart(); 119 this._autoStart();
119 120
@@ -173,13 +174,6 @@ export default class AppStore extends Store {
173 174
174 debug('Window is visible/focused', isVisible); 175 debug('Window is visible/focused', isVisible);
175 }); 176 });
176
177 // analytics autorun
178 reaction(() => this.stores.router.location.pathname, (pathname) => {
179 gaPage(pathname);
180 });
181
182 statsEvent('app-start');
183 } 177 }
184 178
185 @computed get cacheSize() { 179 @computed get cacheSize() {
@@ -267,8 +261,6 @@ export default class AppStore extends Store {
267 } catch (err) { 261 } catch (err) {
268 console.warn(err); 262 console.warn(err);
269 } 263 }
270
271 gaEvent('App', enable ? 'enable autostart' : 'disable autostart');
272 } 264 }
273 265
274 @action _openExternalUrl({ url }) { 266 @action _openExternalUrl({ url }) {
@@ -278,8 +270,6 @@ export default class AppStore extends Store {
278 if (isValidExternalURL(url)) { 270 if (isValidExternalURL(url)) {
279 shell.openExternal(url); 271 shell.openExternal(url);
280 } 272 }
281
282 gaEvent('External URL', 'open', parsedUrl.host);
283 } 273 }
284 274
285 @action _checkForUpdates() { 275 @action _checkForUpdates() {
@@ -373,7 +363,7 @@ export default class AppStore extends Store {
373 } 363 }
374 364
375 _muteAppHandler() { 365 _muteAppHandler() {
376 const showMessageBadgesEvenWhenMuted = this.stores.ui.showMessageBadgesEvenWhenMuted; 366 const { showMessageBadgesEvenWhenMuted } = this.stores.ui;
377 367
378 if (!showMessageBadgesEvenWhenMuted) { 368 if (!showMessageBadgesEvenWhenMuted) {
379 this.actions.app.setBadge({ unreadDirectMessageCount: 0, unreadIndirectMessageCount: 0 }); 369 this.actions.app.setBadge({ unreadDirectMessageCount: 0, unreadIndirectMessageCount: 0 });
diff --git a/src/stores/GlobalErrorStore.js b/src/stores/GlobalErrorStore.js
index 7a85c2daa..8bdafb68c 100644
--- a/src/stores/GlobalErrorStore.js
+++ b/src/stores/GlobalErrorStore.js
@@ -24,9 +24,12 @@ export default class GlobalErrorStore extends Store {
24 this.response = {}; 24 this.response = {};
25 } 25 }
26 if (this.error.status === 401) { 26 if (this.error.status === 401) {
27 this.actions.user.logout({ serverLogout: true }); 27 window.ferdi.stores.app.authRequestFailed = true;
28 // this.actions.user.logout({ serverLogout: true });
28 } 29 }
29 } 30 }
31 } else {
32 window.ferdi.stores.app.authRequestFailed = false;
30 } 33 }
31 }); 34 });
32} 35}
diff --git a/src/stores/PaymentStore.js b/src/stores/PaymentStore.js
index d4de476c8..8579812ad 100644
--- a/src/stores/PaymentStore.js
+++ b/src/stores/PaymentStore.js
@@ -3,7 +3,6 @@ import { action, observable, computed } from 'mobx';
3import Store from './lib/Store'; 3import Store from './lib/Store';
4import CachedRequest from './lib/CachedRequest'; 4import CachedRequest from './lib/CachedRequest';
5import Request from './lib/Request'; 5import Request from './lib/Request';
6import { gaEvent } from '../lib/analytics';
7 6
8export default class PaymentStore extends Store { 7export default class PaymentStore extends Store {
9 @observable plansRequest = new CachedRequest(this.api.payment, 'plans'); 8 @observable plansRequest = new CachedRequest(this.api.payment, 'plans');
@@ -26,8 +25,6 @@ export default class PaymentStore extends Store {
26 @action _createHostedPage({ planId }) { 25 @action _createHostedPage({ planId }) {
27 const request = this.createHostedPageRequest.execute(planId); 26 const request = this.createHostedPageRequest.execute(planId);
28 27
29 gaEvent('Payment', 'createHostedPage', planId);
30
31 return request; 28 return request;
32 } 29 }
33} 30}
diff --git a/src/stores/RecipePreviewsStore.js b/src/stores/RecipePreviewsStore.js
index 382820d58..989e1124a 100644
--- a/src/stores/RecipePreviewsStore.js
+++ b/src/stores/RecipePreviewsStore.js
@@ -1,11 +1,8 @@
1import { action, computed, observable } from 'mobx'; 1import { action, computed, observable } from 'mobx';
2import { debounce } from 'lodash';
3import ms from 'ms';
4 2
5import Store from './lib/Store'; 3import Store from './lib/Store';
6import CachedRequest from './lib/CachedRequest'; 4import CachedRequest from './lib/CachedRequest';
7import Request from './lib/Request'; 5import Request from './lib/Request';
8import { gaEvent } from '../lib/analytics';
9 6
10export default class RecipePreviewsStore extends Store { 7export default class RecipePreviewsStore extends Store {
11 @observable allRecipePreviewsRequest = new CachedRequest(this.api.recipePreviews, 'all'); 8 @observable allRecipePreviewsRequest = new CachedRequest(this.api.recipePreviews, 'all');
@@ -41,13 +38,6 @@ export default class RecipePreviewsStore extends Store {
41 @action _search({ needle }) { 38 @action _search({ needle }) {
42 if (needle !== '') { 39 if (needle !== '') {
43 this.searchRecipePreviewsRequest.execute(needle); 40 this.searchRecipePreviewsRequest.execute(needle);
44
45 this._analyticsSearch(needle);
46 } 41 }
47 } 42 }
48
49 // Helper
50 _analyticsSearch = debounce((needle) => {
51 gaEvent('Recipe', 'search', needle);
52 }, ms('3s'));
53} 43}
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js
index 2fc543192..876851a66 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -4,14 +4,13 @@ import {
4 computed, 4 computed,
5 observable, 5 observable,
6} from 'mobx'; 6} from 'mobx';
7import { debounce, remove } from 'lodash'; 7import { remove } from 'lodash';
8import ms from 'ms'; 8import ms from 'ms';
9 9
10import Store from './lib/Store'; 10import 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, statsEvent } from '../lib/analytics';
15import { workspaceStore } from '../features/workspaces'; 14import { workspaceStore } from '../features/workspaces';
16import { serviceLimitStore } from '../features/serviceLimit'; 15import { serviceLimitStore } from '../features/serviceLimit';
17import { RESTRICTION_TYPES } from '../models/Service'; 16import { RESTRICTION_TYPES } from '../models/Service';
@@ -181,7 +180,6 @@ export default class ServicesStore extends Store {
181 180
182 if (redirect) { 181 if (redirect) {
183 this.stores.router.push('/settings/recipes'); 182 this.stores.router.push('/settings/recipes');
184 gaEvent('Service', 'create', recipeId);
185 } 183 }
186 } 184 }
187 185
@@ -258,7 +256,6 @@ export default class ServicesStore extends Store {
258 256
259 if (redirect) { 257 if (redirect) {
260 this.stores.router.push('/settings/services'); 258 this.stores.router.push('/settings/services');
261 gaEvent('Service', 'update', service.recipe.id);
262 } 259 }
263 } 260 }
264 261
@@ -273,19 +270,14 @@ export default class ServicesStore extends Store {
273 remove(result, c => c.id === serviceId); 270 remove(result, c => c.id === serviceId);
274 }); 271 });
275 272
276 const service = this.one(serviceId);
277
278 await request._promise; 273 await request._promise;
279 this.actionStatus = request.result.status; 274 this.actionStatus = request.result.status;
280
281 gaEvent('Service', 'delete', service.recipe.id);
282 } 275 }
283 276
284 @action async _clearCache({ serviceId }) { 277 @action async _clearCache({ serviceId }) {
285 this.clearCacheRequest.reset(); 278 this.clearCacheRequest.reset();
286 const request = this.clearCacheRequest.execute(serviceId); 279 const request = this.clearCacheRequest.execute(serviceId);
287 await request._promise; 280 await request._promise;
288 gaEvent('Service', 'clear cache');
289 } 281 }
290 282
291 @action _setActive({ serviceId, keepActiveRoute }) { 283 @action _setActive({ serviceId, keepActiveRoute }) {
@@ -297,8 +289,6 @@ export default class ServicesStore extends Store {
297 }); 289 });
298 service.isActive = true; 290 service.isActive = true;
299 291
300 statsEvent('activate-service', service.recipe.id);
301
302 this._focusActiveService(); 292 this._focusActiveService();
303 } 293 }
304 294
@@ -401,7 +391,7 @@ export default class ServicesStore extends Store {
401 }, 391 },
402 }); 392 });
403 } else if (channel === 'notification') { 393 } else if (channel === 'notification') {
404 const options = args[0].options; 394 const { options } = args[0];
405 if (service.recipe.hasNotificationSound || service.isMuted || this.stores.settings.all.app.isAppMuted) { 395 if (service.recipe.hasNotificationSound || service.isMuted || this.stores.settings.all.app.isAppMuted) {
406 Object.assign(options, { 396 Object.assign(options, {
407 silent: true, 397 silent: true,
@@ -528,7 +518,7 @@ export default class ServicesStore extends Store {
528 } 518 }
529 519
530 @action _reorderService({ oldIndex, newIndex }) { 520 @action _reorderService({ oldIndex, newIndex }) {
531 const showDisabledServices = this.stores.settings.all.app.showDisabledServices; 521 const { showDisabledServices } = this.stores.settings.all.app;
532 const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]); 522 const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]);
533 const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]); 523 const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]);
534 524
@@ -547,8 +537,6 @@ export default class ServicesStore extends Store {
547 service.order = services[s.id]; 537 service.order = services[s.id];
548 }); 538 });
549 }); 539 });
550
551 this._reorderAnalytics();
552 } 540 }
553 541
554 @action _toggleNotifications({ serviceId }) { 542 @action _toggleNotifications({ serviceId }) {
@@ -624,8 +612,8 @@ export default class ServicesStore extends Store {
624 } 612 }
625 613
626 _getUnreadMessageCountReaction() { 614 _getUnreadMessageCountReaction() {
627 const showMessageBadgeWhenMuted = this.stores.settings.all.app.showMessageBadgeWhenMuted; 615 const { showMessageBadgeWhenMuted } = this.stores.settings.all.app;
628 const showMessageBadgesEvenWhenMuted = this.stores.ui.showMessageBadgesEvenWhenMuted; 616 const { showMessageBadgesEvenWhenMuted } = this.stores.ui;
629 617
630 const unreadDirectMessageCount = this.allDisplayed 618 const unreadDirectMessageCount = this.allDisplayed
631 .filter(s => (showMessageBadgeWhenMuted || s.isNotificationEnabled) && showMessageBadgesEvenWhenMuted && s.isBadgeEnabled) 619 .filter(s => (showMessageBadgeWhenMuted || s.isNotificationEnabled) && showMessageBadgesEvenWhenMuted && s.isBadgeEnabled)
@@ -750,10 +738,6 @@ export default class ServicesStore extends Store {
750 } 738 }
751 } 739 }
752 740
753 _reorderAnalytics = debounce(() => {
754 gaEvent('Service', 'order');
755 }, ms('5s'));
756
757 _wrapIndex(index, delta, size) { 741 _wrapIndex(index, delta, size) {
758 return (((index + delta) % size) + size) % size; 742 return (((index + delta) % size) + size) % size;
759 } 743 }
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js
index a456195bf..bc01291d8 100644
--- a/src/stores/SettingsStore.js
+++ b/src/stores/SettingsStore.js
@@ -8,6 +8,7 @@ import Store from './lib/Store';
8import Request from './lib/Request'; 8import Request from './lib/Request';
9import CachedRequest from './lib/CachedRequest'; 9import CachedRequest from './lib/CachedRequest';
10import { getLocale } from '../helpers/i18n-helpers'; 10import { getLocale } from '../helpers/i18n-helpers';
11import { API } from '../environment';
11 12
12import { DEFAULT_APP_SETTINGS, FILE_SYSTEM_SETTINGS_TYPES } from '../config'; 13import { DEFAULT_APP_SETTINGS, FILE_SYSTEM_SETTINGS_TYPES } from '../config';
13import { SPELLCHECKER_LOCALES } from '../i18n/languages'; 14import { SPELLCHECKER_LOCALES } from '../i18n/languages';
@@ -147,6 +148,7 @@ export default class SettingsStore extends Store {
147 runInBackground: legacySettings.runInBackground, 148 runInBackground: legacySettings.runInBackground,
148 enableSystemTray: legacySettings.enableSystemTray, 149 enableSystemTray: legacySettings.enableSystemTray,
149 minimizeToSystemTray: legacySettings.minimizeToSystemTray, 150 minimizeToSystemTray: legacySettings.minimizeToSystemTray,
151 server: API,
150 isAppMuted: legacySettings.isAppMuted, 152 isAppMuted: legacySettings.isAppMuted,
151 enableGPUAcceleration: legacySettings.enableGPUAcceleration, 153 enableGPUAcceleration: legacySettings.enableGPUAcceleration,
152 showMessageBadgeWhenMuted: legacySettings.showMessageBadgeWhenMuted, 154 showMessageBadgeWhenMuted: legacySettings.showMessageBadgeWhenMuted,
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js
index b652098f9..e1d9672b6 100644
--- a/src/stores/UserStore.js
+++ b/src/stores/UserStore.js
@@ -8,7 +8,6 @@ import { isDevMode } from '../environment';
8import Store from './lib/Store'; 8import Store from './lib/Store';
9import Request from './lib/Request'; 9import Request from './lib/Request';
10import CachedRequest from './lib/CachedRequest'; 10import CachedRequest from './lib/CachedRequest';
11import { gaEvent } from '../lib/analytics';
12import { sleep } from '../helpers/async-helpers'; 11import { sleep } from '../helpers/async-helpers';
13import { getPlan } from '../helpers/plan-helpers'; 12import { getPlan } from '../helpers/plan-helpers';
14import { PLANS } from '../config'; 13import { PLANS } from '../config';
@@ -94,7 +93,7 @@ export default class UserStore extends Store {
94 93
95 // Reactions 94 // Reactions
96 this.registerReactions([ 95 this.registerReactions([
97 this._requireAuthenticatedUser, 96 // this._requireAuthenticatedUser,
98 this._getUserData.bind(this), 97 this._getUserData.bind(this),
99 this._resetTrialActivationState.bind(this), 98 this._resetTrialActivationState.bind(this),
100 ]); 99 ]);
@@ -190,16 +189,12 @@ export default class UserStore extends Store {
190 this._setUserData(authToken); 189 this._setUserData(authToken);
191 190
192 this.stores.router.push('/'); 191 this.stores.router.push('/');
193
194 gaEvent('User', 'login');
195 } 192 }
196 193
197 @action _tokenLogin(authToken) { 194 @action _tokenLogin(authToken) {
198 this._setUserData(authToken); 195 this._setUserData(authToken);
199 196
200 this.stores.router.push('/'); 197 this.stores.router.push('/');
201
202 gaEvent('User', 'tokenLogin');
203 } 198 }
204 199
205 @action async _signup({ 200 @action async _signup({
@@ -215,13 +210,11 @@ export default class UserStore extends Store {
215 locale: this.stores.app.locale, 210 locale: this.stores.app.locale,
216 }); 211 });
217 212
218 this.hasCompletedSignup = false; 213 this.hasCompletedSignup = true;
219 214
220 this._setUserData(authToken); 215 this._setUserData(authToken);
221 216
222 this.stores.router.push(this.PRICING_ROUTE); 217 this.stores.router.push('/');
223
224 gaEvent('User', 'signup');
225 } 218 }
226 219
227 @action async _retrievePassword({ email }) { 220 @action async _retrievePassword({ email }) {
@@ -229,8 +222,6 @@ export default class UserStore extends Store {
229 222
230 await request._promise; 223 await request._promise;
231 this.actionStatus = request.result.status || []; 224 this.actionStatus = request.result.status || [];
232
233 gaEvent('User', 'retrievePassword');
234 } 225 }
235 226
236 @action async _activateTrial({ planId }) { 227 @action async _activateTrial({ planId }) {
@@ -246,9 +237,6 @@ export default class UserStore extends Store {
246 237
247 this.stores.features.featuresRequest.invalidate({ immediately: true }); 238 this.stores.features.featuresRequest.invalidate({ immediately: true });
248 this.stores.user.getUserInfoRequest.invalidate({ immediately: true }); 239 this.stores.user.getUserInfoRequest.invalidate({ immediately: true });
249
250
251 gaEvent('User', 'activateTrial');
252 } 240 }
253 241
254 @action async _invite({ invites }) { 242 @action async _invite({ invites }) {
@@ -262,8 +250,6 @@ export default class UserStore extends Store {
262 if (this.stores.router.location.pathname.includes(this.INVITE_ROUTE)) { 250 if (this.stores.router.location.pathname.includes(this.INVITE_ROUTE)) {
263 this.stores.router.push('/'); 251 this.stores.router.push('/');
264 } 252 }
265
266 gaEvent('User', 'inviteUsers');
267 } 253 }
268 254
269 @action async _update({ userData }) { 255 @action async _update({ userData }) {
@@ -273,8 +259,6 @@ export default class UserStore extends Store {
273 259
274 this.getUserInfoRequest.patch(() => response.data); 260 this.getUserInfoRequest.patch(() => response.data);
275 this.actionStatus = response.status || []; 261 this.actionStatus = response.status || [];
276
277 gaEvent('User', 'update');
278 } 262 }
279 263
280 @action _resetStatus() { 264 @action _resetStatus() {
@@ -297,12 +281,12 @@ export default class UserStore extends Store {
297 const recipes = services.filter((obj, pos, arr) => arr.map(mapObj => mapObj.recipe.id).indexOf(obj.recipe.id) === pos).map(s => s.recipe.id); 281 const recipes = services.filter((obj, pos, arr) => arr.map(mapObj => mapObj.recipe.id).indexOf(obj.recipe.id) === pos).map(s => s.recipe.id);
298 282
299 // Install recipes 283 // Install recipes
300 for (const recipe of recipes) { 284 for (const recipe of recipes) { // eslint-disable-line no-unused-vars
301 // eslint-disable-next-line 285 // eslint-disable-next-line
302 await this.stores.recipes._install({ recipeId: recipe }); 286 await this.stores.recipes._install({ recipeId: recipe });
303 } 287 }
304 288
305 for (const service of services) { 289 for (const service of services) { // eslint-disable-line no-unused-vars
306 this.actions.service.createFromLegacyService({ 290 this.actions.service.createFromLegacyService({
307 data: service, 291 data: service,
308 }); 292 });