123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 |
- import ExternalLink from 'sentry/components/links/externalLink';
- import crashReportCallout from 'sentry/components/onboarding/gettingStartedDoc/feedback/crashReportCallout';
- import widgetCallout from 'sentry/components/onboarding/gettingStartedDoc/feedback/widgetCallout';
- import TracePropagationMessage from 'sentry/components/onboarding/gettingStartedDoc/replay/tracePropagationMessage';
- import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
- import type {
- Docs,
- DocsParams,
- OnboardingConfig,
- } from 'sentry/components/onboarding/gettingStartedDoc/types';
- import {getUploadSourceMapsStep} from 'sentry/components/onboarding/gettingStartedDoc/utils';
- import {
- getCrashReportModalConfigDescription,
- getCrashReportModalInstallDescriptionJavaScript,
- getCrashReportModalIntroduction,
- getFeedbackConfigureDescription,
- getFeedbackSDKSetupSnippet,
- } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
- import exampleSnippets from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsExampleSnippets';
- import {metricTagsExplanation} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
- import {
- getReplayConfigureDescription,
- getReplaySDKSetupSnippet,
- } from 'sentry/components/onboarding/gettingStartedDoc/utils/replayOnboarding';
- import {t, tct} from 'sentry/locale';
- type Params = DocsParams;
- const getConfigureSnippet = (params: Params) => `
- import * as Sentry from "@sentry/electron";
- Sentry.init({
- dsn: "${params.dsn.public}",
- });`;
- const getMetricsConfigureSnippet = (params: Params) => `
- import * as Sentry from '@sentry/electron/main';
- // main process init
- Sentry.init({
- dsn: "${params.dsn.public}",
- // Only needed for SDK versions < 8.0.0
- // _experiments: {
- // metricsAggregator: true,
- // },
- });`;
- const getInstallConfig = () => [
- {
- code: [
- {
- label: 'npm',
- value: 'npm',
- language: 'bash',
- code: 'npm install --save @sentry/electron',
- },
- {
- label: 'yarn',
- value: 'yarn',
- language: 'bash',
- code: 'yarn add @sentry/electron',
- },
- ],
- },
- ];
- const onboarding: OnboardingConfig = {
- install: () => [
- {
- type: StepType.INSTALL,
- description: t('Add the Sentry Electron SDK package as a dependency:'),
- configurations: getInstallConfig(),
- },
- ],
- configure: params => [
- {
- type: StepType.CONFIGURE,
- description: tct(
- `You need to call [codeInit:Sentry.init] in the [codeMain:main] process and in every [codeRenderer:renderer] process you spawn.
- For more details about configuring the Electron SDK [docsLink:click here].`,
- {
- codeInit: <code />,
- codeMain: <code />,
- codeRenderer: <code />,
- docsLink: (
- <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/electron/" />
- ),
- }
- ),
- configurations: [
- {
- language: 'javascript',
- code: getConfigureSnippet(params),
- },
- ],
- },
- getUploadSourceMapsStep({
- guideLink:
- 'https://docs.sentry.io/platforms/javascript/guides/electron/sourcemaps/',
- ...params,
- }),
- ],
- verify: () => [
- {
- type: StepType.VERIFY,
- description: t(
- `One way to verify your setup is by intentionally causing an error that breaks your application.`
- ),
- configurations: [
- {
- description: t(
- `Calling an undefined function will throw a JavaScript exception:`
- ),
- language: 'javascript',
- code: 'myUndefinedFunction();',
- },
- {
- description: t(
- `With Electron you can test native crash reporting by triggering a crash:`
- ),
- language: 'javascript',
- code: 'process.crash();',
- },
- ],
- additionalInfo: t(
- 'You may want to try inserting these code snippets into both your main and any renderer processes to verify Sentry is operational in both.'
- ),
- },
- ],
- };
- const replayOnboarding: OnboardingConfig = {
- install: () => [
- {
- type: StepType.INSTALL,
- description: tct(
- 'For the Session Replay to work, you must have the framework SDK (e.g. [code:@sentry/electron]) installed, minimum version 4.2.0.',
- {
- code: <code />,
- }
- ),
- configurations: getInstallConfig(),
- },
- ],
- configure: (params: Params) => [
- {
- type: StepType.CONFIGURE,
- description: getReplayConfigureDescription({
- link: 'https://docs.sentry.io/platforms/javascript/guides/electron/session-replay/',
- }),
- configurations: [
- {
- code: [
- {
- label: 'JavaScript',
- value: 'javascript',
- language: 'javascript',
- code: getReplaySDKSetupSnippet({
- importStatement: `import * as Sentry from "@sentry/electron/renderer";`,
- dsn: params.dsn.public,
- mask: params.replayOptions?.mask,
- block: params.replayOptions?.block,
- }),
- },
- ],
- additionalInfo: <TracePropagationMessage />,
- },
- ],
- },
- ],
- verify: () => [],
- nextSteps: () => [],
- };
- const customMetricsOnboarding: OnboardingConfig = {
- install: () => [
- {
- type: StepType.INSTALL,
- description: tct(
- 'You need a minimum version [codeVersion:4.17.0] of [codePackage:@sentry/electron].',
- {
- codeVersion: <code />,
- codePackage: <code />,
- }
- ),
- configurations: getInstallConfig(),
- },
- ],
- configure: params => [
- {
- type: StepType.CONFIGURE,
- description: t(
- 'With the default snippet in place, there is no need for any further configuration.'
- ),
- configurations: [
- {
- code: getMetricsConfigureSnippet(params),
- language: 'javascript',
- },
- ],
- },
- ],
- verify: () => [
- {
- type: StepType.VERIFY,
- description: tct(
- "Then you'll be able to add metrics as [codeCounters:counters], [codeSets:sets], [codeDistribution:distributions], and [codeGauge:gauges]. These are available under the [codeNamespace:Sentry.metrics] namespace. This API is available in both renderer and main processes.",
- {
- codeCounters: <code />,
- codeSets: <code />,
- codeDistribution: <code />,
- codeGauge: <code />,
- codeNamespace: <code />,
- }
- ),
- configurations: [
- {
- description: metricTagsExplanation,
- },
- {
- description: t('Try out these examples:'),
- code: [
- {
- label: 'Counter',
- value: 'counter',
- language: 'javascript',
- code: exampleSnippets.javascript.counter,
- },
- {
- label: 'Distribution',
- value: 'distribution',
- language: 'javascript',
- code: exampleSnippets.javascript.distribution,
- },
- {
- label: 'Set',
- value: 'set',
- language: 'javascript',
- code: exampleSnippets.javascript.set,
- },
- {
- label: 'Gauge',
- value: 'gauge',
- language: 'javascript',
- code: exampleSnippets.javascript.gauge,
- },
- ],
- },
- {
- description: t(
- 'It can take up to 3 minutes for the data to appear in the Sentry UI.'
- ),
- },
- {
- description: tct(
- 'Learn more about metrics and how to configure them, by reading the [docsLink:docs].',
- {
- docsLink: (
- <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/electron/metrics/" />
- ),
- }
- ),
- },
- ],
- },
- ],
- };
- const feedbackOnboarding: OnboardingConfig = {
- install: () => [
- {
- type: StepType.INSTALL,
- description: tct(
- 'For the User Feedback integration to work, you must have the Sentry browser SDK package, or an equivalent framework SDK (e.g. [code:@sentry/electron]) installed, minimum version 7.85.0.',
- {
- code: <code />,
- }
- ),
- configurations: getInstallConfig(),
- },
- ],
- configure: (params: Params) => [
- {
- type: StepType.CONFIGURE,
- description: getFeedbackConfigureDescription({
- linkConfig:
- 'https://docs.sentry.io/platforms/javascript/guides/electron/user-feedback/configuration/',
- linkButton:
- 'https://docs.sentry.io/platforms/javascript/guides/electron/user-feedback/configuration/#bring-your-own-button',
- }),
- configurations: [
- {
- code: [
- {
- label: 'JavaScript',
- value: 'javascript',
- language: 'javascript',
- code: getFeedbackSDKSetupSnippet({
- importStatement: `import * as Sentry from "@sentry/electron/renderer";`,
- dsn: params.dsn.public,
- feedbackOptions: params.feedbackOptions,
- }),
- },
- ],
- },
- ],
- additionalInfo: crashReportCallout({
- link: 'https://docs.sentry.io/platforms/javascript/guides/electron/user-feedback/#crash-report-modal',
- }),
- },
- ],
- verify: () => [],
- nextSteps: () => [],
- };
- const crashReportOnboarding: OnboardingConfig = {
- introduction: () => getCrashReportModalIntroduction(),
- install: (params: Params) => [
- {
- type: StepType.INSTALL,
- description: getCrashReportModalInstallDescriptionJavaScript(),
- configurations: [
- {
- code: [
- {
- label: 'JavaScript',
- value: 'javascript',
- language: 'javascript',
- code: `const { init, showReportDialog } = require("@sentry/electron");
- init({
- dsn: "${params.dsn.public}",
- beforeSend(event) {
- // Check if it is an exception, if so, show the report dialog
- // Note that this only will work in the renderer process, it's a noop on the main process
- if (event.exception && event.event_id) {
- showReportDialog({ eventId: event_id });
- }
- return event;
- },
- });`,
- },
- ],
- },
- ],
- },
- ],
- configure: () => [
- {
- type: StepType.CONFIGURE,
- description: getCrashReportModalConfigDescription({
- link: 'https://docs.sentry.io/platforms/javascript/guides/electron/user-feedback/configuration/#crash-report-modal',
- }),
- additionalInfo: widgetCallout({
- link: 'https://docs.sentry.io/platforms/javascript/guides/electron/user-feedback/#user-feedback-widget',
- }),
- },
- ],
- verify: () => [],
- nextSteps: () => [],
- };
- const docs: Docs = {
- onboarding,
- feedbackOnboardingNpm: feedbackOnboarding,
- replayOnboardingNpm: replayOnboarding,
- customMetricsOnboarding,
- crashReportOnboarding,
- };
- export default docs;
|