ember.tsx 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
  2. import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
  3. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  4. import {getUploadSourceMapsStep} from 'sentry/components/onboarding/gettingStartedDoc/utils';
  5. import {ProductSolution} from 'sentry/components/onboarding/productSelection';
  6. import {t, tct} from 'sentry/locale';
  7. // Configuration Start
  8. const replayIntegration = `
  9. new Sentry.Replay(),
  10. `;
  11. const replayOtherConfig = `
  12. // Session Replay
  13. 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.
  14. replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
  15. `;
  16. const performanceOtherConfig = `
  17. // Performance Monitoring
  18. tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production!
  19. `;
  20. export const steps = ({
  21. sentryInitContent,
  22. }: {
  23. sentryInitContent?: string;
  24. } = {}): LayoutProps['steps'] => [
  25. {
  26. type: StepType.INSTALL,
  27. description: t(
  28. 'Sentry captures data by using an SDK within your application’s runtime.'
  29. ),
  30. configurations: [
  31. {
  32. language: 'bash',
  33. code: `
  34. # Using ember-cli
  35. ember install @sentry/ember
  36. `,
  37. },
  38. ],
  39. },
  40. {
  41. type: StepType.CONFIGURE,
  42. description: (
  43. <p>
  44. {tct(
  45. 'You should [code:init] the Sentry SDK as soon as possible during your application load up in [code:app.js], before initializing Ember:',
  46. {
  47. code: <code />,
  48. }
  49. )}
  50. </p>
  51. ),
  52. configurations: [
  53. {
  54. language: 'javascript',
  55. code: `
  56. import Application from "@ember/application";
  57. import Resolver from "ember-resolver";
  58. import loadInitializers from "ember-load-initializers";
  59. import config from "./config/environment";
  60. import * as Sentry from "@sentry/ember";
  61. Sentry.init({
  62. ${sentryInitContent}
  63. });
  64. export default class App extends Application {
  65. modulePrefix = config.modulePrefix;
  66. podModulePrefix = config.podModulePrefix;
  67. Resolver = Resolver;
  68. }
  69. `,
  70. },
  71. ],
  72. },
  73. getUploadSourceMapsStep(
  74. 'https://docs.sentry.io/platforms/javascript/guides/ember/sourcemaps/'
  75. ),
  76. {
  77. type: StepType.VERIFY,
  78. description: t(
  79. "This snippet contains an intentional error and can be used as a test to make sure that everything's working as expected."
  80. ),
  81. configurations: [
  82. {
  83. language: 'javascript',
  84. code: `myUndefinedFunction();`,
  85. },
  86. ],
  87. },
  88. ];
  89. export const nextSteps = [
  90. {
  91. id: 'performance-monitoring',
  92. name: t('Performance Monitoring'),
  93. description: t(
  94. 'Track down transactions to connect the dots between 10-second page loads and poor-performing API calls or slow database queries.'
  95. ),
  96. link: 'https://docs.sentry.io/platforms/javascript/guides/ember/performance/',
  97. },
  98. {
  99. id: 'session-replay',
  100. name: t('Session Replay'),
  101. description: t(
  102. '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.'
  103. ),
  104. link: 'https://docs.sentry.io/platforms/javascript/guides/ember/session-replay/',
  105. },
  106. ];
  107. // Configuration End
  108. export function GettingStartedWithEmber({
  109. dsn,
  110. activeProductSelection = [],
  111. ...props
  112. }: ModuleProps) {
  113. const integrations: string[] = [];
  114. const otherConfigs: string[] = [];
  115. let nextStepDocs = [...nextSteps];
  116. if (activeProductSelection.includes(ProductSolution.PERFORMANCE_MONITORING)) {
  117. otherConfigs.push(performanceOtherConfig.trim());
  118. nextStepDocs = nextStepDocs.filter(
  119. step => step.id !== ProductSolution.PERFORMANCE_MONITORING
  120. );
  121. }
  122. if (activeProductSelection.includes(ProductSolution.SESSION_REPLAY)) {
  123. integrations.push(replayIntegration.trim());
  124. otherConfigs.push(replayOtherConfig.trim());
  125. nextStepDocs = nextStepDocs.filter(
  126. step => step.id !== ProductSolution.SESSION_REPLAY
  127. );
  128. }
  129. let sentryInitContent: string[] = [`dsn: "${dsn}",`];
  130. if (integrations.length > 0) {
  131. sentryInitContent = sentryInitContent.concat('integrations: [', integrations, '],');
  132. }
  133. if (otherConfigs.length > 0) {
  134. sentryInitContent = sentryInitContent.concat(otherConfigs);
  135. }
  136. return (
  137. <Layout
  138. steps={steps({
  139. sentryInitContent: sentryInitContent.join('\n'),
  140. })}
  141. nextSteps={nextStepDocs}
  142. {...props}
  143. />
  144. );
  145. }
  146. export default GettingStartedWithEmber;