content.tsx 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import {useEffect} from 'react';
  2. import styled from '@emotion/styled';
  3. import {trackAnalytics} from 'sentry/utils/analytics';
  4. import useOrganization from 'sentry/utils/useOrganization';
  5. import FluidHeight from 'sentry/views/replays/detail/layout/fluidHeight';
  6. import getOutputType, {
  7. Output,
  8. } from 'sentry/views/replays/detail/network/details/getOutputType';
  9. import {
  10. Setup,
  11. UnsupportedOp,
  12. } from 'sentry/views/replays/detail/network/details/onboarding';
  13. import type {SectionProps} from 'sentry/views/replays/detail/network/details/sections';
  14. import {
  15. GeneralSection,
  16. QueryParamsSection,
  17. RequestHeadersSection,
  18. RequestPayloadSection,
  19. ResponseHeadersSection,
  20. ResponsePayloadSection,
  21. } from 'sentry/views/replays/detail/network/details/sections';
  22. type Props = Parameters<typeof getOutputType>[0] & SectionProps;
  23. export default function NetworkDetailsContent(props: Props) {
  24. const {item, isSetup, visibleTab} = props;
  25. const output = getOutputType(props);
  26. const organization = useOrganization();
  27. useEffect(() => {
  28. trackAnalytics('replay.details-network-tab-changed', {
  29. is_sdk_setup: isSetup,
  30. organization,
  31. output,
  32. resource_method: item.data.method,
  33. resource_status: item.data.statusCode,
  34. resource_type: item.op,
  35. tab: visibleTab,
  36. });
  37. }, [isSetup, item, organization, output, visibleTab]);
  38. switch (visibleTab) {
  39. case 'request':
  40. return (
  41. <OverflowFluidHeight>
  42. <SectionList>
  43. <QueryParamsSection {...props} />
  44. {output === Output.DATA && <RequestPayloadSection {...props} />}
  45. </SectionList>
  46. {[Output.SETUP, Output.URL_SKIPPED, Output.BODY_SKIPPED].includes(output) && (
  47. <Setup showSnippet={output} {...props} />
  48. )}
  49. {output === Output.UNSUPPORTED && <UnsupportedOp type="bodies" />}
  50. </OverflowFluidHeight>
  51. );
  52. case 'response':
  53. return (
  54. <OverflowFluidHeight>
  55. {output === Output.DATA && (
  56. <SectionList>
  57. <ResponsePayloadSection {...props} />
  58. </SectionList>
  59. )}
  60. {[Output.SETUP, Output.URL_SKIPPED, Output.BODY_SKIPPED].includes(output) && (
  61. <Setup showSnippet={output} {...props} />
  62. )}
  63. {output === Output.UNSUPPORTED && <UnsupportedOp type="bodies" />}
  64. </OverflowFluidHeight>
  65. );
  66. case 'details':
  67. default:
  68. return (
  69. <OverflowFluidHeight>
  70. <SectionList>
  71. <GeneralSection {...props} />
  72. {output === Output.DATA && <RequestHeadersSection {...props} />}
  73. {output === Output.DATA && <ResponseHeadersSection {...props} />}
  74. </SectionList>
  75. {[Output.SETUP, Output.URL_SKIPPED, Output.DATA].includes(output) && (
  76. <Setup showSnippet={output} {...props} />
  77. )}
  78. {output === Output.UNSUPPORTED && <UnsupportedOp type="headers" />}
  79. </OverflowFluidHeight>
  80. );
  81. }
  82. }
  83. const OverflowFluidHeight = styled(FluidHeight)`
  84. overflow: auto;
  85. `;
  86. const SectionList = styled('dl')`
  87. margin: 0;
  88. `;