From ca436be8277e28593d360f0538a9b32e4c0b332e Mon Sep 17 00:00:00 2001 From: ArthurKnaus Date: Fri, 12 Jan 2024 12:37:35 +0100 Subject: [PATCH] ref(onboarding-docs): Convert unity platform (#63099) - closes https://github.com/getsentry/sentry/issues/56549 --- .../gettingStartedDocs/unity/unity.spec.tsx | 36 ++- static/app/gettingStartedDocs/unity/unity.tsx | 210 +++++++++--------- 2 files changed, 123 insertions(+), 123 deletions(-) diff --git a/static/app/gettingStartedDocs/unity/unity.spec.tsx b/static/app/gettingStartedDocs/unity/unity.spec.tsx index 4af3857085bb9d..35a5d86522899d 100644 --- a/static/app/gettingStartedDocs/unity/unity.spec.tsx +++ b/static/app/gettingStartedDocs/unity/unity.spec.tsx @@ -1,18 +1,30 @@ -import {render, screen} from 'sentry-test/reactTestingLibrary'; +import {renderWithOnboardingLayout} from 'sentry-test/onboarding/renderWithOnboardingLayout'; +import {screen} from 'sentry-test/reactTestingLibrary'; +import {textWithMarkupMatcher} from 'sentry-test/utils'; -import {StepTitle} from 'sentry/components/onboarding/gettingStartedDoc/step'; +import docs from './unity'; -import {GettingStartedWithUnity, steps} from './unity'; +describe('unity onboarding docs', function () { + it('renders docs correctly', async function () { + renderWithOnboardingLayout(docs, { + releaseRegistry: { + 'sentry.dotnet.unity': { + version: '1.99.9', + }, + }, + }); -describe('GettingStartedWithUnity', function () { - it('renders doc correctly', function () { - render(); + // Renders main headings + expect(screen.getByRole('heading', {name: 'Install'})).toBeInTheDocument(); + expect(screen.getByRole('heading', {name: 'Configure SDK'})).toBeInTheDocument(); + expect(screen.getByRole('heading', {name: 'Verify'})).toBeInTheDocument(); + expect(screen.getByRole('heading', {name: 'Troubleshooting'})).toBeInTheDocument(); - // Steps - for (const step of steps()) { - expect( - screen.getByRole('heading', {name: step.title ?? StepTitle[step.type]}) - ).toBeInTheDocument(); - } + // Renders SDK version from registry + expect( + await screen.findByText( + textWithMarkupMatcher(/https:\/\/github.com\/getsentry\/unity\.git#1\.99\.9/) + ) + ).toBeInTheDocument(); }); }); diff --git a/static/app/gettingStartedDocs/unity/unity.tsx b/static/app/gettingStartedDocs/unity/unity.tsx index f04a9376322c2c..7c82f45ce8dd8d 100644 --- a/static/app/gettingStartedDocs/unity/unity.tsx +++ b/static/app/gettingStartedDocs/unity/unity.tsx @@ -3,111 +3,104 @@ import styled from '@emotion/styled'; import {Alert} from 'sentry/components/alert'; import ExternalLink from 'sentry/components/links/externalLink'; -import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout'; -import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation'; import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step'; +import { + Docs, + OnboardingConfig, +} from 'sentry/components/onboarding/gettingStartedDoc/types'; import {t, tct} from 'sentry/locale'; +import {getPackageVersion} from 'sentry/utils/gettingStartedDocs/getPackageVersion'; -// Configuration Start -export const steps = ({ - dsn, - sourcePackageRegistries, -}: Partial< - Pick -> = {}): LayoutProps['steps'] => [ - { - type: StepType.INSTALL, - description: ( -

- {tct( - "Install the package via the [link:Unity Package Manager] using a Git URL to Sentry's SDK repository:", - { - link: ( - - ), - } - )} -

- ), - configurations: [ - { - language: 'bash', - partialLoading: sourcePackageRegistries?.isLoading, - code: `https://github.com/getsentry/unity.git#${ - sourcePackageRegistries?.isLoading - ? t('\u2026loading') - : sourcePackageRegistries?.data?.['sentry.dotnet.unity']?.version ?? '1.5.0' - }`, - }, - ], - additionalInfo: ( - - {tct( - 'The Unity SDK now supports line numbers for IL2CPP. The feature is currently in beta, but you can enable it at [code:Tools -> Sentry -> Advanced -> IL2CPP] line numbers. To learn more check out our [link:docs].', - { - code: , - link: ( - - ), - } - )} - - ), - }, - { - type: StepType.CONFIGURE, - description: ( -

- {tct( - "Access the Sentry configuration window by going to Unity's top menu: [toolsCode:Tools] > [sentryCode:Sentry] and enter the following DSN:", - {toolsCode: , sentryCode: } - )} -

- ), - configurations: [ - { - language: 'bash', - code: dsn, - }, - ], - additionalInfo: ( - - {t("And that's it! Now Sentry can capture errors automatically.")} -

+const getVerifySnippet = () => ` +using Sentry; // On the top of the script + +SentrySdk.CaptureMessage("Test event");`; + +const onboarding: OnboardingConfig = { + install: params => [ + { + type: StepType.INSTALL, + description: tct( + "Install the package via the [link:Unity Package Manager] using a Git URL to Sentry's SDK repository:", + { + link: ( + + ), + } + ), + configurations: [ + { + language: 'url', + partialLoading: params.sourcePackageRegistries.isLoading, + code: `https://github.com/getsentry/unity.git#${getPackageVersion( + params, + 'sentry.dotnet.unity', + '1.5.0' + )}`, + }, + ], + additionalInfo: ( + + {tct( + 'The Unity SDK now supports line numbers for IL2CPP. The feature is currently in beta, but you can enable it at [code:Tools -> Sentry -> Advanced -> IL2CPP] line numbers. To learn more check out our [link:docs].', + { + code: , + link: ( + + ), + } + )} + + ), + }, + ], + configure: params => [ + { + type: StepType.CONFIGURE, + description: tct( + "Access the Sentry configuration window by going to Unity's top menu: [toolsCode:Tools] > [sentryCode:Sentry] and enter the following DSN:", + {toolsCode: , sentryCode: } + ), + configurations: [ + { + language: 'url', + code: params.dsn, + }, + ], + additionalInfo: ( + +

{t("And that's it! Now Sentry can capture errors automatically.")}

{tct('If you like additional contexts you could enable [link:Screenshots].', { link: ( ), })} -

-
- ), - }, - { - type: StepType.VERIFY, - description: t( - 'Once it is configured with the DSN you can call the SDK from anywhere:' - ), - configurations: [ - { - language: 'csharp', - - code: ` -using Sentry; // On the top of the script - -SentrySdk.CaptureMessage("Test event"); - `, - }, - ], - }, - { - title: t('Troubleshooting'), - description: ( - - {t( - "Confirm the URL doesn't have a trailing whitespace at the end. The Unity Package Manager will fail to find the package if a trailing whitespace is appended." - )} -

+ + ), + }, + ], + verify: () => [ + { + type: StepType.VERIFY, + description: t( + 'Once it is configured with the DSN you can call the SDK from anywhere:' + ), + configurations: [ + { + language: 'csharp', + code: getVerifySnippet(), + }, + ], + }, + { + title: t('Troubleshooting'), + description: ( + +

+ {t( + "Confirm the URL doesn't have a trailing whitespace at the end. The Unity Package Manager will fail to find the package if a trailing whitespace is appended." + )} +

{tct( "If you're running into any kind of issue please check out our [troubleshootingLink:troubleshooting page] or [raiseAnIssueLink:raise an issue].", { @@ -119,22 +112,17 @@ SentrySdk.CaptureMessage("Test event"); ), } )} -

-
- ), - }, -]; -// Configuration End + + ), + }, + ], +}; -export function GettingStartedWithUnity({ - dsn, - sourcePackageRegistries, - ...props -}: ModuleProps) { - return ; -} +const docs: Docs = { + onboarding, +}; -export default GettingStartedWithUnity; +export default docs; const AlertWithoutMarginBottom = styled(Alert)` margin-bottom: 0;