aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers/preferences.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/controllers/preferences.js')
-rw-r--r--app/scripts/controllers/preferences.js44
1 files changed, 43 insertions, 1 deletions
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js
index 584b6bc51..f92341353 100644
--- a/app/scripts/controllers/preferences.js
+++ b/app/scripts/controllers/preferences.js
@@ -1,6 +1,6 @@
const ObservableStore = require('obs-store')
const normalizeAddress = require('eth-sig-util').normalize
-const { isValidAddress } = require('ethereumjs-util')
+const { isValidAddress, sha3, bufferToHex } = require('ethereumjs-util')
const extend = require('xtend')
@@ -42,6 +42,8 @@ class PreferencesController {
// perform sensitive operations.
featureFlags: {},
knownMethodData: {},
+ participateInMetaMetrics: null,
+ firstTimeFlowType: null,
currentLocale: opts.initLangCode,
identities: {},
lostIdentities: {},
@@ -52,6 +54,8 @@ class PreferencesController {
},
completedOnboarding: false,
completedUiMigration: true,
+ metaMetricsId: null,
+ metaMetricsSendCount: 0,
}, opts.initState)
this.diagnostics = opts.diagnostics
@@ -92,6 +96,44 @@ class PreferencesController {
this.store.updateState({ useBlockie: val })
}
+ /**
+ * Setter for the `participateInMetaMetrics` property
+ *
+ * @param {boolean} bool Whether or not the user wants to participate in MetaMetrics
+ * @returns {string|null} the string of the new metametrics id, or null if not set
+ *
+ */
+ setParticipateInMetaMetrics (bool) {
+ this.store.updateState({ participateInMetaMetrics: bool })
+ let metaMetricsId = null
+ if (bool && !this.store.getState().metaMetricsId) {
+ metaMetricsId = bufferToHex(sha3(String(Date.now()) + String(Math.round(Math.random() * Number.MAX_SAFE_INTEGER))))
+ this.store.updateState({ metaMetricsId })
+ } else if (bool === false) {
+ this.store.updateState({ metaMetricsId })
+ }
+ return metaMetricsId
+ }
+
+ setMetaMetricsSendCount (val) {
+ this.store.updateState({ metaMetricsSendCount: val })
+ }
+
+ getMetaMetricsSendCount () {
+ return this.store.getState().metaMetricsSendCount
+ }
+
+ /**
+ * Setter for the `firstTimeFlowType` property
+ *
+ * @param {String} type Indicates the type of first time flow - create or import - the user wishes to follow
+ *
+ */
+ setFirstTimeFlowType (type) {
+ this.store.updateState({ firstTimeFlowType: type })
+ }
+
+
getSuggestedTokens () {
return this.store.getState().suggestedTokens
}