bun.tsx 2.2 KB

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