Consolidate Raven constants under one namespace

This commit is contained in:
Brett Sun 2016-06-24 16:11:43 +02:00
parent 3291af0812
commit dbaf1a2e99
2 changed files with 13 additions and 18 deletions

View File

@ -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;

View File

@ -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);