ember.tsx 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  2. import {
  3. Docs,
  4. DocsParams,
  5. OnboardingConfig,
  6. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  7. import {
  8. getReplayConfigureDescription,
  9. getUploadSourceMapsStep,
  10. } from 'sentry/components/onboarding/gettingStartedDoc/utils';
  11. import {t, tct} from 'sentry/locale';
  12. type Params = DocsParams;
  13. const getSdkSetupSnippet = (params: Params) => `
  14. import Application from "@ember/application";
  15. import Resolver from "ember-resolver";
  16. import loadInitializers from "ember-load-initializers";
  17. import config from "./config/environment";
  18. import * as Sentry from "@sentry/ember";
  19. Sentry.init({
  20. dsn: "${params.dsn}",
  21. integrations: [${
  22. params.isPerformanceSelected
  23. ? `
  24. new Sentry.BrowserTracing({
  25. // Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
  26. tracePropagationTargets: ["localhost", /^https:\\/\\/yourserver\\.io\\/api/],
  27. }),`
  28. : ''
  29. }${
  30. params.isReplaySelected
  31. ? `
  32. new Sentry.Replay(),`
  33. : ''
  34. }
  35. ],${
  36. params.isPerformanceSelected
  37. ? `
  38. // Performance Monitoring
  39. tracesSampleRate: 1.0, // Capture 100% of the transactions`
  40. : ''
  41. }${
  42. params.isReplaySelected
  43. ? `
  44. // Session Replay
  45. replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
  46. replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.`
  47. : ''
  48. }
  49. });
  50. export default class App extends Application {
  51. modulePrefix = config.modulePrefix;
  52. podModulePrefix = config.podModulePrefix;
  53. Resolver = Resolver;
  54. }
  55. `;
  56. const getInstallConfig = () => [
  57. {
  58. language: 'bash',
  59. code: `
  60. # Using ember-cli
  61. ember install @sentry/ember
  62. `,
  63. },
  64. ];
  65. const getVerifyEmberSnippet = () => `
  66. myUndefinedFunction();`;
  67. const onboarding: OnboardingConfig = {
  68. install: () => [
  69. {
  70. type: StepType.INSTALL,
  71. description: t(
  72. 'Sentry captures data by using an SDK within your application’s runtime.'
  73. ),
  74. configurations: getInstallConfig(),
  75. },
  76. ],
  77. configure: (params: Params) => [
  78. {
  79. type: StepType.CONFIGURE,
  80. description: tct(
  81. 'You should [initCode:init] the Sentry SDK as soon as possible during your application load up in [appCode:app.js], before initializing Ember:',
  82. {
  83. initCode: <code />,
  84. appCode: <code />,
  85. }
  86. ),
  87. configurations: [
  88. {
  89. code: [
  90. {
  91. label: 'JavaScript',
  92. value: 'javascript',
  93. language: 'javascript',
  94. code: getSdkSetupSnippet(params),
  95. },
  96. ],
  97. },
  98. ],
  99. },
  100. getUploadSourceMapsStep({
  101. guideLink: 'https://docs.sentry.io/platforms/javascript/guides/ember/sourcemaps/',
  102. }),
  103. ],
  104. verify: () => [
  105. {
  106. type: StepType.VERIFY,
  107. description: t(
  108. "This snippet contains an intentional error and can be used as a test to make sure that everything's working as expected."
  109. ),
  110. configurations: [
  111. {
  112. code: [
  113. {
  114. label: 'JavaScript',
  115. value: 'javascript',
  116. language: 'javascript',
  117. code: getVerifyEmberSnippet(),
  118. },
  119. ],
  120. },
  121. ],
  122. },
  123. ],
  124. nextSteps: () => [
  125. {
  126. id: 'performance-monitoring',
  127. name: t('Performance Monitoring'),
  128. description: t(
  129. 'Track down transactions to connect the dots between 10-second page loads and poor-performing API calls or slow database queries.'
  130. ),
  131. link: 'https://docs.sentry.io/platforms/javascript/guides/ember/performance/',
  132. },
  133. {
  134. id: 'session-replay',
  135. name: t('Session Replay'),
  136. description: t(
  137. 'Get to the root cause of an error or latency issue faster by seeing all the technical details related to that issue in one visual replay on your web application.'
  138. ),
  139. link: 'https://docs.sentry.io/platforms/javascript/guides/ember/session-replay/',
  140. },
  141. ],
  142. };
  143. const replayOnboarding: OnboardingConfig = {
  144. install: () => [
  145. {
  146. type: StepType.INSTALL,
  147. description: tct(
  148. 'You need a minimum version 7.27.0 of [code:@sentry/ember] in order to use Session Replay. You do not need to install any additional packages.',
  149. {
  150. code: <code />,
  151. }
  152. ),
  153. configurations: getInstallConfig(),
  154. },
  155. ],
  156. configure: (params: Params) => [
  157. {
  158. type: StepType.CONFIGURE,
  159. description: getReplayConfigureDescription({
  160. link: 'https://docs.sentry.io/platforms/javascript/guides/ember/session-replay/',
  161. }),
  162. configurations: [
  163. {
  164. code: [
  165. {
  166. label: 'JavaScript',
  167. value: 'javascript',
  168. language: 'javascript',
  169. code: getSdkSetupSnippet({...params, isReplaySelected: true}),
  170. },
  171. ],
  172. },
  173. ],
  174. },
  175. ],
  176. verify: () => [],
  177. nextSteps: () => [],
  178. };
  179. const docs: Docs = {
  180. onboarding,
  181. replayOnboardingNpm: replayOnboarding,
  182. };
  183. export default docs;