import {Fragment} from 'react'; import {Link} from 'react-router'; import * as qs from 'query-string'; import type {GridColumnHeader, GridColumnOrder} from 'sentry/components/gridEditable'; import GridEditable, {COL_WIDTH_UNDEFINED} from 'sentry/components/gridEditable'; import Pagination from 'sentry/components/pagination'; import {useLocation} from 'sentry/utils/useLocation'; import {BrowserStarfishFields} from 'sentry/views/performance/browser/useBrowserFilters'; import type {ValidSort} from 'sentry/views/performance/browser/useBrowserSort'; import {useInteractionsQuery} from 'sentry/views/performance/browser/useInteractionsQuery'; import {DurationCell} from 'sentry/views/starfish/components/tableCells/durationCell'; import {renderHeadCell} from 'sentry/views/starfish/components/tableCells/renderHeadCell'; import {TextAlignRight} from 'sentry/views/starfish/components/textAlign'; type Row = { 'count()': number; interactionElement: string; 'p75(transaction.duration)': number; 'span.group': string; transaction: string; 'transaction.op': string; }; type Column = GridColumnHeader; type Props = { sort: ValidSort; }; function InteractionsTable({sort}: Props) { const location = useLocation(); const columnOrder: GridColumnOrder[] = [ {key: 'span.group', width: COL_WIDTH_UNDEFINED, name: 'Interaction'}, {key: 'transaction', width: COL_WIDTH_UNDEFINED, name: 'Page'}, {key: 'count()', width: COL_WIDTH_UNDEFINED, name: 'Count'}, { key: 'p75(transaction.duration)', width: COL_WIDTH_UNDEFINED, name: 'Duration (p75)', }, ]; const {data, isLoading, pageLinks} = useInteractionsQuery({sort}); const tableData: Row[] = !isLoading && data.length ? data.map(row => ({ 'span.group': 'NOT IMPLEMENTED', ...row, })) : []; const renderBodyCell = (col: Column, row: Row) => { const {key} = col; if (key === 'span.group') { return ( {getActionName(row['transaction.op'])} {row.interactionElement} ); } if (key === 'p75(transaction.duration)') { return ; } if (key === 'count()') { return {row[key]}; } return {row[key]}; }; return ( renderHeadCell({ column, location, sort, }), renderBodyCell, }} location={location} /> ); } export const getActionName = (transactionOp: string) => { switch (transactionOp) { case 'ui.action.click': return 'Click'; default: return transactionOp; } }; export default InteractionsTable;