unity.tsx 8.1 KB

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