123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- import {Fragment} from 'react';
- import ExternalLink from 'sentry/components/links/externalLink';
- import List from 'sentry/components/list';
- import ListItem from 'sentry/components/list/listItem';
- import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
- import type {
- Docs,
- DocsParams,
- OnboardingConfig,
- } from 'sentry/components/onboarding/gettingStartedDoc/types';
- import {
- getCrashReportModalConfigDescription,
- getCrashReportModalIntroduction,
- getCrashReportSDKInstallFirstStep,
- } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
- import {getDotnetMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
- import replayOnboardingJsLoader from 'sentry/gettingStartedDocs/javascript/jsLoader/jsLoader';
- import {t, tct} from 'sentry/locale';
- import {getPackageVersion} from 'sentry/utils/gettingStartedDocs/getPackageVersion';
- type Params = DocsParams;
- const getInstallSnippetPackageManager = (params: Params) => `
- Install-Package Sentry.AspNet -Version ${getPackageVersion(
- params,
- 'sentry.dotnet.aspnet',
- '3.34.0'
- )}`;
- const getInstallSnippetEntityFramework = (params: Params) => `
- Install-Package Sentry.EntityFramework -Version ${getPackageVersion(
- params,
- 'sentry.dotnet.aspnet',
- '3.34.0'
- )}`;
- const getConfigureSnippet = (params: Params) => `
- using System;
- using System.Configuration;
- using System.Web.Mvc;
- using System.Web.Routing;
- using Sentry;
- using Sentry.AspNet;
- using Sentry.EntityFramework; // if you installed Sentry.EntityFramework
- public class MvcApplication : HttpApplication
- {
- private IDisposable _sentry;
- protected void Application_Start()
- {
- // Initialize Sentry to capture AppDomain unhandled exceptions and more.
- _sentry = SentrySdk.Init(o =>
- {
- o.AddAspNet();
- o.Dsn = "${params.dsn.public}";
- // When configuring for the first time, to see what the SDK is doing:
- o.Debug = true;${
- params.isPerformanceSelected
- ? `
- // Set TracesSampleRate to 1.0 to capture 100%
- // of transactions for tracing.
- // We recommend adjusting this value in production
- o.TracesSampleRate = 1.0;`
- : ''
- }
- // If you are using EF (and installed the NuGet package):
- o.AddEntityFramework();
- });
- }
- // Global error catcher
- protected void Application_Error() => Server.CaptureLastError();
- ${
- params.isPerformanceSelected
- ? `
- protected void Application_BeginRequest()
- {
- Context.StartSentryTransaction();
- }
- protected void Application_EndRequest()
- {
- Context.FinishSentryTransaction();
- }`
- : ''
- }
- protected void Application_End()
- {
- // Flushes out events before shutting down.
- _sentry?.Dispose();
- }
- }
- `;
- const onboarding: OnboardingConfig = {
- install: params => [
- {
- type: StepType.INSTALL,
- description: tct('Install the [strong:NuGet] package:', {
- strong: <strong />,
- }),
- configurations: [
- {
- language: 'shell',
- partialLoading: params.sourcePackageRegistries.isLoading,
- description: t('Package Manager:'),
- code: getInstallSnippetPackageManager(params),
- },
- {
- language: 'shell',
- partialLoading: params.sourcePackageRegistries.isLoading,
- description: t('Using Entity Framework 6?'),
- code: getInstallSnippetEntityFramework(params),
- },
- ],
- },
- ],
- configure: params => [
- {
- type: StepType.CONFIGURE,
- description: tct(
- 'You should [initCode:init] the Sentry SDK as soon as possible during your application load by adding Sentry to [globalCode:Global.asax.cs]:',
- {
- initCode: <code />,
- globalCode: <code />,
- }
- ),
- configurations: [
- {
- language: 'csharp',
- code: getConfigureSnippet(params),
- },
- ],
- },
- ],
- // TODO: Add proper verify step
- verify: () => [
- {
- title: t('Documentation'),
- description: tct(
- "Once you've verified the package is initialized properly and sent a test event, consider visiting our [link:complete ASP.NET docs].",
- {
- link: (
- <ExternalLink href="https://docs.sentry.io/platforms/dotnet/guides/aspnet/" />
- ),
- }
- ),
- },
- {
- title: t('Samples'),
- description: (
- <Fragment>
- {t(
- 'See the following examples that demonstrate how to integrate Sentry with various frameworks.'
- )}
- <List symbol="bullet">
- <ListItem>
- {tct(
- '[link:Multiple samples in the [code:dotnet] SDK repository] [strong:(C#)]',
- {
- link: (
- <ExternalLink href="https://github.com/getsentry/sentry-dotnet/tree/main/samples" />
- ),
- code: <code />,
- strong: <strong />,
- }
- )}
- </ListItem>
- <ListItem>
- {tct('[link:Basic F# sample] [strong:(F#)]', {
- link: <ExternalLink href="https://github.com/sentry-demos/fsharp" />,
- strong: <strong />,
- })}
- </ListItem>
- </List>
- </Fragment>
- ),
- },
- ],
- };
- const crashReportOnboarding: OnboardingConfig = {
- introduction: () => getCrashReportModalIntroduction(),
- install: (params: Params) => [
- {
- type: StepType.INSTALL,
- configurations: [
- getCrashReportSDKInstallFirstStep(params),
- {
- description: tct(
- 'If you are rendering the page from the server, for example on ASP.NET MVC, the [code:Error.cshtml] razor page can be:',
- {code: <code />}
- ),
- code: [
- {
- label: 'cshtml',
- value: 'html',
- language: 'html',
- code: `@if (SentrySdk.LastEventId != SentryId.Empty) {
- <script>
- Sentry.init({ dsn: "${params.dsn.public}" });
- Sentry.showReportDialog({ eventId: "@SentrySdk.LastEventId" });
- </script>
- }`,
- },
- ],
- },
- ],
- },
- ],
- configure: () => [
- {
- type: StepType.CONFIGURE,
- description: getCrashReportModalConfigDescription({
- link: 'https://docs.sentry.io/platforms/dotnet/guides/aspnet/user-feedback/configuration/#crash-report-modal',
- }),
- },
- ],
- verify: () => [],
- nextSteps: () => [],
- };
- const docs: Docs = {
- onboarding,
- replayOnboardingJsLoader,
- customMetricsOnboarding: getDotnetMetricsOnboarding({packageName: 'Sentry.AspNet'}),
- crashReportOnboarding,
- };
- export default docs;
|