1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-14 02:06:29 +00:00

Merge pull request #1243 from BoostIO/detect-AMA-errors

Detect ama errors
This commit is contained in:
Kazz Yokomizo
2017-12-20 18:27:24 +09:00
committed by GitHub

View File

@@ -7,7 +7,7 @@ const os = require('os')
let mobileAnalyticsClient let mobileAnalyticsClient
AWS.config.region = 'us-east-1' AWS.config.region = 'us-east-1'
if (process.env.NODE_ENV === 'production' && ConfigManager.default.get().amaEnabled) { if (!getSendEventCond()) {
AWS.config.credentials = new AWS.CognitoIdentityCredentials({ AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'us-east-1:xxxxxxxxxxxxxxxxxxxxxxxxx' IdentityPoolId: 'us-east-1:xxxxxxxxxxxxxxxxxxxxxxxxx'
}) })
@@ -34,8 +34,15 @@ function convertPlatformName (platformName) {
} }
} }
function getSendEventCond () {
const isDev = process.env.NODE_ENV !== 'production'
const isDisable = !ConfigManager.default.get().amaEnabled
const isOffline = !window.navigator.onLine
return isDev || isDisable || isOffline
}
function initAwsMobileAnalytics () { function initAwsMobileAnalytics () {
if (process.env.NODE_ENV !== 'production' || !ConfigManager.default.get().amaEnabled) return if (getSendEventCond()) return
AWS.config.credentials.get((err) => { AWS.config.credentials.get((err) => {
if (!err) { if (!err) {
console.log('Cognito Identity ID: ' + AWS.config.credentials.identityId) console.log('Cognito Identity ID: ' + AWS.config.credentials.identityId)
@@ -46,7 +53,7 @@ function initAwsMobileAnalytics () {
} }
function recordDynamicCustomEvent (type, options = {}) { function recordDynamicCustomEvent (type, options = {}) {
if (process.env.NODE_ENV !== 'production' || !ConfigManager.default.get().amaEnabled) return if (getSendEventCond()) return
try { try {
mobileAnalyticsClient.recordEvent(type, options) mobileAnalyticsClient.recordEvent(type, options)
} catch (analyticsError) { } catch (analyticsError) {
@@ -57,7 +64,7 @@ function recordDynamicCustomEvent (type, options = {}) {
} }
function recordStaticCustomEvent () { function recordStaticCustomEvent () {
if (process.env.NODE_ENV !== 'production' || !ConfigManager.default.get().amaEnabled) return if (getSendEventCond()) return
try { try {
mobileAnalyticsClient.recordEvent('UI_COLOR_THEME', { mobileAnalyticsClient.recordEvent('UI_COLOR_THEME', {
uiColorTheme: ConfigManager.default.get().ui.theme uiColorTheme: ConfigManager.default.get().ui.theme