From 764fd70e065a56a2bf11ede657c83d4c803e1c87 Mon Sep 17 00:00:00 2001 From: jazzari Date: Mon, 12 Jun 2023 11:20:26 -0300 Subject: [PATCH] fix: add try catch to application.js so can notify js errors with the console #13578 --- app/javascript/packs/application.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 492ca736..9cbc30bf 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -2,11 +2,21 @@ import { Notifier } from '@airbrake/browser' -window.airbrake = new Notifier({ - projectId: window.env.AIRBRAKE_SITE_ID, - projectKey: window.env.AIRBRAKE_API_KEY, - host: window.env.PANEL_URL -}) +try { + window.airbrake = new Notifier({ + projectId: window.env.AIRBRAKE_PROJECT_ID, + projectKey: window.env.AIRBRAKE_PROJECT_KEY, + host: window.env.PANEL_URL + }); + + console.originalError = console.error; + console.error = (...e) => { + window.airbrake.notify(e.join(" ")); + return console.originalError(...e); + }; +} catch(e) { + console.error(e); +} import 'core-js/stable' import 'regenerator-runtime/runtime'