ember.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 {getUploadSourceMapsStep} from 'sentry/components/onboarding/gettingStartedDoc/utils';
  8. import {t, tct} from 'sentry/locale';
  9. type Params = DocsParams;
  10. const getSdkSetupSnippet = (params: Params) => `
  11. import Application from "@ember/application";
  12. import Resolver from "ember-resolver";
  13. import loadInitializers from "ember-load-initializers";
  14. import config from "./config/environment";
  15. import * as Sentry from "@sentry/ember";
  16. Sentry.init({
  17. dsn: "${params.dsn}",
  18. integrations: [${
  19. params.isPerformanceSelected
  20. ? `
  21. new Sentry.BrowserTracing({
  22. // Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
  23. tracePropagationTargets: ["localhost", /^https:\\/\\/yourserver\\.io\\/api/],
  24. }),`
  25. : ''
  26. }${
  27. params.isReplaySelected
  28. ? `
  29. new Sentry.Replay(),`
  30. : ''
  31. }
  32. ],${
  33. params.isPerformanceSelected
  34. ? `
  35. // Performance Monitoring
  36. tracesSampleRate: 1.0, // Capture 100% of the transactions`
  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 getVerifyEmberSnippet = () => `
  54. myUndefinedFunction();`;
  55. const onboarding: OnboardingConfig = {
  56. install: () => [
  57. {
  58. type: StepType.INSTALL,
  59. description: t(
  60. 'Sentry captures data by using an SDK within your application’s runtime.'
  61. ),
  62. configurations: [
  63. {
  64. language: 'bash',
  65. code: `
  66. # Using ember-cli
  67. ember install @sentry/ember
  68. `,
  69. },
  70. ],
  71. },
  72. ],
  73. configure: (params: Params) => [
  74. {
  75. type: StepType.CONFIGURE,
  76. description: tct(
  77. 'You should [initCode:init] the Sentry SDK as soon as possible during your application load up in [appCode:app.js], before initializing Ember:',
  78. {
  79. initCode: <code />,
  80. appCode: <code />,
  81. }
  82. ),
  83. configurations: [
  84. {
  85. code: [
  86. {
  87. label: 'JavaScript',
  88. value: 'javascript',
  89. language: 'javascript',
  90. code: getSdkSetupSnippet(params),
  91. },
  92. ],
  93. },
  94. ],
  95. },
  96. getUploadSourceMapsStep({
  97. guideLink: 'https://docs.sentry.io/platforms/javascript/guides/ember/sourcemaps/',
  98. }),
  99. ],
  100. verify: () => [
  101. {
  102. type: StepType.VERIFY,
  103. description: t(
  104. "This snippet contains an intentional error and can be used as a test to make sure that everything's working as expected."
  105. ),
  106. configurations: [
  107. {
  108. code: [
  109. {
  110. label: 'JavaScript',
  111. value: 'javascript',
  112. language: 'javascript',
  113. code: getVerifyEmberSnippet(),
  114. },
  115. ],
  116. },
  117. ],
  118. },
  119. ],
  120. nextSteps: () => [
  121. {
  122. id: 'performance-monitoring',
  123. name: t('Performance Monitoring'),
  124. description: t(
  125. 'Track down transactions to connect the dots between 10-second page loads and poor-performing API calls or slow database queries.'
  126. ),
  127. link: 'https://docs.sentry.io/platforms/javascript/guides/ember/performance/',
  128. },
  129. {
  130. id: 'session-replay',
  131. name: t('Session Replay'),
  132. description: t(
  133. '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.'
  134. ),
  135. link: 'https://docs.sentry.io/platforms/javascript/guides/ember/session-replay/',
  136. },
  137. ],
  138. };
  139. const docs: Docs = {
  140. onboarding,
  141. };
  142. export default docs;