onboarding.tsx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import styled from '@emotion/styled';
  2. import {CodeSnippet} from 'sentry/components/codeSnippet';
  3. import ExternalLink from 'sentry/components/links/externalLink';
  4. import List from 'sentry/components/list';
  5. import ListItem from 'sentry/components/list/listItem';
  6. import {Panel, PanelBody, PanelHeader} from 'sentry/components/panels';
  7. import {t, tct} from 'sentry/locale';
  8. import space from 'sentry/styles/space';
  9. import {Monitor} from './types';
  10. type Props = {
  11. monitor: Monitor;
  12. };
  13. const MonitorOnboarding = ({monitor}: Props) => {
  14. const checkInUrl = `https://sentry.io/api/0/monitors/${monitor.id}/checkins/`;
  15. return (
  16. <Panel>
  17. <PanelHeader>{t('How to instrument monitors')}</PanelHeader>
  18. <PanelBody withPadding>
  19. <List symbol="bullet">
  20. <StyledListItem>
  21. <OnboardingText>
  22. {tct(
  23. 'To report on the status of a job make POST requests using [linkDocs:DSN authentication]',
  24. {
  25. linkDocs: (
  26. <ExternalLink href="https://docs.sentry.io/api/auth/#dsn-authentication" />
  27. ),
  28. }
  29. )}
  30. </OnboardingText>
  31. <CodeSnippet language="text" hideActionBar>
  32. {`POST ${checkInUrl}`}
  33. </CodeSnippet>
  34. </StyledListItem>
  35. <StyledListItem>
  36. <OnboardingText>
  37. {t(
  38. 'Supply one of the following JSON bodies to the POST request depending on the job status to be reported'
  39. )}
  40. </OnboardingText>
  41. <OnboardingText>
  42. {t('For the start of a job')}
  43. <CodeSnippet language="json" hideActionBar>
  44. {`{ "status": "in_progress" }`}
  45. </CodeSnippet>
  46. </OnboardingText>
  47. <OnboardingText>
  48. {t('For job completion with optional duration in milliseconds')}
  49. <CodeSnippet language="json" hideActionBar>
  50. {`{ "status": "ok", "duration": 3000 }`}
  51. </CodeSnippet>
  52. </OnboardingText>
  53. <OnboardingText>
  54. {t('For a job failure with optional duration in milliseconds')}
  55. <CodeSnippet language="json" hideActionBar>
  56. {`{ "status": "error", "duration": 3000 }`}
  57. </CodeSnippet>
  58. </OnboardingText>
  59. </StyledListItem>
  60. </List>
  61. </PanelBody>
  62. </Panel>
  63. );
  64. };
  65. const OnboardingText = styled('p')`
  66. font-size: ${p => p.theme.fontSizeLarge};
  67. `;
  68. const StyledListItem = styled(ListItem)`
  69. margin-bottom: ${space(2)};
  70. `;
  71. export default MonitorOnboarding;