Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.

Commit 54a56eb

Browse files
committed
✨ Adding Sentry
1 parent 38d02ec commit 54a56eb

File tree

9 files changed

+382
-38
lines changed

9 files changed

+382
-38
lines changed

.github/workflows/deploy.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ jobs:
3232
yarn run dist
3333
- name: Building
3434
run: yarn run build
35+
env:
36+
DSN: ${{ secrets.DSN }}
3537
- name: Building AppImage
3638
run: |
3739
jq -c '.productName = "PreMiD Portable"' ./dist/app/package.json > tmp.$$.json && mv tmp.$$.json ./dist/app/package.json
3840
yarn run build:n-appimage
41+
env:
42+
DSN: ${{ secrets.DSN }}
3943
- name: Release
4044
uses: softprops/action-gh-release@v1
4145
with:
@@ -74,6 +78,8 @@ jobs:
7478
yarn run dist
7579
- name: Building
7680
run: yarn run build
81+
env:
82+
DSN: ${{ secrets.DSN }}
7783
- name: Release
7884
uses: softprops/action-gh-release@v1
7985
with:
@@ -91,3 +97,4 @@ jobs:
9197
yarn run build:appimage
9298
env:
9399
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100+
DSN: ${{ secrets.DSN }}

@types/PreMiD/ExtensionSettings.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
export default interface ExtensionSettings {
2+
/**
3+
* If it's the first run of the app
4+
*/
5+
firstLaunch: boolean;
6+
/**
7+
* If the user approved to use the automatic crash reporter
8+
*/
9+
improvementProgramme: boolean;
210
/**
311
* If extension is enabled
412
*/

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"typescript": "3.8.3"
6363
},
6464
"dependencies": {
65+
"@sentry/electron": "1.3.0",
6566
"auto-launch": "5.0.5",
6667
"discord-rpc": "github:discordjs/RPC",
6768
"electron-store": "5.1.1",

src/index.ts

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import "source-map-support/register";
2+
import * as Sentry from "@sentry/electron";
23

3-
import { app, dialog } from "electron";
4+
import { app, dialog, shell } from "electron";
45
import { init as initSocket, socket } from "./managers/socketManager";
56
import { update as initAutoLaunch } from "./managers/launchManager";
6-
import { checkForUpdate } from "./util/updateChecker";
77
import { TrayManager } from "./managers/trayManager";
8+
import { settings } from "./managers/settingsManager";
9+
import { checkForUpdate } from "./util/updateChecker";
810

911
export let trayManager: TrayManager;
1012

@@ -13,6 +15,32 @@ export let trayManager: TrayManager;
1315
//* When app is ready
1416
export let updateCheckerInterval = null;
1517
app.whenReady().then(async () => {
18+
if (settings.get("firstLaunch")) {
19+
settings.set("firstLaunch", false);
20+
dialog
21+
.showMessageBox({
22+
message: "Welcome to PreMiD!",
23+
detail:
24+
"In order to work, the browser extension is also required, would you like to install it now?",
25+
buttons: ["I already have it", "Show me"],
26+
type: "question",
27+
cancelId: 0,
28+
defaultId: 0,
29+
checkboxLabel: "Also enable automatic crash reporting",
30+
checkboxChecked: true
31+
})
32+
.then(async value => {
33+
if (value.checkboxChecked) await initReporter(true);
34+
switch (value.response) {
35+
case 1:
36+
shell.openExternal("https://premid.app/downloads#ext-downloads");
37+
break;
38+
}
39+
});
40+
} else {
41+
await initReporter();
42+
}
43+
1644
trayManager = new TrayManager();
1745
await initAutoLaunch();
1846
await initSocket();
@@ -25,6 +53,16 @@ app.whenReady().then(async () => {
2553
}
2654
});
2755

56+
async function initReporter(firstLaunch: boolean = false) {
57+
if (firstLaunch) settings.set("improvementProgramme", true);
58+
if (settings.get("improvementProgramme")) {
59+
console.log("Initializing Sentry...");
60+
Sentry.init({
61+
dsn: process.env.DSN
62+
});
63+
}
64+
}
65+
2866
//* If second instance started, close old one
2967
app.on("second-instance", () => app.exit(0));
3068

src/managers/discordManager.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ class RPCClient {
4545

4646
if (!this.clientReady || !presenceData) return;
4747

48-
presenceData.presenceData.largeImageText += ` App v${app.getVersion()}`;
48+
// Workaround
49+
if(presenceData.presenceData.largeImageText && presenceData.presenceData.largeImageText.includes("PreMiD")) {
50+
presenceData.presenceData.largeImageText = "PreMiD 🐧 v" + app.getVersion();
51+
}
52+
4953
this.client
5054
.setActivity(presenceData.presenceData)
5155
.catch(() => this.destroy());

src/managers/settingsManager.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import ExtensionSettings from "../../@types/PreMiD/ExtensionSettings";
77
//* Export and set default settings
88
export let settings = new ElectronStore({
99
defaults: {
10-
autoLaunch: true
10+
firstLaunch: true,
11+
autoLaunch: true,
12+
improvementProgramme: false
1113
}
1214
});
1315

@@ -16,12 +18,11 @@ export let settings = new ElectronStore({
1618
* @param extensionSettings Settings from extension
1719
*/
1820
export function update(extensionSettings: ExtensionSettings) {
19-
//* remove title if disabled
2021
//* Update autolaunch if updated
2122
//* Save Settings
22-
console.log("Updated settings");
2323
if (settings.get("autoLaunch") != extensionSettings.autoLaunch) {
2424
settings.set("autoLaunch", extensionSettings.autoLaunch);
2525
updateAutoLaunch();
26+
console.log("Updated settings");
2627
}
2728
}

src/managers/trayManager.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import { trayManager } from "..";
44
import { checkForUpdate, updateProcess } from "../util/updateChecker";
55
import { connected } from "./socketManager";
66

7-
let trayIcon = join(__dirname, "../assets/tray/[email protected]");
87
export class TrayManager {
98
tray: Tray;
109

1110
constructor() {
12-
this.tray = new Tray(trayIcon);
11+
this.tray = new Tray(join(__dirname, "../assets/tray/[email protected]"));
1312
this.tray.setToolTip(app.name);
1413

1514
this.tray.on("right-click", () => this.update());
@@ -19,7 +18,6 @@ export class TrayManager {
1918
this.tray.setContextMenu(
2019
Menu.buildFromTemplate([
2120
{
22-
icon: join(__dirname, "../assets/tray/Icon.png"),
2321
label: `${app.name} v${app.getVersion()}`,
2422
enabled: false
2523
},

tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
"removeComments": true,
88
"esModuleInterop": true,
99
"inlineSourceMap": true,
10+
"inlineSources": true,
11+
"sourceRoot": "/",
1012
"skipLibCheck": true,
1113
"noUnusedParameters": true,
1214
"noUnusedLocals": true
1315
},
1416
"include": ["src/**/*"],
1517
"exclude": ["node_modules"]
16-
}
18+
}

0 commit comments

Comments
 (0)