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.

fix(heatmaps): surface unauthorized URL error in main flow (#71798)

Ben Lea05d2dc6e7806
diff --git a/frontend/src/scenes/heatmaps/components/HeatmapAdvancedSettings.tsx b/frontend/src/scenes/heatmaps/components/HeatmapAdvancedSettings.tsx
index 4695e9a9fc0f..6e82c764fa68 100644
--- a/frontend/src/scenes/heatmaps/components/HeatmapAdvancedSettings.tsx
+++ b/frontend/src/scenes/heatmaps/components/HeatmapAdvancedSettings.tsx
@@ -2,23 +2,20 @@ import { useActions, useValues } from 'kea'
import { LemonCollapse, LemonInput, LemonLabel, LemonSwitch } from '@posthog/lemon-ui'
-import { HeatmapsForbiddenURL } from 'scenes/heatmaps/components/HeatmapsForbiddenURL'
import { heatmapLogic } from 'scenes/heatmaps/scenes/heatmap/heatmapLogic'
export interface HeatmapAdvancedSettingsProps {
dataUrlPlaceholderFallback: string
dataUrlHelp: React.ReactNode
consentHelp: React.ReactNode
- showForbiddenUrl?: boolean
}
export function HeatmapAdvancedSettings({
dataUrlPlaceholderFallback,
dataUrlHelp,
consentHelp,
- showForbiddenUrl = false,
}: HeatmapAdvancedSettingsProps): JSX.Element {
- const { dataUrl, displayUrl, type, blockConsentModals, isBrowserUrlAuthorized } = useValues(heatmapLogic)
+ const { dataUrl, displayUrl, type, blockConsentModals } = useValues(heatmapLogic)
const { setDataUrl, setDataUrlUserTouched, setBlockConsentModals } = useActions(heatmapLogic)
return (
@@ -44,9 +41,6 @@ export function HeatmapAdvancedSettings({
fullWidth={true}
/>
<div className="text-xs text-muted mt-1">{dataUrlHelp}</div>
- {showForbiddenUrl && dataUrl && !isBrowserUrlAuthorized ? (
- <HeatmapsForbiddenURL />
- ) : null}
</div>
<div>
<LemonSwitch
diff --git a/frontend/src/scenes/heatmaps/components/HeatmapHeader.tsx b/frontend/src/scenes/heatmaps/components/HeatmapHeader.tsx
index d112b3e4f9ac..fb4c51971717 100644
--- a/frontend/src/scenes/heatmaps/components/HeatmapHeader.tsx
+++ b/frontend/src/scenes/heatmaps/components/HeatmapHeader.tsx
@@ -5,6 +5,7 @@ import { LemonBanner, LemonButton, LemonInput, LemonLabel } from '@posthog/lemon
import { HeatmapAdvancedSettings } from 'scenes/heatmaps/components/HeatmapAdvancedSettings'
import { HeatmapRecordingFallback } from 'scenes/heatmaps/components/HeatmapRecordingFallback'
import { heatmapsBrowserLogic } from 'scenes/heatmaps/components/heatmapsBrowserLogic'
+import { HeatmapsForbiddenURL } from 'scenes/heatmaps/components/HeatmapsForbiddenURL'
import { HeatmapsInvalidURL } from 'scenes/heatmaps/components/HeatmapsInvalidURL'
import { heatmapLogic } from 'scenes/heatmaps/scenes/heatmap/heatmapLogic'
@@ -19,7 +20,7 @@ export function HeatmapHeader(): JSX.Element {
displayUrlIsPattern,
type,
} = useValues(heatmapLogic)
- const { iframeBanner } = useValues(heatmapsBrowserLogic)
+ const { iframeBanner, dataUrl, isBrowserUrlAuthorized } = useValues(heatmapsBrowserLogic)
const { setPageUrlDraft, applyPageUrlDraft, regenerateScreenshot } = useActions(heatmapLogic)
const draftIsEmpty = pageUrlDraft.trim() === ''
@@ -65,6 +66,7 @@ export function HeatmapHeader(): JSX.Element {
<HeatmapsInvalidURL />
)
) : null}
+ {dataUrl && !isBrowserUrlAuthorized ? <HeatmapsForbiddenURL /> : null}
</div>
{type === 'screenshot' && screenshotError && (
<div className="flex flex-col gap-2">
diff --git a/frontend/src/scenes/heatmaps/components/HeatmapsForbiddenURL.tsx b/frontend/src/scenes/heatmaps/components/HeatmapsForbiddenURL.tsx
index 1d7b0186756f..7aafac915d68 100644
--- a/frontend/src/scenes/heatmaps/components/HeatmapsForbiddenURL.tsx
+++ b/frontend/src/scenes/heatmaps/components/HeatmapsForbiddenURL.tsx
@@ -12,7 +12,7 @@ import {
validateProposedUrl,
} from 'lib/components/AuthorizedUrlList/authorizedUrlListLogic'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
-import { heatmapLogic } from 'scenes/heatmaps/scenes/heatmap/heatmapLogic'
+import { heatmapsBrowserLogic } from 'scenes/heatmaps/components/heatmapsBrowserLogic'
const HOST_WILDCARD_REGEX = /^https?:\/\/[^/]*\*/
@@ -29,7 +29,7 @@ function deriveAuthorizationCandidate(dataUrl: string): string | null {
}
export function HeatmapsForbiddenURL(): JSX.Element {
- const { dataUrl } = useValues(heatmapLogic({ id: 'new' }))
+ const { dataUrl } = useValues(heatmapsBrowserLogic)
const logic = authorizedUrlListLogic({
...defaultAuthorizedUrlProperties,
type: AuthorizedUrlListType.TOOLBAR_URLS,
diff --git a/frontend/src/scenes/heatmaps/scenes/heatmap/HeatmapNewScene.tsx b/frontend/src/scenes/heatmaps/scenes/heatmap/HeatmapNewScene.tsx
index 79a6558083c7..5f33c2f36fac 100644
--- a/frontend/src/scenes/heatmaps/scenes/heatmap/HeatmapNewScene.tsx
+++ b/frontend/src/scenes/heatmaps/scenes/heatmap/HeatmapNewScene.tsx
@@ -10,6 +10,7 @@ import { LemonRadio } from 'lib/lemon-ui/LemonRadio'
import { Link } from 'lib/lemon-ui/Link'
import { HeatmapAdvancedSettings } from 'scenes/heatmaps/components/HeatmapAdvancedSettings'
import { heatmapsBrowserLogic } from 'scenes/heatmaps/components/heatmapsBrowserLogic'
+import { HeatmapsForbiddenURL } from 'scenes/heatmaps/components/HeatmapsForbiddenURL'
import { HeatmapsInvalidURL } from 'scenes/heatmaps/components/HeatmapsInvalidURL'
import { urls } from 'scenes/urls'
@@ -89,6 +90,9 @@ export function HeatmapNewScene(): JSX.Element {
<HeatmapsInvalidURL />
)
) : null}
+ {displayUrl && isDisplayUrlValid && dataUrl && !isBrowserUrlAuthorized ? (
+ <HeatmapsForbiddenURL />
+ ) : null}
{!displayUrl && noPageviews && !topUrlsLoading ? (
<div className="text-xs text-muted mt-1">No pageview events have been received yet.</div>
) : null}
@@ -125,7 +129,6 @@ export function HeatmapNewScene(): JSX.Element {
dataUrlPlaceholderFallback="https://www.example.com/*"
dataUrlHelp="Defaults to the page URL. Add * for wildcards to aggregate data from multiple pages — e.g. https://www.example.com/users/* aggregates all pages under /users/."
consentHelp="Ask the browser to close cookie/consent popups before capturing the screenshot. This can slow down or fail the render on some sites, so it's off by default."
- showForbiddenUrl
/>
<SceneDivider />
<div className="flex gap-2">
@@ -136,11 +139,13 @@ export function HeatmapNewScene(): JSX.Element {
onClick={createHeatmap}
loading={false}
disabledReason={
- !isDisplayUrlValid || (!!dataUrl && !isBrowserUrlAuthorized)
- ? 'Invalid URL or forbidden URL'
- : !displayUrl
- ? 'URL is required'
- : null
+ !displayUrl
+ ? 'URL is required'
+ : !isDisplayUrlValid
+ ? 'Enter a valid URL'
+ : !!dataUrl && !isBrowserUrlAuthorized
+ ? 'Authorize the URL first'
+ : null
}
>
Save