Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error collection optin #570

Merged
merged 22 commits into from
Apr 2, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 50 additions & 32 deletions app/src/renderer/components/common/NiSessionImport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,28 @@
placeholder="Must be exactly 12 words")
form-msg(name='Seed' type='required' v-if='!$v.fields.importSeed.required')

form-group(field-id="error-collection" field-label=' ')
.ni-field-checkbox
.ni-field-checkbox-input
input#sign-up-warning(type="checkbox" v-model="fields.errorCollection")
label.ni-field-checkbox-label(for="error-collection")
| I help development of Voyager by sending automatic error reports. This can be turned off at any time.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"I'd like to opt in for remote error tracking to help improve Voyager"


.ni-session-footer
btn(icon="arrow_forward" icon-pos="right" value="Next" size="lg")
</template>

<script>
import { required, minLength, sameAs } from 'vuelidate/lib/validators'
import Btn from '@nylira/vue-button'
import Field from '@nylira/vue-field'
import FieldGroup from 'common/NiFieldGroup'
import FieldSeed from 'common/NiFieldSeed'
import FormGroup from 'common/NiFormGroup'
import FormMsg from 'common/NiFormMsg'
import FormStruct from 'common/NiFormStruct'
import { required, minLength, sameAs } from "vuelidate/lib/validators";
import Btn from "@nylira/vue-button";
import Field from "@nylira/vue-field";
import FieldGroup from "common/NiFieldGroup";
import FieldSeed from "common/NiFieldSeed";
import FormGroup from "common/NiFormGroup";
import FormMsg from "common/NiFormMsg";
import FormStruct from "common/NiFormStruct";
export default {
name: 'ni-session-import',
name: "ni-session-import",
components: {
Btn,
Field,
Expand All @@ -64,51 +71,62 @@ export default {
},
data: () => ({
fields: {
importName: '',
importPassword: '',
importPasswordConfirm: '',
importSeed: ''
importName: "",
importPassword: "",
importPasswordConfirm: "",
importSeed: ""
}
}),
methods: {
help () {
this.$store.commit('setModalHelp', true)
help() {
this.$store.commit("setModalHelp", true);
},
setState (value) {
this.$store.commit('setModalSessionState', value)
setState(value) {
this.$store.commit("setModalSessionState", value);
},
async onSubmit () {
this.$v.$touch()
if (this.$v.$error) return
async onSubmit() {
this.$v.$touch();
if (this.$v.$error) return;
try {
let key = await this.$store.dispatch('createKey', {
let key = await this.$store.dispatch("createKey", {
seedPhrase: this.fields.importSeed,
password: this.fields.importPassword,
name: this.fields.importName
})
});
if (key) {
this.$store.commit('setModalSession', false)
this.$store.commit('notify', { title: 'Welcome back!', body: 'Your account has been successfully imported.' })
this.$store.dispatch('signIn', {
this.$store.commit("setErrorCollection", {
account: this.fields.signUpName,
optin: this.fields.errorCollection
});
this.$store.commit("setModalSession", false);
this.$store.commit("notify", {
title: "Welcome back!",
body: "Your account has been successfully imported."
});
this.$store.dispatch("signIn", {
account: this.fields.importName,
password: this.fields.importPassword
})
});
}
} catch (err) {
this.$store.commit('notifyError', { title: `Couldn't create account`, body: err.message })
this.$store.commit("notifyError", {
title: `Couldn't create account`,
body: err.message
});
}
}
},
mounted () {
this.$el.querySelector('#import-seed').focus()
mounted() {
this.$el.querySelector("#import-seed").focus();
},
validations: () => ({
fields: {
importName: { required, minLength: minLength(5) },
importPassword: { required, minLength: minLength(10) },
importPasswordConfirm: { sameAsPassword: sameAs('importPassword') },
importSeed: { required }
importPasswordConfirm: { sameAsPassword: sameAs("importPassword") },
importSeed: { required },
errorCollection: false
}
})
}
};
</script>
97 changes: 60 additions & 37 deletions app/src/renderer/components/common/NiSessionSignUp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,29 @@
label.ni-field-checkbox-label(for="sign-up-backup")
| I have securely written down my seed.
form-msg(name='Backup confirmation' type='required' v-if='!$v.fields.signUpBackup.required')

form-group(field-id="error-collection" field-label=' ')
.ni-field-checkbox
.ni-field-checkbox-input
input#sign-up-warning(type="checkbox" v-model="fields.errorCollection")
label.ni-field-checkbox-label(for="error-collection")
| I help development of Voyager by sending automatic error reports. This can be turned off at any time.

.ni-session-footer
btn(icon="arrow_forward" icon-pos="right" value="Next" size="lg" :disabled="creating")
</template>

<script>
import { required, minLength, sameAs } from 'vuelidate/lib/validators'
import Btn from '@nylira/vue-button'
import Field from '@nylira/vue-field'
import FieldSeed from 'common/NiFieldSeed'
import FieldGroup from 'common/NiFieldGroup'
import FormGroup from 'common/NiFormGroup'
import FormMsg from 'common/NiFormMsg'
import FormStruct from 'common/NiFormStruct'
import { required, minLength, sameAs } from "vuelidate/lib/validators";
import Btn from "@nylira/vue-button";
import Field from "@nylira/vue-field";
import FieldSeed from "common/NiFieldSeed";
import FieldGroup from "common/NiFieldGroup";
import FormGroup from "common/NiFormGroup";
import FormMsg from "common/NiFormMsg";
import FormStruct from "common/NiFormStruct";
export default {
name: 'ni-session-sign-up',
name: "ni-session-sign-up",
components: {
Btn,
Field,
Expand All @@ -79,54 +87,69 @@ export default {
data: () => ({
creating: true,
fields: {
signUpName: '',
signUpSeed: 'Creating seed...',
signUpPassword: '',
signUpPasswordConfirm: '',
signUpName: "",
signUpSeed: "Creating seed...",
signUpPassword: "",
signUpPasswordConfirm: "",
signUpWarning: false,
signUpBackup: false
}
}),
methods: {
help () {
this.$store.commit('setModalHelp', true)
help() {
this.$store.commit("setModalHelp", true);
},
setState (value) {
this.$store.commit('setModalSessionState', value)
setState(value) {
this.$store.commit("setModalSessionState", value);
},
async onSubmit () {
this.$v.$touch()
if (this.$v.$error) return
async onSubmit() {
this.$v.$touch();
if (this.$v.$error) return;
try {
let key = await this.$store.dispatch('createKey', {
seedPhrase: this.fields.signUpSeed, password: this.fields.signUpPassword, name: this.fields.signUpName
})
let key = await this.$store.dispatch("createKey", {
seedPhrase: this.fields.signUpSeed,
password: this.fields.signUpPassword,
name: this.fields.signUpName
});
if (key) {
this.$store.commit('setModalSession', false)
this.$store.commit('notify', { title: 'Signed Up', body: 'Your account has been created.' })
this.$store.dispatch('signIn', { password: this.fields.signUpPassword, account: this.fields.signUpName })
this.$store.commit("setErrorCollection", {
account: this.fields.signUpName,
optin: this.fields.errorCollection
});
this.$store.commit("setModalSession", false);
this.$store.commit("notify", {
title: "Signed Up",
body: "Your account has been created."
});
this.$store.dispatch("signIn", {
password: this.fields.signUpPassword,
account: this.fields.signUpName
});
}
} catch (err) {
this.$store.commit('notifyError', { title: `Couldn't create account`, body: err.message })
this.$store.commit("notifyError", {
title: `Couldn't create account`,
body: err.message
});
}
}
},
mounted () {
this.$el.querySelector('#sign-up-name').focus()
this.$store.dispatch('createSeed')
.then(seedPhrase => {
this.creating = false
this.fields.signUpSeed = seedPhrase
})
mounted() {
this.$el.querySelector("#sign-up-name").focus();
this.$store.dispatch("createSeed").then(seedPhrase => {
this.creating = false;
this.fields.signUpSeed = seedPhrase;
});
},
validations: () => ({
fields: {
signUpName: { required, minLength: minLength(5) },
signUpPassword: { required, minLength: minLength(10) },
signUpPasswordConfirm: { sameAsPassword: sameAs('signUpPassword') },
signUpPasswordConfirm: { sameAsPassword: sameAs("signUpPassword") },
signUpWarning: { required },
signUpBackup: { required }
signUpBackup: { required },
errorCollection: false
}
})
}
};
</script>
39 changes: 27 additions & 12 deletions app/src/renderer/components/common/PageProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,47 @@ page(title="My Profile")
part(title='My Profile')
list-item(dt="Account Name" :dd="user.account")
list-item(dt="Address" :dd="user.address")
.ni-li
.ni-li-container
.ni-li-dl
.ni-li-dt Automatic error reports
.ni-li-dd
.ni-field-checkbox
.ni-field-checkbox-input
input(type="checkbox" :checked="user.errorCollection || undefined" @change="setErrorCollection")

.ni-session-footer
btn(icon='exit_to_app' type='button' @click.native="signOut" value='Sign Out')
</template>

<script>
import { mapGetters } from 'vuex'
import Btn from '@nylira/vue-button'
import ListItem from 'common/NiListItem'
import ToolBar from 'common/NiToolBar'
import Page from 'common/NiPage'
import Part from 'common/NiPart'
import { mapGetters } from "vuex";
import Btn from "@nylira/vue-button";
import ListItem from "common/NiListItem";
import ToolBar from "common/NiToolBar";
import Page from "common/NiPage";
import Part from "common/NiPart";
export default {
name: 'page-profile',
name: "page-profile",
components: {
Btn,
ListItem,
Page,
Part,
ToolBar
},
computed: { ...mapGetters(['user']) },
computed: { ...mapGetters(["user"]) },
methods: {
signOut () {
this.$store.dispatch('signOut')
this.$store.commit('notifySignOut')
signOut() {
this.$store.dispatch("signOut");
this.$store.commit("notifySignOut");
},
setErrorCollection() {
this.$store.commit("setErrorCollection", {
account: this.user.account,
optin: !this.user.errorCollection
});
}
}
}
};
</script>
26 changes: 25 additions & 1 deletion app/src/renderer/vuex/modules/user.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import enableGoogleAnalytics from '../../google-analytics.js'
import Raven from 'raven-js'
const config = require('../../../../../config')

export default ({ commit, node }) => {
const ERROR_COLLECTION_KEY = 'voyager_error_collection'

const state = {
atoms: 0,
signedIn: false,
accounts: [],
password: null,
account: null,
address: null
address: null,
errorCollection: false
}

const mutations = {
Expand All @@ -14,6 +21,18 @@ export default ({ commit, node }) => {
},
setAtoms (state, atoms) {
state.atoms = atoms
},
setErrorCollection (state, { account, optin }) {
localStorage.setItem(`${ERROR_COLLECTION_KEY}_${account}`, optin)
state.errorCollection = optin

Raven.uninstall().config(optin ? config.sentry_dsn_public : '').install()
if (optin) {
console.log('Analytics enabled in browser')
enableGoogleAnalytics(config.google_analytics_uid)
} else {
console.log('Analytics disabled in browser')
}
}
}

Expand Down Expand Up @@ -81,6 +100,7 @@ export default ({ commit, node }) => {

commit('setModalSession', false)
dispatch('initializeWallet', key)
dispatch('loadErrorCollection', account)
},
signOut ({ state, commit, dispatch }) {
state.password = null
Expand All @@ -89,6 +109,10 @@ export default ({ commit, node }) => {

commit('setModalSession', true)
dispatch('showInitialScreen')
},
loadErrorCollection ({ state, commit }, account) {
let errorCollection = localStorage.getItem(`${ERROR_COLLECTION_KEY}_${account}`) === 'true'
commit('setErrorCollection', { account, optin: errorCollection })
}
}

Expand Down