ItsSim / fsolauncher

Official FreeSO Launcher made with Electron
https://beta.freeso.org
Mozilla Public License 2.0
18 stars 9 forks source link

[Windows/Mac] Setup Sentry (error logger) #50

Closed ItsSim closed 1 year ago

ItsSim commented 1 year ago

Is your feature request related to a problem? Please describe. Errors that are not easy to reproduce could be caught with Sentry.

Describe the solution you'd like This task focuses on setting up and making Sentry (free tier) available to both the main and renderer processes in order to capture errors and identify issues that have not been caught during development and/or are hard to pinpoint.

There are approximately ~150-200 launchers running at any given time, this metric should be considered to verify that Sentry's free tier is sufficient for our needs.

If someone other than me implements this, leave the DSN field empty - I'll add it to the merge request, it will be added during the build process and not committed to the repository.

You may test the Sentry integration with your own account and DSN before submitting a pull request, using the Sentry docs available below.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

Sentry docs

Sentry is a popular error tracking and performance monitoring platform. It helps developers identify, diagnose, and fix issues in their applications. To integrate Sentry into an Electron.js app, you need to follow several steps.

Install Sentry SDK: First, you'll need to install the Sentry SDK for JavaScript and Electron. You can do this using npm (Node Package Manager). Open a terminal and run the following command within your project directory:

npm install --save @sentry/electron @sentry/browser

Configure Sentry in your Electron app: Create a new file called sentry.js in your project's root directory. This file will contain the configuration code for Sentry. You'll need to import Sentry's SDK and initialize it with your DSN (Data Source Name). You can obtain the DSN from your Sentry account.

Here's a sample sentry.js file:

import * as Sentry from "@sentry/electron";
Sentry.init({
  dsn: "YOUR_SENTRY_DSN",
});

Replace "YOUR_SENTRY_DSN" with your actual DSN.

Load Sentry in your Electron app: Now that you've set up the configuration, you need to load Sentry in your Electron app. In your main Electron process file (usually main.js or index.js), import the sentry.js file at the top:

import "./sentry";

Similarly, in your renderer process file (usually the JavaScript file loaded by your app's HTML file), import sentry.js as well:

import "../sentry";

Test Sentry integration: You can now test if Sentry is working correctly in your Electron app. Add some code to throw an error in your main or renderer process:

throw new Error("Sentry test error");

Run your app, and the error should be captured by Sentry. Check your Sentry dashboard for the error event.

That's it! Sentry is now integrated with your Electron.js app, and you'll be able to track errors and monitor performance effectively.

ItsSim commented 1 year ago

Implemented in develop