Skip to content

Commit

Permalink
fix: Upgrade Electron stack to latest versions (#490)
Browse files Browse the repository at this point in the history
This is to fix #484 as we are using a quite old stack (and Electron
version).
  • Loading branch information
BYK authored Aug 13, 2024
1 parent ae3badc commit 3d18ce3
Show file tree
Hide file tree
Showing 7 changed files with 1,326 additions and 462 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-mayflies-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@spotlightjs/electron': patch
---

Upgrade Electron stack for macOS 15 compatibility
21 changes: 9 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,18 @@ jobs:
# platform: [x64, arm64]

steps:
- uses: actions/checkout@v4
- name: Checkout Repo
uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
fetch-depth: 0
node-version-file: 'package.json'

- name: Install pnpm
- name: Setup pnpm & install dependencies
uses: pnpm/action-setup@v4

- name: Setup Node
uses: actions/setup-node@v3

- name: Install deps
run: pnpm install

- name: Build packages
run: pnpm build
with:
run_install: true

- name: Build Electron
env:
Expand Down
13 changes: 2 additions & 11 deletions packages/electron/electron.vite.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { sentryVitePlugin } from '@sentry/vite-plugin';
import { defineConfig, loadEnv } from 'electron-vite';
import { resolve } from 'path';
import sourcemaps from 'rollup-plugin-sourcemaps';
import { resolve } from 'node:path';
import sourcemaps from 'rollup-plugin-sourcemaps2';

export default defineConfig(({ mode }) => {
// Load env file based on `mode` in the current working directory.
Expand All @@ -28,9 +28,6 @@ export default defineConfig(({ mode }) => {
sourcemap: true,
rollupOptions: {
plugins: [sourcemaps()],
output: {
sourcemap: true,
},
input: {
index: resolve(__dirname, 'src/electron/main/index.ts'),
},
Expand All @@ -52,9 +49,6 @@ export default defineConfig(({ mode }) => {
sourcemap: true,
rollupOptions: {
plugins: [sourcemaps()],
output: {
sourcemap: true,
},
input: {
index: resolve(__dirname, 'src/electron/preload/index.ts'),
},
Expand All @@ -75,9 +69,6 @@ export default defineConfig(({ mode }) => {
sourcemap: true,
rollupOptions: {
plugins: [sourcemaps()],
output: {
sourcemap: true,
},
input: {
index: resolve(__dirname, 'index.html'),
},
Expand Down
18 changes: 9 additions & 9 deletions packages/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
"build:mac": "pnpm build && node electron-builder.js"
},
"dependencies": {
"@sentry/electron": "4.15.1",
"@sentry/electron": "^5.3.0",
"@spotlightjs/overlay": "workspace:*",
"@spotlightjs/sidecar": "workspace:*",
"electron-store": "^8.1.0"
"electron-store": "^10.0.0"
},
"devDependencies": {
"@electron/notarize": "^2.2.0",
"@sentry/vite-plugin": "2.10.2",
"dotenv": "^16.3.1",
"electron": "^28.0.0",
"electron-builder": "^24.9.1",
"electron-vite": "^2.0.0-beta.1",
"rollup-plugin-sourcemaps": "^0.6.3"
"@electron/notarize": "^2.3.2",
"@sentry/vite-plugin": "^2.22.1",
"dotenv": "^16.4.5",
"electron": "^31.3.1",
"electron-builder": "^24.13.3",
"electron-vite": "^2.3.0",
"rollup-plugin-sourcemaps2": "^0.4.1"
},
"volta": {
"extends": "../../package.json"
Expand Down
33 changes: 15 additions & 18 deletions packages/electron/src/electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import * as Sentry from '@sentry/electron/main';
import { clearBuffer, setupSidecar } from '@spotlightjs/sidecar';
import { BrowserWindow, Menu, app, dialog, ipcMain, shell } from 'electron';
import Store from 'electron-store';
import path from 'path';
import path from 'node:path';

const store = new Store();

Sentry.init({
dsn: 'https://192df1a78878de014eb416a99ff70269@o1.ingest.sentry.io/4506400311934976',
tracesSampleRate: 1.0,
release: 'spotlight@' + process.env.npm_package_version,
release: `spotlight@${process.env.npm_package_version}`,
beforeSend: askForPermissionToSendToSentry,
});

let alwaysOnTop = false;
let win;
let win: BrowserWindow;

const createWindow = () => {
win = new BrowserWindow({
Expand Down Expand Up @@ -44,13 +44,13 @@ const createWindow = () => {

// win.webContents.openDevTools();

if (!app.isPackaged && process.env['ELECTRON_RENDERER_URL']) {
win.loadURL(process.env['ELECTRON_RENDERER_URL']);
if (!app.isPackaged && process.env.ELECTRON_RENDERER_URL) {
win.loadURL(process.env.ELECTRON_RENDERER_URL);
} else {
win.loadFile(path.join(__dirname, '../renderer/index.html'));
}

win.once('ready-to-show', function () {
win.once('ready-to-show', () => {
win.show();
win.focus();
});
Expand Down Expand Up @@ -273,13 +273,13 @@ const showErrorMessage = () => {
}
};

async function askForPermissionToSendToSentry(event: Sentry.Event, hint?: Sentry.EventHint) {
async function askForPermissionToSendToSentry(event: Sentry.Event, hint: Sentry.EventHint) {
showErrorMessage();
if (store.get('sentry-enabled') === false) {
return null;
}
if (store.get('sentry-enabled') === true) {
if (hint?.attachments && hint.attachments.length > 0) {
if (hint.attachments && hint.attachments.length > 0) {
return askToSendEnvelope(event, hint);
}
return event;
Expand Down Expand Up @@ -322,9 +322,7 @@ async function askToSendEnvelope(event: Sentry.Event, hint?: Sentry.EventHint) {
});

if (response === 1) {
Sentry.configureScope(scope => {
scope.clearAttachments();
});
Sentry.getCurrentScope().clearAttachments();
if (hint?.attachments && hint.attachments.length > 0) {
hint.attachments = [];
}
Expand All @@ -338,13 +336,12 @@ async function askToSendEnvelope(event: Sentry.Event, hint?: Sentry.EventHint) {

function storeIncomingPayload(body: string) {
if (store.get('sentry-send-envelopes') === true || store.get('sentry-send-envelopes') === undefined) {
Sentry.configureScope(scope => {
scope.clearAttachments();
scope.addAttachment({
data: body,
filename: 'payload.txt',
contentType: 'text/plain',
});
const scope = Sentry.getCurrentScope();
scope.clearAttachments();
scope.addAttachment({
data: body,
filename: 'payload.txt',
contentType: 'text/plain',
});
}
}
Expand Down
3 changes: 1 addition & 2 deletions packages/overlay/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import react from '@vitejs/plugin-react';
import MagicString from 'magic-string';
import { sep } from 'node:path';
import { resolve } from 'path';
import { resolve, sep } from 'node:path';
import type { PluginOption } from 'vite';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
Expand Down
Loading

0 comments on commit 3d18ce3

Please sign in to comment.