From d56bcc4fdf5c02073c05d75ec7542050627a0ef6 Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Sat, 30 Sep 2017 12:19:51 +0900 Subject: [PATCH 1/3] enable to get appVerion and platformName --- browser/main/lib/AwsMobileAnalyticsConfig.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/browser/main/lib/AwsMobileAnalyticsConfig.js b/browser/main/lib/AwsMobileAnalyticsConfig.js index 70df7b7d..9bfa8767 100644 --- a/browser/main/lib/AwsMobileAnalyticsConfig.js +++ b/browser/main/lib/AwsMobileAnalyticsConfig.js @@ -2,6 +2,9 @@ const AWS = require('aws-sdk') const AMA = require('aws-sdk-mobile-analytics') const ConfigManager = require('browser/main/lib/ConfigManager') +const remote = require('electron').remote +const os = require('os') + AWS.config.region = 'us-east-1' if (process.env.NODE_ENV === 'production' && ConfigManager.default.get().amaEnabled) { AWS.config.credentials = new AWS.CognitoIdentityCredentials({ @@ -9,7 +12,9 @@ if (process.env.NODE_ENV === 'production' && ConfigManager.default.get().amaEnab }) const mobileAnalyticsClient = new AMA.Manager({ appId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - appTitle: 'xxxxxxxxxx' + appTitle: 'xxxxxxxxxx', + appVersionName: remote.app.getVersion().toString(), + platform: os.platform() }) } From d772551c600ac696d94ae357b01911afba1783a8 Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Tue, 10 Oct 2017 14:58:52 +0900 Subject: [PATCH 2/3] convert platformName from os.platfoem() form to AMA form --- browser/main/lib/AwsMobileAnalyticsConfig.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/browser/main/lib/AwsMobileAnalyticsConfig.js b/browser/main/lib/AwsMobileAnalyticsConfig.js index 9bfa8767..037513c2 100644 --- a/browser/main/lib/AwsMobileAnalyticsConfig.js +++ b/browser/main/lib/AwsMobileAnalyticsConfig.js @@ -10,11 +10,23 @@ if (process.env.NODE_ENV === 'production' && ConfigManager.default.get().amaEnab AWS.config.credentials = new AWS.CognitoIdentityCredentials({ 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 mobileAnalyticsClient = new AMA.Manager({ appId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx', appTitle: 'xxxxxxxxxx', appVersionName: remote.app.getVersion().toString(), - platform: os.platform() + platform: actualPlatform }) } From 0d7155bda618e11b5dbe33d1c9d661a381d5f76e Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Sat, 14 Oct 2017 12:12:35 +0900 Subject: [PATCH 3/3] 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) => {