electron.tsx 2.6 KB

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