From 212d7027fc0cca4744c694412322a1592ed18b0c Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Mon, 26 Jun 2017 15:10:31 +0900 Subject: [PATCH] Exclude auth of aws only production --- browser/main/lib/AwsMobileAnalyticsConfig.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/browser/main/lib/AwsMobileAnalyticsConfig.js b/browser/main/lib/AwsMobileAnalyticsConfig.js index c485d37d..3ec20918 100644 --- a/browser/main/lib/AwsMobileAnalyticsConfig.js +++ b/browser/main/lib/AwsMobileAnalyticsConfig.js @@ -3,16 +3,18 @@ const AMA = require('aws-sdk-mobile-analytics') const ConfigManager = require('browser/main/lib/ConfigManager') AWS.config.region = 'us-east-1' -AWS.config.credentials = new AWS.CognitoIdentityCredentials({ - IdentityPoolId: 'us-east-1:xxxxxxxxxxxxxxxxxxxxxxxxx' -}) - -const mobileAnalyticsClient = new AMA.Manager({ - appId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - appTitle: 'xxxxxxxxxx' -}) +if (process.env.NODE_ENV === 'production') { + AWS.config.credentials = new AWS.CognitoIdentityCredentials({ + IdentityPoolId: 'us-east-1:xxxxxxxxxxxxxxxxxxxxxxxxx' + }) + const mobileAnalyticsClient = new AMA.Manager({ + appId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + appTitle: 'xxxxxxxxxx' + }) +} function initAwsMobileAnalytics () { + if (process.env.NODE_ENV !== 'production') return AWS.config.credentials.get((err) => { if (!err) { console.log('Cognito Identity ID: ' + AWS.config.credentials.identityId) @@ -22,10 +24,12 @@ function initAwsMobileAnalytics () { } function recordDynamitCustomEvent (type) { + if (process.env.NODE_ENV !== 'production') return mobileAnalyticsClient.recordEvent(type) } function recordStaticCustomEvent () { + if (process.env.NODE_ENV !== 'production') return mobileAnalyticsClient.recordEvent('UI_COLOR_THEME', { uiColorTheme: ConfigManager.default.get().ui.theme })