### Initialize Sentry in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/sessions/native-crash-renderer-electron-uploader/src/index.html Call `init` from `@sentry/electron/renderer` to configure Sentry. Enable `debug` for verbose logging. This example also demonstrates triggering a crash after a delay. ```javascript const { init } = require('@sentry/electron/renderer'); init({ debug: true, }); setTimeout(() => { process.crash(); }, 1000); ``` -------------------------------- ### Initialize Sentry in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/other/custom-renderer-name/src/index.html Use this snippet to initialize the Sentry SDK in your Electron application's renderer process. Ensure you have installed the `@sentry/electron/renderer` package. This example enables debug mode and simulates an error after 500ms. ```javascript const { init } = require('@sentry/electron/renderer'); init({ debug: true, }); setTimeout(() => { throw new Error('Some renderer error'); }, 500); ``` -------------------------------- ### Run Unit Tests Source: https://github.com/getsentry/sentry-electron/blob/master/test/README.md Execute all unit tests for the Sentry Electron SDK. Ensure all dependencies are installed before running. ```shell yarn test ``` -------------------------------- ### Initialize Sentry in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/sessions/window-bad/src/index.html Use this snippet to initialize the Sentry SDK in your Electron application's renderer process. Ensure you have installed the `@sentry/electron/renderer` package. This example also includes a delayed error to test Sentry's error capturing. ```javascript const { init } = require('@sentry/electron/renderer'); init({ debug: true, }); setTimeout(() => { throw new Error('Some renderer error'); }, 1000); ``` -------------------------------- ### JavaScript: Initialize Sentry Disabling Session Tracking Source: https://github.com/getsentry/sentry-electron/blob/master/MIGRATION.md This example shows how to initialize the Sentry Electron SDK while disabling the default session tracking by setting `autoSessionTracking` to `false`. ```javascript Sentry.init({ dsn: '__DSN__', autoSessionTracking: false, }); ``` -------------------------------- ### Initialize Sentry in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/javascript/renderer-error/src/index.html Use this snippet to initialize the Sentry SDK in your Electron application's renderer process. Ensure `@sentry/electron/renderer` is installed. Debugging is enabled by default. ```javascript const { init } = require('@sentry/electron/renderer'); init({ debug: true, }); setTimeout(() => { throw new Error('Some renderer error'); }, 500); ``` -------------------------------- ### Initialize Sentry and Log Events in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/other/renderer-error/src/index.html Initializes Sentry with debug and logging enabled for the renderer process. Includes an example of logging a trace event with custom data after a delay. ```javascript const { init, logger } = require('@sentry/electron/renderer'); init({ debug: true, enableLogs: true, }); setTimeout(() => { logger.trace('User clicked submit button', { buttonId: 'submit-form', formId: 'user-profile', timestamp: Date.now() }); }, 1000); ``` -------------------------------- ### Initialize Sentry and Trigger Crash in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/native-sentry/renderer-limit/src/index.html Initializes Sentry with debug mode enabled in the renderer process and then triggers a process crash after a delay. Ensure `@sentry/electron/renderer` is installed. ```javascript const { init } = require('@sentry/electron/renderer'); init({ debug: true, }); setTimeout(() => { process.crash(); }, 500); ``` -------------------------------- ### Initialize Sentry in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/other/browser-replay/src/index.html Use this snippet to initialize Sentry in your Electron renderer process. Ensure you have the '@sentry/electron/renderer' package installed. This configuration enables debug mode, includes the replay integration, and sets sampling rates for sessions and errors. ```javascript const { init, replayIntegration } = require('@sentry/electron/renderer'); init({ debug: true, integrations: [ replayIntegration() ], replaysSessionSampleRate: 0, replaysOnErrorSampleRate: 1, }); console.log('Some renderer message'); setTimeout(() => { throw new Error('Some renderer error'); }, 1000); ``` -------------------------------- ### Initialize Sentry Electron Renderer and Trigger Crash Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/native-electron/renderer/src/index.html Use this snippet to initialize Sentry in your Electron application's renderer process. Ensure `@sentry/electron/renderer` is installed. The `process.crash()` call is for testing error reporting and should be removed in production. ```javascript const { init } = require('@sentry/electron/renderer'); init({ debug: true, }); setTimeout(() => { process.crash(); }, 500); ``` -------------------------------- ### Manual UI Profiling and Work Execution Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/other/browser-profiling-manual/src/index.html Starts UI profiling manually, executes a 'Long work' span that includes the 'longWork' function, and then stops profiling to send the collected data. ```javascript setTimeout(async () => { // Start UI profiling manually uiProfiler.startProfiler(); await startSpan({ name: 'Long work' }, async () => { await longWork(); }); // Stop profiling - this will send a profile_chunk uiProfiler.stopProfiler(); }, 500); ``` -------------------------------- ### Initialize Sentry with Browser Tracing Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/other/startup-tracing/src/index.html Configures the Sentry SDK in the renderer process to track startup performance. ```javascript const { init, browserTracingIntegration } = require('@sentry/electron/renderer'); init({ integrations: [browserTracingIntegration()], tracesSampleRate: 1, }); ``` -------------------------------- ### Initialize Sentry Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/other/metrics/src/index.html Call `init` to set up Sentry in the renderer process. Ensure `debug` is set to `true` for verbose logging during development. ```javascript const { init, metrics } = require('@sentry/electron/renderer'); init({ debug: true, }); ``` -------------------------------- ### Initialize Sentry in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/other/browser-tracing/src/index.html Use this configuration to set up Sentry with browser tracing enabled in the renderer process. ```javascript const { init, browserTracingIntegration } = require('@sentry/electron/renderer'); init({ debug: true, integrations: [browserTracingIntegration()], tracesSampleRate: 1, }); ``` -------------------------------- ### Initialize Sentry in Electron Main Process Source: https://github.com/getsentry/sentry-electron/blob/master/MIGRATION.md Import from @sentry/electron/main when initializing in the main process. ```javascript import * as Sentry from '@sentry/electron/main'; Sentry.init({ dsn: '__DSN__', // ...more options }); ``` -------------------------------- ### Initialize Sentry in Electron Main Process Source: https://github.com/getsentry/sentry-electron/blob/master/README.md Call init as early as possible in the main process entry module to hook the environment. ```javascript import { init } from '@sentry/electron/main'; init({ dsn: '__DSN__', // ... }); ``` -------------------------------- ### Combine Sentry Electron with Framework SDKs Source: https://github.com/getsentry/sentry-electron/blob/master/README.md Pass a framework-specific init function as the second parameter to combine functionalities. ```javascript import { init } from '@sentry/electron/renderer'; import { init as reactInit } from '@sentry/react'; init( { /* config */ }, reactInit, ); ``` -------------------------------- ### Initialize Sentry in Main Process Source: https://github.com/getsentry/sentry-electron/blob/master/MIGRATION.md Basic initialization for the main process. ```ts import * as Sentry from '@sentry/electron/main'; Sentry.init({ dsn: '__DSN__', }); ``` -------------------------------- ### Initialize Sentry Electron with Profiling Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/other/browser-profiling-trace/src/index.html Configures the Sentry renderer process with browser profiling enabled and sets sampling rates for traces and profiles. ```javascript const crypto = require('crypto'); const { init, browserProfilingIntegration, startSpan } = require('@sentry/electron/renderer'); init({ debug: true, integrations: [browserProfilingIntegration()], tracesSampleRate: 1, profileSessionSampleRate: 1, profileLifecycle: 'trace', }); function pbkdf2() { return new Promise((resolve) => { const salt = crypto.randomBytes(128).toString('base64'); crypto.pbkdf2('myPassword', salt, 10000, 512, 'sha512', resolve); }); } async function longWork() { for (let i = 0; i < 10; i++) { await startSpan({ name: 'PBKDF2' }, async () => { await pbkdf2(); }); } } // In trace mode, profiling automatically starts/stops with spans setTimeout(async () => { await startSpan({ name: 'Long work' }, async () => { await longWork(); }); }, 500); ``` -------------------------------- ### JavaScript: Import Sentry for Main Process Source: https://github.com/getsentry/sentry-electron/blob/master/MIGRATION.md This demonstrates how to import the Sentry SDK specifically for the main process when using relative imports for bundler support. Use this if you need to apply specific integrations to the main process only. ```javascript const Sentry = require('@sentry/electron/main'); // or import * as Sentry from '@sentry/electron/main'; ``` -------------------------------- ### Initialize Sentry in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/offline/renderer-error-drop/src/index.html Initializes the Sentry SDK in the renderer process. Ensure this is called after the DOM is ready. Includes a simulated error for testing purposes. ```javascript const { init } = require('@sentry/electron/renderer'); init({ debug: true, }); if (process.env.APP_FIRST_RUN) { setTimeout(() => { throw new Error('Some renderer error'); }, 500); } ``` -------------------------------- ### Configure ElectronMinidump Integration Source: https://github.com/getsentry/sentry-electron/blob/master/MIGRATION.md Add the ElectronMinidump integration to the initialization process. ```ts import { init, Integrations } from '@sentry/electron'; init({ dsn: '__DSN__', // Adding the ElectronMinidump integration like this // ensures that it is the first integrations to be initialized. integrations: (defaultIntegrations) => { return [new Integrations.ElectronMinidump(), ...defaultIntegrations]; }, }); ``` -------------------------------- ### Initialize Sentry with Profiling Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/other/browser-profiling-manual/src/index.html Initializes Sentry with the browser profiling integration and configures sampling rates for traces and profiles. Manual profile lifecycle management is enabled. ```javascript const crypto = require('crypto'); const { init, browserProfilingIntegration, startSpan, uiProfiler } = require('@sentry/electron/renderer'); init({ debug: true, integrations: [browserProfilingIntegration()], tracesSampleRate: 1, profileSessionSampleRate: 1, profileLifecycle: 'manual', }); ``` -------------------------------- ### Initialize Sentry in Electron Renderer Process Source: https://github.com/getsentry/sentry-electron/blob/master/README.md Call init in all renderer processes to capture JavaScript errors. ```javascript // In the Electron renderer processes import { init } from '@sentry/electron/renderer'; init(); ``` -------------------------------- ### Initialize Sentry and Send Feedback in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/other/feedback/src/index.html Initializes the Sentry SDK with debug mode enabled and sends a feedback object after a 500ms timeout. ```javascript const crypto = require('crypto'); const { init, sendFeedback } = require('@sentry/electron/renderer'); init({ debug: true, }); setTimeout(() => { sendFeedback({ name: 'John Doe', email: 'john@doe.com', message: 'I really like your App, thanks!', }); }, 500); ``` -------------------------------- ### Electron Main Process Options Interface Source: https://github.com/getsentry/sentry-electron/blob/master/MIGRATION.md Configuration options specific to the Electron main process. ```ts export interface ElectronMainOptions extends NodeOptions { /** * Inter-process communication mode to receive event and scope from renderers * * IPCMode.Classic - Configures Electron IPC * IPCMode.Protocol - Configures a custom protocol * IPCMode.Both - Configures both IPC and custom protocol * * Defaults to IPCMode.Both for maximum compatibility */ ipcMode: IPCMode; /** * A function that returns an array of Electron session objects * * These sessions are used to configure communication between the Electron * main and renderer processes. * * Defaults to () => [session.defaultSession] */ getSessions: () => Session[]; /** * Callback to allow custom naming of renderer processes. * * If the callback is not set, or it returns `undefined`, the default naming * scheme is used. */ getRendererName?: (contents: WebContents) => string | undefined; } ``` -------------------------------- ### Initialize Sentry in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/native-sentry/main/src/index.html Import and initialize the Sentry SDK in your Electron renderer process. Enable debug mode for detailed logging. This snippet also includes a conditional log for the application's first run, useful for capturing breadcrumbs from a crashing session. ```javascript const { init } = require('@sentry/electron/renderer'); init({ debug: true, }); if (process.env.APP_FIRST_RUN) { console.log('renderer process breadcrumb from first crashing run'); } ``` -------------------------------- ### Initialize Sentry in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/javascript/renderer-error-protocol/src/index.html Initializes the Sentry SDK in the renderer process with debug mode enabled and triggers a test error after 500ms. ```javascript const { init } = require('@sentry/electron/renderer'); init({ debug: true, }); setTimeout(() => { throw new Error('Some renderer error'); }, 500); ``` -------------------------------- ### Initialize Sentry in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/native-electron/renderer-custom-release/src/index.html Initializes the Sentry SDK in the renderer process with debug mode enabled and triggers a crash after 500ms. ```javascript const { init } = require('@sentry/electron/renderer'); init({ debug: true, }); setTimeout(() => { process.crash(); }, 500); ``` -------------------------------- ### Initialize Sentry in Electron Renderer Process Source: https://github.com/getsentry/sentry-electron/blob/master/MIGRATION.md Import from @sentry/electron/renderer when initializing in renderer processes. ```javascript // In the Electron renderer processes import * as Sentry from '@sentry/electron/renderer'; // It's not a requirement to pass any options in the renderer processes because // much of the functionality is configured from the main process Sentry.init(); ``` -------------------------------- ### Configure Preload Script Source: https://github.com/getsentry/sentry-electron/blob/master/MIGRATION.md Load the Sentry preload module to enable IPC communication. ```ts require('@sentry/electron/preload'); // or import '@sentry/electron/preload'; ``` -------------------------------- ### JavaScript: Initialize Sentry with Default Session Tracking Source: https://github.com/getsentry/sentry-electron/blob/master/MIGRATION.md This is the default initialization for Sentry Electron SDK, enabling session tracking by default. Ensure you replace `__DSN__` and `__RELEASE__` with your actual values. ```javascript Sentry.init({ dsn: '__DSN__', release: '__RELEASE__', }); ``` -------------------------------- ### Initialize Sentry in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/javascript/renderer-error-namespaced/src/index.html Initializes the Sentry SDK for the renderer process. Ensure this is called early in your application's lifecycle. The `ipcNamespace` option is used to customize the IPC channel name. ```javascript const { init } = require('@sentry/electron/renderer'); init({ debug: true, ipcNamespace: 'test-app', }); setTimeout(() => { throw new Error('Some renderer error'); }, 500); ``` -------------------------------- ### Run End-to-End Tests Source: https://github.com/getsentry/sentry-electron/blob/master/test/README.md Execute the comprehensive suite of end-to-end tests. This command tests various Electron versions, platforms, and SDK features against a mock Sentry server. ```shell yarn e2e ``` -------------------------------- ### Initialize Sentry in Renderer Process Source: https://github.com/getsentry/sentry-electron/blob/master/MIGRATION.md Import the Sentry renderer module using either CommonJS or ES modules. ```ts const Sentry = require('@sentry/electron/renderer'); // or import * as Sentry from '@sentry/electron/renderer'; ``` -------------------------------- ### Initialize Sentry in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/other/child-process/src/index.html Use this to configure Sentry in the renderer process. The debug flag is enabled for troubleshooting purposes. ```javascript const { init } = require('@sentry/electron/renderer'); init({ debug: true, }); setTimeout(() => { throw new Error('Some renderer error'); }, 2000); ``` -------------------------------- ### Initialize Sentry in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/other/window-titles/src/index.html Initializes the Sentry SDK in the renderer process with debug mode enabled and sets up a periodic title update. ```javascript const { init } = require('@sentry/electron/renderer'); init({ debug: true, }); setInterval(() => { document.title = `This is the new page title: ${Math.random()}`; }, 10); ``` -------------------------------- ### Initialize Sentry with Event Loop Block Integration Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/anr/anr-renderer/src/index.html Initialize Sentry in the renderer process and configure the eventLoopBlockIntegration to monitor for UI thread blocks. Set the threshold for detecting blocks in milliseconds. ```javascript const crypto = require('crypto'); const { init, eventLoopBlockIntegration } = require('@sentry/electron/renderer'); function longWork() { for (let i = 0; i < 100; i++) { const salt = crypto.randomBytes(128).toString('base64'); // eslint-disable-next-line no-unused-vars const hash = crypto.pbkdf2Sync('myPassword', salt, 10000, 512, 'sha512'); } } init({ debug: true, integrations: [ eventLoopBlockIntegration({threshold: 1000}) ], }); setTimeout(() => { longWork(); }, 2000); ``` -------------------------------- ### Initialize Sentry in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/offline/native-crash/src/index.html Initializes the Sentry SDK with debug mode enabled and includes a conditional crash trigger for testing application stability. ```javascript const { init } = require('@sentry/electron/renderer'); init({ debug: true, }); if (process.env.APP_FIRST_RUN) { setTimeout(() => { process.crash(); }, 1000); } ``` -------------------------------- ### Enable IP Address Collection Source: https://github.com/getsentry/sentry-electron/blob/master/MIGRATION.md Set sendDefaultPii to true to include user IP addresses in events. ```javascript import * as Sentry from "@sentry/electron/main"; Sentry.init({ dsn: "__DSN__", sendDefaultPii: true, }); ``` -------------------------------- ### Enable Browser Tracing in Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/MIGRATION.md Configure BrowserTracing integration within the renderer process. ```ts import * as Sentry from '@sentry/electron/renderer'; import { Integrations } from '@sentry/tracing'; Sentry.init({ integrations: [new Integrations.BrowserTracing()], tracesSampleRate: 1.0, }); ``` -------------------------------- ### Initialize Sentry in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/other/capture-console/src/index.html Configures Sentry with debug mode enabled and the console integration to capture error messages. ```javascript const { init, captureConsoleIntegration } = require('@sentry/electron/renderer'); init({ debug: true, integrations: [captureConsoleIntegration()], }); setTimeout(() => { console.error('This is an error message'); }, 1000); ``` -------------------------------- ### Initialize Sentry in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/other/scope-breadcrumbs/src/index.html Configures Sentry with debug mode and a beforeSend hook to attach screenshots. Sets a custom tag on the current scope and triggers a test error. ```javascript const { init, getCurrentScope } = require('@sentry/electron/renderer'); init({ debug: true, beforeSend: (event, hint) => { hint.attachments = [{ filename: 'screenshot.png', data: 'captureScreen()' }, ...(hint.attachments || [])]; return event; }, }); const scope = getCurrentScope(); scope.setTag('renderer-tag', 'another-value'); console.log('Some logging from the renderer process'); setTimeout(() => { throw new Error('Some renderer error'); }, 1000); ``` -------------------------------- ### Initialize Sentry in Electron Renderer Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/javascript/renderer-unhandledrejection/src/index.html Initialize Sentry in the renderer process with debug mode enabled. This snippet also demonstrates capturing an unhandled promise rejection. ```javascript const { init } = require('@sentry/electron/renderer'); init({ debug: true, }); setTimeout(() => { new Promise((_resolve, _reject) => { throw new Error('Unhanded promise rejection in renderer process'); }); }, 500); ``` -------------------------------- ### Manage Scope and Capture Events Source: https://github.com/getsentry/sentry-electron/blob/master/README.md Use exported functions to set user context, tags, breadcrumbs, and capture manual events after initialization. ```javascript 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: [ // ... ], }); ``` -------------------------------- ### Perform PBKDF2 Hashing Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/other/browser-profiling-manual/src/index.html A utility function to perform a PBKDF2 hashing operation. It generates a random salt and uses it with the provided password for hashing. ```javascript function pbkdf2() { return new Promise((resolve) => { const salt = crypto.randomBytes(128).toString('base64'); crypto.pbkdf2('myPassword', salt, 10000, 512, 'sha512', resolve); }); } ``` -------------------------------- ### Conditional Test Execution in Recipes Source: https://github.com/getsentry/sentry-electron/blob/master/test/README.md JavaScript expressions used in `recipe.yml` to conditionally skip tests based on platform, Electron version, or other environment factors. The `version` object provides access to major, minor, and patch numbers. ```typescript namespace Global { const platform: 'win32' | 'darwin' | 'linux'; const version: { major: number; minor: number; patch: number }; const supportsContextIsolation: boolean; } version.major >= 5; ``` -------------------------------- ### TypeScript: New shouldSend and shouldStore Callbacks Source: https://github.com/getsentry/sentry-electron/blob/master/MIGRATION.md These are the new callback signatures for the offline transport, replacing `beforeSend`. `shouldSend` determines if an envelope should be sent, and `shouldStore` determines if it should be queued if sending fails. ```typescript /** * Called before we attempt to send an envelope to Sentry. * * If this function returns false, `shouldStore` will be called to determine if the envelope should be stored. * * Default: () => true * * @param envelope The envelope that will be sent. * @returns Whether we should attempt to send the envelope */ shouldSend?: (envelope: Envelope) => boolean | Promise; ``` ```typescript /** * Called before an event is stored. * * Return false to drop the envelope rather than store it. * * Default: () => true * * @param envelope The envelope that failed to send. * @param error The error that occurred. * @param retryDelay The current retry delay in milliseconds. * @returns Whether we should store the envelope in the queue */ shouldStore?: (envelope: Envelope, error: Error, retryDelay: number) => boolean | Promise; ``` -------------------------------- ### Execute Long Work with Spans Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/other/browser-profiling-manual/src/index.html Simulates a lengthy operation by repeatedly performing PBKDF2 hashing within Sentry spans. Each PBKDF2 call is wrapped in a 'PBKDF2' span. ```javascript async function longWork() { for (let i = 0; i < 10; i++) { await startSpan({ name: 'PBKDF2' }, async () => { await pbkdf2(); }); } } ``` -------------------------------- ### Record Custom Metric in Sentry Source: https://github.com/getsentry/sentry-electron/blob/master/test/e2e/test-apps/other/metrics/src/index.html Use the `metrics.count` method to send a custom count metric to Sentry. Provide a descriptive name and a value, along with optional attributes for context. ```javascript metrics.count('User clicked submit button', 1, { attributes: { buttonId: 'submit-form', formId: 'user-profile', }, }); ``` -------------------------------- ### Disable Session Tracking in v6 Source: https://github.com/getsentry/sentry-electron/blob/master/MIGRATION.md Disable session tracking by filtering out the MainProcessSession integration in version 6. ```javascript import * as Sentry from "@sentry/electron/main"; Sentry.init({ dsn: "__DSN__", integrations: (defaults) => defaults.filter((i) => i.name !== "MainProcessSession"), }); ``` -------------------------------- ### TypeScript: BeforeSend Callback Signature (Deprecated) Source: https://github.com/getsentry/sentry-electron/blob/master/MIGRATION.md This is the deprecated signature for the `beforeSend` callback in the offline transport. It was used to control event sending behavior. ```typescript type BeforeSendResponse = 'send' | 'queue' | 'drop'; /** * Called before attempting to send an event to Sentry. * * Return 'send' to attempt to send the event. * Return 'queue' to queue and persist the event for sending later. * Return 'drop' to drop the event. */ beforeSend?: (request: TransportRequest) => BeforeSendResponse | Promise; ``` -------------------------------- ### Disable Session Tracking in v5 Source: https://github.com/getsentry/sentry-electron/blob/master/MIGRATION.md Use the autoSessionTracking option to disable session tracking in version 5. ```javascript import * as Sentry from "@sentry/electron/main"; Sentry.init({ dsn: "__DSN__", autoSessionTracking: false, }); ``` -------------------------------- ### Disable Native Crash Reporting Source: https://github.com/getsentry/sentry-electron/blob/master/MIGRATION.md Remove the SentryMinidump integration to disable native crash reporting. ```ts import { init, Integrations } from '@sentry/electron'; init({ dsn: '__DSN__', integrations: defaultIntegrations => { return ...defaultIntegrations.filter(i => i.name != Integrations.SentryMinidump.Id); } }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.