ember.tsx 5.4 KB

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