ember.tsx 8.9 KB

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