import DateTime from 'sentry/components/dateTime'; import Duration from 'sentry/components/duration'; import GridEditable, {GridColumnHeader} from 'sentry/components/gridEditable'; import Link from 'sentry/components/links/link'; import EventView from 'sentry/utils/discover/eventView'; import { DiscoverQueryProps, useGenericDiscoverQuery, } from 'sentry/utils/discover/genericDiscoverQuery'; import {useLocation} from 'sentry/utils/useLocation'; import useOrganization from 'sentry/utils/useOrganization'; import {TextAlignLeft} from 'sentry/views/starfish/modules/APIModule/endpointTable'; type Props = { eventView: EventView; }; type DataRow = { id: string; profile_id: string; timestamp: string; 'transaction.duration': number; }; type Keys = 'id' | 'profile_id' | 'transaction.duration' | 'timestamp'; type TableColumnHeader = GridColumnHeader; const COLUMN_ORDER: TableColumnHeader[] = [ { key: 'id', name: 'Event ID', width: 300, }, { key: 'profile_id', name: 'Profile ID', width: 300, }, { key: 'transaction.duration', name: 'Duration', width: -1, }, { key: 'timestamp', name: 'Timestamp', width: -1, }, ]; export function SampleEvents({eventView}: Props) { const location = useLocation(); const organization = useOrganization(); const sampleEventsEventView = eventView .clone() .withColumns([ { field: 'transaction.duration', kind: 'field', }, { field: 'profile_id', kind: 'field', }, { field: 'timestamp', kind: 'field', }, ]) .withSorts([ { field: 'transaction.duration', kind: 'desc', }, ]); function renderBodyCell(column: TableColumnHeader, row: DataRow): React.ReactNode { if (column.key === 'id') { return ( {row.id.slice(0, 8)} ); } if (column.key === 'profile_id') { return row.profile_id ? ( {row.profile_id.slice(0, 8)} ) : ( '(no value)' ); } if (column.key === 'timestamp') { return ; } if (column.key === 'transaction.duration') { return ( ); } return {row[column.key]}; } const {isLoading, data} = useGenericDiscoverQuery({ route: 'events', eventView: sampleEventsEventView, referrer: 'starfish-transaction-summary-sample-events', limit: 5, location, orgSlug: organization.slug, getRequestPayload: () => ({ ...sampleEventsEventView.getEventsAPIPayload(location), }), }); return ( ); }