Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions static/app/components/onboarding/productSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@ export const platformProductAvailability = {
ProductSolution.LOGS,
ProductSolution.METRICS,
],
electron: [
ProductSolution.PERFORMANCE_MONITORING,
ProductSolution.SESSION_REPLAY,
ProductSolution.LOGS,
ProductSolution.METRICS,
],
native: [ProductSolution.LOGS],
node: [
ProductSolution.PERFORMANCE_MONITORING,
Expand Down
4 changes: 4 additions & 0 deletions static/app/gettingStartedDocs/electron/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import type {Docs} from 'sentry/components/onboarding/gettingStartedDoc/types';

import {crashReport} from './crashReport';
import {feedback} from './feedback';
import {logs} from './logs';
import {metrics} from './metrics';
import {onboarding} from './onboarding';
import {replay} from './replay';

Expand All @@ -10,4 +12,6 @@ export const docs: Docs = {
feedbackOnboardingNpm: feedback,
replayOnboarding: replay,
crashReportOnboarding: crashReport,
logsOnboarding: logs,
metricsOnboarding: metrics,
};
139 changes: 139 additions & 0 deletions static/app/gettingStartedDocs/electron/logs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import {ExternalLink} from '@sentry/scraps/link';

import type {
DocsParams,
OnboardingConfig,
} from 'sentry/components/onboarding/gettingStartedDoc/types';
import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/types';
import {t, tct} from 'sentry/locale';

import {installCodeBlock} from './utils';

const getConfigureSnippet = (params: DocsParams) => ({
main: `
import * as Sentry from "@sentry/electron/main";

Sentry.init({
dsn: "${params.dsn.public}",
enableLogs: true,
});`,
renderer: `
import * as Sentry from "@sentry/electron/renderer";

Sentry.init({
enableLogs: true,
});`,
});

const getVerifySnippet = () => ({
main: `
import * as Sentry from "@sentry/electron/main";

// Send a log from the main process
Sentry.logger.info('Application started', {
process: 'main',
timestamp: Date.now(),
});`,
renderer: `
import * as Sentry from "@sentry/electron/renderer";

// Send a log from the renderer process
Sentry.logger.info('Renderer loaded', {
process: 'renderer',
url: window.location.href,
});`,
});

export const logs: OnboardingConfig = {
install: () => [
{
type: StepType.INSTALL,
content: [
{
type: 'text',
text: tct(
'Logs support is included in [code:@sentry/electron] version [code:6.7.0] and above.',
{
code: <code />,
}
),
},
installCodeBlock,
],
},
],
configure: params => [
{
type: StepType.CONFIGURE,
content: [
{
type: 'text',
text: t(
'Enable logs in both your main and renderer process initialization by setting enableLogs to true:'
),
},
{
type: 'text',
text: t('Main Process:'),
},
{
type: 'code',
language: 'javascript',
code: getConfigureSnippet(params).main,
},
{
type: 'text',
text: t('Renderer Process:'),
},
{
type: 'code',
language: 'javascript',
code: getConfigureSnippet(params).renderer,
},
],
},
],
verify: () => [
{
type: StepType.VERIFY,
content: [
{
type: 'text',
text: t('Send a test log from both processes to verify your setup:'),
},
{
type: 'text',
text: t('Main Process:'),
},
{
type: 'code',
language: 'javascript',
code: getVerifySnippet().main,
},
{
type: 'text',
text: t('Renderer Process:'),
},
{
type: 'code',
language: 'javascript',
code: getVerifySnippet().renderer,
},
{
type: 'text',
text: t(
'After running your application, you should see these logs appear in your Sentry project.'
),
},
{
type: 'text',
text: tct('For more detailed information, see the [link:logs documentation].', {
link: (
<ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/electron/logs/" />
),
}),
},
],
},
],
};
151 changes: 151 additions & 0 deletions static/app/gettingStartedDocs/electron/metrics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import {ExternalLink} from '@sentry/scraps/link';

import type {
DocsParams,
OnboardingConfig,
} from 'sentry/components/onboarding/gettingStartedDoc/types';
import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/types';
import {t, tct} from 'sentry/locale';

import {installCodeBlock} from './utils';

const getConfigureSnippet = (params: DocsParams) => ({
main: `
import * as Sentry from "@sentry/electron/main";

Sentry.init({
dsn: "${params.dsn.public}",
});`,
renderer: `
import * as Sentry from "@sentry/electron/renderer";

Sentry.init({
// Metrics are sent through the main process
});`,
});

const getVerifySnippet = () => ({
main: `
import * as Sentry from "@sentry/electron/main";

// Send a custom counter metric
Sentry.metrics.count('app.startup', 1, {
attributes: { process: 'main' },
});

// Send a gauge metric
Sentry.metrics.gauge('memory.used', process.memoryUsage().heapUsed, {
unit: 'byte',
attributes: { process: 'main' },
});`,
renderer: `
import * as Sentry from "@sentry/electron/renderer";

// Send a custom counter metric from renderer
Sentry.metrics.count('button.click', 1, {
attributes: { component: 'test-button' },
});

// Send a distribution metric
Sentry.metrics.distribution('page.load_time', 1234, {
unit: 'millisecond',
attributes: { page: 'home' },
});`,
});

export const metrics: OnboardingConfig = {
install: () => [
{
type: StepType.INSTALL,
content: [
{
type: 'text',
text: tct(
'Metrics support is included in [code:@sentry/electron] version [code:7.5.0] and above.',
{
code: <code />,
}
),
},
installCodeBlock,
],
},
],
configure: params => [
{
type: StepType.CONFIGURE,
content: [
{
type: 'text',
text: t(
'Metrics are automatically enabled. You can emit metrics from both main and renderer processes:'
),
},
{
type: 'text',
text: t('Main Process:'),
},
{
type: 'code',
language: 'javascript',
code: getConfigureSnippet(params).main,
},
{
type: 'text',
text: t('Renderer Process:'),
},
{
type: 'code',
language: 'javascript',
code: getConfigureSnippet(params).renderer,
},
],
},
],
verify: () => [
{
type: StepType.VERIFY,
content: [
{
type: 'text',
text: t('Send test metrics from both processes to verify your setup:'),
},
{
type: 'text',
text: t('Main Process:'),
},
{
type: 'code',
language: 'javascript',
code: getVerifySnippet().main,
},
{
type: 'text',
text: t('Renderer Process:'),
},
{
type: 'code',
language: 'javascript',
code: getVerifySnippet().renderer,
},
{
type: 'text',
text: t(
'After running your application and emitting metrics, you should see them appear in your Sentry project metrics dashboard.'
),
},
{
type: 'text',
text: tct(
'For more detailed information, see the [link:metrics documentation].',
{
link: (
<ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/electron/metrics/" />
),
}
),
},
],
},
],
};
Loading
Loading