ember.tsx 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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: tct(
  43. 'You should [code:init] the Sentry SDK as soon as possible during your application load up in [code:app.js], before initializing Ember:',
  44. {
  45. code: <code />,
  46. }
  47. ),
  48. configurations: [
  49. {
  50. language: 'javascript',
  51. code: `
  52. import Application from "@ember/application";
  53. import Resolver from "ember-resolver";
  54. import loadInitializers from "ember-load-initializers";
  55. import config from "./config/environment";
  56. import * as Sentry from "@sentry/ember";
  57. Sentry.init({
  58. ${sentryInitContent}
  59. });
  60. export default class App extends Application {
  61. modulePrefix = config.modulePrefix;
  62. podModulePrefix = config.podModulePrefix;
  63. Resolver = Resolver;
  64. }
  65. `,
  66. },
  67. ],
  68. },
  69. getUploadSourceMapsStep(
  70. 'https://docs.sentry.io/platforms/javascript/guides/ember/sourcemaps/'
  71. ),
  72. {
  73. type: StepType.VERIFY,
  74. description: t(
  75. "This snippet contains an intentional error and can be used as a test to make sure that everything's working as expected."
  76. ),
  77. configurations: [
  78. {
  79. language: 'javascript',
  80. code: `myUndefinedFunction();`,
  81. },
  82. ],
  83. },
  84. ];
  85. export const nextSteps = [
  86. {
  87. id: 'performance-monitoring',
  88. name: t('Performance Monitoring'),
  89. description: t(
  90. 'Track down transactions to connect the dots between 10-second page loads and poor-performing API calls or slow database queries.'
  91. ),
  92. link: 'https://docs.sentry.io/platforms/javascript/guides/ember/performance/',
  93. },
  94. {
  95. id: 'session-replay',
  96. name: t('Session Replay'),
  97. description: t(
  98. '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.'
  99. ),
  100. link: 'https://docs.sentry.io/platforms/javascript/guides/ember/session-replay/',
  101. },
  102. ];
  103. // Configuration End
  104. export function GettingStartedWithEmber({
  105. dsn,
  106. activeProductSelection = [],
  107. ...props
  108. }: ModuleProps) {
  109. const integrations: string[] = [];
  110. const otherConfigs: string[] = [];
  111. let nextStepDocs = [...nextSteps];
  112. if (activeProductSelection.includes(ProductSolution.PERFORMANCE_MONITORING)) {
  113. otherConfigs.push(performanceOtherConfig.trim());
  114. nextStepDocs = nextStepDocs.filter(
  115. step => step.id !== ProductSolution.PERFORMANCE_MONITORING
  116. );
  117. }
  118. if (activeProductSelection.includes(ProductSolution.SESSION_REPLAY)) {
  119. integrations.push(replayIntegration.trim());
  120. otherConfigs.push(replayOtherConfig.trim());
  121. nextStepDocs = nextStepDocs.filter(
  122. step => step.id !== ProductSolution.SESSION_REPLAY
  123. );
  124. }
  125. let sentryInitContent: string[] = [`dsn: "${dsn}",`];
  126. if (integrations.length > 0) {
  127. sentryInitContent = sentryInitContent.concat('integrations: [', integrations, '],');
  128. }
  129. if (otherConfigs.length > 0) {
  130. sentryInitContent = sentryInitContent.concat(otherConfigs);
  131. }
  132. return (
  133. <Layout
  134. steps={steps({
  135. sentryInitContent: sentryInitContent.join('\n'),
  136. })}
  137. nextSteps={nextStepDocs}
  138. {...props}
  139. />
  140. );
  141. }
  142. export default GettingStartedWithEmber;