From 6667fe53ba68e90583561b008e6decd52dbd88a8 Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 28 Sep 2023 12:32:14 +0100 Subject: [PATCH] refactor: add error logging to analytics --- frontend/src/ts/ready.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frontend/src/ts/ready.ts b/frontend/src/ts/ready.ts index 75d5fc87b..49abdd677 100644 --- a/frontend/src/ts/ready.ts +++ b/frontend/src/ts/ready.ts @@ -12,6 +12,7 @@ import { Workbox } from "workbox-window"; import * as FunboxList from "./test/funbox/funbox-list"; //@ts-ignore import Konami from "konami"; +import { log } from "./controllers/analytics-controller"; if (Misc.isLocalhost()) { $("footer .currentVersion .text").text("localhost"); @@ -141,3 +142,15 @@ if ("serviceWorker" in navigator) { } }); } + +window.onerror = function (message, url, line, column, error): void { + log("error", { + error: error?.stack ?? "", + }); +}; + +window.onunhandledrejection = function (e): void { + log("error", { + error: e.reason.stack ?? "", + }); +};