ember.tsx 8.8 KB

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