ember.tsx 5.1 KB

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