123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- import {Fragment} from 'react';
- import ExternalLink from 'sentry/components/links/externalLink';
- 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 {csharpFeedbackOnboarding} from 'sentry/gettingStartedDocs/dotnet/dotnet';
- import {t, tct} from 'sentry/locale';
- import {getPackageVersion} from 'sentry/utils/gettingStartedDocs/getPackageVersion';
- type Params = DocsParams;
- const getInstallSnippetXamarin = (params: Params) => `
- Install-Package Sentry.Xamarin -Version ${getPackageVersion(
- params,
- 'sentry.dotnet.xamarin',
- '1.5.2'
- )}`;
- const getInstallSnippetXamarinForms = (params: Params) => `
- Install-Package Sentry.Xamarin.Forms -Version ${getPackageVersion(
- params,
- 'sentry.dotnet.xamarin-forms',
- '1.5.2'
- )}`;
- const getConfigureSnippetAndroid = (params: Params) => `
- public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
- {
- protected override void OnCreate(Bundle savedInstanceState)
- {
- SentryXamarin.Init(options =>
- {
- // Tells which project in Sentry to send events to:
- options.Dsn = "${params.dsn.public}";
- // When configuring for the first time, to see what the SDK is doing:
- options.Debug = true;
- // Set TracesSampleRate to 1.0 to capture 100% of transactions for tracing.
- // We recommend adjusting this value in production.
- options.TracesSampleRate = 1.0;
- // If you installed Sentry.Xamarin.Forms:
- options.AddXamarinFormsIntegration();
- });`;
- const getConfigureSnippetIOS = (params: Params) => `
- public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
- {
- public override bool FinishedLaunching(UIApplication app, NSDictionary options)
- {
- SentryXamarin.Init(options =>
- {
- options.Dsn = "${params.dsn.public}";
- // When configuring for the first time, to see what the SDK is doing:
- options.Debug = true;
- // Set TracesSampleRate to 1.0 to capture 100% of transactions for tracing.
- // We recommend adjusting this value in production.
- options.TracesSampleRate = 1.0;
- options.AddXamarinFormsIntegration();
- });`;
- const getConfigureSnippetUWP = (params: Params) => `
- sealed partial class App : Application
- {
- protected override void OnLaunched(LaunchActivatedEventArgs e)
- {
- SentryXamarin.Init(options =>
- {
- options.Dsn = "${params.dsn.public}";
- // When configuring for the first time, to see what the SDK is doing:
- options.Debug = true;
- // Set TracesSampleRate to 1.0 to capture 100% of transactions for tracing.
- // We recommend adjusting this value in production.
- options.TracesSampleRate = 1.0;
- options.AddXamarinFormsIntegration();
- });`;
- const getPerformanceInstrumentationSnippet = () => `
- // Transaction can be started by providing, at minimum, the name and the operation
- var transaction = SentrySdk.StartTransaction(
- "test-transaction-name",
- "test-transaction-operation"
- );
- // Transactions can have child spans (and those spans can have child spans as well)
- var span = transaction.StartChild("test-child-operation");
- // ...
- // (Perform the operation represented by the span/transaction)
- // ...
- span.Finish(); // Mark the span as finished
- transaction.Finish(); // Mark the transaction as finished and send it to Sentry`;
- const onboarding: OnboardingConfig = {
- install: params => [
- {
- type: StepType.INSTALL,
- description: tct('Install the [strong:NuGet] package:', {
- strong: <strong />,
- }),
- configurations: [
- {
- partialLoading: params.sourcePackageRegistries.isLoading,
- code: [
- {
- language: 'shell',
- label: 'Xamarin.Forms',
- value: 'xamarinForms',
- code: getInstallSnippetXamarinForms(params),
- },
- {
- language: 'shell',
- label: 'Xamarin',
- value: 'xamarin',
- code: getInstallSnippetXamarin(params),
- },
- ],
- },
- ],
- },
- ],
- configure: params => [
- {
- type: StepType.CONFIGURE,
- description: tct(
- 'Initialize the SDK as early as possible, like in the constructor of the [code:App], and Add [code:SentryXamarinFormsIntegration] as a new Integration to [code:SentryXamarinOptions] if you are going to run your app with Xamarin Forms:',
- {
- code: <code />,
- }
- ),
- configurations: [
- {
- description: <h5>{t('Android')}</h5>,
- configurations: [
- {
- description: tct('Initialize the SDK on your [code:MainActivity].', {
- code: <code />,
- }),
- language: `csharp`,
- code: getConfigureSnippetAndroid(params),
- },
- ],
- },
- {
- description: <h5>{t('iOS')}</h5>,
- configurations: [
- {
- description: tct('Initialize the SDK on your [code:AppDelegate.cs].', {
- code: <code />,
- }),
- language: `csharp`,
- code: getConfigureSnippetIOS(params),
- },
- ],
- },
- {
- description: <h5>{t('UWP')}</h5>,
- configurations: [
- {
- description: (
- <Fragment>
- <p>
- {tct('Initialize the SDK on [code:App.xaml.cs].', {
- code: <code />,
- })}
- </p>
- {t("NOTE: It's recommended to not setup the CacheDirectory for UWP.")}
- </Fragment>
- ),
- language: `csharp`,
- code: getConfigureSnippetUWP(params),
- },
- ],
- },
- ],
- },
- ],
- verify: () => [
- {
- type: StepType.VERIFY,
- description: t('To verify your set up, you can capture a message with the SDK:'),
- configurations: [
- {
- language: 'csharp',
- code: 'SentrySdk.CaptureMessage("Hello Sentry");',
- },
- ],
- additionalInfo: t(
- 'You might need to open the app again for the crash report to be sent to the server.'
- ),
- },
- {
- title: t('Tracing'),
- description: t(
- 'You can measure the performance of your code by capturing transactions and spans.'
- ),
- configurations: [
- {
- language: 'csharp',
- code: getPerformanceInstrumentationSnippet(),
- },
- ],
- additionalInfo: tct(
- 'Check out [link:the documentation] to learn more about the API and automatic instrumentations.',
- {
- link: (
- <ExternalLink href="https://docs.sentry.io/platforms/dotnet/tracing/instrumentation/" />
- ),
- }
- ),
- },
- {
- title: t('Documentation'),
- description: tct(
- "Once you've verified the package is initialized properly and sent a test event, consider visiting our [link:complete Xamarin Forms docs].",
- {
- link: (
- <ExternalLink href="https://docs.sentry.io/platforms/dotnet/guides/xamarin/" />
- ),
- }
- ),
- },
- {
- title: t('Limitations'),
- description: t(
- 'There are no line numbers on stack traces for UWP and in release builds for Android and iOS.'
- ),
- },
- {
- title: t('Samples'),
- description: tct(
- 'You can find an example of a Xamarin Forms app with Sentry integrated [link:on this GitHub repository].',
- {
- link: (
- <ExternalLink href="https://github.com/getsentry/sentry-xamarin/tree/main/Samples" />
- ),
- }
- ),
- },
- ],
- };
- const crashReportOnboarding: OnboardingConfig = {
- introduction: () => getCrashReportModalIntroduction(),
- install: (params: Params) => getCrashReportGenericInstallStep(params),
- configure: () => [
- {
- type: StepType.CONFIGURE,
- description: getCrashReportModalConfigDescription({
- link: 'https://docs.sentry.io/platforms/dotnet/guides/xamarin/user-feedback/configuration/#crash-report-modal',
- }),
- },
- ],
- verify: () => [],
- nextSteps: () => [],
- };
- const docs: Docs = {
- onboarding,
- feedbackOnboardingCrashApi: csharpFeedbackOnboarding,
- crashReportOnboarding,
- };
- export default docs;
|