gui/modules/desktop/src/libs/sentry.ts
Neil 4d0c611b1f
init sentry on packaged app only (#530)
Co-authored-by: neil molina <neil@neils-MacBook-Pro.local>
2023-05-01 08:01:01 +08:00

24 lines
783 B
TypeScript

import * as Sentry from "@sentry/browser";
import type { Session } from "./types";
import { isPackaged } from "electron-is-packaged";
export function initSentry(session?: Session) {
if (isPackaged) {
Sentry.init({
dsn: "https://5ff29bb5b3b64cd4bd4f4960ef1db2e3@o4504750197899264.ingest.sentry.io/4504750206746624"
});
if (session) {
console.log("sentry init", session);
Sentry.configureScope(async (scope) => {
scope.setUser({
id: session.device_id, // device_id this should exist in our pg db: developer_id is to many device_id
username: session?.user?.login || "" // github username or handler
});
});
}
}
}
export function captureException(exception: any) {
Sentry.captureException(exception);
}