Merge pull request #720 from hydralauncher/ci/sentry

ci: adding sentry
This commit is contained in:
Chubby Granny Chaser 2024-06-28 20:55:42 +01:00 committed by GitHub
commit b61fd1e61a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 1253 additions and 17 deletions

View file

@ -1,4 +1,5 @@
import jwt from "jsonwebtoken";
import * as Sentry from "@sentry/electron/main";
import { userAuthRepository } from "@main/repository";
import { registerEvent } from "../register-event";
@ -8,6 +9,9 @@ const getSessionHash = async (_event: Electron.IpcMainInvokeEvent) => {
if (!auth) return null;
const payload = jwt.decode(auth.accessToken) as jwt.JwtPayload;
Sentry.setContext("sessionId", payload.sessionId);
return payload.sessionId;
};

View file

@ -1,4 +1,5 @@
import { registerEvent } from "../register-event";
import * as Sentry from "@sentry/electron/main";
import { HydraApi, TorrentDownloader, gamesPlaytime } from "@main/services";
import { dataSource } from "@main/data-source";
import { DownloadQueue, Game, UserAuth } from "@main/entity";
@ -19,6 +20,9 @@ const signOut = async (_event: Electron.IpcMainInvokeEvent) => {
gamesPlaytime.clear();
});
/* Removes user from Sentry */
Sentry.setUser(null);
/* Disconnects libtorrent */
TorrentDownloader.kill();

View file

@ -1,4 +1,5 @@
import { registerEvent } from "../register-event";
import * as Sentry from "@sentry/electron/main";
import { HydraApi } from "@main/services";
import { UserProfile } from "@types";
import { userAuthRepository } from "@main/repository";
@ -21,6 +22,8 @@ const getMe = async (
["id"]
);
Sentry.setUser({ id: me.id, username: me.username });
return me;
})
.catch((err) => {