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 {
getCrashReportGenericInstallStep,
getCrashReportModalConfigDescription,
getCrashReportModalIntroduction,
} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
import {getDotnetMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
import {csharpFeedbackOnboarding} from 'sentry/gettingStartedDocs/dotnet/dotnet';
import {t, tct} from 'sentry/locale';
import {getPackageVersion} from 'sentry/utils/gettingStartedDocs/getPackageVersion';
type Params = DocsParams;
const getInstallSnippetPackageManager = (params: Params) => `
Install-Package Sentry.Google.Cloud.Functions -Version ${getPackageVersion(
params,
'sentry.dotnet.google-cloud-function',
'3.34.0'
)}`;
const getInstallSnippetCoreCli = (params: Params) => `
dotnet add package Sentry.Google.Cloud.Functions -v ${getPackageVersion(
params,
'sentry.dotnet.google-cloud-function',
'3.34.0'
)}`;
const getInstallSnippetManual = (params: Params) => `
`;
const getConfigureCSharpSnippet = () => `
// Add the following line:
[assembly: FunctionsStartup(typeof(SentryStartup))]
public class Function : IHttpFunction
{
public Task HandleAsync(HttpContext context)
{
// Your function code here.
}
}`;
const getConfigureJsonSnippet = (params: Params) => `
{
"Sentry": {
"Dsn": "${params.dsn.public}",
// Sends Cookies, User Id when one is logged on and user IP address to sentry. It's turned off by default.
"SendDefaultPii": true,
// When configuring for the first time, to see what the SDK is doing:
"Debug": true,
// Opt-in for payload submission.
"MaxRequestBodySize": "Always"${
params.isPerformanceSelected
? `,
// Set TracesSampleRate to 1.0 to capture 100% of transactions for tracing.
// We recommend adjusting this value in production.
"TracesSampleRate": 1`
: ''
}
}
}`;
const getVerifySnippet = () => `
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Sentry;
public Task HandleAsync(HttpContext context)
{
SentrySdk.CaptureMessage("Hello Sentry");
}`;
const onboarding: OnboardingConfig = {
install: params => [
{
type: StepType.INSTALL,
configurations: [
{
description: tct(
'Install the [strong:NuGet] package with Package Manager or .NET Core CLI:',
{
strong: ,
}
),
partialLoading: params.sourcePackageRegistries.isLoading,
code: [
{
language: 'shell',
label: 'Package Manager',
value: 'packageManager',
code: getInstallSnippetPackageManager(params),
},
{
language: 'shell',
label: '.NET Core CLI',
value: 'coreCli',
code: getInstallSnippetCoreCli(params),
},
],
},
{
language: 'xml',
partialLoading: params.sourcePackageRegistries?.isLoading,
description: t('Or, manually add the Sentry dependency into your csproj file:'),
code: getInstallSnippetManual(params),
},
],
},
],
configure: params => [
{
type: StepType.CONFIGURE,
description: tct(
'Then, add Sentry to the [code:Function] class through [code:FunctionsStartup]:',
{
code:
,
}
),
configurations: [
{
language: 'csharp',
code: getConfigureCSharpSnippet(),
},
{
language: 'json',
description: (
{tct(
"Additionally, you'll need to set up your [code:Sentry] settings on [code:appsettings.json]:",
{code:
}
)}
),
code: getConfigureJsonSnippet(params),
},
],
},
],
verify: () => [
{
type: StepType.VERIFY,
description: t('To verify your setup, you can capture a message with the SDK:'),
configurations: [
{
language: 'csharp',
code: getVerifySnippet(),
},
],
},
{
title: t('Samples'),
description: (
{t(
'See the following examples that demonstrate how to integrate Sentry with various frameworks.'
)}
{tct('[link:Google Cloud Functions sample]', {
link: (
),
})}
{tct(
'[link:Multiple samples in the [code:dotnet] SDK repository] [strong:(C#)]',
{
link: (
),
strong: ,
code:
,
}
)}
{tct('[link:Basic F# sample] [strong:(F#)]', {
link: ,
strong: ,
})}
),
},
],
};
const crashReportOnboarding: OnboardingConfig = {
introduction: () => getCrashReportModalIntroduction(),
install: (params: Params) => getCrashReportGenericInstallStep(params),
configure: () => [
{
type: StepType.CONFIGURE,
description: getCrashReportModalConfigDescription({
link: 'https://docs.sentry.io/platforms/dotnet/guides/google-cloud-functions/user-feedback/configuration/#crash-report-modal',
}),
},
],
verify: () => [],
nextSteps: () => [],
};
const docs: Docs = {
onboarding,
feedbackOnboardingCrashApi: csharpFeedbackOnboarding,
customMetricsOnboarding: getDotnetMetricsOnboarding({
packageName: 'Sentry.Google.Cloud.Functions',
}),
crashReportOnboarding,
};
export default docs;