Skip to content

Commit

Permalink
ref(onboarding-docs): Convert unity platform (#63099)
Browse files Browse the repository at this point in the history
- closes #56549
  • Loading branch information
ArthurKnaus authored Jan 12, 2024
1 parent d8feacb commit ca436be
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 123 deletions.
36 changes: 24 additions & 12 deletions static/app/gettingStartedDocs/unity/unity.spec.tsx
Original file line number Diff line number Diff line change
@@ -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(<GettingStartedWithUnity dsn="test-dsn" projectSlug="test-project" />);
// 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();
});
});
210 changes: 99 additions & 111 deletions static/app/gettingStartedDocs/unity/unity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<ModuleProps, 'dsn' | 'sourcePackageRegistries'>
> = {}): LayoutProps['steps'] => [
{
type: StepType.INSTALL,
description: (
<p>
{tct(
"Install the package via the [link:Unity Package Manager] using a Git URL to Sentry's SDK repository:",
{
link: (
<ExternalLink href="https://docs.unity3d.com/Manual/upm-ui-giturl.html" />
),
}
)}
</p>
),
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: (
<AlertWithoutMarginBottom type="info">
{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: <code />,
link: (
<ExternalLink href="https://docs.sentry.io/platforms/unity/configuration/il2cpp/" />
),
}
)}
</AlertWithoutMarginBottom>
),
},
{
type: StepType.CONFIGURE,
description: (
<p>
{tct(
"Access the Sentry configuration window by going to Unity's top menu: [toolsCode:Tools] > [sentryCode:Sentry] and enter the following DSN:",
{toolsCode: <code />, sentryCode: <code />}
)}
</p>
),
configurations: [
{
language: 'bash',
code: dsn,
},
],
additionalInfo: (
<Fragment>
{t("And that's it! Now Sentry can capture errors automatically.")}
<p>
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: (
<ExternalLink href="https://docs.unity3d.com/Manual/upm-ui-giturl.html" />
),
}
),
configurations: [
{
language: 'url',
partialLoading: params.sourcePackageRegistries.isLoading,
code: `https://github.com/getsentry/unity.git#${getPackageVersion(
params,
'sentry.dotnet.unity',
'1.5.0'
)}`,
},
],
additionalInfo: (
<AlertWithoutMarginBottom type="info">
{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: <code />,
link: (
<ExternalLink href="https://docs.sentry.io/platforms/unity/configuration/il2cpp/" />
),
}
)}
</AlertWithoutMarginBottom>
),
},
],
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: <code />, sentryCode: <code />}
),
configurations: [
{
language: 'url',
code: params.dsn,
},
],
additionalInfo: (
<Fragment>
<p>{t("And that's it! Now Sentry can capture errors automatically.")}</p>
{tct('If you like additional contexts you could enable [link:Screenshots].', {
link: (
<ExternalLink href="https://docs.sentry.io/platforms/unity/enriching-events/screenshots/" />
),
})}
</p>
</Fragment>
),
},
{
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: (
<Fragment>
{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."
)}
<p>
</Fragment>
),
},
],
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: (
<Fragment>
<p>
{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."
)}
</p>
{tct(
"If you're running into any kind of issue please check out our [troubleshootingLink:troubleshooting page] or [raiseAnIssueLink:raise an issue].",
{
Expand All @@ -119,22 +112,17 @@ SentrySdk.CaptureMessage("Test event");
),
}
)}
</p>
</Fragment>
),
},
];
// Configuration End
</Fragment>
),
},
],
};

export function GettingStartedWithUnity({
dsn,
sourcePackageRegistries,
...props
}: ModuleProps) {
return <Layout steps={steps({dsn, sourcePackageRegistries})} {...props} />;
}
const docs: Docs = {
onboarding,
};

export default GettingStartedWithUnity;
export default docs;

const AlertWithoutMarginBottom = styled(Alert)`
margin-bottom: 0;
Expand Down

0 comments on commit ca436be

Please sign in to comment.