Skip to content

Commit

Permalink
fix: squash error on the product page (#25460)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
raquelmsmith and github-actions[bot] authored Oct 15, 2024
1 parent 2efac4c commit 4fc739d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
27 changes: 14 additions & 13 deletions frontend/src/scenes/activity/live/liveEventsTableLogic.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { lemonToast, Spinner } from '@posthog/lemon-ui'
import { actions, connect, events, kea, listeners, path, reducers, selectors } from 'kea'
import { router } from 'kea-router'
import { actions, connect, events, kea, listeners, path, props, reducers, selectors } from 'kea'
import { liveEventsHostOrigin } from 'lib/utils/apiHost'
import { teamLogic } from 'scenes/teamLogic'

Expand All @@ -10,8 +9,13 @@ import type { liveEventsTableLogicType } from './liveEventsTableLogicType'

const ERROR_TOAST_ID = 'live-stream-error'

export interface LiveEventsTableProps {
showLiveStreamErrorToast: boolean
}

export const liveEventsTableLogic = kea<liveEventsTableLogicType>([
path(['scenes', 'activity', 'live-events', 'liveEventsTableLogic']),
props({} as LiveEventsTableProps),
connect({
values: [teamLogic, ['currentTeam']],
}),
Expand All @@ -26,7 +30,6 @@ export const liveEventsTableLogic = kea<liveEventsTableLogicType>([
setClientSideFilters: (clientSideFilters) => ({ clientSideFilters }),
pollStats: true,
setStats: (stats) => ({ stats }),
showLiveStreamErrorToast: true,
addEventHost: (eventHost) => ({ eventHost }),
})),
reducers({
Expand Down Expand Up @@ -110,7 +113,7 @@ export const liveEventsTableLogic = kea<liveEventsTableLogicType>([
},
],
})),
listeners(({ actions, values, cache }) => ({
listeners(({ actions, values, cache, props }) => ({
setFilters: () => {
actions.clearEvents()
actions.updateEventsConnection()
Expand Down Expand Up @@ -153,15 +156,13 @@ export const liveEventsTableLogic = kea<liveEventsTableLogicType>([
}

source.onerror = function (e) {
console.error('Failed to poll events: ', e)
if (
!cache.hasShownLiveStreamErrorToast &&
!router.values.currentLocation.pathname.includes('onboarding')
) {
lemonToast.error(
`Cannot connect to the live event stream. Continuing to retry in the background…`,
{ icon: <Spinner />, toastId: ERROR_TOAST_ID, autoClose: false }
)
if (!cache.hasShownLiveStreamErrorToast && props.showLiveStreamErrorToast) {
console.error('Failed to poll events. You likely have no events coming in.', e)
lemonToast.error(`No live events found. Continuing to retry in the background…`, {
icon: <Spinner />,
toastId: ERROR_TOAST_ID,
autoClose: false,
})
cache.hasShownLiveStreamErrorToast = true // Only show once
}
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/onboarding/onboardingLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const onboardingLogic = kea<onboardingLogicType>([
props({} as OnboardingLogicProps),
path(['scenes', 'onboarding', 'onboardingLogic']),
// connect this so we start collecting live events the whole time during onboarding
connect(liveEventsTableLogic),
connect(liveEventsTableLogic({ showLiveStreamErrorToast: false })),
connect({
values: [
billingLogic,
Expand Down

0 comments on commit 4fc739d

Please sign in to comment.