Skip to content

Commit

Permalink
fix: better inspector icons (#26377)
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra authored Nov 25, 2024
1 parent 432e23e commit 280d556
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 6 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ export function ItemEvent({ item }: ItemEventProps): JSX.Element {
<div className="truncate">
<PropertyKeyInfo
className="font-medium"
disablePopover
disablePopover={true}
disableIcon={true}
ellipsis={true}
value={capitalizeFirstLetter(autoCaptureEventToDescription(item.data))}
type={TaxonomicFilterGroupType.Events}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import {
BaseIcon,
IconBolt,
IconChat,
IconCloud,
IconCursor,
IconDashboard,
IconEye,
IconGear,
IconLeave,
IconLogomark,
IconMinusSquare,
IconPlusSquare,
IconTerminal,
Expand All @@ -12,8 +18,8 @@ import clsx from 'clsx'
import { useActions, useValues } from 'kea'
import { Dayjs } from 'lib/dayjs'
import useIsHovering from 'lib/hooks/useIsHovering'
import { IconComment, IconOffline } from 'lib/lemon-ui/icons'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
import { CORE_FILTER_DEFINITIONS_BY_GROUP } from 'lib/taxonomy'
import { ceilMsToClosestSecond, colonDelimitedDuration } from 'lib/utils'
import { useEffect, useRef } from 'react'
import { ItemComment, ItemCommentDetail } from 'scenes/session-recordings/player/inspector/components/ItemComment'
Expand Down Expand Up @@ -49,7 +55,7 @@ const typeToIconAndDescription = {
tooltip: 'Network event',
},
['offline-status']: {
Icon: IconOffline,
Icon: IconCloud,
tooltip: 'browser went offline or returned online',
},
['browser-visibility']: {
Expand All @@ -65,7 +71,7 @@ const typeToIconAndDescription = {
tooltip: 'Doctor event',
},
['comment']: {
Icon: IconComment,
Icon: IconChat,
tooltip: 'A user commented on this timestamp in the recording',
},
['inspector-summary']: {
Expand All @@ -78,6 +84,37 @@ const typeToIconAndDescription = {
},
}

// TODO @posthog/icons doesn't export the type we need here
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/explicit-function-return-type
export function eventToIcon(event: string | undefined | null) {
switch (event) {
case '$pageview':
return IconEye
case '$screen':
return IconEye
case '$pageleave':
return IconLeave
case '$autocapture':
return IconBolt
}

if (event && !!CORE_FILTER_DEFINITIONS_BY_GROUP.events[event]) {
return IconLogomark
}

// technically we should have the select all icon for "All events" completeness,
// but we never actually display it, and it messes up the type signatures for the icons
if (event === null) {
return BaseIcon
}

if (event !== undefined) {
return IconCursor
}

return BaseIcon
}

function ItemTimeDisplay({ item }: { item: InspectorListItem }): JSX.Element {
const { timestampFormat } = useValues(playerSettingsLogic)
const { logicProps } = useValues(sessionRecordingPlayerLogic)
Expand Down Expand Up @@ -227,7 +264,11 @@ export function PlayerInspectorListItem({

const isHovering = useIsHovering(hoverRef)

const TypeIcon = typeToIconAndDescription[item.type].Icon
let TypeIcon = typeToIconAndDescription[item.type].Icon
if (TypeIcon === undefined && item.type === FilterableInspectorListItemTypes.EVENTS) {
// KLUDGE this is a hack to lean on this function, yuck
TypeIcon = eventToIcon(item.data.event)
}

return (
<div
Expand Down Expand Up @@ -281,7 +322,7 @@ export function PlayerInspectorListItem({

{item.type !== 'inspector-summary' && item.type !== 'inactivity' && <ItemTimeDisplay item={item} />}

{TypeIcon ? <TypeIcon className="min-w-4" /> : <BaseIcon className="min-w-4" />}
{TypeIcon ? <TypeIcon /> : <BaseIcon className="min-w-4" />}

<div
className={clsx(
Expand Down

0 comments on commit 280d556

Please sign in to comment.