ember.tsx 9.0 KB

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