ember.tsx 8.9 KB

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