From 275e3317a38a3c6f39466ee9a68db3f1cb42e911 Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Sat, 22 Jul 2017 08:59:27 +0900 Subject: [PATCH 1/5] Add checkbox for ama --- browser/main/lib/AwsMobileAnalyticsConfig.js | 8 ++--- browser/main/lib/ConfigManager.js | 1 + .../main/modals/PreferencesModal/InfoTab.js | 29 +++++++++++++++++++ browser/main/modals/PreferencesModal/index.js | 7 ++++- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/browser/main/lib/AwsMobileAnalyticsConfig.js b/browser/main/lib/AwsMobileAnalyticsConfig.js index 3ec209187..1b68a044f 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 2a0b14c03..e35cdad18 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 697177c77..8e1ef3577 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 (
@@ -68,6 +90,13 @@ class InfoTab extends React.Component { License: GPL v3 + this.handleConfigChange(e)} + checked={this.state.config.amaEnabled} + ref='amaEnabled' + type='checkbox' + /> + Enable to send analytics to our servers +
) } diff --git a/browser/main/modals/PreferencesModal/index.js b/browser/main/modals/PreferencesModal/index.js index 278927fd9..c7b9a68db 100644 --- a/browser/main/modals/PreferencesModal/index.js +++ b/browser/main/modals/PreferencesModal/index.js @@ -44,7 +44,12 @@ class Preferences extends React.Component { switch (this.state.currentTab) { case 'INFO': - return + return ( + + ) case 'HOTKEY': return ( Date: Sat, 22 Jul 2017 13:58:02 +0900 Subject: [PATCH 2/5] Add policy --- browser/main/modals/PreferencesModal/InfoTab.js | 11 ++++++++++- browser/main/modals/PreferencesModal/InfoTab.styl | 7 +++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/browser/main/modals/PreferencesModal/InfoTab.js b/browser/main/modals/PreferencesModal/InfoTab.js index 8e1ef3577..e92e77a74 100644 --- a/browser/main/modals/PreferencesModal/InfoTab.js +++ b/browser/main/modals/PreferencesModal/InfoTab.js @@ -3,6 +3,7 @@ import CSSModules from 'browser/lib/CSSModules' import styles from './InfoTab.styl' import ConfigManager from 'browser/main/lib/ConfigManager' import store from 'browser/main/store' +import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig' const electron = require('electron') const { shell, remote } = electron @@ -39,6 +40,9 @@ class InfoTab extends React.Component { type: 'SET_CONFIG', config: newConfig }) + if (newConfig.amaEnabled) { + AwsMobileAnalyticsConfig.recordDynamitCustomEvent('DISABLE_AMA') + } } render () { @@ -90,12 +94,17 @@ class InfoTab extends React.Component { License: GPL v3 +
+
Data collectiong policy
+

We collect only the amount of users on Boostnote for DAU and any detail information +

such as a note's content or title is not collected.

+

You can see how it works on GitHub

this.handleConfigChange(e)} checked={this.state.config.amaEnabled} ref='amaEnabled' type='checkbox' /> - Enable to send analytics to our servers + Enable to send analytics to our servers
) diff --git a/browser/main/modals/PreferencesModal/InfoTab.styl b/browser/main/modals/PreferencesModal/InfoTab.styl index 4947c3bcd..7279fffd1 100644 --- a/browser/main/modals/PreferencesModal/InfoTab.styl +++ b/browser/main/modals/PreferencesModal/InfoTab.styl @@ -41,7 +41,10 @@ a color #4E8EC6 text-decoration none - + +.policy + font-size 20px + body[data-theme="dark"] .root - color alpha($tab--dark-text-color, 80%) \ No newline at end of file + color alpha($tab--dark-text-color, 80%) From eddfdea2ca462a1e0f63c2790f6d92572c3ac7d9 Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Sat, 22 Jul 2017 14:20:42 +0900 Subject: [PATCH 3/5] Fix a closing tag and a condition --- browser/main/modals/PreferencesModal/InfoTab.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/browser/main/modals/PreferencesModal/InfoTab.js b/browser/main/modals/PreferencesModal/InfoTab.js index e92e77a74..20e0fc7ab 100644 --- a/browser/main/modals/PreferencesModal/InfoTab.js +++ b/browser/main/modals/PreferencesModal/InfoTab.js @@ -40,7 +40,7 @@ class InfoTab extends React.Component { type: 'SET_CONFIG', config: newConfig }) - if (newConfig.amaEnabled) { + if (!newConfig.amaEnabled) { AwsMobileAnalyticsConfig.recordDynamitCustomEvent('DISABLE_AMA') } } @@ -96,8 +96,8 @@ class InfoTab extends React.Component {
Data collectiong policy
-

We collect only the amount of users on Boostnote for DAU and any detail information -

such as a note's content or title is not collected.

+

We collect only the amount of users on Boostnote for DAU and any detail information
+ such as a note's content or title is not collected.

You can see how it works on GitHub

this.handleConfigChange(e)} checked={this.state.config.amaEnabled} From 5d9aeb4c04544b780efb3ec4c57e1bd84ad30fe3 Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Sat, 22 Jul 2017 14:32:18 +0900 Subject: [PATCH 4/5] Fix typo --- browser/main/modals/PreferencesModal/InfoTab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/main/modals/PreferencesModal/InfoTab.js b/browser/main/modals/PreferencesModal/InfoTab.js index 20e0fc7ab..f0e4e42b3 100644 --- a/browser/main/modals/PreferencesModal/InfoTab.js +++ b/browser/main/modals/PreferencesModal/InfoTab.js @@ -95,7 +95,7 @@ class InfoTab extends React.Component {
-
Data collectiong policy
+
Data collection policy

We collect only the amount of users on Boostnote for DAU and any detail information
such as a note's content or title is not collected.

You can see how it works on GitHub

From 690549b57f4b8b4c8aeba538d2c4aa92b7471489 Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Sat, 22 Jul 2017 14:34:28 +0900 Subject: [PATCH 5/5] Change a word --- browser/main/modals/PreferencesModal/InfoTab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/main/modals/PreferencesModal/InfoTab.js b/browser/main/modals/PreferencesModal/InfoTab.js index f0e4e42b3..1f5d58b7c 100644 --- a/browser/main/modals/PreferencesModal/InfoTab.js +++ b/browser/main/modals/PreferencesModal/InfoTab.js @@ -96,7 +96,7 @@ class InfoTab extends React.Component {
Data collection policy
-

We collect only the amount of users on Boostnote for DAU and any detail information
+

We collect only the number of users on Boostnote for DAU and any detail information
such as a note's content or title is not collected.

You can see how it works on GitHub

this.handleConfigChange(e)}