ember.tsx 5.2 KB

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