deno.tsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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.public}",${
  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.public}',
  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: () => [],
  98. };
  99. const customMetricsOnboarding: OnboardingConfig = {
  100. install: () => [
  101. {
  102. type: StepType.INSTALL,
  103. description: tct(
  104. 'You need a minimum version [code:7.91.0] of [code:@sentry/deno].',
  105. {
  106. code: <code />,
  107. }
  108. ),
  109. configurations: getInstallConfig(),
  110. },
  111. ],
  112. configure: params => [
  113. {
  114. type: StepType.CONFIGURE,
  115. description: t(
  116. 'With the default snippet in place, there is no need for any further configuration.'
  117. ),
  118. configurations: [
  119. {
  120. code: getMetricsConfigureSnippet(params),
  121. language: 'javascript',
  122. },
  123. ],
  124. },
  125. ],
  126. verify: () => [
  127. {
  128. type: StepType.VERIFY,
  129. description: tct(
  130. "Then you'll be able to add metrics as [code:counters], [code:sets], [code:distributions], and [code:gauges]. These are available under the [code:Sentry.metrics] namespace. This API is available in both renderer and main processes. Try out this example:",
  131. {
  132. code: <code />,
  133. }
  134. ),
  135. configurations: [
  136. {
  137. code: [
  138. {
  139. label: 'JavaScript',
  140. value: 'javascript',
  141. language: 'javascript',
  142. code: getMetricsVerifySnippet(),
  143. },
  144. ],
  145. },
  146. {
  147. description: t(
  148. 'It can take up to 3 minutes for the data to appear in the Sentry UI.'
  149. ),
  150. },
  151. {
  152. description: tct(
  153. 'Learn more about metrics and how to configure them, by reading the [docsLink:docs].',
  154. {
  155. docsLink: (
  156. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/deno/metrics/" />
  157. ),
  158. }
  159. ),
  160. },
  161. ],
  162. },
  163. ],
  164. };
  165. const docs: Docs = {
  166. onboarding,
  167. replayOnboardingJsLoader,
  168. customMetricsOnboarding,
  169. };
  170. export default docs;