unity.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import {Alert} from 'sentry/components/alert';
  4. import ExternalLink from 'sentry/components/links/externalLink';
  5. import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
  6. import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
  7. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  8. import {t, tct} from 'sentry/locale';
  9. // Configuration Start
  10. export const steps = ({
  11. dsn,
  12. sourcePackageRegistries,
  13. }: Partial<
  14. Pick<ModuleProps, 'dsn' | 'sourcePackageRegistries'>
  15. > = {}): LayoutProps['steps'] => [
  16. {
  17. type: StepType.INSTALL,
  18. description: (
  19. <p>
  20. {tct(
  21. "Install the package via the [link:Unity Package Manager] using a Git URL to Sentry's SDK repository:",
  22. {
  23. link: (
  24. <ExternalLink href="https://docs.unity3d.com/Manual/upm-ui-giturl.html" />
  25. ),
  26. }
  27. )}
  28. </p>
  29. ),
  30. configurations: [
  31. {
  32. language: 'bash',
  33. partialLoading: sourcePackageRegistries?.isLoading,
  34. code: `https://github.com/getsentry/unity.git#${
  35. sourcePackageRegistries?.isLoading
  36. ? t('\u2026loading')
  37. : sourcePackageRegistries?.data?.['sentry.dotnet.unity']?.version ?? '1.5.0'
  38. }`,
  39. },
  40. ],
  41. additionalInfo: (
  42. <AlertWithoutMarginBottom type="info">
  43. {tct(
  44. '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].',
  45. {
  46. code: <code />,
  47. link: (
  48. <ExternalLink href="https://docs.sentry.io/platforms/unity/configuration/il2cpp/" />
  49. ),
  50. }
  51. )}
  52. </AlertWithoutMarginBottom>
  53. ),
  54. },
  55. {
  56. type: StepType.CONFIGURE,
  57. description: (
  58. <p>
  59. {tct(
  60. "Access the Sentry configuration window by going to Unity's top menu: [toolsCode:Tools] > [sentryCode:Sentry] and enter the following DSN:",
  61. {toolsCode: <code />, sentryCode: <code />}
  62. )}
  63. </p>
  64. ),
  65. configurations: [
  66. {
  67. language: 'bash',
  68. code: dsn,
  69. },
  70. ],
  71. additionalInfo: (
  72. <Fragment>
  73. {t("And that's it! Now Sentry can capture errors automatically.")}
  74. <p>
  75. {tct('If you like additional contexts you could enable [link:Screenshots].', {
  76. link: (
  77. <ExternalLink href="https://docs.sentry.io/platforms/unity/enriching-events/screenshots/" />
  78. ),
  79. })}
  80. </p>
  81. </Fragment>
  82. ),
  83. },
  84. {
  85. type: StepType.VERIFY,
  86. description: t(
  87. 'Once it is configured with the DSN you can call the SDK from anywhere:'
  88. ),
  89. configurations: [
  90. {
  91. language: 'csharp',
  92. code: `
  93. using Sentry; // On the top of the script
  94. SentrySdk.CaptureMessage("Test event");
  95. `,
  96. },
  97. ],
  98. },
  99. {
  100. title: t('Troubleshooting'),
  101. description: (
  102. <Fragment>
  103. {t(
  104. "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."
  105. )}
  106. <p>
  107. {tct(
  108. "If you're running into any kind of issue please check out our [troubleshootingLink:troubleshooting page] or [raiseAnIssueLink:raise an issue].",
  109. {
  110. troubleshootingLink: (
  111. <ExternalLink href="https://docs.sentry.io/platforms/unity/troubleshooting/" />
  112. ),
  113. raiseAnIssueLink: (
  114. <ExternalLink href="https://github.com/getsentry/sentry-unity/issues/new?assignees=&labels=Platform%3A+Unity%2CType%3A+Bug&template=bug.md" />
  115. ),
  116. }
  117. )}
  118. </p>
  119. </Fragment>
  120. ),
  121. },
  122. ];
  123. // Configuration End
  124. export function GettingStartedWithUnity({
  125. dsn,
  126. sourcePackageRegistries,
  127. ...props
  128. }: ModuleProps) {
  129. return <Layout steps={steps({dsn, sourcePackageRegistries})} {...props} />;
  130. }
  131. export default GettingStartedWithUnity;
  132. const AlertWithoutMarginBottom = styled(Alert)`
  133. margin-bottom: 0;
  134. `;