javascript.tsx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. import {css} from '@emotion/react';
  2. import {IntegrationOptions} from 'sentry/components/events/featureFlags/utils';
  3. import ExternalLink from 'sentry/components/links/externalLink';
  4. import crashReportCallout from 'sentry/components/onboarding/gettingStartedDoc/feedback/crashReportCallout';
  5. import widgetCallout from 'sentry/components/onboarding/gettingStartedDoc/feedback/widgetCallout';
  6. import TracePropagationMessage from 'sentry/components/onboarding/gettingStartedDoc/replay/tracePropagationMessage';
  7. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  8. import type {
  9. BasePlatformOptions,
  10. Docs,
  11. DocsParams,
  12. OnboardingConfig,
  13. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  14. import {getUploadSourceMapsStep} from 'sentry/components/onboarding/gettingStartedDoc/utils';
  15. import {
  16. getCrashReportJavaScriptInstallStep,
  17. getCrashReportModalConfigDescription,
  18. getCrashReportModalIntroduction,
  19. getFeedbackConfigOptions,
  20. getFeedbackConfigureDescription,
  21. } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  22. import {getJSMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
  23. import {
  24. getProfilingDocumentHeaderConfigurationStep,
  25. MaybeBrowserProfilingBetaWarning,
  26. } from 'sentry/components/onboarding/gettingStartedDoc/utils/profilingOnboarding';
  27. import {
  28. getReplayConfigOptions,
  29. getReplayConfigureDescription,
  30. getReplayVerifyStep,
  31. } from 'sentry/components/onboarding/gettingStartedDoc/utils/replayOnboarding';
  32. import {
  33. feedbackOnboardingJsLoader,
  34. replayOnboardingJsLoader,
  35. } from 'sentry/gettingStartedDocs/javascript/jsLoader/jsLoader';
  36. import {t, tct} from 'sentry/locale';
  37. import {space} from 'sentry/styles/space';
  38. import {trackAnalytics} from 'sentry/utils/analytics';
  39. import TextBlock from 'sentry/views/settings/components/text/textBlock';
  40. import {updateDynamicSdkLoaderOptions} from './jsLoader/updateDynamicSdkLoaderOptions';
  41. export enum InstallationMode {
  42. AUTO = 'auto',
  43. MANUAL = 'manual',
  44. }
  45. const platformOptions = {
  46. installationMode: {
  47. label: t('Installation Mode'),
  48. items: [
  49. {
  50. label: t('Loader Script'),
  51. value: InstallationMode.AUTO,
  52. },
  53. {
  54. label: t('Npm/Yarn'),
  55. value: InstallationMode.MANUAL,
  56. },
  57. ],
  58. defaultValue: InstallationMode.AUTO,
  59. },
  60. } satisfies BasePlatformOptions;
  61. type PlatformOptions = typeof platformOptions;
  62. type Params = DocsParams<PlatformOptions>;
  63. type FlagOptions = {
  64. importStatement: string; // feature flag SDK import
  65. integration: string; // what's in the integrations array
  66. sdkInit: string; // code to register with feature flag SDK
  67. };
  68. const FLAG_OPTIONS: Record<IntegrationOptions, FlagOptions> = {
  69. [IntegrationOptions.LAUNCHDARKLY]: {
  70. importStatement: `import * as LaunchDarkly from 'launchdarkly-js-client-sdk';`,
  71. integration: 'launchDarklyIntegration()',
  72. sdkInit: `const ldClient = LaunchDarkly.initialize(
  73. 'my-client-ID',
  74. {kind: 'user', key: 'my-user-context-key'},
  75. {inspectors: [Sentry.buildLaunchDarklyFlagUsedHandler()]}
  76. );
  77. // Evaluates a flag
  78. const flagVal = ldClient.variation('my-flag', false);`,
  79. },
  80. [IntegrationOptions.OPENFEATURE]: {
  81. importStatement: `import { OpenFeature } from '@openfeature/web-sdk';`,
  82. integration: 'openFeatureIntegration()',
  83. sdkInit: `const client = OpenFeature.getClient();
  84. client.addHooks(new Sentry.OpenFeatureIntegrationHook());
  85. // Evaluating flags will record the result on the Sentry client.
  86. const result = client.getBooleanValue('my-flag', false);`,
  87. },
  88. [IntegrationOptions.GENERIC]: {
  89. importStatement: ``,
  90. integration: 'featureFlagsIntegration()',
  91. sdkInit: `const flagsIntegration = Sentry.getClient()?.getIntegrationByName<Sentry.FeatureFlagsIntegration>('FeatureFlags');
  92. if (flagsIntegration) {
  93. flagsIntegration.addFeatureFlag('test-flag', false);
  94. } else {
  95. // Something went wrong, check your DSN and/or integrations
  96. }
  97. Sentry.captureException(new Error('Something went wrong!'));`,
  98. },
  99. };
  100. const isAutoInstall = (params: Params) =>
  101. params.platformOptions.installationMode === InstallationMode.AUTO;
  102. const getSdkSetupSnippet = (params: Params) => `
  103. import * as Sentry from "@sentry/browser";
  104. Sentry.init({
  105. dsn: "${params.dsn.public}",
  106. integrations: [${
  107. params.isPerformanceSelected
  108. ? `
  109. Sentry.browserTracingIntegration(),`
  110. : ''
  111. }${
  112. params.isProfilingSelected
  113. ? `
  114. Sentry.browserProfilingIntegration(),`
  115. : ''
  116. }${
  117. params.isFeedbackSelected
  118. ? `
  119. Sentry.feedbackIntegration({
  120. // Additional SDK configuration goes in here, for example:
  121. colorScheme: "system",
  122. ${getFeedbackConfigOptions(params.feedbackOptions)}}),`
  123. : ''
  124. }${
  125. params.isReplaySelected
  126. ? `
  127. Sentry.replayIntegration(${getReplayConfigOptions(params.replayOptions)}),`
  128. : ''
  129. }
  130. ],${
  131. params.isPerformanceSelected
  132. ? `
  133. // Tracing
  134. tracesSampleRate: 1.0, // Capture 100% of the transactions
  135. // Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
  136. tracePropagationTargets: ["localhost", /^https:\\/\\/yourserver\\.io\\/api/],`
  137. : ''
  138. }${
  139. params.isReplaySelected
  140. ? `
  141. // Session Replay
  142. 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.
  143. replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.`
  144. : ''
  145. }${
  146. params.isProfilingSelected
  147. ? `
  148. // Set profilesSampleRate to 1.0 to profile every transaction.
  149. // Since profilesSampleRate is relative to tracesSampleRate,
  150. // the final profiling rate can be computed as tracesSampleRate * profilesSampleRate
  151. // For example, a tracesSampleRate of 0.5 and profilesSampleRate of 0.5 would
  152. // results in 25% of transactions being profiled (0.5*0.5=0.25)
  153. profilesSampleRate: 1.0,`
  154. : ''
  155. }
  156. });
  157. `;
  158. const getVerifyJSSnippet = () => `
  159. myUndefinedFunction();`;
  160. const getInstallConfig = () => [
  161. {
  162. language: 'bash',
  163. code: [
  164. {
  165. label: 'npm',
  166. value: 'npm',
  167. language: 'bash',
  168. code: 'npm install --save @sentry/browser',
  169. },
  170. {
  171. label: 'yarn',
  172. value: 'yarn',
  173. language: 'bash',
  174. code: 'yarn add @sentry/browser',
  175. },
  176. ],
  177. },
  178. ];
  179. const getVerifyConfig = () => [
  180. {
  181. type: StepType.VERIFY,
  182. description: t(
  183. "This snippet contains an intentional error and can be used as a test to make sure that everything's working as expected."
  184. ),
  185. configurations: [
  186. {
  187. code: [
  188. {
  189. label: 'Javascript',
  190. value: 'javascript',
  191. language: 'javascript',
  192. code: getVerifyJSSnippet(),
  193. },
  194. ],
  195. },
  196. ],
  197. },
  198. ];
  199. const loaderScriptOnboarding: OnboardingConfig<PlatformOptions> = {
  200. introduction: () =>
  201. tct('In this quick guide you’ll use our [strong: Loader Script] to set up:', {
  202. strong: <strong />,
  203. }),
  204. install: params => [
  205. {
  206. type: StepType.INSTALL,
  207. description: t('Add this script tag to the top of the page:'),
  208. configurations: [
  209. {
  210. language: 'html',
  211. code: [
  212. {
  213. label: 'HTML',
  214. value: 'html',
  215. language: 'html',
  216. code: `
  217. <script
  218. src="${params.dsn.cdn}"
  219. crossorigin="anonymous"
  220. ></script>`,
  221. },
  222. ],
  223. },
  224. ],
  225. },
  226. ],
  227. configure: params => [
  228. {
  229. title: t('Configure SDK (Optional)'),
  230. description: t(
  231. "Initialize Sentry as early as possible in your application's lifecycle."
  232. ),
  233. collapsible: true,
  234. configurations: [
  235. {
  236. language: 'html',
  237. code: [
  238. {
  239. label: 'HTML',
  240. value: 'html',
  241. language: 'html',
  242. code: `
  243. <script>
  244. Sentry.onLoad(function() {
  245. Sentry.init({${
  246. !(params.isPerformanceSelected || params.isReplaySelected)
  247. ? `
  248. // You can add any additional configuration here`
  249. : ''
  250. }${
  251. params.isPerformanceSelected
  252. ? `
  253. // Tracing
  254. tracesSampleRate: 1.0, // Capture 100% of the transactions`
  255. : ''
  256. }${
  257. params.isReplaySelected
  258. ? `
  259. // Session Replay
  260. 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.
  261. replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.`
  262. : ''
  263. }
  264. });
  265. });
  266. </script>`,
  267. },
  268. ],
  269. },
  270. ],
  271. onOptionalToggleClick: showOptionalConfig => {
  272. if (showOptionalConfig) {
  273. trackAnalytics('onboarding.js_loader_npm_docs_optional_shown', {
  274. organization: params.organization,
  275. platform: params.platformKey,
  276. project_id: params.projectId,
  277. });
  278. }
  279. },
  280. },
  281. ],
  282. verify: getVerifyConfig,
  283. nextSteps: () => [
  284. {
  285. id: 'source-maps',
  286. name: t('Source Maps'),
  287. description: t('Learn how to enable readable stack traces in your Sentry errors.'),
  288. link: 'https://docs.sentry.io/platforms/javascript/sourcemaps/',
  289. },
  290. ],
  291. onPageLoad: params => {
  292. return () => {
  293. trackAnalytics('onboarding.setup_loader_docs_rendered', {
  294. organization: params.organization,
  295. platform: params.platformKey,
  296. project_id: params.projectId,
  297. });
  298. };
  299. },
  300. onPlatformOptionsChange: params => {
  301. return () => {
  302. trackAnalytics('onboarding.js_loader_npm_docs_shown', {
  303. organization: params.organization,
  304. platform: params.platformKey,
  305. project_id: params.projectId,
  306. });
  307. };
  308. },
  309. onProductSelectionChange: params => {
  310. return products => {
  311. updateDynamicSdkLoaderOptions({
  312. orgSlug: params.organization.slug,
  313. projectSlug: params.projectSlug,
  314. products,
  315. projectKey: params.projectKeyId,
  316. api: params.api,
  317. });
  318. };
  319. },
  320. onProductSelectionLoad: params => {
  321. return products => {
  322. updateDynamicSdkLoaderOptions({
  323. orgSlug: params.organization.slug,
  324. projectSlug: params.projectSlug,
  325. products,
  326. projectKey: params.projectKeyId,
  327. api: params.api,
  328. });
  329. };
  330. },
  331. };
  332. const packageManagerOnboarding: OnboardingConfig<PlatformOptions> = {
  333. introduction: () =>
  334. tct('In this quick guide you’ll use [strong:npm] or [strong:yarn] to set up:', {
  335. strong: <strong />,
  336. }),
  337. install: () => [
  338. {
  339. type: StepType.INSTALL,
  340. description: t(
  341. 'Sentry captures data by using an SDK within your application’s runtime.'
  342. ),
  343. configurations: getInstallConfig(),
  344. },
  345. ],
  346. configure: params => [
  347. {
  348. type: StepType.CONFIGURE,
  349. description: t(
  350. "Initialize Sentry as early as possible in your application's lifecycle."
  351. ),
  352. configurations: [
  353. {
  354. code: [
  355. {
  356. label: 'JavaScript',
  357. value: 'javascript',
  358. language: 'javascript',
  359. code: getSdkSetupSnippet(params),
  360. },
  361. ],
  362. },
  363. ...(params.isProfilingSelected
  364. ? [getProfilingDocumentHeaderConfigurationStep()]
  365. : []),
  366. ],
  367. },
  368. getUploadSourceMapsStep({
  369. guideLink: 'https://docs.sentry.io/platforms/javascript/sourcemaps/',
  370. ...params,
  371. }),
  372. ],
  373. verify: getVerifyConfig,
  374. nextSteps: () => [],
  375. onPageLoad: params => {
  376. return () => {
  377. trackAnalytics('onboarding.js_loader_npm_docs_shown', {
  378. organization: params.organization,
  379. platform: params.platformKey,
  380. project_id: params.projectId,
  381. });
  382. };
  383. },
  384. onPlatformOptionsChange: params => {
  385. return () => {
  386. trackAnalytics('onboarding.setup_loader_docs_rendered', {
  387. organization: params.organization,
  388. platform: params.platformKey,
  389. project_id: params.projectId,
  390. });
  391. };
  392. },
  393. };
  394. const onboarding: OnboardingConfig<PlatformOptions> = {
  395. introduction: params => (
  396. <div
  397. css={css`
  398. display: flex;
  399. flex-direction: column;
  400. gap: ${space(1)};
  401. `}
  402. >
  403. <MaybeBrowserProfilingBetaWarning {...params} />
  404. <TextBlock noMargin>
  405. {isAutoInstall(params)
  406. ? loaderScriptOnboarding.introduction?.(params)
  407. : packageManagerOnboarding.introduction?.(params)}
  408. </TextBlock>
  409. </div>
  410. ),
  411. install: params =>
  412. isAutoInstall(params)
  413. ? loaderScriptOnboarding.install(params)
  414. : packageManagerOnboarding.install(params),
  415. configure: (params: Params) =>
  416. isAutoInstall(params)
  417. ? loaderScriptOnboarding.configure(params)
  418. : packageManagerOnboarding.configure(params),
  419. verify: params =>
  420. isAutoInstall(params)
  421. ? loaderScriptOnboarding.verify(params)
  422. : packageManagerOnboarding.verify(params),
  423. nextSteps: params =>
  424. isAutoInstall(params)
  425. ? loaderScriptOnboarding.nextSteps?.(params)
  426. : packageManagerOnboarding.nextSteps?.(params),
  427. onPageLoad: params =>
  428. isAutoInstall(params)
  429. ? loaderScriptOnboarding.onPageLoad?.(params)
  430. : packageManagerOnboarding.onPageLoad?.(params),
  431. onProductSelectionChange: params =>
  432. isAutoInstall(params)
  433. ? loaderScriptOnboarding.onProductSelectionChange?.(params)
  434. : packageManagerOnboarding.onProductSelectionChange?.(params),
  435. onPlatformOptionsChange: params =>
  436. isAutoInstall(params)
  437. ? loaderScriptOnboarding.onPlatformOptionsChange?.(params)
  438. : packageManagerOnboarding.onPlatformOptionsChange?.(params),
  439. onProductSelectionLoad: params =>
  440. isAutoInstall(params)
  441. ? loaderScriptOnboarding.onProductSelectionLoad?.(params)
  442. : packageManagerOnboarding.onProductSelectionLoad?.(params),
  443. };
  444. const replayOnboarding: OnboardingConfig<PlatformOptions> = {
  445. install: () => [
  446. {
  447. type: StepType.INSTALL,
  448. description: tct(
  449. 'For the Session Replay to work, you must have the Sentry browser SDK package, or an equivalent framework SDK (e.g. [code:@sentry/react]) installed, minimum version 7.27.0.',
  450. {
  451. code: <code />,
  452. }
  453. ),
  454. configurations: getInstallConfig(),
  455. },
  456. ],
  457. configure: (params: Params) => [
  458. {
  459. type: StepType.CONFIGURE,
  460. description: getReplayConfigureDescription({
  461. link: 'https://docs.sentry.io/platforms/javascript/session-replay/',
  462. }),
  463. configurations: [
  464. {
  465. code: [
  466. {
  467. label: 'JavaScript',
  468. value: 'javascript',
  469. language: 'javascript',
  470. code: getSdkSetupSnippet(params),
  471. },
  472. ],
  473. },
  474. ],
  475. additionalInfo: <TracePropagationMessage />,
  476. },
  477. ],
  478. verify: getReplayVerifyStep(),
  479. nextSteps: () => [],
  480. };
  481. const feedbackOnboarding: OnboardingConfig<PlatformOptions> = {
  482. install: () => [
  483. {
  484. type: StepType.INSTALL,
  485. description: tct(
  486. 'For the User Feedback integration to work, you must have the Sentry browser SDK package, or an equivalent framework SDK (e.g. [code:@sentry/react]) installed, minimum version 7.85.0.',
  487. {
  488. code: <code />,
  489. }
  490. ),
  491. configurations: getInstallConfig(),
  492. },
  493. ],
  494. configure: (params: Params) => [
  495. {
  496. type: StepType.CONFIGURE,
  497. description: getFeedbackConfigureDescription({
  498. linkConfig:
  499. 'https://docs.sentry.io/platforms/javascript/user-feedback/configuration/',
  500. linkButton:
  501. 'https://docs.sentry.io/platforms/javascript/user-feedback/configuration/#bring-your-own-button',
  502. }),
  503. configurations: [
  504. {
  505. code: [
  506. {
  507. label: 'JavaScript',
  508. value: 'javascript',
  509. language: 'javascript',
  510. code: getSdkSetupSnippet(params),
  511. },
  512. ],
  513. },
  514. ],
  515. additionalInfo: crashReportCallout({
  516. link: 'https://docs.sentry.io/platforms/javascript/user-feedback/#crash-report-modal',
  517. }),
  518. },
  519. ],
  520. verify: () => [],
  521. nextSteps: () => [],
  522. };
  523. const crashReportOnboarding: OnboardingConfig<PlatformOptions> = {
  524. introduction: () => getCrashReportModalIntroduction(),
  525. install: (params: Params) => getCrashReportJavaScriptInstallStep(params),
  526. configure: () => [
  527. {
  528. type: StepType.CONFIGURE,
  529. description: getCrashReportModalConfigDescription({
  530. link: 'https://docs.sentry.io/platforms/javascript/user-feedback/configuration/#crash-report-modal',
  531. }),
  532. additionalInfo: widgetCallout({
  533. link: 'https://docs.sentry.io/platforms/javascript/user-feedback/#user-feedback-widget',
  534. }),
  535. },
  536. ],
  537. verify: () => [],
  538. nextSteps: () => [],
  539. };
  540. const performanceOnboarding: OnboardingConfig<PlatformOptions> = {
  541. introduction: () =>
  542. t(
  543. "Adding Performance to your Browser JavaScript project is simple. Make sure you've got these basics down."
  544. ),
  545. install: () => [
  546. {
  547. type: StepType.INSTALL,
  548. description: tct(
  549. 'Install our JavaScript browser SDK using either [code:yarn] or [code:npm]:',
  550. {code: <code />}
  551. ),
  552. configurations: getInstallConfig(),
  553. },
  554. ],
  555. configure: params => [
  556. {
  557. type: StepType.CONFIGURE,
  558. description: t(
  559. "Configuration should happen as early as possible in your application's lifecycle."
  560. ),
  561. configurations: [
  562. {
  563. language: 'javascript',
  564. code: `
  565. import * as Sentry from "@sentry/browser";
  566. Sentry.init({
  567. dsn: "${params.dsn.public}",
  568. integrations: [Sentry.browserTracingIntegration()],
  569. // Set tracesSampleRate to 1.0 to capture 100%
  570. // of transactions for performance monitoring.
  571. // We recommend adjusting this value in production
  572. tracesSampleRate: 1.0,
  573. // Set \`tracePropagationTargets\` to control for which URLs distributed tracing should be enabled
  574. tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
  575. });
  576. `,
  577. additionalInfo: tct(
  578. 'We recommend adjusting the value of [code:tracesSampleRate] in production. Learn more about tracing [linkTracingOptions:options], how to use the [linkTracesSampler:traces_sampler] function, or how to [linkSampleTransactions:sample transactions].',
  579. {
  580. code: <code />,
  581. linkTracingOptions: (
  582. <ExternalLink href="https://docs.sentry.io/platforms/javascript/configuration/options/#tracing-options" />
  583. ),
  584. linkTracesSampler: (
  585. <ExternalLink href="https://docs.sentry.io/platforms/javascript/configuration/sampling/" />
  586. ),
  587. linkSampleTransactions: (
  588. <ExternalLink href="https://docs.sentry.io/platforms/javascript/configuration/sampling/" />
  589. ),
  590. }
  591. ),
  592. },
  593. ],
  594. },
  595. ],
  596. verify: () => [
  597. {
  598. type: StepType.VERIFY,
  599. description: tct(
  600. 'Verify that performance monitoring is working correctly with our [link:automatic instrumentation] by simply using your JavaScript application.',
  601. {
  602. link: (
  603. <ExternalLink href="https://docs.sentry.io/platforms/javascript/tracing/instrumentation/automatic-instrumentation/" />
  604. ),
  605. }
  606. ),
  607. configurations: [
  608. {
  609. description: tct(
  610. 'You have the option to manually construct a transaction using [link:custom instrumentation].',
  611. {
  612. link: (
  613. <ExternalLink href="https://docs.sentry.io/platforms/javascript/tracing/instrumentation/custom-instrumentation/" />
  614. ),
  615. }
  616. ),
  617. language: 'javascript',
  618. code: `
  619. const transaction = Sentry.startTransaction({ name: "test-transaction" });
  620. const span = transaction.startChild({ op: "functionX" }); // This function returns a Span
  621. // exampleFunctionCall();
  622. span.finish(); // Remember that only finished spans will be sent with the transaction
  623. transaction.finish(); // Finishing the transaction will send it to Sentry`,
  624. },
  625. ],
  626. },
  627. ],
  628. nextSteps: () => [],
  629. };
  630. const profilingOnboarding: OnboardingConfig<PlatformOptions> = {
  631. ...onboarding,
  632. introduction: params => <MaybeBrowserProfilingBetaWarning {...params} />,
  633. };
  634. export const featureFlagOnboarding: OnboardingConfig = {
  635. install: () => [],
  636. configure: ({featureFlagOptions = {integration: ''}, dsn}) => [
  637. {
  638. type: StepType.CONFIGURE,
  639. description: tct(
  640. 'Add [name] to your integrations list, and then register with your feature flag SDK.',
  641. {
  642. name: (
  643. <code>{`${FLAG_OPTIONS[featureFlagOptions.integration].integration}`}</code>
  644. ),
  645. }
  646. ),
  647. configurations: [
  648. {
  649. language: 'JavaScript',
  650. code: `
  651. ${FLAG_OPTIONS[featureFlagOptions.integration].importStatement}
  652. // Register with Sentry
  653. Sentry.init({
  654. dsn: "${dsn.public}",
  655. integrations: [
  656. Sentry.${FLAG_OPTIONS[featureFlagOptions.integration].integration},
  657. ],
  658. });
  659. // Register with your feature flag SDK
  660. ${FLAG_OPTIONS[featureFlagOptions.integration].sdkInit}
  661. `,
  662. },
  663. ],
  664. },
  665. ],
  666. verify: () => [],
  667. nextSteps: () => [],
  668. };
  669. const docs: Docs<PlatformOptions> = {
  670. onboarding,
  671. feedbackOnboardingNpm: feedbackOnboarding,
  672. feedbackOnboardingJsLoader,
  673. replayOnboarding,
  674. replayOnboardingJsLoader,
  675. performanceOnboarding,
  676. customMetricsOnboarding: getJSMetricsOnboarding({getInstallConfig}),
  677. crashReportOnboarding,
  678. platformOptions,
  679. profilingOnboarding,
  680. featureFlagOnboarding,
  681. };
  682. export default docs;