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

fix: report when player state is error #26989

Merged
merged 24 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f4e59f0
feat: report when player state is error
pauldambra Dec 17, 2024
922381a
Update UI snapshots for `chromium` (1)
github-actions[bot] Dec 17, 2024
0b15784
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 17, 2024
eef4c55
Update UI snapshots for `chromium` (1)
github-actions[bot] Dec 17, 2024
447aaf6
stop overreporting player speed changed
pauldambra Dec 17, 2024
35f31db
don't over report skip inactivity
pauldambra Dec 17, 2024
a33aa9d
Update UI snapshots for `chromium` (1)
github-actions[bot] Dec 17, 2024
2008d71
more like this maybe
pauldambra Dec 17, 2024
7c9059f
don't report an error at the start of a recording
pauldambra Dec 17, 2024
396635b
fix
pauldambra Dec 17, 2024
65087da
fix
pauldambra Dec 17, 2024
8c2f730
Merge branch 'master' into feat/pd/report-when-player-state-is-error
pauldambra Dec 18, 2024
e8186c9
fix
pauldambra Dec 18, 2024
572f423
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 18, 2024
1a2d79d
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 18, 2024
278f656
Merge branch 'master' into feat/pd/report-when-player-state-is-error
pauldambra Dec 18, 2024
c23abb4
Add a couple of tooltips
pauldambra Dec 18, 2024
e1231ff
flyby fix and tooltips
pauldambra Dec 18, 2024
f66e139
flyby fix and tooltips
pauldambra Dec 18, 2024
87b9196
fix test
pauldambra Dec 18, 2024
8bc9f36
fix
pauldambra Dec 18, 2024
f470b61
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 18, 2024
3260f78
fix
pauldambra Dec 18, 2024
4874f20
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 18, 2024
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
Binary file modified frontend/__snapshots__/exporter-exporter--dashboard--dark.png
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.
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.
8 changes: 0 additions & 8 deletions frontend/src/lib/utils/eventUsageLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,6 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
reportRecordingsListPropertiesFetched: (loadTime: number) => ({ loadTime }),
reportRecordingsListFilterAdded: (filterType: SessionRecordingFilterType) => ({ filterType }),
reportRecordingPlayerSeekbarEventHovered: true,
reportRecordingPlayerSpeedChanged: (newSpeed: number) => ({ newSpeed }),
Copy link
Member Author

Choose a reason for hiding this comment

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

i hate this gigantic logic that just hides calling posthog capture

reportRecordingPlayerSkipInactivityToggled: (skipInactivity: boolean) => ({ skipInactivity }),
reportRecordingInspectorItemExpanded: (tab: InspectorListItemType, index: number) => ({ tab, index }),
reportRecordingInspectorMiniFilterViewed: (minifilterKey: MiniFilterKey, enabled: boolean) => ({
minifilterKey,
Expand Down Expand Up @@ -948,12 +946,6 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
reportRecordingPlayerSeekbarEventHovered: () => {
posthog.capture('recording player seekbar event hovered')
},
reportRecordingPlayerSpeedChanged: ({ newSpeed }) => {
posthog.capture('recording player speed changed', { new_speed: newSpeed })
},
reportRecordingPlayerSkipInactivityToggled: ({ skipInactivity }) => {
posthog.capture('recording player skip inactivity toggled', { skip_inactivity: skipInactivity })
},
reportRecordingInspectorItemExpanded: ({ tab, index }) => {
posthog.capture('recording inspector item expanded', { tab: 'replay-4000', type: tab, index })
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { actions, connect, kea, path, reducers, selectors } from 'kea'
import { actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
import posthog from 'posthog-js'
import { teamLogic } from 'scenes/teamLogic'

import { AutoplayDirection, SessionRecordingSidebarStacking } from '~/types'
Expand Down Expand Up @@ -122,4 +123,13 @@ export const playerSettingsLogic = kea<playerSettingsLogicType>([
(preferredSidebarStacking) => preferredSidebarStacking === SessionRecordingSidebarStacking.Vertical,
],
}),

listeners({
setSpeed: ({ speed }) => {
posthog.capture('recording player speed changed', { new_speed: speed })
Copy link
Member Author

Choose a reason for hiding this comment

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

moved these captures closer to the source

},
setSkipInactivitySetting: ({ skipInactivitySetting }) => {
posthog.capture('recording player skip inactivity toggled', { skip_inactivity: skipInactivitySetting })
},
}),
])
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,7 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
playerSettingsLogic,
['setSpeed', 'setSkipInactivitySetting'],
eventUsageLogic,
[
'reportNextRecordingTriggered',
'reportRecordingPlayerSkipInactivityToggled',
'reportRecordingPlayerSpeedChanged',
'reportRecordingExportedToFile',
],
['reportNextRecordingTriggered', 'reportRecordingExportedToFile'],
],
})),
actions({
Expand Down Expand Up @@ -672,7 +667,6 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
}
},
setSkipInactivitySetting: ({ skipInactivitySetting }) => {
actions.reportRecordingPlayerSkipInactivityToggled(skipInactivitySetting)
if (!values.currentSegment?.isActive && skipInactivitySetting) {
actions.setSkippingInactivity(true)
} else {
Expand Down Expand Up @@ -848,9 +842,10 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
startScrub: () => {
actions.stopAnimation()
},
setSpeed: ({ speed }) => {
actions.reportRecordingPlayerSpeedChanged(speed)
Copy link
Member Author

Choose a reason for hiding this comment

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

there are always three instances of the player logic, all three are listening to the player settings logic, so all three were reporting this making usage look higher than it is... luckily not an important metric

actions.syncPlayerSpeed()
setSpeed: () => {
if (props.mode !== SessionRecordingPlayerMode.Preview) {
actions.syncPlayerSpeed()
}
},
seekToTimestamp: ({ timestamp, forcePlay }, breakpoint) => {
actions.stopAnimation()
Expand Down Expand Up @@ -1018,7 +1013,7 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
cache.pausedMediaElements = values.endReached ? [] : playingElements
},
restartIframePlayback: () => {
cache.pausedMediaElements.forEach((el: HTMLMediaElement) => el.play())
cache.pausedMediaElements?.forEach((el: HTMLMediaElement) => el.play())
Copy link
Member Author

Choose a reason for hiding this comment

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

saw an error from trying to access this when it was undefined while debugging the rest of this

cache.pausedMediaElements = []
},

Expand Down Expand Up @@ -1143,6 +1138,16 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
actions.reportMessageTooLargeWarningSeen(values.sessionRecordingId)
}
},
currentPlayerState: (prev, next) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

pretty sure we're setting this more than we need to, but this at least can report on that too high a number

if (next === SessionPlayerState.ERROR && prev !== SessionPlayerState.ERROR) {
posthog.capture('recording player error', {
watchedSessionId: values.sessionRecordingId,
currentTimestamp: values.currentTimestamp,
currentSegment: values.currentSegment,
currentPlayerTime: values.currentPlayerTime,
})
}
},
})),

beforeUnmount(({ values, actions, cache, props }) => {
Expand Down
64 changes: 46 additions & 18 deletions frontend/src/toolbar/debug/EventDebugMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseIcon, IconCheck, IconEye, IconLogomark, IconSearch, IconVideoCamera } from '@posthog/icons'
import { BaseIcon, IconCheck, IconEye, IconHide, IconLogomark, IconSearch, IconVideoCamera } from '@posthog/icons'
import { useActions, useValues } from 'kea'
import { AnimatedCollapsible } from 'lib/components/AnimatedCollapsible'
import { PropertyKeyInfo } from 'lib/components/PropertyKeyInfo'
Expand All @@ -15,10 +15,10 @@ import { EventType } from '~/types'

import { ToolbarMenu } from '../bar/ToolbarMenu'

function showEventMenuItem(
function checkableMenuItem(
label: string,
count: number,
icon: JSX.Element,
count: number | null,
icon: JSX.Element | null,
isActive: boolean,
onClick: () => void
): LemonMenuItem {
Expand All @@ -30,13 +30,15 @@ function showEventMenuItem(
{icon}
{label}
</div>
<span
// without setting fontVariant to none a single digit number between brackets gets rendered as a ligature 🤷
// eslint-disable-next-line react/forbid-dom-props
style={{ fontVariant: 'none' }}
>
({count})
</span>
{count !== null && (
<span
// without setting fontVariant to none a single digit number between brackets gets rendered as a ligature 🤷
// eslint-disable-next-line react/forbid-dom-props
style={{ fontVariant: 'none' }}
>
({count})
</span>
)}
</div>
),
active: isActive,
Expand Down Expand Up @@ -70,39 +72,59 @@ export const EventDebugMenu = (): JSX.Element => {
searchFilteredEventsCount,
expandedEvent,
selectedEventTypes,
hidePostHogProperties,
hidePostHogFlags,
expandedProperties,
} = useValues(eventDebugMenuLogic)
const { markExpanded, setSelectedEventType, setSearchText, setSearchVisible } = useActions(eventDebugMenuLogic)
const {
markExpanded,
setSelectedEventType,
setSearchText,
setSearchVisible,
setHidePostHogProperties,
setHidePostHogFlags,
} = useActions(eventDebugMenuLogic)

const showEventsMenuItems = [
showEventMenuItem(
checkableMenuItem(
'PostHog Events',
searchFilteredEventsCount['posthog'],
<IconLogomark />,
selectedEventTypes.includes('posthog'),
() => setSelectedEventType('posthog', !selectedEventTypes.includes('posthog'))
),
showEventMenuItem(
checkableMenuItem(
'Custom Events',
searchFilteredEventsCount['custom'],
<IconVideoCamera />,
selectedEventTypes.includes('custom'),
() => setSelectedEventType('custom', !selectedEventTypes.includes('custom'))
),
showEventMenuItem(
checkableMenuItem(
'Replay Events',
searchFilteredEventsCount['snapshot'],
<IconUnverifiedEvent />,
selectedEventTypes.includes('snapshot'),
() => setSelectedEventType('snapshot', !selectedEventTypes.includes('snapshot'))
),
]

const hideThingsMenuItems = [
checkableMenuItem('Hide PostHog properties', null, null, hidePostHogProperties, () =>
setHidePostHogProperties(!hidePostHogProperties)
),
checkableMenuItem('Hide PostHog flags', null, null, hidePostHogFlags, () =>
setHidePostHogFlags(!hidePostHogFlags)
),
]

return (
<ToolbarMenu>
<ToolbarMenu.Header noPadding>
<div className="flex flex-col pb-2 space-y-1">
<div className="flex justify-center flex-col">
<SettingsBar border="bottom" className="justify-end">
<div className="flex-1 text-sm">
<div className="flex-1 text-sm pl-1">
View events from this page as they are sent to PostHog.
</div>
<SettingsToggle
Expand Down Expand Up @@ -149,7 +171,7 @@ export const EventDebugMenu = (): JSX.Element => {
>
<div className="my-1 ml-1 pl-2 border-l-2">
<SimpleKeyValueList
item={e.properties}
item={expandedProperties}
emptyMessage={searchText ? 'No matching properties' : 'No properties'}
/>
</div>
Expand All @@ -167,7 +189,13 @@ export const EventDebugMenu = (): JSX.Element => {
</div>
</ToolbarMenu.Body>
<ToolbarMenu.Footer noPadding>
<SettingsBar border="top" className="justify-end">
<SettingsBar border="top" className="justify-between">
<SettingsMenu
items={hideThingsMenuItems}
Copy link
Member Author

Choose a reason for hiding this comment

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

found myself needing this while figuring out the rest of this

highlightWhenActive={false}
icon={<IconHide />}
label="Hide properties"
/>
<SettingsMenu
items={showEventsMenuItems}
highlightWhenActive={false}
Expand Down
52 changes: 51 additions & 1 deletion frontend/src/toolbar/debug/eventDebugMenuLogic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { actions, afterMount, connect, kea, path, reducers, selectors } from 'kea'
import { CORE_FILTER_DEFINITIONS_BY_GROUP } from 'lib/taxonomy'
import { CLOUD_INTERNAL_POSTHOG_PROPERTY_KEYS, CORE_FILTER_DEFINITIONS_BY_GROUP, PROPERTY_KEYS } from 'lib/taxonomy'
import { uuid } from 'lib/utils'
import { permanentlyMount } from 'lib/utils/kea-logic-builders'

Expand All @@ -22,8 +22,22 @@ export const eventDebugMenuLogic = kea<eventDebugMenuLogicType>([
eventType,
enabled,
}),
setHidePostHogProperties: (hide: boolean) => ({ hide }),
setHidePostHogFlags: (hide: boolean) => ({ hide }),
}),
reducers({
hidePostHogProperties: [
false,
{
setHidePostHogProperties: (_, { hide }) => hide,
},
],
hidePostHogFlags: [
false,
{
setHidePostHogFlags: (_, { hide }) => hide,
},
],
searchVisible: [
false,
{
Expand Down Expand Up @@ -123,6 +137,42 @@ export const eventDebugMenuLogic = kea<eventDebugMenuLogicType>([
})
},
],

expandedProperties: [
(s) => [s.expandedEvent, s.events, s.hidePostHogProperties, s.hidePostHogFlags],
(expandedEvent, events, hidePostHogProperties, hidePostHogFlags) => {
if (!expandedEvent) {
return []
}
const theExpandedEvent = events.find((e) => e.uuid === expandedEvent)
if (!theExpandedEvent) {
return []
}

const propsFiltered = hidePostHogProperties
? Object.fromEntries(
Object.entries(theExpandedEvent.properties).filter(([key]) => {
const isPostHogProperty = key.startsWith('$') && PROPERTY_KEYS.includes(key)
const isNonDollarPostHogProperty = CLOUD_INTERNAL_POSTHOG_PROPERTY_KEYS.includes(key)
return !isPostHogProperty && !isNonDollarPostHogProperty
})
)
: theExpandedEvent.properties

return Object.fromEntries(
Object.entries(propsFiltered).filter(([key]) => {
if (hidePostHogFlags) {
if (key === '$active_feature_flags') {
return false
} else if (key.startsWith('$feature/')) {
return false
}
}
return true
})
)
},
],
}),
afterMount(({ values, actions }) => {
values.posthog?.on('eventCaptured', (e) => {
Expand Down
Loading