ember.tsx 5.6 KB

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