From c5fe79c15d48b09415cd2dd7698c0648c065c44f Mon Sep 17 00:00:00 2001 From: Daniel Bulant Date: Mon, 12 Dec 2022 15:36:48 +0100 Subject: [PATCH] more sentry data --- package.json | 1 + src/hooks.server.ts | 11 +++++++++++ src/lib/util/anilist.ts | 2 ++ 3 files changed, 14 insertions(+) create mode 100644 src/hooks.server.ts diff --git a/package.json b/package.json index 8eee43b..5561235 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ }, "dependencies": { "@sentry/browser": "^7.25.0", + "@sentry/node": "^7.25.0", "fflate": "^0.6.10", "streamsaver": "^2.0.6", "svelte-local-storage-store": "^0.3.1", diff --git a/src/hooks.server.ts b/src/hooks.server.ts new file mode 100644 index 0000000..ad9b4bd --- /dev/null +++ b/src/hooks.server.ts @@ -0,0 +1,11 @@ +import * as Sentry from "@sentry/node"; +/** @type {import('@sveltejs/kit').HandleClientError} */ +export function handleError({ error, event }) { + // @ts-ignore + Sentry.captureException(error, { event }); + + return { + ...error, + code: error?.code ?? 'UNKNOWN' + }; + } \ No newline at end of file diff --git a/src/lib/util/anilist.ts b/src/lib/util/anilist.ts index d95f77d..d3dda01 100644 --- a/src/lib/util/anilist.ts +++ b/src/lib/util/anilist.ts @@ -1,3 +1,4 @@ +import * as Sentry from "@sentry/browser"; var isLogedInCache: boolean | null = null; var isLogedInCacheTime: number | null = null; @@ -20,6 +21,7 @@ export function isLogedIn() { export function getUserID() { const token = localStorage.getItem("token")!; let data = JSON.parse(atob(token.substring(token.indexOf(".") + 1, token.lastIndexOf(".")))); + Sentry.setUser({ id: data.sub }); return data.sub; }