123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- import ExternalLink from 'sentry/components/links/externalLink';
- import widgetCallout from 'sentry/components/onboarding/gettingStartedDoc/feedback/widgetCallout';
- import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
- import type {
- Docs,
- DocsParams,
- OnboardingConfig,
- } from 'sentry/components/onboarding/gettingStartedDoc/types';
- import {
- getCrashReportJavaScriptInstallStep,
- getCrashReportModalConfigDescription,
- getCrashReportModalIntroduction,
- } 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 replayOnboardingJsLoader from 'sentry/gettingStartedDocs/javascript/jsLoader/jsLoader';
- import {t, tct} from 'sentry/locale';
- type Params = DocsParams;
- const getInstallConfig = () => [
- {
- language: 'bash',
- code: 'bun add @sentry/bun',
- },
- ];
- const getConfigureSnippet = (params: Params) => `
- //...
- import * as Sentry from "@sentry/bun";
- Sentry.init({
- dsn: "${params.dsn.public}",${
- params.isPerformanceSelected
- ? `
- // Tracing
- tracesSampleRate: 1.0, // Capture 100% of the transactions`
- : ''
- }
- });`;
- const getVerifySnippet = () => `try {
- throw new Error('Sentry Bun test');
- } catch (e) {
- Sentry.captureException(e);
- }`;
- const getMetricsConfigureSnippet = (params: DocsParams) => `
- Sentry.init({
- dsn: "${params.dsn.public}",
- // Only needed for SDK versions < 8.0.0
- // _experiments: {
- // metricsAggregator: true,
- // },
- });`;
- const onboarding: OnboardingConfig = {
- install: () => [
- {
- type: StepType.INSTALL,
- description: t(
- "Sentry captures data by using an SDK within your application's runtime."
- ),
- configurations: getInstallConfig(),
- },
- ],
- configure: params => [
- {
- type: StepType.CONFIGURE,
- description: t(
- "Initialize Sentry as early as possible in your application's lifecycle."
- ),
- configurations: [
- {
- language: 'javascript',
- code: getConfigureSnippet(params),
- },
- ],
- },
- ],
- verify: () => [
- {
- type: StepType.VERIFY,
- description: t(
- "This snippet contains an intentional error and can be used as a test to make sure that everything's working as expected."
- ),
- configurations: [
- {
- language: 'javascript',
- code: getVerifySnippet(),
- },
- ],
- },
- ],
- nextSteps: () => [],
- };
- const customMetricsOnboarding: OnboardingConfig = {
- install: () => [
- {
- type: StepType.INSTALL,
- description: tct(
- 'You need a minimum version [code:7.91.0] of [code:@sentry/bun].',
- {
- code: <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 [code:counters], [code:sets], [code:distributions], and [code:gauges]. These are available under the [code:Sentry.metrics] namespace. This API is available in both renderer and main processes.",
- {
- code: <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/bun/metrics/" />
- ),
- }
- ),
- },
- ],
- },
- ],
- };
- const crashReportOnboarding: OnboardingConfig = {
- introduction: () => getCrashReportModalIntroduction(),
- install: (params: Params) => getCrashReportJavaScriptInstallStep(params),
- configure: () => [
- {
- type: StepType.CONFIGURE,
- description: getCrashReportModalConfigDescription({
- link: 'https://docs.sentry.io/platforms/javascript/guides/bun/user-feedback/configuration/#crash-report-modal',
- }),
- additionalInfo: widgetCallout({
- link: 'https://docs.sentry.io/platforms/javascript/guides/bun/user-feedback/#user-feedback-widget',
- }),
- },
- ],
- verify: () => [],
- nextSteps: () => [],
- };
- const docs: Docs = {
- onboarding,
- replayOnboardingJsLoader,
- customMetricsOnboarding,
- crashReportOnboarding,
- };
- export default docs;
|