electron.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
  3. import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
  4. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  5. import {getUploadSourceMapsStep} from 'sentry/components/onboarding/gettingStartedDoc/utils';
  6. import {PlatformKey} from 'sentry/data/platformCategories';
  7. import {t, tct} from 'sentry/locale';
  8. import type {Organization} from 'sentry/types';
  9. type StepProps = {
  10. newOrg: boolean;
  11. organization: Organization;
  12. platformKey: PlatformKey;
  13. projectId: string;
  14. sentryInitContent: string;
  15. };
  16. export const steps = ({
  17. sentryInitContent,
  18. ...props
  19. }: Partial<StepProps> = {}): LayoutProps['steps'] => [
  20. {
  21. type: StepType.INSTALL,
  22. description: t('Add the Sentry Electron SDK package as a dependency:'),
  23. configurations: [
  24. {
  25. language: 'bash',
  26. code: `
  27. # Using yarn
  28. yarn add @sentry/electron
  29. # Using npm
  30. npm install --save @sentry/electron
  31. `,
  32. },
  33. ],
  34. },
  35. {
  36. type: StepType.CONFIGURE,
  37. description: (
  38. <p>
  39. {tct(
  40. `You need to call [codeInit:Sentry.init] in the [codeMain:main] process and in every [codeRenderer:renderer] process you spawn.
  41. For more details about configuring the Electron SDK [docsLink:click here].`,
  42. {
  43. codeInit: <code />,
  44. codeMain: <code />,
  45. codeRenderer: <code />,
  46. docsLink: (
  47. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/electron/" />
  48. ),
  49. }
  50. )}
  51. </p>
  52. ),
  53. configurations: [
  54. {
  55. language: 'javascript',
  56. code: `
  57. import * as Sentry from "@sentry/electron";
  58. Sentry.init({
  59. ${sentryInitContent}
  60. });
  61. `,
  62. },
  63. ],
  64. },
  65. getUploadSourceMapsStep({
  66. guideLink: 'https://docs.sentry.io/platforms/javascript/guides/electron/sourcemaps/',
  67. ...props,
  68. }),
  69. {
  70. type: StepType.VERIFY,
  71. description: t(
  72. `One way to verify your setup is by intentionally causing an error that breaks your application.`
  73. ),
  74. configurations: [
  75. {
  76. description: t(
  77. `Calling an undefined function will throw a JavaScript exception:`
  78. ),
  79. language: 'javascript',
  80. code: `
  81. myUndefinedFunction();
  82. `,
  83. },
  84. {
  85. description: t(
  86. `With Electron you can test native crash reporting by triggering a crash:`
  87. ),
  88. language: 'javascript',
  89. code: `
  90. process.crash();
  91. `,
  92. },
  93. ],
  94. additionalInfo: t(
  95. 'You may want to try inserting these code snippets into both your main and any renderer processes to verify Sentry is operational in both.'
  96. ),
  97. },
  98. ];
  99. // Configuration End
  100. export function GettingStartedWithElectron({
  101. dsn,
  102. organization,
  103. platformKey,
  104. projectId,
  105. newOrg,
  106. }: ModuleProps) {
  107. const sentryInitContent: string[] = [`dsn: "${dsn}",`];
  108. return (
  109. <Layout
  110. steps={steps({
  111. sentryInitContent: sentryInitContent.join('\n'),
  112. organization,
  113. platformKey,
  114. projectId,
  115. newOrg,
  116. })}
  117. nextSteps={[]}
  118. newOrg={newOrg}
  119. platformKey={platformKey}
  120. />
  121. );
  122. }
  123. export default GettingStartedWithElectron;