ember.tsx 5.5 KB

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