From 9d2d811b10eb42cbe3faa21974d9052bb9b4c746 Mon Sep 17 00:00:00 2001 From: f Date: Sun, 19 Sep 2021 12:56:05 -0300 Subject: [PATCH 1/4] Ignorar reportes de error de bots closes sutty/sutty#2740 --- _packs/entry.js | 26 +++++++++++++++++--------- package.json | 1 + yarn.lock | 5 +++++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/_packs/entry.js b/_packs/entry.js index 5de0945..237ef10 100644 --- a/_packs/entry.js +++ b/_packs/entry.js @@ -1,15 +1,23 @@ +import BotDetector from 'device-detector-js/dist/parsers/bot' import { Notifier } from '@airbrake/browser' -window.airbrake = new Notifier({ - projectId: window.env.AIRBRAKE_PROJECT_ID, - projectKey: window.env.AIRBRAKE_PROJECT_KEY, - host: 'https://panel.sutty.nl' -}) +if ('userAgent' in navigator) { + window.bot_detector = new BotDetector + const bot = window.bot_detector.parse(navigator.userAgent) -console.originalError = console.error -console.error = (...e) => { - window.airbrake.notify(e.join(' ')) - return console.originalError(...e) + if (!bot) { + window.airbrake = new Notifier({ + projectId: window.env.AIRBRAKE_PROJECT_ID, + projectKey: window.env.AIRBRAKE_PROJECT_KEY, + host: 'https://panel.sutty.nl' + }) + + console.originalError = console.error + console.error = (...e) => { + window.airbrake.notify(e.join(' ')) + return console.originalError(...e) + } + } } import 'core-js/stable' diff --git a/package.json b/package.json index 895cf0f..edbf46f 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "axe-core": "^4.1.2", "babel-loader": "^8.1.0", "core-js": "^3.6.5", + "device-detector-js": "^2.2.10", "dotenv-webpack": "^6.0.0", "liquidjs": "^9.14.0", "regenerator-runtime": "^0.13.5", diff --git a/yarn.lock b/yarn.lock index d441339..b63a829 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2519,6 +2519,11 @@ detect-node@^2.0.4: resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.1.0.tgz#c9c70775a49c3d03bc2c06d9a73be550f978f8b1" integrity sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g== +device-detector-js@^2.2.10: + version "2.2.10" + resolved "https://registry.yarnpkg.com/device-detector-js/-/device-detector-js-2.2.10.tgz#a8fd47837ce89024d7647a4ddf18154d7a920538" + integrity sha512-zLcDSU10WIqbARXecaVJJxx0ZuGWq+MVhj9f9qehdBCFr9RMa5mQGTt2IZNIgKuCIind/j/DzRDViEdc2FfBGQ== + diffie-hellman@^5.0.0: version "5.0.3" resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" From dd230c2fa1446bbbe7083ab3d802fa89bafc0034 Mon Sep 17 00:00:00 2001 From: Nulo Date: Mon, 20 Sep 2021 14:18:31 -0300 Subject: [PATCH 2/4] No chequear si existe navigator.userAgent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ¡Existe desde IE 4! --- _packs/entry.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/_packs/entry.js b/_packs/entry.js index 237ef10..5a612e6 100644 --- a/_packs/entry.js +++ b/_packs/entry.js @@ -1,22 +1,20 @@ import BotDetector from 'device-detector-js/dist/parsers/bot' import { Notifier } from '@airbrake/browser' -if ('userAgent' in navigator) { - window.bot_detector = new BotDetector - const bot = window.bot_detector.parse(navigator.userAgent) +window.bot_detector = new BotDetector +const bot = window.bot_detector.parse(navigator.userAgent) - if (!bot) { - window.airbrake = new Notifier({ - projectId: window.env.AIRBRAKE_PROJECT_ID, - projectKey: window.env.AIRBRAKE_PROJECT_KEY, - host: 'https://panel.sutty.nl' - }) +if (!bot) { + window.airbrake = new Notifier({ + projectId: window.env.AIRBRAKE_PROJECT_ID, + projectKey: window.env.AIRBRAKE_PROJECT_KEY, + host: 'https://panel.sutty.nl' + }) - console.originalError = console.error - console.error = (...e) => { - window.airbrake.notify(e.join(' ')) - return console.originalError(...e) - } + console.originalError = console.error + console.error = (...e) => { + window.airbrake.notify(e.join(' ')) + return console.originalError(...e) } } From 06b3d8d69b429dc075b8373807c249ffa3b11fd7 Mon Sep 17 00:00:00 2001 From: Nulo Date: Mon, 20 Sep 2021 15:38:26 -0300 Subject: [PATCH 3/4] Chequear si es bot, no si es parseado --- _packs/entry.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_packs/entry.js b/_packs/entry.js index 5a612e6..bee006a 100644 --- a/_packs/entry.js +++ b/_packs/entry.js @@ -2,9 +2,9 @@ import BotDetector from 'device-detector-js/dist/parsers/bot' import { Notifier } from '@airbrake/browser' window.bot_detector = new BotDetector -const bot = window.bot_detector.parse(navigator.userAgent) +const device = window.bot_detector.parse(navigator.userAgent) -if (!bot) { +if (!device.bot) { window.airbrake = new Notifier({ projectId: window.env.AIRBRAKE_PROJECT_ID, projectKey: window.env.AIRBRAKE_PROJECT_KEY, From 357ddcf07c45aea101ae91afd2289f03beb614c4 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 20 Sep 2021 22:27:01 -0300 Subject: [PATCH 4/4] Revert "Chequear si es bot, no si es parseado" This reverts commit 06b3d8d69b429dc075b8373807c249ffa3b11fd7. --- _packs/entry.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_packs/entry.js b/_packs/entry.js index bee006a..5a612e6 100644 --- a/_packs/entry.js +++ b/_packs/entry.js @@ -2,9 +2,9 @@ import BotDetector from 'device-detector-js/dist/parsers/bot' import { Notifier } from '@airbrake/browser' window.bot_detector = new BotDetector -const device = window.bot_detector.parse(navigator.userAgent) +const bot = window.bot_detector.parse(navigator.userAgent) -if (!device.bot) { +if (!bot) { window.airbrake = new Notifier({ projectId: window.env.AIRBRAKE_PROJECT_ID, projectKey: window.env.AIRBRAKE_PROJECT_KEY,