bun.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  2. import type {
  3. Docs,
  4. DocsParams,
  5. OnboardingConfig,
  6. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  7. import replayOnboardingJsLoader from 'sentry/gettingStartedDocs/javascript/jsLoader/jsLoader';
  8. import {t} from 'sentry/locale';
  9. type Params = DocsParams;
  10. const getConfigureSnippet = (params: Params) => `
  11. //...
  12. import * as Sentry from "@sentry/bun";
  13. Sentry.init({
  14. dsn: "${params.dsn}",${
  15. params.isPerformanceSelected
  16. ? `
  17. // Performance Monitoring
  18. tracesSampleRate: 1.0, // Capture 100% of the transactions`
  19. : ''
  20. }
  21. });`;
  22. const getVerifySnippet = () => `try {
  23. throw new Error('Sentry Bun test');
  24. } catch (e) {
  25. Sentry.captureException(e);
  26. }`;
  27. const onboarding: OnboardingConfig = {
  28. install: () => [
  29. {
  30. type: StepType.INSTALL,
  31. description: t(
  32. "Sentry captures data by using an SDK within your application's runtime."
  33. ),
  34. configurations: [
  35. {
  36. language: 'bash',
  37. code: 'bun add @sentry/bun',
  38. },
  39. ],
  40. },
  41. ],
  42. configure: params => [
  43. {
  44. type: StepType.CONFIGURE,
  45. description: t(
  46. "Initialize Sentry as early as possible in your application's lifecycle."
  47. ),
  48. configurations: [
  49. {
  50. language: 'javascript',
  51. code: getConfigureSnippet(params),
  52. },
  53. ],
  54. },
  55. ],
  56. verify: () => [
  57. {
  58. type: StepType.VERIFY,
  59. description: t(
  60. "This snippet contains an intentional error and can be used as a test to make sure that everything's working as expected."
  61. ),
  62. configurations: [
  63. {
  64. language: 'javascript',
  65. code: getVerifySnippet(),
  66. },
  67. ],
  68. },
  69. ],
  70. nextSteps: params =>
  71. params.isPerformanceSelected
  72. ? []
  73. : [
  74. {
  75. id: 'performance-monitoring',
  76. name: t('Performance Monitoring'),
  77. description: t(
  78. 'Track down transactions to connect the dots between 10-second page loads and poor-performing API calls or slow database queries.'
  79. ),
  80. link: 'https://docs.sentry.io/platforms/javascript/guides/bun/performance/',
  81. },
  82. ],
  83. };
  84. const docs: Docs = {
  85. onboarding,
  86. replayOnboardingJsLoader,
  87. };
  88. export default docs;