deno.tsx 4.3 KB

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