aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/UserStore.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores/UserStore.js')
-rw-r--r--src/stores/UserStore.js39
1 files changed, 12 insertions, 27 deletions
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js
index b652098f9..61b7d4adf 100644
--- a/src/stores/UserStore.js
+++ b/src/stores/UserStore.js
@@ -8,12 +8,11 @@ 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';
15 14
16const debug = require('debug')('Franz:UserStore'); 15const debug = require('debug')('Ferdi:UserStore');
17 16
18// TODO: split stores into UserStore and AuthStore 17// TODO: split stores into UserStore and AuthStore
19export default class UserStore extends Store { 18export default class UserStore extends Store {
@@ -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 ]);
@@ -157,7 +156,7 @@ export default class UserStore extends Store {
157 } 156 }
158 157
159 @computed get isPremium() { 158 @computed get isPremium() {
160 return !!this.data.isPremium; 159 return true;
161 } 160 }
162 161
163 @computed get isPremiumOverride() { 162 @computed get isPremiumOverride() {
@@ -172,12 +171,13 @@ export default class UserStore extends Store {
172 } 171 }
173 172
174 @computed get isPro() { 173 @computed get isPro() {
175 if (this.isPremiumOverride) return true; 174 return true;
175 // if (this.isPremiumOverride) return true;
176 176
177 if (!this.team || (!this.team.plan || this.team.state === 'expired')) return false; 177 // if (!this.team || (!this.team.plan || this.team.state === 'expired')) return false;
178 const plan = getPlan(this.team.plan); 178 // const plan = getPlan(this.team.plan);
179 179
180 return plan === PLANS.PRO || plan === PLANS.LEGACY; 180 // return plan === PLANS.PRO || plan === PLANS.LEGACY;
181 } 181 }
182 182
183 @computed get legacyServices() { 183 @computed get legacyServices() {
@@ -190,16 +190,12 @@ export default class UserStore extends Store {
190 this._setUserData(authToken); 190 this._setUserData(authToken);
191 191
192 this.stores.router.push('/'); 192 this.stores.router.push('/');
193
194 gaEvent('User', 'login');
195 } 193 }
196 194
197 @action _tokenLogin(authToken) { 195 @action _tokenLogin(authToken) {
198 this._setUserData(authToken); 196 this._setUserData(authToken);
199 197
200 this.stores.router.push('/'); 198 this.stores.router.push('/');
201
202 gaEvent('User', 'tokenLogin');
203 } 199 }
204 200
205 @action async _signup({ 201 @action async _signup({
@@ -215,13 +211,11 @@ export default class UserStore extends Store {
215 locale: this.stores.app.locale, 211 locale: this.stores.app.locale,
216 }); 212 });
217 213
218 this.hasCompletedSignup = false; 214 this.hasCompletedSignup = true;
219 215
220 this._setUserData(authToken); 216 this._setUserData(authToken);
221 217
222 this.stores.router.push(this.PRICING_ROUTE); 218 this.stores.router.push('/');
223
224 gaEvent('User', 'signup');
225 } 219 }
226 220
227 @action async _retrievePassword({ email }) { 221 @action async _retrievePassword({ email }) {
@@ -229,8 +223,6 @@ export default class UserStore extends Store {
229 223
230 await request._promise; 224 await request._promise;
231 this.actionStatus = request.result.status || []; 225 this.actionStatus = request.result.status || [];
232
233 gaEvent('User', 'retrievePassword');
234 } 226 }
235 227
236 @action async _activateTrial({ planId }) { 228 @action async _activateTrial({ planId }) {
@@ -246,9 +238,6 @@ export default class UserStore extends Store {
246 238
247 this.stores.features.featuresRequest.invalidate({ immediately: true }); 239 this.stores.features.featuresRequest.invalidate({ immediately: true });
248 this.stores.user.getUserInfoRequest.invalidate({ immediately: true }); 240 this.stores.user.getUserInfoRequest.invalidate({ immediately: true });
249
250
251 gaEvent('User', 'activateTrial');
252 } 241 }
253 242
254 @action async _invite({ invites }) { 243 @action async _invite({ invites }) {
@@ -262,8 +251,6 @@ export default class UserStore extends Store {
262 if (this.stores.router.location.pathname.includes(this.INVITE_ROUTE)) { 251 if (this.stores.router.location.pathname.includes(this.INVITE_ROUTE)) {
263 this.stores.router.push('/'); 252 this.stores.router.push('/');
264 } 253 }
265
266 gaEvent('User', 'inviteUsers');
267 } 254 }
268 255
269 @action async _update({ userData }) { 256 @action async _update({ userData }) {
@@ -273,8 +260,6 @@ export default class UserStore extends Store {
273 260
274 this.getUserInfoRequest.patch(() => response.data); 261 this.getUserInfoRequest.patch(() => response.data);
275 this.actionStatus = response.status || []; 262 this.actionStatus = response.status || [];
276
277 gaEvent('User', 'update');
278 } 263 }
279 264
280 @action _resetStatus() { 265 @action _resetStatus() {
@@ -297,12 +282,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); 282 const recipes = services.filter((obj, pos, arr) => arr.map(mapObj => mapObj.recipe.id).indexOf(obj.recipe.id) === pos).map(s => s.recipe.id);
298 283
299 // Install recipes 284 // Install recipes
300 for (const recipe of recipes) { 285 for (const recipe of recipes) { // eslint-disable-line no-unused-vars
301 // eslint-disable-next-line 286 // eslint-disable-next-line
302 await this.stores.recipes._install({ recipeId: recipe }); 287 await this.stores.recipes._install({ recipeId: recipe });
303 } 288 }
304 289
305 for (const service of services) { 290 for (const service of services) { // eslint-disable-line no-unused-vars
306 this.actions.service.createFromLegacyService({ 291 this.actions.service.createFromLegacyService({
307 data: service, 292 data: service,
308 }); 293 });