import {useEffect} from 'react'; import styled from '@emotion/styled'; import {t} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import {trackAnalytics} from 'sentry/utils/analytics'; import {getFrameMethod, getFrameStatus} from 'sentry/utils/replays/resourceFrame'; import useOrganization from 'sentry/utils/useOrganization'; import FluidHeight from 'sentry/views/replays/detail/layout/fluidHeight'; import getOutputType, { Output, } from 'sentry/views/replays/detail/network/details/getOutputType'; import { Setup, UnsupportedOp, } from 'sentry/views/replays/detail/network/details/onboarding'; import type {SectionProps} from 'sentry/views/replays/detail/network/details/sections'; import { GeneralSection, QueryParamsSection, RequestHeadersSection, RequestPayloadSection, ResponseHeadersSection, ResponsePayloadSection, } from 'sentry/views/replays/detail/network/details/sections'; type Props = Parameters[0] & SectionProps; export default function NetworkDetailsContent(props: Props) { const {item, isSetup, visibleTab} = props; const output = getOutputType(props); const organization = useOrganization(); useEffect(() => { trackAnalytics('replay.details-network-tab-changed', { is_sdk_setup: isSetup, organization, output, resource_method: getFrameMethod(item), resource_status: String(getFrameStatus(item)), resource_type: item.op, tab: visibleTab, }); }, [isSetup, item, organization, output, visibleTab]); switch (visibleTab) { case 'request': return ( {output === Output.DATA && } {[Output.SETUP, Output.URL_SKIPPED, Output.BODY_SKIPPED].includes(output) && ( )} {output === Output.UNSUPPORTED && } ); case 'response': return ( {output === Output.DATA && ( )} {[Output.SETUP, Output.URL_SKIPPED, Output.BODY_SKIPPED].includes(output) && ( )} {output === Output.UNSUPPORTED && } {output === Output.BODY_PARSE_ERROR && ( {t('The SDK was unable to parse the response body.')} )} {output === Output.BODY_PARSE_TIMEOUT && ( {t( 'The SDK timed out while parsing response body. This is to reduce CPU usage on client browsers.' )} )} ); case 'details': default: return ( {output === Output.DATA && } {output === Output.DATA && } {[Output.SETUP, Output.URL_SKIPPED, Output.DATA].includes(output) && ( )} {output === Output.UNSUPPORTED && } ); } } const OverflowFluidHeight = styled(FluidHeight)` overflow: auto; `; const SectionList = styled('dl')` margin: 0; `; const ParseError = styled('p')` padding: ${space(2)}; `;