electron.tsx 3.3 KB

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