Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add type column to WebLogView #372

Merged
merged 3 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/WebLogView/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { MethodBadge } from '../MethodBadge'
import { ResponseStatusBadge } from '../ResponseStatusBadge'
import { TableCellWithTooltip } from '../TableCellWithTooltip'
import { HighlightedText } from '../HighlightedText'
import { getRequestType } from './WebLogView.utils'

interface RowProps {
data: ProxyDataWithMatches
Expand Down Expand Up @@ -53,6 +54,7 @@ export function Row({ data, isSelected, onSelectRequest }: RowProps) {
/>
</ResponseStatusBadge>
</Table.Cell>
<TableCellWithTooltip>{getRequestType(data)}</TableCellWithTooltip>
<TableCellWithTooltip>
<HighlightedText text={data.request.host} matches={data.matches} />
</TableCellWithTooltip>
Expand Down
1 change: 1 addition & 0 deletions src/components/WebLogView/WebLogView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function RequestList({
<Table.Row>
<Table.ColumnHeaderCell width="70px">Method</Table.ColumnHeaderCell>
<Table.ColumnHeaderCell width="60px">Status</Table.ColumnHeaderCell>
<Table.ColumnHeaderCell width="80px">Type</Table.ColumnHeaderCell>
<Table.ColumnHeaderCell width="20%">Host</Table.ColumnHeaderCell>
<Table.ColumnHeaderCell width="80%">Path</Table.ColumnHeaderCell>
</Table.Row>
Expand Down
11 changes: 11 additions & 0 deletions src/components/WebLogView/WebLogView.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { GroupedProxyData, ProxyData } from '@/types'
import { getContentType } from '@/utils/headers'
import { isNonStaticAssetResponse } from '@/utils/staticAssets'

export function removeQueryStringFromUrl(url: string) {
return url.split('?')[0]
Expand All @@ -20,3 +22,12 @@ export function isGroupedProxyData(
): data is GroupedProxyData {
return !Array.isArray(data)
}

export function getRequestType(data: ProxyData) {
if (isNonStaticAssetResponse(data)) {
return 'fetch'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChromeDevTools categorizes this a bit more. I was debating whether to call it "document", "dynamic" or "fetch". Any thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, we can make use of the content-type header to categorize different types of dynamic requests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@going-confetti and I discussed that most dynamic requests have the following content types:

  • text/plain
  • text/html
  • application/json

This makes it tricky to differentiate them so we'll leave them as fetch for now and come back later on if needed.

}

const mimeType = getContentType(data.response?.headers ?? [])
return mimeType ? mimeType.split('/')[1] : 'unknown'
}
Loading