unity.tsx 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  6. import type {
  7. Docs,
  8. OnboardingConfig,
  9. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  10. import {
  11. getCrashReportApiIntroduction,
  12. getCrashReportInstallDescription,
  13. } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  14. import {t, tct} from 'sentry/locale';
  15. import {getPackageVersion} from 'sentry/utils/gettingStartedDocs/getPackageVersion';
  16. const getVerifySnippet = () => `
  17. using Sentry; // On the top of the script
  18. SentrySdk.CaptureMessage("Test event");`;
  19. const onboarding: OnboardingConfig = {
  20. install: params => [
  21. {
  22. type: StepType.INSTALL,
  23. description: tct(
  24. "Install the package via the [link:Unity Package Manager] using a Git URL to Sentry's SDK repository:",
  25. {
  26. link: (
  27. <ExternalLink href="https://docs.unity3d.com/Manual/upm-ui-giturl.html" />
  28. ),
  29. }
  30. ),
  31. configurations: [
  32. {
  33. language: 'url',
  34. partialLoading: params.sourcePackageRegistries.isLoading,
  35. code: `https://github.com/getsentry/unity.git#${getPackageVersion(
  36. params,
  37. 'sentry.dotnet.unity',
  38. '1.5.0'
  39. )}`,
  40. },
  41. ],
  42. additionalInfo: (
  43. <AlertWithoutMarginBottom type="info">
  44. {tct(
  45. '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].',
  46. {
  47. code: <code />,
  48. link: (
  49. <ExternalLink href="https://docs.sentry.io/platforms/unity/configuration/il2cpp/" />
  50. ),
  51. }
  52. )}
  53. </AlertWithoutMarginBottom>
  54. ),
  55. },
  56. ],
  57. configure: params => [
  58. {
  59. type: StepType.CONFIGURE,
  60. description: tct(
  61. "Access the Sentry configuration window by going to Unity's top menu: [toolsCode:Tools] > [sentryCode:Sentry] and enter the following DSN:",
  62. {toolsCode: <code />, sentryCode: <code />}
  63. ),
  64. configurations: [
  65. {
  66. language: 'url',
  67. code: params.dsn,
  68. },
  69. ],
  70. additionalInfo: (
  71. <Fragment>
  72. <p>{t("And that's it! Now Sentry can capture errors automatically.")}</p>
  73. {tct('If you like additional contexts you could enable [link:Screenshots].', {
  74. link: (
  75. <ExternalLink href="https://docs.sentry.io/platforms/unity/enriching-events/screenshots/" />
  76. ),
  77. })}
  78. </Fragment>
  79. ),
  80. },
  81. ],
  82. verify: () => [
  83. {
  84. type: StepType.VERIFY,
  85. description: t(
  86. 'Once it is configured with the DSN you can call the SDK from anywhere:'
  87. ),
  88. configurations: [
  89. {
  90. language: 'csharp',
  91. code: getVerifySnippet(),
  92. },
  93. ],
  94. },
  95. {
  96. title: t('Troubleshooting'),
  97. description: (
  98. <Fragment>
  99. <p>
  100. {t(
  101. "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."
  102. )}
  103. </p>
  104. {tct(
  105. "If you're running into any kind of issue please check out our [troubleshootingLink:troubleshooting page] or [raiseAnIssueLink:raise an issue].",
  106. {
  107. troubleshootingLink: (
  108. <ExternalLink href="https://docs.sentry.io/platforms/unity/troubleshooting/" />
  109. ),
  110. raiseAnIssueLink: (
  111. <ExternalLink href="https://github.com/getsentry/sentry-unity/issues/new?assignees=&labels=Platform%3A+Unity%2CType%3A+Bug&template=bug.md" />
  112. ),
  113. }
  114. )}
  115. </Fragment>
  116. ),
  117. },
  118. ],
  119. };
  120. export const feedbackOnboarding: OnboardingConfig = {
  121. introduction: () => getCrashReportApiIntroduction(),
  122. install: () => [
  123. {
  124. type: StepType.INSTALL,
  125. description: getCrashReportInstallDescription(),
  126. configurations: [
  127. {
  128. code: [
  129. {
  130. label: 'C#',
  131. value: 'csharp',
  132. language: 'csharp',
  133. code: `var eventId = SentrySdk.CaptureMessage("An event that will receive user feedback.");
  134. SentrySdk.CaptureUserFeedback(eventId, "user@example.com", "It broke.", "The User");`,
  135. },
  136. {
  137. label: 'F#',
  138. value: 'fsharp',
  139. language: 'fsharp',
  140. code: `let eventId = SentrySdk.CaptureMessage("An event that will receive user feedback.")
  141. SentrySdk.CaptureUserFeedback(eventId, "user@example.com", "It broke.", "The User")`,
  142. },
  143. ],
  144. },
  145. ],
  146. },
  147. ],
  148. configure: () => [],
  149. verify: () => [],
  150. nextSteps: () => [],
  151. };
  152. const docs: Docs = {
  153. onboarding,
  154. feedbackOnboardingCrashApi: feedbackOnboarding,
  155. crashReportOnboarding: feedbackOnboarding,
  156. };
  157. export default docs;
  158. const AlertWithoutMarginBottom = styled(Alert)`
  159. margin-bottom: 0;
  160. `;