Skip to content

Commit

Permalink
Add raven to collect deprecations warnings
Browse files Browse the repository at this point in the history
closes CORE-1460

Test Plan:
  - When the selenium chrome deprecations build
    runs, you should see data in sentry.
  - You should see no change in behavior when run
    in prod or without DEPRECATION_SENTRY_DSN environment
    variable set.

Change-Id: I7703d44612af6189a13122de15fdb0d067d2110d
Reviewed-on: https://gerrit.instructure.com/161736
Reviewed-by: Ryan Shaw <[email protected]>
Tested-by: Jenkins
Product-Review: Clay Diffrient <[email protected]>
QA-Review: Clay Diffrient <[email protected]>
  • Loading branch information
claydiffrient committed Aug 23, 2018
1 parent 4219b13 commit b575d1c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
34 changes: 34 additions & 0 deletions app/jsx/appBootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,40 @@ if (typeof ENV !== 'undefined') {
if (ENV.BIGEASY_LOCALE) tz.changeLocale(ENV.BIGEASY_LOCALE, ENV.MOMENT_LOCALE)
}

// This will inject and set up sentry for deprecation reporting. It should be
// stripped out and be a no-op in production.
if (process.env.NODE_ENV !== 'production' && process.env.DEPRECATION_SENTRY_DSN) {
const Raven = require('raven-js')
Raven.config(process.env.DEPRECATION_SENTRY_DSN, {
release: process.env.GIT_COMMIT
}).install();

const CONSOLE_LEVELS = ['debug', 'info', 'warn', 'error'];
CONSOLE_LEVELS.forEach(level => {
window.console[level] = (...args) => {
const msg = args.join(' ');
if (msg.includes('deprecated')) {
let trace = null;
try {
throw new Error('');
} catch (e) {
trace = e.stack;
}
const data = {
level: level === 'warn' ? 'warning' : level,
logger: 'console',
extra: {
arguments: args,
stackTrace: trace
}
};

Raven.captureMessage(msg, data);
}
}
});
}

// setup the inst-ui default theme
if (ENV.use_high_contrast) {
canvasTheme.use({ accessible: true })
Expand Down
6 changes: 5 additions & 1 deletion frontend_build/baseWebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ module.exports = {
// sets these environment variables in compiled code.
// process.env.NODE_ENV will make it so react and others are much smaller and don't run their
// debug/propType checking in prod.
new webpack.EnvironmentPlugin(['NODE_ENV']),
new webpack.EnvironmentPlugin({
NODE_ENV: null,
DEPRECATION_SENTRY_DSN: null,
GIT_COMMIT: null
}),

new WebpackCleanupPlugin({
exclude: ['selinimum-manifest.json']
Expand Down

0 comments on commit b575d1c

Please sign in to comment.