mirror of
https://github.com/ivabus/gui
synced 2025-06-08 00:00:27 +03:00
sentry logs: add github username and device_id (#521)
* add uid and username in main thread logs * add more metadata to sentry client side logs * add more logging --------- Co-authored-by: neil molina <neil@neils-MacBook-Pro.local>
This commit is contained in:
parent
c478c99539
commit
a5c80d4d5c
6 changed files with 37 additions and 9 deletions
|
@ -15,6 +15,7 @@ import initializePushNotification, {
|
||||||
} from "./libs/push-notification";
|
} from "./libs/push-notification";
|
||||||
|
|
||||||
import init from "./libs/initialize";
|
import init from "./libs/initialize";
|
||||||
|
import { readSessionData } from "./libs/auth";
|
||||||
|
|
||||||
log.info("App starting...");
|
log.info("App starting...");
|
||||||
if (app.isPackaged) {
|
if (app.isPackaged) {
|
||||||
|
@ -30,6 +31,13 @@ if (app.isPackaged) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Sentry.configureScope(async (scope) => {
|
||||||
|
const session = await readSessionData();
|
||||||
|
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
|
||||||
|
});
|
||||||
|
});
|
||||||
setSentryLogging(Sentry);
|
setSentryLogging(Sentry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +156,7 @@ app.on("activate", () => {
|
||||||
createMainWindow();
|
createMainWindow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
app.on("window-all-closed", async () => {
|
app.on("window-all-closed", () => {
|
||||||
// mac ux is just minimize them when closed unless forced quite CMD+Q
|
// mac ux is just minimize them when closed unless forced quite CMD+Q
|
||||||
macWindowClosed = true;
|
macWindowClosed = true;
|
||||||
if (process.platform !== "darwin") {
|
if (process.platform !== "darwin") {
|
||||||
|
|
|
@ -18,15 +18,19 @@ let lastStatus: AutoUpdateStatus = { status: "up-to-date" };
|
||||||
export const getUpdater = () => autoUpdater;
|
export const getUpdater = () => autoUpdater;
|
||||||
|
|
||||||
export function checkUpdater(mainWindow: BrowserWindow): AppUpdater {
|
export function checkUpdater(mainWindow: BrowserWindow): AppUpdater {
|
||||||
window = mainWindow;
|
try {
|
||||||
autoUpdater.checkForUpdatesAndNotify();
|
window = mainWindow;
|
||||||
|
autoUpdater.checkForUpdatesAndNotify();
|
||||||
|
|
||||||
if (!initalized) {
|
if (!initalized) {
|
||||||
initalized = true;
|
initalized = true;
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
autoUpdater.checkForUpdatesAndNotify();
|
autoUpdater.checkForUpdatesAndNotify();
|
||||||
}, 1000 * 60 * 30); // check for updates every 30 minutes
|
}, 1000 * 60 * 30); // check for updates every 30 minutes
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
log.error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return autoUpdater;
|
return autoUpdater;
|
||||||
|
|
|
@ -94,6 +94,7 @@ export async function installPackage(pkg: GUIPackage, version?: string) {
|
||||||
const specificVersion = version || latestVersion;
|
const specificVersion = version || latestVersion;
|
||||||
|
|
||||||
log.info(`installing package: ${pkg.name} version: ${specificVersion}`);
|
log.info(`installing package: ${pkg.name} version: ${specificVersion}`);
|
||||||
|
|
||||||
const res = await ipcRenderer.invoke("install-package", {
|
const res = await ipcRenderer.invoke("install-package", {
|
||||||
full_name: pkg.full_name,
|
full_name: pkg.full_name,
|
||||||
version: specificVersion
|
version: specificVersion
|
||||||
|
|
|
@ -1,9 +1,19 @@
|
||||||
import * as Sentry from "@sentry/browser";
|
import * as Sentry from "@sentry/browser";
|
||||||
|
import type { Session } from "./types";
|
||||||
|
|
||||||
export function initSentry() {
|
export function initSentry(session?: Session) {
|
||||||
Sentry.init({
|
Sentry.init({
|
||||||
dsn: "https://5ff29bb5b3b64cd4bd4f4960ef1db2e3@o4504750197899264.ingest.sentry.io/4504750206746624"
|
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) {
|
export function captureException(exception: any) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { getDeviceAuth } from "@native";
|
||||||
import type { Developer } from "@tea/ui/types";
|
import type { Developer } from "@tea/ui/types";
|
||||||
import type { Session } from "$libs/types";
|
import type { Session } from "$libs/types";
|
||||||
import { getSession as electronGetSession, updateSession as electronUpdateSession } from "@native";
|
import { getSession as electronGetSession, updateSession as electronUpdateSession } from "@native";
|
||||||
|
import { initSentry } from "../sentry";
|
||||||
|
|
||||||
export let session: Session | null = null;
|
export let session: Session | null = null;
|
||||||
export const getSession = async (): Promise<Session | null> => {
|
export const getSession = async (): Promise<Session | null> => {
|
||||||
|
@ -22,6 +23,7 @@ export default function initAuthStore() {
|
||||||
getSession().then((sess) => {
|
getSession().then((sess) => {
|
||||||
if (sess) {
|
if (sess) {
|
||||||
session = sess;
|
session = sess;
|
||||||
|
initSentry(sess);
|
||||||
sessionStore.set(sess);
|
sessionStore.set(sess);
|
||||||
deviceIdStore.set(sess.device_id!);
|
deviceIdStore.set(sess.device_id!);
|
||||||
deviceId = sess.device_id!;
|
deviceId = sess.device_id!;
|
||||||
|
@ -36,6 +38,8 @@ export default function initAuthStore() {
|
||||||
...val,
|
...val,
|
||||||
...data
|
...data
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
initSentry(data);
|
||||||
await electronUpdateSession(data);
|
await electronUpdateSession(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,6 +219,7 @@ To read more about this package go to [${guiPkg.homepage}](${guiPkg.homepage}).
|
||||||
message: `Package ${pkg.full_name} v${versionToInstall} has been installed.`
|
message: `Package ${pkg.full_name} v${versionToInstall} has been installed.`
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
log.error(error);
|
||||||
let message = "Unknown Error";
|
let message = "Unknown Error";
|
||||||
if (error instanceof Error) message = error.message;
|
if (error instanceof Error) message = error.message;
|
||||||
trackInstallFailed(pkg.full_name, message || "unknown");
|
trackInstallFailed(pkg.full_name, message || "unknown");
|
||||||
|
|
Loading…
Reference in a new issue