Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support Electron utility process #991

Merged
merged 6 commits into from
Oct 4, 2024

Conversation

timfish
Copy link
Collaborator

@timfish timfish commented Oct 1, 2024

Closes #987

utility.js

import * as Sentry from '@sentry/electron/utility';

// No config required in utility process
Sentry.init();

main.js

import * as path from 'path';
import * as Sentry from '@sentry/main';
import { app, utilityProcess } from 'electron';

Sentry.init({
  dsn: '__DSN__'
});

app.on('ready', () => {
  // No special config required in the main process, just fork as before
  const child = utilityProcess.fork(path.join(__dirname, 'utility.js'));
});

How it works

We wrap electron.utilityProcess.fork which allows us to set up a message port between the processes. All events from the utility process are passed to the main process via a custom transport. This way we retain the offline support, events get the full Electron context and all events go through the main process beforeSend callback.

Unlike renderer processes, utility processes do not yet sync scope (ie. user, tags, extra, etc) to the main process.

@timfish timfish marked this pull request as ready for review October 1, 2024 19:27
Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make sure to update docs. Should we update https://github.com/getsentry/sentry-wizard as well?

@timfish
Copy link
Collaborator Author

timfish commented Oct 4, 2024

Will definitely need adding to the docs. Not sure this Electron feature is widely used enough to warrant adding to the wizard 🤔

@timfish timfish merged commit 9ac67e5 into getsentry:master Oct 4, 2024
34 checks passed
@timfish timfish deleted the feat/utility-process branch October 4, 2024 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Electron utility processes
2 participants