ember.tsx 5.2 KB

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