jsLoader.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import styled from '@emotion/styled';
  2. import beautify from 'js-beautify';
  3. import Alert from 'sentry/components/alert';
  4. import ExternalLink from 'sentry/components/links/externalLink';
  5. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  6. import {
  7. DocsParams,
  8. OnboardingConfig,
  9. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  10. import {
  11. getReplayConfigureDescription,
  12. getReplayJsLoaderSdkSetupSnippet,
  13. } from 'sentry/components/onboarding/gettingStartedDoc/utils';
  14. import {t, tct} from 'sentry/locale';
  15. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  16. type Params = DocsParams;
  17. const getInstallConfig = (params: Params) => [
  18. {
  19. type: StepType.INSTALL,
  20. configurations: [
  21. {
  22. description: t('Add this script tag to the top of the page:'),
  23. language: 'html',
  24. code: beautify.html(
  25. `<script src="${params.cdn}" crossorigin="anonymous"></script>`,
  26. {indent_size: 2, wrap_attributes: 'force-expand-multiline'}
  27. ),
  28. additionalInfo: (
  29. <StyledAlert type="info" showIcon>
  30. {tct(
  31. 'Make sure that Session Replay is enabled in your [link:project settings].',
  32. {
  33. link: (
  34. <ExternalLink
  35. href={normalizeUrl(
  36. `/settings/projects/${params.projectSlug}/loader-script/`
  37. )}
  38. />
  39. ),
  40. }
  41. )}
  42. </StyledAlert>
  43. ),
  44. },
  45. ],
  46. },
  47. ];
  48. const replayOnboardingJsLoader: OnboardingConfig = {
  49. install: (params: Params) => getInstallConfig(params),
  50. configure: () => [
  51. {
  52. type: StepType.CONFIGURE,
  53. description: getReplayConfigureDescription({
  54. link: 'https://docs.sentry.io/platforms/javascript/session-replay/',
  55. }),
  56. configurations: [
  57. {
  58. language: 'html',
  59. code: getReplayJsLoaderSdkSetupSnippet(),
  60. },
  61. ],
  62. isOptional: true,
  63. },
  64. ],
  65. verify: () => [],
  66. nextSteps: () => [],
  67. };
  68. const StyledAlert = styled(Alert)`
  69. margin: 0;
  70. `;
  71. export default replayOnboardingJsLoader;