ember.tsx 9.2 KB

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