From 90253b69c994b3b73e01aee9d7bcab6f64819dfc Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sat, 29 Jul 2017 17:36:46 -0400 Subject: [PATCH] Integrating Sentry for JS error tracking --- gulpfile.js | 5 +++++ lib/partials/layout.hbs | 2 ++ lib/partials/sentry.hbs | 6 ++++++ src/js/main.js | 14 -------------- 4 files changed, 13 insertions(+), 14 deletions(-) create mode 100644 lib/partials/sentry.hbs diff --git a/gulpfile.js b/gulpfile.js index bd8c26d..fcd7ae2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -77,6 +77,11 @@ gulp.task('markup', 'Build markup into ./build directory.', ['webpack'], functio 'gaPropertyId': process.env.GA_PROP }); } + if (process.env.SENTRY_KEY) { + hbStream.data({ + 'sentryKey': process.env.SENTRY_KEY + }); + } return gulp.src(config.globs.templates) .pipe(frontMatter()) .pipe(hbStream) diff --git a/lib/partials/layout.hbs b/lib/partials/layout.hbs index 356b857..84af82a 100644 --- a/lib/partials/layout.hbs +++ b/lib/partials/layout.hbs @@ -63,6 +63,8 @@ + + {{> "sentry"}} {{/block}} diff --git a/lib/partials/sentry.hbs b/lib/partials/sentry.hbs new file mode 100644 index 0000000..f9c4d1a --- /dev/null +++ b/lib/partials/sentry.hbs @@ -0,0 +1,6 @@ +{{#if sentryKey}} + + +{{/if}} diff --git a/src/js/main.js b/src/js/main.js index a56f2b3..f041241 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -11,20 +11,6 @@ import Parser from './parser/javascript.js'; import _ from 'lodash'; (function() { - // Global error handler that will send unhandled JavaScript exceptions and - // stack-traces to Google Analytics. This data can be used to find errors in - // code that were not found during testing. - window.addEventListener('error', function(error) { - if (error.lineno !== 0) { - util.track('send', 'event', 'global', 'exception', - `${error.filename}(${error.lineno},${error.colno}): ${error.message}`); - - if (typeof error.error !== 'undefined' && typeof error.error.stack !== 'undefined') { - util.track('send', 'event', 'global', 'stack trace', error.error.stack); - } - } - }); - // Initialize the main page of the site. Functionality is kept in the // [Regexper class](./regexper.html). if (document.body.querySelector('#content .application')) {