ember.tsx 7.1 KB

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