From dbaf1a2e99f60756b753a907b9d13869922e78be Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Fri, 24 Jun 2016 16:11:43 +0200 Subject: [PATCH] Consolidate Raven constants under one namespace --- js/constants/application_constants.js | 12 ++++++------ js/utils/error.js | 19 +++++++------------ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/js/constants/application_constants.js b/js/constants/application_constants.js index 4766f563..f6f8e828 100644 --- a/js/constants/application_constants.js +++ b/js/constants/application_constants.js @@ -103,7 +103,11 @@ const constants = { 'cssUrl': '//vjs.zencdn.net/4.12/video-js.css' }, 'raven': { - 'url': 'https://0955da3388c64ab29bd32c2a429f9ef4@app.getsentry.com/48351' + ignoreErrors: [ + 'Authentication credentials were not provided.', + 'Informations d\'authentification non fournies.' + ], + url: process.env.RAVEN_DSL_URL }, 'facebook': { 'appId': '420813844732240', @@ -112,11 +116,7 @@ const constants = { 'twitter': { 'sdkUrl': 'https://platform.twitter.com/widgets.js' }, - 'cloudfrontDomain': 'd1qjsxua1o9x03.cloudfront.net', - 'errorMessagesToIgnore': [ - 'Authentication credentials were not provided.', - 'Informations d\'authentification non fournies.' - ] + 'cloudfrontDomain': 'd1qjsxua1o9x03.cloudfront.net' }; export default constants; diff --git a/js/utils/error.js b/js/utils/error.js index 4aa74247..9a820e24 100644 --- a/js/utils/error.js +++ b/js/utils/error.js @@ -1,5 +1,3 @@ -'use strict'; - import Raven from 'raven-js'; import AppConstants from '../constants/application_constants'; @@ -16,10 +14,7 @@ function logGlobal(error, comment, ignoreSentry) { console.error(error); if (error.hasOwnProperty('json')) { - comment = { - ...comment, - json: error.json - }; + comment.json = error.json; } if (!ignoreSentry) { @@ -28,10 +23,12 @@ function logGlobal(error, comment, ignoreSentry) { } export function initLogging() { + const { raven: { ignoreErrors, url: ravenUrl }, version } = AppConstants; + // Initialize Raven for logging on Sentry - Raven.config(AppConstants.raven.url, { - release: AppConstants.version, - ignoreErrors: AppConstants.errorMessagesToIgnore + Raven.config(ravenUrl, { + ignoreErrors, + release: version, }).install(); window.onerror = Raven.process; @@ -49,9 +46,7 @@ export function getJsonErrorsAsArray(error) { const errorArrays = Object .keys(errors) - .map((errorKey) => { - return errors[errorKey]; - }); + .map((errorKey) => errors[errorKey]); // Collapse each errorKey's errors into a flat array return [].concat(...errorArrays);