ember.tsx 7.4 KB

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