Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.8 KB
Raw Blame
import { useActions, useValues } from 'kea'

import { IconRefresh } from '@posthog/icons'

import { supportLogic } from 'lib/components/Support/supportLogic'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { sceneLogic } from 'scenes/sceneLogic'

/**
 * Shown when a scene's code fails to import, or its logic throws while mounting. Without it the
 * address bar moves to the new scene while the old one stays rendered, so the person is left on a
 * page that no longer matches the URL.
 */
export function SceneLoadError(): JSX.Element {
    const { openSupportForm } = useActions(supportLogic)
    const { sceneLoadExceptionEvent } = useValues(sceneLogic)

    return (
        <div className="p-4">
            <h1 className="mb-1 text-2xl font-bold">Couldn't load this page</h1>
            <p>
                Something went wrong while this page was loading. Reload to try again. If it keeps happening, let us
                know.
            </p>
            <div className="flex gap-2 flex-wrap">
                <LemonButton
                    type="primary"
                    icon={<IconRefresh />}
                    onClick={() => window.location.reload()}
                    data-attr="scene-load-error-reload"
                >
                    Reload the page
                </LemonButton>
                <LemonButton
                    type="secondary"
                    onClick={() =>
                        openSupportForm({
                            kind: 'bug',
                            isEmailFormOpen: true,
                            exception_event: sceneLoadExceptionEvent ?? undefined,
                        })
                    }
                    data-attr="scene-load-error-email-engineer"
                >
                    Email an engineer
                </LemonButton>
            </div>
        </div>
    )
}