Mailspring/internal_packages/onboarding/lib
Evan Morikawa e638e94084 feat(usage): Add a FeatureUsageStore and move Identity to the DB
Summary:
This is a WIP

Depends on D3799 on billing.nylas.com

This adds a `FeatureUsageStore` which determines whether a feature can be
used or not. It also allows us to record "using" a feature.

Feature Usage is ultimately backed by the Nylas Identity and cached
locally in the Identity object. Since feature usage is attached to the
Nylas Identity, we move the whole Identity object (except for the ID) to
the database.

This includes a migration (with tests!) to move the Nylas Identity from
the config into the Database. We still, however, need the Nylas ID to stay
in the config so it can be synchronously accessed by the /browser process
on bootup when determining what windows to show. It's also convenient to
know what the Nylas ID is by looking at the config. There's logic (with
tests!) to make sure these stay in sync. If you delete the Nylas ID from
the config, it'll be the same as logging you out.

The schema for the feature usage can be found in more detail on D3799. By
the time it reaches Nylas Mail, the Nylas ID object has a `feature_usage`
attribute that has each feature (keyed by the feature name) and
information about the plans attached to it. The schema Nylas Mail sees
looks like:

```
"feature_usage": {
   "snooze": {
     quota: 10,
     peroid: 'monthly',
     used_in_period: 8,
     feature_limit_name: 'Snooze Group A',
   },
}
```

See D3799 for more info about how these are generated.

One final change that's in here is how Stores are loaded. Most of our
core stores are loaded at require time, but now things like the
IdentityStore need to do asynchronous things on activation. In reality
most of our stores do this and it's a miracle it hasn't caused more
problems! Now when stores activate we optionally look for an `activate`
method and `await` for it. This was necessary so downstream classes (like
the Onboarding Store), see a fully initialized IdentityStore by the time
it's time to use them

Test Plan: New tests!

Reviewers: khamidou, juan, halla

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3808
2017-02-03 15:31:31 -08:00
..
decorators fix(auth) Dont allow invalid form submission with Enter key 2017-01-24 17:43:34 -08:00
account-types.es6 feat(fastmail): Add fastmail as a supported provider 2017-01-14 17:36:00 -08:00
form-error-message.jsx lint(*): Bump to ESLint 3.8 2016-10-17 18:07:35 -07:00
form-field.jsx fix(auth): ssl_required => true instead of "on" 2016-06-30 13:38:54 -07:00
main.es6 feat(pro): New Nylas identity provider, onboarding and auth 2016-05-27 14:21:19 -07:00
onboarding-actions.es6 lint(*): Fix linter errors within K2, update eslint grunt task 2016-12-01 15:38:16 -08:00
onboarding-helpers.es6 🎨 Fix to using imap-provider-settings package 2017-01-24 16:25:03 -08:00
onboarding-root.jsx fix(auth): Properly wait for acct to be inited before adding to sidebar 2017-01-24 07:34:18 -08:00
onboarding-store.es6 feat(usage): Add a FeatureUsageStore and move Identity to the DB 2017-02-03 15:31:31 -08:00
page-account-choose.jsx fix(custom-imap): Hide custom imap accounts and settings from onboarding 2017-01-12 10:25:33 -08:00
page-account-onboarding-success.jsx fix(auth): Properly wait for acct to be inited before adding to sidebar 2017-01-24 07:34:18 -08:00
page-account-settings-exchange.jsx feat(pro): New Nylas identity provider, onboarding and auth 2016-05-27 14:21:19 -07:00
page-account-settings-gmail.jsx fix(auth): Properly wait for acct to be inited before adding to sidebar 2017-01-24 07:34:18 -08:00
page-account-settings-imap.jsx fix(auth): ssl_required => true instead of "on" 2016-06-30 13:38:54 -07:00
page-account-settings.jsx fix(custom-imap): Hide custom imap accounts and settings from onboarding 2017-01-12 10:25:33 -08:00
page-authenticate.jsx feat(onboarding): add client_edition=basic to onboarding flow 2017-01-15 12:07:45 -08:00
page-initial-preferences.cjsx 🎨(rename): Update Nylas N1 to Nylas Mail 2017-01-12 12:05:44 -08:00
page-top-bar.jsx fix(onboarding): Don't allow going back into N1 signin 2016-06-08 13:48:56 -07:00
page-tutorial.jsx [N1] Changes required for implementing snooze 2017-02-02 17:05:32 -08:00
page-welcome.jsx 🎨(rename): Update Nylas N1 to Nylas Mail 2017-01-12 12:05:44 -08:00