bun.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import widgetCallout from 'sentry/components/onboarding/gettingStartedDoc/feedback/widgetCallout';
  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 {
  9. getCrashReportJavaScriptInstallStep,
  10. getCrashReportModalConfigDescription,
  11. getCrashReportModalIntroduction,
  12. } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  13. import {
  14. feedbackOnboardingJsLoader,
  15. replayOnboardingJsLoader,
  16. } from 'sentry/gettingStartedDocs/javascript/jsLoader/jsLoader';
  17. import {t} from 'sentry/locale';
  18. type Params = DocsParams;
  19. const getInstallConfig = () => [
  20. {
  21. language: 'bash',
  22. code: 'bun add @sentry/bun',
  23. },
  24. ];
  25. const getConfigureSnippet = (params: Params) => `
  26. //...
  27. import * as Sentry from "@sentry/bun";
  28. Sentry.init({
  29. dsn: "${params.dsn.public}",${
  30. params.isPerformanceSelected
  31. ? `
  32. // Tracing
  33. tracesSampleRate: 1.0, // Capture 100% of the transactions`
  34. : ''
  35. }
  36. });`;
  37. const getVerifySnippet = () => `try {
  38. throw new Error('Sentry Bun test');
  39. } catch (e) {
  40. Sentry.captureException(e);
  41. }`;
  42. const onboarding: OnboardingConfig = {
  43. install: () => [
  44. {
  45. type: StepType.INSTALL,
  46. description: t(
  47. "Sentry captures data by using an SDK within your application's runtime."
  48. ),
  49. configurations: getInstallConfig(),
  50. },
  51. ],
  52. configure: params => [
  53. {
  54. type: StepType.CONFIGURE,
  55. description: t(
  56. "Initialize Sentry as early as possible in your application's lifecycle."
  57. ),
  58. configurations: [
  59. {
  60. language: 'javascript',
  61. code: getConfigureSnippet(params),
  62. },
  63. ],
  64. },
  65. ],
  66. verify: () => [
  67. {
  68. type: StepType.VERIFY,
  69. description: t(
  70. "This snippet contains an intentional error and can be used as a test to make sure that everything's working as expected."
  71. ),
  72. configurations: [
  73. {
  74. language: 'javascript',
  75. code: getVerifySnippet(),
  76. },
  77. ],
  78. },
  79. ],
  80. nextSteps: () => [],
  81. };
  82. const crashReportOnboarding: OnboardingConfig = {
  83. introduction: () => getCrashReportModalIntroduction(),
  84. install: (params: Params) => getCrashReportJavaScriptInstallStep(params),
  85. configure: () => [
  86. {
  87. type: StepType.CONFIGURE,
  88. description: getCrashReportModalConfigDescription({
  89. link: 'https://docs.sentry.io/platforms/javascript/guides/bun/user-feedback/configuration/#crash-report-modal',
  90. }),
  91. additionalInfo: widgetCallout({
  92. link: 'https://docs.sentry.io/platforms/javascript/guides/bun/user-feedback/#user-feedback-widget',
  93. }),
  94. },
  95. ],
  96. verify: () => [],
  97. nextSteps: () => [],
  98. };
  99. const docs: Docs = {
  100. onboarding,
  101. replayOnboardingJsLoader,
  102. crashReportOnboarding,
  103. feedbackOnboardingJsLoader,
  104. };
  105. export default docs;