
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
@sentry/electron
Advanced tools
@sentry/electron is a package that provides error tracking and performance monitoring for Electron applications. It allows developers to capture and report errors, monitor application performance, and gain insights into application behavior in production environments.
Error Tracking
This feature allows developers to initialize Sentry in their Electron application to automatically capture and report errors. The DSN (Data Source Name) is used to identify the project in Sentry.
const { init } = require('@sentry/electron');
init({
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
});
Performance Monitoring
This feature enables performance monitoring by setting a sample rate for tracing. It helps in capturing performance data to analyze application speed and responsiveness.
const { init } = require('@sentry/electron');
init({
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
tracesSampleRate: 1.0,
});
Breadcrumbs
Breadcrumbs are used to record events leading up to an error. This feature allows developers to add custom breadcrumbs to provide context around errors.
const { addBreadcrumb } = require('@sentry/electron');
addBreadcrumb({
category: 'ui.click',
message: 'User clicked on button',
level: 'info',
});
electron-log is a package for logging in Electron applications. Unlike @sentry/electron, it focuses on logging messages to files, console, and remote endpoints without providing error tracking or performance monitoring capabilities.
Winston is a versatile logging library for Node.js applications, including Electron. It provides logging capabilities but lacks the integrated error tracking and performance monitoring features of @sentry/electron.
log4js is another logging library for Node.js that can be used in Electron applications. It offers logging features similar to winston but does not include the error tracking and performance monitoring functionalities of @sentry/electron.
@sentry/node
)@sentry/browser
)electron >= v15
To use this SDK, call init(options)
as early as possible in the entry modules in the main process as well as all
renderer processes or further sub processes you spawn. This will initialize the SDK and hook the environment.
In the Electron main process:
import { init } from '@sentry/electron/main';
init({
dsn: '__DSN__',
// ...
});
In all Electron renderer processes:
// In the Electron renderer processes
import { init } from '@sentry/electron/renderer';
init();
If you are using a framework specific Sentry SDK, you can pass that init
function as the second parameter in the
renderer and the two SDKs functionalities will be combined:
import { init } from '@sentry/electron/renderer';
import { init as reactInit } from '@sentry/react';
init({ /* config */ }, reactInit);
To set context information or send manual events, use the exported functions of @sentry/electron
. Note that these
functions will not perform any action before you have called init()
:
import * as Sentry from '@sentry/electron/main';
// Set user information, as well as tags and further extras
const scope = Sentry.getCurrentScope();
scope.setExtra('battery', 0.7);
scope.setTag('user_mode', 'admin');
scope.setUser({ id: '4711' });
// Add a breadcrumb for future events
Sentry.addBreadcrumb({
message: 'My Breadcrumb',
// ...
});
// Capture exceptions, messages or manual events
Sentry.captureMessage('Hello, world!');
Sentry.captureException(new Error('Good bye'));
Sentry.captureEvent({
message: 'Manual',
stacktrace: [
// ...
],
});
Thanks to everyone who contributed to the Sentry Electron SDK!
FAQs
Official Sentry SDK for Electron
The npm package @sentry/electron receives a total of 164,409 weekly downloads. As such, @sentry/electron popularity was classified as popular.
We found that @sentry/electron demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.