unreal.tsx 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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. DocsParams,
  9. OnboardingConfig,
  10. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  11. import {
  12. getCrashReportApiIntroduction,
  13. getCrashReportInstallDescription,
  14. } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  15. import {t, tct} from 'sentry/locale';
  16. type Params = DocsParams;
  17. const getVerifySnippet = () => `
  18. #include "SentrySubsystem.h"
  19. void Verify()
  20. {
  21. // Obtain reference to GameInstance
  22. UGameInstance* GameInstance = ...;
  23. // Capture message
  24. USentrySubsystem* SentrySubsystem = GameInstance->GetSubsystem<USentrySubsystem>();
  25. SentrySubsystem->CaptureMessage(TEXT("Capture message"));
  26. }`;
  27. const getCrashReporterConfigSnippet = (params: Params) => `
  28. [CrashReportClient]
  29. CrashReportClientVersion=1.0
  30. DataRouterUrl="${params.dsn}"`;
  31. const onboarding: OnboardingConfig = {
  32. install: () => [
  33. {
  34. type: StepType.INSTALL,
  35. description: (
  36. <Fragment>
  37. <p>
  38. {tct(
  39. "Download the latest plugin sources from the [link:Releases] page and place it in the project's 'Plugins' directory. On the next project launch, UE will prompt to build Sentry module.",
  40. {
  41. link: (
  42. <ExternalLink href="https://github.com/getsentry/sentry-unreal/releases" />
  43. ),
  44. }
  45. )}
  46. </p>
  47. <p>
  48. {tct(
  49. 'After the successful build, in the editor navigate to the [strong:Project Settings > Plugins > Code Plugins] menu and check whether the Sentry plugin is enabled.',
  50. {
  51. strong: <strong />,
  52. }
  53. )}
  54. </p>
  55. </Fragment>
  56. ),
  57. configurations: [
  58. {
  59. language: 'csharp',
  60. description: t(
  61. "To access the plugin API from within C++, add Sentry support to the build script (MyProject.build.cs):'"
  62. ),
  63. code: 'PublicDependencyModuleNames.AddRange(new string[] { ..., "Sentry" });',
  64. },
  65. ],
  66. },
  67. ],
  68. configure: params => [
  69. {
  70. type: StepType.CONFIGURE,
  71. description: tct(
  72. "Access the Sentry configuration window by going to editor's menu: [strong:Project Settings > Plugins > Sentry] and enter the following DSN:",
  73. {strong: <strong />}
  74. ),
  75. configurations: [
  76. {
  77. language: 'url',
  78. code: params.dsn,
  79. },
  80. ],
  81. },
  82. ],
  83. verify: params => [
  84. {
  85. type: StepType.VERIFY,
  86. description: t(
  87. 'Once everything is configured you can call the plugin API from both C++ and blueprints:'
  88. ),
  89. configurations: [
  90. {
  91. language: 'cpp',
  92. code: getVerifySnippet(),
  93. },
  94. ],
  95. },
  96. {
  97. title: t('Crash Reporter Client'),
  98. description: tct(
  99. 'For Windows and Mac, [link:Crash Reporter Client] provided along with Unreal Engine has to be configured in order to capture errors automatically.',
  100. {
  101. link: (
  102. <ExternalLink href="https://docs.sentry.io/platforms/unreal/setup-crashreporter/" />
  103. ),
  104. }
  105. ),
  106. configurations: [
  107. {
  108. description: (
  109. <Fragment>
  110. <h5>{t('Include the UE Crash Reporter')}</h5>
  111. <p>
  112. {tct(
  113. 'You can add the crash reporter client to your game in [strong:Project Settings].',
  114. {strong: <strong />}
  115. )}
  116. </p>
  117. <p>
  118. {tct(
  119. 'The option is located under [strong:Project > Packaging]; select "show advanced" followed by checking the box for "Include Crash Reporter".',
  120. {strong: <strong />}
  121. )}
  122. </p>
  123. </Fragment>
  124. ),
  125. },
  126. {
  127. description: (
  128. <Fragment>
  129. <h5>{t('Debug Information')}</h5>
  130. {t(
  131. 'To get the most out of Sentry, crash reports must include debug information. In order for Sentry to be able to process the crash report and translate memory addresses to meaningful information like function names, module names, and line numbers, the crash itself must include debug information. In addition, symbols need to be uploaded to Sentry.'
  132. )}
  133. <p>
  134. {tct(
  135. "The option is also located under [strong:Project > Packaging]; select 'show advanced' followed by checking the box for 'Include Debug Files'.",
  136. {strong: <strong />}
  137. )}
  138. </p>
  139. </Fragment>
  140. ),
  141. },
  142. {
  143. description: (
  144. <Fragment>
  145. <h5>{t('Configure the Crash Reporter Endpoint')}</h5>
  146. <p>
  147. {tct(
  148. "Now that the crash reporter and debug files are included, UE needs to know where to send the crash. For that, add the Sentry 'Unreal Engine Endpoint' from the 'Client Keys' settings page to the game's configuration file. This will include which project in Sentry you want to see crashes displayed in. That's accomplished by configuring the [code:CrashReportClient] in the [italic:DefaultEngine.ini] file. Changing the engine is necessary for this to work. Edit the file:",
  149. {
  150. code: <code />,
  151. italic: <i />,
  152. }
  153. )}
  154. </p>
  155. <AlertWithoutMarginBottom type="info">
  156. engine-dir\Engine\Programs\CrashReportClient\Config\DefaultEngine.ini
  157. </AlertWithoutMarginBottom>
  158. </Fragment>
  159. ),
  160. configurations: [
  161. {
  162. description: t('Add the configuration section:'),
  163. language: 'ini',
  164. code: getCrashReporterConfigSnippet(params),
  165. additionalInfo: (
  166. <p>
  167. {tct(
  168. 'If a [crashReportCode:CrashReportClient] section already exists, simply changing the value of [dataRouterUrlCode:DataRouterUrl] is enough.',
  169. {crashReportCode: <code />, dataRouterUrlCode: <code />}
  170. )}
  171. </p>
  172. ),
  173. },
  174. ],
  175. },
  176. ],
  177. },
  178. {
  179. title: t('Upload Debug Symbols'),
  180. description: (
  181. <Fragment>
  182. <p>
  183. {tct(
  184. 'To allow Sentry to fully process native crashes and provide you with symbolicated stack traces, you need to upload [debugInformationItalic:debug information files] (sometimes also referred to as [debugSymbolsItalic:debug symbols] or just [symbolsItalic:symbols]). We recommend uploading debug information during your build or release process.',
  185. {
  186. debugInformationItalic: <i />,
  187. symbolsItalic: <i />,
  188. debugSymbolsItalic: <i />,
  189. }
  190. )}
  191. </p>
  192. <p>
  193. {tct(
  194. "For all libraries where you'd like to receive symbolication, [strong:you need to provide debug information]. This includes dependencies and operating system libraries.",
  195. {
  196. strong: <strong />,
  197. }
  198. )}
  199. </p>
  200. <p>
  201. {tct(
  202. 'In addition to debug information files, Sentry needs [italic:call frame information] (CFI) to extract accurate stack traces from minidumps of optimized release builds. CFI is usually part of the executables and not copied to debug symbols. Unless you are uploading Breakpad symbols, be sure to also include the binaries when uploading files to Sentry',
  203. {italic: <i />}
  204. )}
  205. </p>
  206. <p>
  207. {tct(
  208. 'For more information on uploading debug information and their supported formats, check out our [link:Debug Information Files documentation].',
  209. {
  210. link: (
  211. <ExternalLink href="https://docs.sentry.io/platforms/native/data-management/debug-files/" />
  212. ),
  213. }
  214. )}
  215. </p>
  216. </Fragment>
  217. ),
  218. },
  219. ],
  220. };
  221. const feedbackOnboardingCrashApi: OnboardingConfig = {
  222. introduction: () => getCrashReportApiIntroduction(),
  223. install: () => [
  224. {
  225. type: StepType.INSTALL,
  226. description: getCrashReportInstallDescription(),
  227. configurations: [
  228. {
  229. code: [
  230. {
  231. label: 'C++',
  232. value: 'cpp',
  233. language: 'cpp',
  234. code: `USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();
  235. USentryId* EventId = SentrySubsystem->CaptureMessage(TEXT("Message with feedback"));
  236. USentryUserFeedback* UserFeedback = NewObject<USentryUserFeedback>();
  237. User->Initialize(EventId);
  238. User->SetEmail("test@sentry.io");
  239. User->SetName("Name");
  240. User->SetComment("Some comment");
  241. SentrySubsystem->CaptureUserFeedback(UserFeedback);
  242. // OR
  243. SentrySubsystem->CaptureUserFeedbackWithParams(EventId, "test@sentry.io", "Some comment", "Name");`,
  244. },
  245. ],
  246. },
  247. ],
  248. },
  249. ],
  250. configure: () => [],
  251. verify: () => [],
  252. nextSteps: () => [],
  253. };
  254. const docs: Docs = {
  255. onboarding,
  256. feedbackOnboardingCrashApi,
  257. crashReportOnboarding: feedbackOnboardingCrashApi,
  258. };
  259. export default docs;
  260. const AlertWithoutMarginBottom = styled(Alert)`
  261. margin-bottom: 0;
  262. `;