mirror of
				https://github.com/hydralauncher/hydra.git
				synced 2025-03-09 15:40:26 +00:00 
			
		
		
		
	ci: adding sentry
This commit is contained in:
		
							parent
							
								
									75b69f38fc
								
							
						
					
					
						commit
						ac27438a35
					
				
					 15 changed files with 1253 additions and 17 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,3 @@
 | 
			
		|||
MAIN_VITE_STEAMGRIDDB_API_KEY=YOUR_API_KEY
 | 
			
		||||
MAIN_VITE_API_URL=API_URL
 | 
			
		||||
 | 
			
		||||
MAIN_VITE_SENTRY_DSN=YOUR_SENTRY_DSN
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								.github/workflows/build.yml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/build.yml
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -40,6 +40,8 @@ jobs:
 | 
			
		|||
          MAIN_VITE_ONLINEFIX_USERNAME: ${{ secrets.ONLINEFIX_USERNAME }}
 | 
			
		||||
          MAIN_VITE_ONLINEFIX_PASSWORD: ${{ secrets.ONLINEFIX_PASSWORD }}
 | 
			
		||||
          MAIN_VITE_API_URL: ${{ vars.MAIN_VITE_API_URL }}
 | 
			
		||||
          SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
 | 
			
		||||
          MAIN_VITE_SENTRY_DSN: ${{ vars.SENTRY_DSN }}
 | 
			
		||||
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 | 
			
		||||
 | 
			
		||||
      - name: Build Windows
 | 
			
		||||
| 
						 | 
				
			
			@ -49,6 +51,8 @@ jobs:
 | 
			
		|||
          MAIN_VITE_ONLINEFIX_USERNAME: ${{ secrets.ONLINEFIX_USERNAME }}
 | 
			
		||||
          MAIN_VITE_ONLINEFIX_PASSWORD: ${{ secrets.ONLINEFIX_PASSWORD }}
 | 
			
		||||
          MAIN_VITE_API_URL: ${{ vars.MAIN_VITE_API_URL }}
 | 
			
		||||
          SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
 | 
			
		||||
          MAIN_VITE_SENTRY_DSN: ${{ vars.SENTRY_DSN }}
 | 
			
		||||
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 | 
			
		||||
 | 
			
		||||
      - name: Create artifact
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								.github/workflows/release.yml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/release.yml
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -42,6 +42,8 @@ jobs:
 | 
			
		|||
          MAIN_VITE_ONLINEFIX_USERNAME: ${{ secrets.ONLINEFIX_USERNAME }}
 | 
			
		||||
          MAIN_VITE_ONLINEFIX_PASSWORD: ${{ secrets.ONLINEFIX_PASSWORD }}
 | 
			
		||||
          MAIN_VITE_API_URL: ${{ vars.MAIN_VITE_API_URL }}
 | 
			
		||||
          SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
 | 
			
		||||
          MAIN_VITE_SENTRY_DSN: ${{ vars.SENTRY_DSN }}
 | 
			
		||||
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 | 
			
		||||
 | 
			
		||||
      - name: Build Windows
 | 
			
		||||
| 
						 | 
				
			
			@ -51,6 +53,8 @@ jobs:
 | 
			
		|||
          MAIN_VITE_ONLINEFIX_USERNAME: ${{ secrets.ONLINEFIX_USERNAME }}
 | 
			
		||||
          MAIN_VITE_ONLINEFIX_PASSWORD: ${{ secrets.ONLINEFIX_PASSWORD }}
 | 
			
		||||
          MAIN_VITE_API_URL: ${{ vars.MAIN_VITE_API_URL }}
 | 
			
		||||
          SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
 | 
			
		||||
          MAIN_VITE_SENTRY_DSN: ${{ vars.SENTRY_DSN }}
 | 
			
		||||
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 | 
			
		||||
 | 
			
		||||
      - name: Release
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -9,3 +9,4 @@ out
 | 
			
		|||
*.log*
 | 
			
		||||
.env
 | 
			
		||||
.vite
 | 
			
		||||
sentry.properties
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,9 +6,16 @@ import {
 | 
			
		|||
  externalizeDepsPlugin,
 | 
			
		||||
} from "electron-vite";
 | 
			
		||||
import react from "@vitejs/plugin-react";
 | 
			
		||||
import { sentryVitePlugin } from "@sentry/vite-plugin";
 | 
			
		||||
import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
 | 
			
		||||
import svgr from "vite-plugin-svgr";
 | 
			
		||||
 | 
			
		||||
const sentryPlugin = sentryVitePlugin({
 | 
			
		||||
  authToken: process.env.SENTRY_AUTH_TOKEN,
 | 
			
		||||
  org: "hydra-launcher",
 | 
			
		||||
  project: "hydra-launcher",
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
export default defineConfig(({ mode }) => {
 | 
			
		||||
  loadEnv(mode);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +35,7 @@ export default defineConfig(({ mode }) => {
 | 
			
		|||
          "@shared": resolve("src/shared"),
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
      plugins: [externalizeDepsPlugin(), swcPlugin()],
 | 
			
		||||
      plugins: [externalizeDepsPlugin(), swcPlugin(), sentryPlugin],
 | 
			
		||||
    },
 | 
			
		||||
    preload: {
 | 
			
		||||
      plugins: [externalizeDepsPlugin()],
 | 
			
		||||
| 
						 | 
				
			
			@ -44,7 +51,7 @@ export default defineConfig(({ mode }) => {
 | 
			
		|||
          "@shared": resolve("src/shared"),
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
      plugins: [svgr(), react(), vanillaExtractPlugin()],
 | 
			
		||||
      plugins: [svgr(), react(), vanillaExtractPlugin(), sentryPlugin],
 | 
			
		||||
    },
 | 
			
		||||
  };
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
{
 | 
			
		||||
  "name": "hydralauncher",
 | 
			
		||||
  "version": "2.0.1",
 | 
			
		||||
  "version": "2.0.2",
 | 
			
		||||
  "description": "Hydra",
 | 
			
		||||
  "main": "./out/main/index.js",
 | 
			
		||||
  "author": "Los Broxas",
 | 
			
		||||
| 
						 | 
				
			
			@ -38,6 +38,7 @@
 | 
			
		|||
    "@fontsource/fira-sans": "^5.0.20",
 | 
			
		||||
    "@primer/octicons-react": "^19.9.0",
 | 
			
		||||
    "@reduxjs/toolkit": "^2.2.3",
 | 
			
		||||
    "@sentry/electron": "^5.1.0",
 | 
			
		||||
    "@vanilla-extract/css": "^1.14.2",
 | 
			
		||||
    "@vanilla-extract/recipes": "^0.5.2",
 | 
			
		||||
    "auto-launch": "^5.0.6",
 | 
			
		||||
| 
						 | 
				
			
			@ -80,6 +81,7 @@
 | 
			
		|||
    "@electron-toolkit/eslint-config-prettier": "^2.0.0",
 | 
			
		||||
    "@electron-toolkit/eslint-config-ts": "^1.0.1",
 | 
			
		||||
    "@electron-toolkit/tsconfig": "^1.0.1",
 | 
			
		||||
    "@sentry/vite-plugin": "^2.20.1",
 | 
			
		||||
    "@swc/core": "^1.4.16",
 | 
			
		||||
    "@types/auto-launch": "^5.0.5",
 | 
			
		||||
    "@types/color": "^3.0.6",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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) => {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
import { app, BrowserWindow, net, protocol } from "electron";
 | 
			
		||||
import { init } from "@sentry/electron/main";
 | 
			
		||||
import updater from "electron-updater";
 | 
			
		||||
import i18n from "i18next";
 | 
			
		||||
import path from "node:path";
 | 
			
		||||
| 
						 | 
				
			
			@ -22,6 +23,12 @@ autoUpdater.logger = logger;
 | 
			
		|||
const gotTheLock = app.requestSingleInstanceLock();
 | 
			
		||||
if (!gotTheLock) app.quit();
 | 
			
		||||
 | 
			
		||||
if (import.meta.env.MAIN_VITE_SENTRY_DSN) {
 | 
			
		||||
  init({
 | 
			
		||||
    dsn: import.meta.env.MAIN_VITE_SENTRY_DSN,
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
app.commandLine.appendSwitch("--no-sandbox");
 | 
			
		||||
 | 
			
		||||
i18n.init({
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								src/main/vite-env.d.ts
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								src/main/vite-env.d.ts
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -3,6 +3,7 @@
 | 
			
		|||
interface ImportMetaEnv {
 | 
			
		||||
  readonly MAIN_VITE_STEAMGRIDDB_API_KEY: string;
 | 
			
		||||
  readonly MAIN_VITE_API_URL: string;
 | 
			
		||||
  readonly MAIN_VITE_SENTRY_DSN: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface ImportMeta {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,6 +6,8 @@ import { Provider } from "react-redux";
 | 
			
		|||
import LanguageDetector from "i18next-browser-languagedetector";
 | 
			
		||||
import { HashRouter, Route, Routes } from "react-router-dom";
 | 
			
		||||
 | 
			
		||||
import * as Sentry from "@sentry/electron/renderer";
 | 
			
		||||
 | 
			
		||||
import "@fontsource/fira-mono/400.css";
 | 
			
		||||
import "@fontsource/fira-mono/500.css";
 | 
			
		||||
import "@fontsource/fira-mono/700.css";
 | 
			
		||||
| 
						 | 
				
			
			@ -29,6 +31,8 @@ import { store } from "./store";
 | 
			
		|||
import * as resources from "@locales";
 | 
			
		||||
import { User } from "./pages/user/user";
 | 
			
		||||
 | 
			
		||||
Sentry.init({});
 | 
			
		||||
 | 
			
		||||
i18n
 | 
			
		||||
  .use(LanguageDetector)
 | 
			
		||||
  .use(initReactI18next)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								src/renderer/src/vite-env.d.ts
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								src/renderer/src/vite-env.d.ts
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -1,6 +1,2 @@
 | 
			
		|||
/// <reference types="vite/client" />
 | 
			
		||||
/// <reference types="vite-plugin-svgr/client" />
 | 
			
		||||
 | 
			
		||||
interface ImportMeta {
 | 
			
		||||
  readonly env: ImportMetaEnv;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -272,6 +272,7 @@ export interface UserDetails {
 | 
			
		|||
export interface UserProfile {
 | 
			
		||||
  id: string;
 | 
			
		||||
  displayName: string;
 | 
			
		||||
  username: string;
 | 
			
		||||
  profileImageUrl: string | null;
 | 
			
		||||
  totalPlayTimeInSeconds: number;
 | 
			
		||||
  libraryGames: UserGame[];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue