deno.tsx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. import ExternalLink from 'sentry/components/links/externalLink';
  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 replayOnboardingJsLoader from 'sentry/gettingStartedDocs/javascript/jsLoader/jsLoader';
  9. import {t, tct} from 'sentry/locale';
  10. type Params = DocsParams;
  11. const getInstallConfig = () => [
  12. {
  13. code: [
  14. {
  15. label: 'Deno registry',
  16. value: 'deno',
  17. language: 'javascript',
  18. code: `import * as Sentry from "https://deno.land/x/sentry/index.mjs";"`,
  19. },
  20. {
  21. label: 'npm registry',
  22. value: 'npm',
  23. language: 'javascript',
  24. code: `import * as Sentry from "npm:@sentry/deno";`,
  25. },
  26. ],
  27. },
  28. ];
  29. const getConfigureSnippet = (params: Params) =>
  30. `
  31. Sentry.init({
  32. dsn: "${params.dsn}",${
  33. params.isPerformanceSelected
  34. ? `
  35. // enable performance
  36. tracesSampleRate: 1.0,`
  37. : ''
  38. }
  39. });
  40. `;
  41. const getVerifySnippet = () => `;
  42. setTimeout(() => {
  43. throw new Error();
  44. });
  45. `;
  46. const getMetricsConfigureSnippet = (params: DocsParams) => `;
  47. Sentry.init({
  48. dsn: '${params.dsn}',
  49. // Only needed for SDK versions < 8.0.0
  50. // _experiments: {
  51. // metricsAggregator: true,
  52. // },
  53. });
  54. `;
  55. const getMetricsVerifySnippet = () => `;
  56. // Add 4 to a counter named 'hits'
  57. Sentry.metrics.increment('hits', 4);
  58. `;
  59. const onboarding: OnboardingConfig = {
  60. install: () => [
  61. {
  62. type: StepType.INSTALL,
  63. description: t(
  64. "Sentry captures data by using an SDK within your application's runtime."
  65. ),
  66. configurations: getInstallConfig(),
  67. },
  68. ],
  69. configure: params => [
  70. {
  71. type: StepType.CONFIGURE,
  72. description: t(
  73. "Initialize Sentry as early as possible in your application's lifecycle."
  74. ),
  75. configurations: [
  76. {
  77. language: 'javascript',
  78. code: getConfigureSnippet(params),
  79. },
  80. ],
  81. },
  82. ],
  83. verify: () => [
  84. {
  85. type: StepType.VERIFY,
  86. description: t(
  87. "This snippet contains an intentional error and can be used as a test to make sure that everything's working as expected."
  88. ),
  89. configurations: [
  90. {
  91. language: 'javascript',
  92. code: getVerifySnippet(),
  93. },
  94. ],
  95. },
  96. ],
  97. nextSteps: params =>
  98. params.isPerformanceSelected
  99. ? []
  100. : [
  101. {
  102. id: 'performance-monitoring',
  103. name: t('Performance Monitoring'),
  104. description: t(
  105. 'Track down transactions to connect the dots between 10-second page loads and poor-performing API calls or slow database queries.'
  106. ),
  107. link: 'https://docs.sentry.io/platforms/javascript/guides/bun/performance/',
  108. },
  109. ],
  110. };
  111. const customMetricsOnboarding: OnboardingConfig = {
  112. install: () => [
  113. {
  114. type: StepType.INSTALL,
  115. description: tct(
  116. 'You need a minimum version [codeVersion:7.91.0] of [codePackage:@sentry/deno].',
  117. {
  118. codeVersion: <code />,
  119. codePackage: <code />,
  120. }
  121. ),
  122. configurations: getInstallConfig(),
  123. },
  124. ],
  125. configure: params => [
  126. {
  127. type: StepType.CONFIGURE,
  128. description: t(
  129. 'With the default snippet in place, there is no need for any further configuration.'
  130. ),
  131. configurations: [
  132. {
  133. code: getMetricsConfigureSnippet(params),
  134. language: 'javascript',
  135. },
  136. ],
  137. },
  138. ],
  139. verify: () => [
  140. {
  141. type: StepType.VERIFY,
  142. description: tct(
  143. "Then you'll be able to add metrics as [codeCounters:counters], [codeSets:sets], [codeDistribution:distributions], and [codeGauge:gauges]. These are available under the [codeNamespace:Sentry.metrics] namespace. This API is available in both renderer and main processes. Try out this example:",
  144. {
  145. codeCounters: <code />,
  146. codeSets: <code />,
  147. codeDistribution: <code />,
  148. codeGauge: <code />,
  149. codeNamespace: <code />,
  150. }
  151. ),
  152. configurations: [
  153. {
  154. code: [
  155. {
  156. label: 'JavaScript',
  157. value: 'javascript',
  158. language: 'javascript',
  159. code: getMetricsVerifySnippet(),
  160. },
  161. ],
  162. },
  163. {
  164. description: t(
  165. 'It can take up to 3 minutes for the data to appear in the Sentry UI.'
  166. ),
  167. },
  168. {
  169. description: tct(
  170. 'Learn more about metrics and how to configure them, by reading the [docsLink:docs].',
  171. {
  172. docsLink: (
  173. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/deno/metrics/" />
  174. ),
  175. }
  176. ),
  177. },
  178. ],
  179. },
  180. ],
  181. };
  182. const docs: Docs = {
  183. onboarding,
  184. replayOnboardingJsLoader,
  185. customMetricsOnboarding,
  186. };
  187. export default docs;