unity.tsx 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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 exampleSnippets from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsExampleSnippets';
  15. import {t, tct} from 'sentry/locale';
  16. import {getPackageVersion} from 'sentry/utils/gettingStartedDocs/getPackageVersion';
  17. const getVerifySnippet = () => `
  18. using Sentry; // On the top of the script
  19. SentrySdk.CaptureMessage("Test event");`;
  20. const getMetricsConfigureSnippet = () => `
  21. public override void Configure(SentryUnityOptions options)
  22. {
  23. options.ExperimentalMetrics = new ExperimentalMetricsOptions
  24. {
  25. EnableCodeLocations = true
  26. };
  27. }`;
  28. const onboarding: OnboardingConfig = {
  29. install: params => [
  30. {
  31. type: StepType.INSTALL,
  32. description: tct(
  33. "Install the package via the [link:Unity Package Manager] using a Git URL to Sentry's SDK repository:",
  34. {
  35. link: (
  36. <ExternalLink href="https://docs.unity3d.com/Manual/upm-ui-giturl.html" />
  37. ),
  38. }
  39. ),
  40. configurations: [
  41. {
  42. language: 'url',
  43. partialLoading: params.sourcePackageRegistries.isLoading,
  44. code: `https://github.com/getsentry/unity.git#${getPackageVersion(
  45. params,
  46. 'sentry.dotnet.unity',
  47. '1.5.0'
  48. )}`,
  49. },
  50. ],
  51. additionalInfo: (
  52. <AlertWithoutMarginBottom type="info">
  53. {tct(
  54. '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].',
  55. {
  56. code: <code />,
  57. link: (
  58. <ExternalLink href="https://docs.sentry.io/platforms/unity/configuration/il2cpp/" />
  59. ),
  60. }
  61. )}
  62. </AlertWithoutMarginBottom>
  63. ),
  64. },
  65. ],
  66. configure: params => [
  67. {
  68. type: StepType.CONFIGURE,
  69. description: tct(
  70. "Access the Sentry configuration window by going to Unity's top menu: [toolsCode:Tools] > [sentryCode:Sentry] and enter the following DSN:",
  71. {toolsCode: <code />, sentryCode: <code />}
  72. ),
  73. configurations: [
  74. {
  75. language: 'url',
  76. code: params.dsn,
  77. },
  78. ],
  79. additionalInfo: (
  80. <Fragment>
  81. <p>{t("And that's it! Now Sentry can capture errors automatically.")}</p>
  82. {tct('If you like additional contexts you could enable [link:Screenshots].', {
  83. link: (
  84. <ExternalLink href="https://docs.sentry.io/platforms/unity/enriching-events/screenshots/" />
  85. ),
  86. })}
  87. </Fragment>
  88. ),
  89. },
  90. ],
  91. verify: () => [
  92. {
  93. type: StepType.VERIFY,
  94. description: t(
  95. 'Once it is configured with the DSN you can call the SDK from anywhere:'
  96. ),
  97. configurations: [
  98. {
  99. language: 'csharp',
  100. code: getVerifySnippet(),
  101. },
  102. ],
  103. },
  104. {
  105. title: t('Troubleshooting'),
  106. description: (
  107. <Fragment>
  108. <p>
  109. {t(
  110. "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."
  111. )}
  112. </p>
  113. {tct(
  114. "If you're running into any kind of issue please check out our [troubleshootingLink:troubleshooting page] or [raiseAnIssueLink:raise an issue].",
  115. {
  116. troubleshootingLink: (
  117. <ExternalLink href="https://docs.sentry.io/platforms/unity/troubleshooting/" />
  118. ),
  119. raiseAnIssueLink: (
  120. <ExternalLink href="https://github.com/getsentry/sentry-unity/issues/new?assignees=&labels=Platform%3A+Unity%2CType%3A+Bug&template=bug.md" />
  121. ),
  122. }
  123. )}
  124. </Fragment>
  125. ),
  126. },
  127. ],
  128. };
  129. export const feedbackOnboarding: OnboardingConfig = {
  130. introduction: () => getCrashReportApiIntroduction(),
  131. install: () => [
  132. {
  133. type: StepType.INSTALL,
  134. description: getCrashReportInstallDescription(),
  135. configurations: [
  136. {
  137. code: [
  138. {
  139. label: 'C#',
  140. value: 'csharp',
  141. language: 'csharp',
  142. code: `var eventId = SentrySdk.CaptureMessage("An event that will receive user feedback.");
  143. SentrySdk.CaptureUserFeedback(eventId, "user@example.com", "It broke.", "The User");`,
  144. },
  145. {
  146. label: 'F#',
  147. value: 'fsharp',
  148. language: 'fsharp',
  149. code: `let eventId = SentrySdk.CaptureMessage("An event that will receive user feedback.")
  150. SentrySdk.CaptureUserFeedback(eventId, "user@example.com", "It broke.", "The User")`,
  151. },
  152. ],
  153. },
  154. ],
  155. },
  156. ],
  157. configure: () => [],
  158. verify: () => [],
  159. nextSteps: () => [],
  160. };
  161. const metricsOnboarding: OnboardingConfig = {
  162. install: () => [
  163. {
  164. type: StepType.INSTALL,
  165. description: tct(
  166. 'You need a minimum version [codeVersion:2.0.0] of the Unity SDK installed.',
  167. {
  168. codeVersion: <code />,
  169. }
  170. ),
  171. },
  172. ],
  173. configure: () => [
  174. {
  175. type: StepType.CONFIGURE,
  176. description: t(
  177. 'Once the SDK is installed or updated, you can enable the experimental metrics feature and code locations being emitted in your RuntimeConfiguration.'
  178. ),
  179. configurations: [
  180. {
  181. language: 'csharp',
  182. code: getMetricsConfigureSnippet(),
  183. },
  184. ],
  185. },
  186. ],
  187. verify: () => [
  188. {
  189. type: StepType.VERIFY,
  190. description: tct(
  191. "Then you'll be able to add metrics as [codeCounters:counters], [codeSets:sets], [codeDistribution:distributions], [codeGauge:gauges], and [codeTimings:timings]. Try out this example:",
  192. {
  193. codeCounters: <code />,
  194. codeSets: <code />,
  195. codeDistribution: <code />,
  196. codeGauge: <code />,
  197. codeTimings: <code />,
  198. }
  199. ),
  200. configurations: [
  201. {
  202. code: [
  203. {
  204. label: 'Counter',
  205. value: 'counter',
  206. language: 'csharp',
  207. code: exampleSnippets.dotnet.counter,
  208. },
  209. {
  210. label: 'Distribution',
  211. value: 'distribution',
  212. language: 'csharp',
  213. code: exampleSnippets.dotnet.distribution,
  214. },
  215. {
  216. label: 'Set',
  217. value: 'set',
  218. language: 'csharp',
  219. code: exampleSnippets.dotnet.set,
  220. },
  221. {
  222. label: 'Gauge',
  223. value: 'gauge',
  224. language: 'csharp',
  225. code: exampleSnippets.dotnet.gauge,
  226. },
  227. ],
  228. },
  229. {
  230. description: t(
  231. 'With a bit of delay you can see the data appear in the Sentry UI.'
  232. ),
  233. },
  234. {
  235. description: tct(
  236. 'Learn more about metrics and how to configure them, by reading the [docsLink:docs].',
  237. {
  238. docsLink: (
  239. <ExternalLink href="https://docs.sentry.io/platforms/unity/metrics/" />
  240. ),
  241. }
  242. ),
  243. },
  244. ],
  245. },
  246. ],
  247. };
  248. const docs: Docs = {
  249. onboarding,
  250. feedbackOnboardingCrashApi: feedbackOnboarding,
  251. crashReportOnboarding: feedbackOnboarding,
  252. customMetricsOnboarding: metricsOnboarding,
  253. };
  254. export default docs;
  255. const AlertWithoutMarginBottom = styled(Alert)`
  256. margin-bottom: 0;
  257. `;