electron.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  3. import type {
  4. Docs,
  5. DocsParams,
  6. OnboardingConfig,
  7. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  8. import {getUploadSourceMapsStep} from 'sentry/components/onboarding/gettingStartedDoc/utils';
  9. import {t, tct} from 'sentry/locale';
  10. type Params = DocsParams;
  11. const getConfigureSnippet = (params: Params) => `
  12. import * as Sentry from "@sentry/electron";
  13. Sentry.init({
  14. dsn: "${params.dsn}",
  15. });`;
  16. const onboarding: OnboardingConfig = {
  17. install: () => [
  18. {
  19. type: StepType.INSTALL,
  20. description: t('Add the Sentry Electron SDK package as a dependency:'),
  21. configurations: [
  22. {
  23. code: [
  24. {
  25. label: 'npm',
  26. value: 'npm',
  27. language: 'bash',
  28. code: 'npm install --save @sentry/electron',
  29. },
  30. {
  31. label: 'yarn',
  32. value: 'yarn',
  33. language: 'bash',
  34. code: 'yarn add @sentry/electron',
  35. },
  36. ],
  37. },
  38. ],
  39. },
  40. ],
  41. configure: params => [
  42. {
  43. type: StepType.CONFIGURE,
  44. description: tct(
  45. `You need to call [codeInit:Sentry.init] in the [codeMain:main] process and in every [codeRenderer:renderer] process you spawn.
  46. For more details about configuring the Electron SDK [docsLink:click here].`,
  47. {
  48. codeInit: <code />,
  49. codeMain: <code />,
  50. codeRenderer: <code />,
  51. docsLink: (
  52. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/electron/" />
  53. ),
  54. }
  55. ),
  56. configurations: [
  57. {
  58. language: 'javascript',
  59. code: getConfigureSnippet(params),
  60. },
  61. ],
  62. },
  63. getUploadSourceMapsStep({
  64. guideLink:
  65. 'https://docs.sentry.io/platforms/javascript/guides/electron/sourcemaps/',
  66. ...params,
  67. }),
  68. ],
  69. verify: () => [
  70. {
  71. type: StepType.VERIFY,
  72. description: t(
  73. `One way to verify your setup is by intentionally causing an error that breaks your application.`
  74. ),
  75. configurations: [
  76. {
  77. description: t(
  78. `Calling an undefined function will throw a JavaScript exception:`
  79. ),
  80. language: 'javascript',
  81. code: 'myUndefinedFunction();',
  82. },
  83. {
  84. description: t(
  85. `With Electron you can test native crash reporting by triggering a crash:`
  86. ),
  87. language: 'javascript',
  88. code: 'process.crash();',
  89. },
  90. ],
  91. additionalInfo: t(
  92. 'You may want to try inserting these code snippets into both your main and any renderer processes to verify Sentry is operational in both.'
  93. ),
  94. },
  95. ],
  96. };
  97. const docs: Docs = {
  98. onboarding,
  99. };
  100. export default docs;