electron.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. Calling an undefined function will throw an exception:`
  74. ),
  75. configurations: [
  76. {
  77. language: 'javascript',
  78. code: `
  79. myUndefinedFunction();
  80. `,
  81. },
  82. ],
  83. additionalInfo: t(
  84. 'You may want to try inserting this code snippet into both your main and any renderer processes to verify Sentry is operational in both.'
  85. ),
  86. },
  87. ];
  88. // Configuration End
  89. export function GettingStartedWithElectron({
  90. dsn,
  91. organization,
  92. platformKey,
  93. projectId,
  94. newOrg,
  95. }: ModuleProps) {
  96. const sentryInitContent: string[] = [`dsn: "${dsn}",`];
  97. return (
  98. <Layout
  99. steps={steps({
  100. sentryInitContent: sentryInitContent.join('\n'),
  101. organization,
  102. platformKey,
  103. projectId,
  104. newOrg,
  105. })}
  106. nextSteps={[]}
  107. newOrg={newOrg}
  108. platformKey={platformKey}
  109. />
  110. );
  111. }
  112. export default GettingStartedWithElectron;