more sentry data

This commit is contained in:
Daniel Bulant 2022-12-12 15:36:48 +01:00
parent 13168158bd
commit c5fe79c15d
3 changed files with 14 additions and 0 deletions

View file

@ -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",

11
src/hooks.server.ts Normal file
View file

@ -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'
};
}

View file

@ -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;
}