platformSelection.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import {useContext} from 'react';
  2. import styled from '@emotion/styled';
  3. import {motion} from 'framer-motion';
  4. import omit from 'lodash/omit';
  5. import {OnboardingContext} from 'sentry/components/onboarding/onboardingContext';
  6. import PlatformPicker from 'sentry/components/platformPicker';
  7. import platforms from 'sentry/data/platforms';
  8. import {t} from 'sentry/locale';
  9. import testableTransition from 'sentry/utils/testableTransition';
  10. import useOrganization from 'sentry/utils/useOrganization';
  11. import StepHeading from 'sentry/views/onboarding/components/stepHeading';
  12. import {CreateProjectsFooter} from './components/createProjectsFooter';
  13. import type {StepProps} from './types';
  14. export function PlatformSelection(props: StepProps) {
  15. const organization = useOrganization();
  16. const onboardingContext = useContext(OnboardingContext);
  17. const selectedPlatform = onboardingContext.data.selectedSDK
  18. ? platforms.find(platform => platform.id === onboardingContext.data.selectedSDK?.key)
  19. ? onboardingContext.data.selectedSDK
  20. : undefined
  21. : undefined;
  22. return (
  23. <Wrapper>
  24. <StepHeading step={props.stepIndex}>
  25. {t('Select the platform you want to monitor')}
  26. </StepHeading>
  27. <motion.div
  28. transition={testableTransition()}
  29. variants={{
  30. initial: {y: 30, opacity: 0},
  31. animate: {y: 0, opacity: 1},
  32. exit: {opacity: 0},
  33. }}
  34. >
  35. <p>
  36. {t(
  37. 'Set up a separate project for each part of your application (for example, your API server and frontend client), to quickly pinpoint which part of your application errors are coming from.'
  38. )}
  39. </p>
  40. <PlatformPicker
  41. noAutoFilter
  42. source="targeted-onboarding"
  43. platform={onboardingContext.data.selectedSDK?.key}
  44. defaultCategory={onboardingContext.data.selectedSDK?.category}
  45. setPlatform={platform => {
  46. onboardingContext.setData({
  47. ...onboardingContext.data,
  48. selectedSDK: platform
  49. ? {...omit(platform, 'id'), key: platform.id}
  50. : undefined,
  51. });
  52. }}
  53. organization={organization}
  54. />
  55. </motion.div>
  56. <CreateProjectsFooter
  57. {...props}
  58. organization={organization}
  59. clearPlatform={() => {
  60. onboardingContext.setData({...onboardingContext.data, selectedSDK: undefined});
  61. }}
  62. selectedPlatform={selectedPlatform}
  63. />
  64. </Wrapper>
  65. );
  66. }
  67. const Wrapper = styled('div')`
  68. max-width: 850px;
  69. margin-left: auto;
  70. margin-right: auto;
  71. width: 100%;
  72. `;