diff --git a/browser/main/lib/AwsMobileAnalyticsConfig.js b/browser/main/lib/AwsMobileAnalyticsConfig.js index 3ec20918..1b68a044 100644 --- a/browser/main/lib/AwsMobileAnalyticsConfig.js +++ b/browser/main/lib/AwsMobileAnalyticsConfig.js @@ -3,7 +3,7 @@ const AMA = require('aws-sdk-mobile-analytics') const ConfigManager = require('browser/main/lib/ConfigManager') AWS.config.region = 'us-east-1' -if (process.env.NODE_ENV === 'production') { +if (process.env.NODE_ENV === 'production' && ConfigManager.default.get().amaEnabled) { AWS.config.credentials = new AWS.CognitoIdentityCredentials({ IdentityPoolId: 'us-east-1:xxxxxxxxxxxxxxxxxxxxxxxxx' }) @@ -14,7 +14,7 @@ if (process.env.NODE_ENV === 'production') { } function initAwsMobileAnalytics () { - if (process.env.NODE_ENV !== 'production') return + if (process.env.NODE_ENV !== 'production' || !ConfigManager.default.get().amaEnabled) return AWS.config.credentials.get((err) => { if (!err) { console.log('Cognito Identity ID: ' + AWS.config.credentials.identityId) @@ -24,12 +24,12 @@ function initAwsMobileAnalytics () { } function recordDynamitCustomEvent (type) { - if (process.env.NODE_ENV !== 'production') return + if (process.env.NODE_ENV !== 'production' || !ConfigManager.default.get().amaEnabled) return mobileAnalyticsClient.recordEvent(type) } function recordStaticCustomEvent () { - if (process.env.NODE_ENV !== 'production') return + if (process.env.NODE_ENV !== 'production' || !ConfigManager.default.get().amaEnabled) return mobileAnalyticsClient.recordEvent('UI_COLOR_THEME', { uiColorTheme: ConfigManager.default.get().ui.theme }) diff --git a/browser/main/lib/ConfigManager.js b/browser/main/lib/ConfigManager.js index 2a0b14c0..e35cdad1 100644 --- a/browser/main/lib/ConfigManager.js +++ b/browser/main/lib/ConfigManager.js @@ -14,6 +14,7 @@ export const DEFAULT_CONFIG = { navWidth: 200, sortBy: 'UPDATED_AT', // 'CREATED_AT', 'UPDATED_AT', 'APLHABETICAL' listStyle: 'DEFAULT', // 'DEFAULT', 'SMALL' + amaEnabled: true, hotkey: { toggleFinder: OSX ? 'Cmd + Alt + S' : 'Super + Alt + S', toggleMain: OSX ? 'Cmd + Alt + L' : 'Super + Alt + E' diff --git a/browser/main/modals/PreferencesModal/InfoTab.js b/browser/main/modals/PreferencesModal/InfoTab.js index 697177c7..8e1ef357 100644 --- a/browser/main/modals/PreferencesModal/InfoTab.js +++ b/browser/main/modals/PreferencesModal/InfoTab.js @@ -1,6 +1,8 @@ import React from 'react' import CSSModules from 'browser/lib/CSSModules' import styles from './InfoTab.styl' +import ConfigManager from 'browser/main/lib/ConfigManager' +import store from 'browser/main/store' const electron = require('electron') const { shell, remote } = electron @@ -11,6 +13,7 @@ class InfoTab extends React.Component { super(props) this.state = { + config: this.props.config } } @@ -19,6 +22,25 @@ class InfoTab extends React.Component { e.preventDefault() } + handleConfigChange (e) { + const newConfig = { amaEnabled: this.refs.amaEnabled.checked } + + this.setState({ config: newConfig }) + } + + handleSaveButtonClick (e) { + let newConfig = { + amaEnabled: this.state.config.amaEnabled + } + + ConfigManager.set(newConfig) + + store.dispatch({ + type: 'SET_CONFIG', + config: newConfig + }) + } + render () { return (