ember.tsx 8.3 KB

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