deno.tsx 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. _experiments: {
  50. metricsAggregator: true,
  51. },
  52. });
  53. `;
  54. const getMetricsVerifySnippet = () => `;
  55. // Add 4 to a counter named 'hits'
  56. Sentry.metrics.increment('hits', 4);
  57. `;
  58. const onboarding: OnboardingConfig = {
  59. install: () => [
  60. {
  61. type: StepType.INSTALL,
  62. description: t(
  63. "Sentry captures data by using an SDK within your application's runtime."
  64. ),
  65. configurations: getInstallConfig(),
  66. },
  67. ],
  68. configure: params => [
  69. {
  70. type: StepType.CONFIGURE,
  71. description: t(
  72. "Initialize Sentry as early as possible in your application's lifecycle."
  73. ),
  74. configurations: [
  75. {
  76. language: 'javascript',
  77. code: getConfigureSnippet(params),
  78. },
  79. ],
  80. },
  81. ],
  82. verify: () => [
  83. {
  84. type: StepType.VERIFY,
  85. description: t(
  86. "This snippet contains an intentional error and can be used as a test to make sure that everything's working as expected."
  87. ),
  88. configurations: [
  89. {
  90. language: 'javascript',
  91. code: getVerifySnippet(),
  92. },
  93. ],
  94. },
  95. ],
  96. nextSteps: params =>
  97. params.isPerformanceSelected
  98. ? []
  99. : [
  100. {
  101. id: 'performance-monitoring',
  102. name: t('Performance Monitoring'),
  103. description: t(
  104. 'Track down transactions to connect the dots between 10-second page loads and poor-performing API calls or slow database queries.'
  105. ),
  106. link: 'https://docs.sentry.io/platforms/javascript/guides/bun/performance/',
  107. },
  108. ],
  109. };
  110. const customMetricsOnboarding: OnboardingConfig = {
  111. install: () => [
  112. {
  113. type: StepType.INSTALL,
  114. description: tct(
  115. 'You need a minimum version [codeVersion:7.91.0] of [codePackage:@sentry/deno].',
  116. {
  117. codeVersion: <code />,
  118. codePackage: <code />,
  119. }
  120. ),
  121. configurations: getInstallConfig(),
  122. },
  123. ],
  124. configure: params => [
  125. {
  126. type: StepType.CONFIGURE,
  127. description: tct(
  128. 'To enable capturing metrics, you first need to add the [codeIntegration:metricsAggregator] experiment to your [codeNamespace:Sentry.init] call in your main process.',
  129. {
  130. codeIntegration: <code />,
  131. codeNamespace: <code />,
  132. }
  133. ),
  134. configurations: [
  135. {
  136. code: [
  137. {
  138. label: 'JavaScript',
  139. value: 'javascript',
  140. language: 'javascript',
  141. code: getMetricsConfigureSnippet(params),
  142. },
  143. ],
  144. },
  145. ],
  146. },
  147. ],
  148. verify: () => [
  149. {
  150. type: StepType.VERIFY,
  151. description: tct(
  152. "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:",
  153. {
  154. codeCounters: <code />,
  155. codeSets: <code />,
  156. codeDistribution: <code />,
  157. codeGauge: <code />,
  158. codeNamespace: <code />,
  159. }
  160. ),
  161. configurations: [
  162. {
  163. code: [
  164. {
  165. label: 'JavaScript',
  166. value: 'javascript',
  167. language: 'javascript',
  168. code: getMetricsVerifySnippet(),
  169. },
  170. ],
  171. },
  172. {
  173. description: t(
  174. 'With a bit of delay you can see the data appear in the Sentry UI.'
  175. ),
  176. },
  177. {
  178. description: tct(
  179. 'Learn more about metrics and how to configure them, by reading the [docsLink:docs].',
  180. {
  181. docsLink: (
  182. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/deno/metrics/" />
  183. ),
  184. }
  185. ),
  186. },
  187. ],
  188. },
  189. ],
  190. };
  191. const docs: Docs = {
  192. onboarding,
  193. replayOnboardingJsLoader,
  194. customMetricsOnboarding,
  195. };
  196. export default docs;