From 0d7155bda618e11b5dbe33d1c9d661a381d5f76e Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Sat, 14 Oct 2017 12:12:35 +0900 Subject: [PATCH] implement convertPlatformName function --- browser/main/lib/AwsMobileAnalyticsConfig.js | 25 +++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/browser/main/lib/AwsMobileAnalyticsConfig.js b/browser/main/lib/AwsMobileAnalyticsConfig.js index 037513c2..6df5b329 100644 --- a/browser/main/lib/AwsMobileAnalyticsConfig.js +++ b/browser/main/lib/AwsMobileAnalyticsConfig.js @@ -11,25 +11,28 @@ if (process.env.NODE_ENV === 'production' && ConfigManager.default.get().amaEnab IdentityPoolId: 'us-east-1:xxxxxxxxxxxxxxxxxxxxxxxxx' }) - const rawPlatform = os.platform() - - let actualPlatform - if (rawPlatform === 'darwin') { - actualPlatform = 'MacOS' - } else if (rawPlatform === 'win32') { - actualPlatform = 'Windows' - } else if (rawPlatform === 'linux') { - actualPlatform = 'Linux' - } + const validPlatformName = convertPlatformName(os.platform()) const mobileAnalyticsClient = new AMA.Manager({ appId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx', appTitle: 'xxxxxxxxxx', appVersionName: remote.app.getVersion().toString(), - platform: actualPlatform + platform: validPlatformName }) } +function convertPlatformName (platformName) { + if (platformName === 'darwin') { + return 'MacOS' + } else if (platformName === 'win32') { + return 'Windows' + } else if (platformName === 'linux') { + return 'Linux' + } else { + return '' + } +} + function initAwsMobileAnalytics () { if (process.env.NODE_ENV !== 'production' || !ConfigManager.default.get().amaEnabled) return AWS.config.credentials.get((err) => {