: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(web-analytics): add screenshot access settings ui (#97876)
Jordan Mryyan42ccfafa7d52
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 26281792eb5e..1b19f65b9aea 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -2113,9 +2113,9 @@ snapshots:components-search--product-recents-and-starred--light:hash: v1.k794b7964.419cabcff30a22d68b283cf59562b74ca2d4910552fc4240e95b856303622508.0xCO-YA2i8xkqSjPXRWXjmLuVEiiP11XfIC6v9y77yUcomponents-search--searching--dark:- hash: v1.k794b7964.79cc43d6523611f3130b2c12fcc4cd29d765ff55983532f2b6b05a965879cb34.RZgOxgnzKDx6FomvNdIwTwxP43EQRgYUqlSn-F3rdRQ+ hash: v1.k794b7964.0acd271bf9ea3d0c88db1b21017625d5bb08728c7ed185696e54c4c7c6d948bf.d1iBj0uFxNNFaPvb8HpTllFJy74qfoeIhmpMgePbCdwcomponents-search--searching--light:- hash: v1.k794b7964.cbcb7b6bf2df9986de6b5dae57696311c3b4b724b3b50f2ac8cff735bd17ad4f._ERsDMH-NJwBiwLZJv5zhZDCQN2bO4dkoiHwN2iJssc+ hash: v1.k794b7964.b43b9ee07664f85109b2f0df3fe70a6e96e1a1628f65cef847153bcc58b3060c.YndsQWYmB9PL0kLyV47NLINY3JU3a4xt0sm250U_jc8components-sentencelist--full-sentence--dark:hash: v1.k794b7964.7e8e5dd2e09d246cc3668f362f2391fe67618bd1143aa393832297f5dc30e558.yptEWKc5RAUY613Fwd5cQ0VIinMvpdoI6cuKgagAGxkcomponents-sentencelist--full-sentence--light:@@ -8077,11 +8077,11 @@ snapshots:scenes-app-health-tables--web-analytics-empty--light:hash: v1.k794b7964.3597e7770e8308581101896e95346e2c84d09419cd39b92d5137ca1fa57adfa5.lpfx7m5tiYOuJWlnL6irM5RlG8w1xVzwDwLaR6ETEpYscenes-app-heatmap--generating--dark:- hash: v1.k794b7964.a1b091218b2c01c2e941b4e958ccba93f96439af1f898e1995995b85d3c7bed0.FmQ58W1kfvKgtwCGG8xRgmT614Giu4VwVLz8zRguLJ0+ hash: v1.k794b7964.31f0acd18085596c954881a42cd08564f6c731ac2b57a08b7e27be4d7b98c440.8aAtWXgjxwQkGrPiW6W2-c_5bbo-fPoAsKaS4isjf-4scenes-app-heatmap--generating--light:- hash: v1.k794b7964.9e9c863c6e06c7e6e610353fbd826ee85406c86419eeba160ad2e525b66021bc.pQ8mxSWr4ScfBLrbe8Ppc_tyJdr0mNjKY5q71eurkBM+ hash: v1.k794b7964.2b49e1892ed6a1c94afd12330b5990fb2a319ab9b8a6a7b94caaef836408b66f.rCRpH38L-jydVm-bYnARWGbodRueWgA8F6P81GgB16Qscenes-app-heatmap--iframe-example--dark:- hash: v1.k794b7964.ecb6fd1c2de83c13a08fad883f74a3b9e18e7381ea6803e2f6b66c98bc8c4d7c.SvgSm1w31kAgXE50mM9O_l6kdJVJ53oBmp1ukGpQPgo+ hash: v1.k794b7964.637695c260925a0ffb332cd88cd82acaf3885d6bdadf0d80a08e9ef4b423fccb.l50zGBCFUuYqxi0_N2FZmn2hdR4CdXVP27MEV0lY8kQscenes-app-heatmap--iframe-example--light:hash: v1.k794b7964.d53f7271d90ce8ee4c2c3655b96f0bb148c6083e7bf9a76bb1ffd8bf5a36efce.EV3kCDfyPP58BHnE-ZQ9rbsF6CPMkDUvGaMvtLkhrtEscenes-app-heatmap--iframe-example-with-event-filter--dark:@@ -8117,9 +8117,9 @@ snapshots:scenes-app-heatmap-new--no-matching-data--light:hash: v1.k794b7964.33d4b183e99f26afe383dd18daedfd49eecaa2f3e9054d6f95666e973611258e.cq7TTsPEj0ETSYPIDf3jlvtMkIh8_t9SdEorBd8AgmYscenes-app-heatmap-new--public-screenshot--dark:- hash: v1.k794b7964.174d3f97dc8a64a3c5d8789c9a398e1029abd2ea115f710b87a8d7f33fb970b8.smJPb9QC52fkCb2G02-_yP0N6bGTsSYnnP5T5gLfDfw+ hash: v1.k794b7964.ab6845b090ef0c57c6afe3ed6964e3ad04273535e3deadece59d00b445e4bf48.K367lHq8Vl1__P-rJZBdRsho91rdspJPEsA_t9-XAvwscenes-app-heatmap-new--public-screenshot--light:- hash: v1.k794b7964.ce9bf63f6972a55c9b2e6852389aa04146dd4eda8e38b1251689fbf4b2bc60e5.SYBVl2dgBIa6sluoCsOKDp2EOKK-B3074l5WcbA3P_U+ hash: v1.k794b7964.4ee1f96da3401371b7048527a383804fc3c8adc4f0f9aedfbb30e79a5d54a829.OPySJzygG_yI_F5QdfVQNLAIuFr56EyXaDI2malOgWcscenes-app-heatmap-new--review--dark:hash: v1.k794b7964.9f674de81b32084faef93230a2c8c5d987ddb6c5bf3a21b5074e000feea345cb.9r4DBoDJFmnqnQarpE00qV-psXUtOGXho2dhUOhuXFYscenes-app-heatmap-new--review--light:@@ -9953,9 +9953,13 @@ snapshots:scenes-app-settings-environment--settings-environment-feature-flags--light:hash: v1.k794b7964.2254e82614b9ae96c0801fbe3657ee60cf94f03ed89ccef973ba931646dd02b6.KnVQosUnK2-W1vnz6CB_xsgqUDD6cq6U3hbl7Cm6z8Iscenes-app-settings-environment--settings-environment-heatmaps--dark:- hash: v1.k794b7964.fcd746832f969670f1f74302129fd07dc02d306ab42ed62132531897a1f373d6.HeOIR5gp6VO9MxSO6TgCSOkv3T2LxQSJ3PdR1QxguxM+ hash: v1.k794b7964.56d4d5c292ebe5f9f9d4b50ea5971c349bfee6c568793196a89b708e0854128c.qruKvRiNvDGPiIFgoj86f7HqbuJTKsjQ2ZYylgETlLwscenes-app-settings-environment--settings-environment-heatmaps--light:- hash: v1.k794b7964.649ca8e61524b3ae912ee89887b7b0d44a17ad40ed00b448749699d1f2f9652c.4tkYKPpAYAMHtJu3ZTsV-LooHS-3z1oXg7H8FPH_ta0+ hash: v1.k794b7964.51682ed4e0137094f4b04b0d640db418079717a20f6f1785fa529dc5889e0982.SjItpbYYDctTGcSRBFPy-QxFIjP3Ps_Am6w3p4-40d4+ scenes-app-settings-environment--settings-environment-heatmaps-screenshot-cookie--dark:+ hash: v1.k794b7964.47e7c9c63e39119de1fa0e82b279a5b57a62ee06f2ff89a5aa4fed345df5fa52.zElyJ5sL6qvHar4FcXKBDlwX-iPNfyRWiZJG4-pj8Jc+ scenes-app-settings-environment--settings-environment-heatmaps-screenshot-cookie--light:+ hash: v1.k794b7964.71b85d9e6f36e2124e6dcdc1c730d34c8decf294a925ddbb7a40f4cf54c1c1e3.Mx1ByTft2OS71PEi3g0HYYyb77DXuEWtu4R-9dtYfvIscenes-app-settings-environment--settings-environment-integrations--dark:hash: v1.k794b7964.bf31464f10d36bfd3279dabc491f218cb2963722f82bcbb493e5dc33d29c86b5.fbO-nOzwF7Wo3Hp8O9FbuDPU-9GXMErI99YgmcOUxI8scenes-app-settings-environment--settings-environment-integrations--light:@@ -11376,6 +11380,26 @@ snapshots:hash: v1.k794b7964.c17be7ebf593bcdc6ad760d1ae2035be3dadad1e049d39ef6c72b9e093a03067.KVwJMpXcfhchvEMKnnqsNnyBE6EI5d9YIUWIB-08xfYutils-autocapture-preview-image--tab-relative-image-with-current-url--light:hash: v1.k794b7964.3e7d7a6fa83916bae8280f36864538241c45bd4122e167b299a046939c802b03.oW1U5X9JYmxSLcn72S6kPmgj_jxgZTKyJa0uZ1kbRJs+ web-analytics-heatmaps-screenshot-cookie-settings--admin--dark:+ hash: v1.k794b7964.c5348c16eb78868ccb7f02aeb327e1c130dc87a2bd3179ab9a1c7cf3ff893d70.bBPSLFvlUh3vxq9dOdJFD0lClID9CSFzwgWzbw3lwiY+ web-analytics-heatmaps-screenshot-cookie-settings--admin--light:+ hash: v1.k794b7964.d4a9914e8ce6f32dfb383b0f2a2ee7c7f6a714eb7e208cb94a7cb5501fbca489.WypBZUwji1_d77gwoOEZw8C7RAZXDVFqifNoTHBIXxY+ web-analytics-heatmaps-screenshot-cookie-settings--delivery-disabled--dark:+ hash: v1.k794b7964.0aa0dbe9f5c677c3b01fbd43ff749bf77348538c2666f41465a3294cd697660b.C8PgWx7atdf6TKZGjhStXhnkDl6MBKeIEZWAhDX9ui4+ web-analytics-heatmaps-screenshot-cookie-settings--delivery-disabled--light:+ hash: v1.k794b7964.ce7ed9d4807e8feeca4a3495a09e2c562bec429a2873f63f4b629a4a4b5b053b.LfI6TB8D3-E1bDpA-ai5YhdduJWW4c1a1r9JXPSRQK8+ web-analytics-heatmaps-screenshot-cookie-settings--editor--dark:+ hash: v1.k794b7964.d4348420635b84b4a4f958f3c00b3b9fdbfc0e6b79fb35116c1222a6cd8e0e28.UT172EFrKfZO4FiFmBIbiD7do8qR_40vMMMI16BEoC4+ web-analytics-heatmaps-screenshot-cookie-settings--editor--light:+ hash: v1.k794b7964.215a52c588e00cee73f54e8cb1c4db130751fb92346557bd7a6141641956a013.HklCn7K4pZOWcjNOEgRJEQ7rOg2XggSmuazCurWuQzE+ web-analytics-heatmaps-screenshot-cookie-settings--narrow--dark:+ hash: v1.k794b7964.8fd988ab61781ac9ae9d1fa7a2b7bd32cc92ba6cd93172a79324598b623e6751.xKMcc_68LpzcanTrAKSQkZgA3tEfC5TiMTJF3f_OaNU+ web-analytics-heatmaps-screenshot-cookie-settings--narrow--light:+ hash: v1.k794b7964.cc06e4cbb44fc0b20827264c9926b00f59afc40b1a82e2d1e623a8c1435feca3.B3LVLNSO48_jFIOhWwoQ6h3g2C_V32z1ZE0OHHmlqdo+ web-analytics-heatmaps-screenshot-cookie-settings--needs-approval--dark:+ hash: v1.k794b7964.037f022d2a360a741442b7a7c02748c85c3dfbf3704b127b8c71156e76295083.noiQbmitnbvh8r5QfNWY12cyIEdP8cStss8pv9seKjo+ web-analytics-heatmaps-screenshot-cookie-settings--needs-approval--light:+ hash: v1.k794b7964.790f27ad4199e77064df360d80709c6f2c6cae2206b587a3aeba135632d66d7e.ffn1fvTuAAz2_7YzsCrcb9VIyMp0THxWP4sLOrkGGNsweb-analytics-overview-metric-cards--conversion-goal--dark:hash: v1.k794b7964.0a6a29eef1c3d6ef3a287b530d4bdd7dbcc8cfbf503d54e02bfb5ab96473b6c3.-DSdM2UYxNQisb23WDltH1M71pRcQt2-_YiAhigLzIwweb-analytics-overview-metric-cards--conversion-goal--light:diff --git a/frontend/src/scenes/settings/SettingsMap.tsx b/frontend/src/scenes/settings/SettingsMap.tsxindex d2cb9ccea975..e11ad485abef 100644--- a/frontend/src/scenes/settings/SettingsMap.tsx+++ b/frontend/src/scenes/settings/SettingsMap.tsx@@ -75,6 +75,7 @@ import { LogsMetricRulesSection } from 'products/logs/frontend/components/LogsMeimport { LogsRetentionSection } from 'products/logs/frontend/components/LogsRetention/LogsRetentionSection'import { LogsSamplingSection } from 'products/logs/frontend/components/LogsSampling/LogsSamplingSection'import { LogsFeatureFlagKeys } from 'products/logs/frontend/logsFeatureFlagKeys'+import { HeatmapScreenshotCookieSettings } from 'products/web_analytics/frontend/heatmaps/components/HeatmapScreenshotCookieSettings'import { WorkflowsEmailTrackingConsentSettings } from 'products/workflows/frontend/scenes/settings/WorkflowsEmailTrackingConsentSettings'import { WorkflowsEngagementEventsSettings } from 'products/workflows/frontend/scenes/settings/WorkflowsEngagementEventsSettings'import { WorkflowsTaskLimitsSettings } from 'products/workflows/frontend/scenes/settings/WorkflowsTaskLimitsSettings'@@ -884,6 +885,24 @@ export const SETTINGS_MAP: SettingSection[] = [component: <HeatmapsSettings />,keywords: ['click map', 'scroll', 'rage click', 'mouse', 'touch'],},+ {+ id: 'heatmap-screenshot-cookie',+ title: 'Screenshot request cookie',+ description:+ 'Heatmap backgrounds are screenshots of your site. Generate a value your screenshots send as a cookie, so bot protection can tell them apart from other headless browsers and allow them.',+ docsUrl: 'https://posthog.com/docs/toolbar/heatmaps',+ component: <HeatmapScreenshotCookieSettings />,+ keywords: [+ 'waf',+ 'bot protection',+ 'firewall',+ 'cloudflare',+ 'screenshot',+ 'blocked',+ 'allowlist',+ 'cookie',+ ],+ },],},{diff --git a/frontend/src/scenes/settings/stories/SettingsEnvironment.stories.tsx b/frontend/src/scenes/settings/stories/SettingsEnvironment.stories.tsxindex 5a6923e3affb..bec5eb5a169f 100644--- a/frontend/src/scenes/settings/stories/SettingsEnvironment.stories.tsx+++ b/frontend/src/scenes/settings/stories/SettingsEnvironment.stories.tsx@@ -1,10 +1,13 @@import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'import type { Meta, StoryObj } from '@storybook/react'+import { useActions } from 'kea'import { router } from 'kea-router'+import { useEffect, useState } from 'react'import { STORYBOOK_FEATURE_FLAGS } from 'lib/constants'import { App } from 'scenes/App'+import { teamLogic } from 'scenes/teamLogic'import { urls } from 'scenes/urls'import { mswDecorator } from '~/mocks/browser'@@ -36,6 +39,11 @@ const meta: Meta<StoryProps> = {},'/api/billing/': { products: [] },'/api/projects/:id/integrations': { results: [] },+ '/api/projects/:id/heatmap_screenshot/settings/': {+ allowed_hostnames: [],+ has_secret: false,+ cookie_delivery_enabled: true,+ },// The GitHub section fetches both on mount; unmocked, their error toasts land in the snapshot.'/api/projects/:id/integrations/github/available_installations/': {installations: [],@@ -84,6 +92,31 @@ export const SettingsEnvironmentAutocapture: Story = { args: { sectionId: 'envirexport const SettingsEnvironmentHeatmaps: Story = { args: { sectionId: 'environment-heatmaps' } }+export const SettingsEnvironmentHeatmapsScreenshotCookie: Story = {+ args: { sectionId: 'environment-heatmaps' },+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:id/heatmap_screenshot/settings/': {+ allowed_hostnames: ['example.com'],+ has_secret: true,+ cookie_delivery_enabled: true,+ },+ },+ }),+ ],+ render: ({ sectionId }: StoryProps) => {+ const { loadCurrentTeamSuccess } = useActions(teamLogic)+ const [initializedSection, setInitializedSection] = useState<SettingSectionId | null>(null)+ useEffect(() => {+ loadCurrentTeamSuccess({ ...MOCK_DEFAULT_TEAM, heatmaps_screenshot_secret: 'phh_example1234abcd' })+ router.actions.push(urls.settings(sectionId))+ setInitializedSection(sectionId)+ }, [loadCurrentTeamSuccess, sectionId])+ return <>{initializedSection === sectionId && <App />}</>+ },+}+export const SettingsEnvironmentProductAnalytics: Story = { args: { sectionId: 'environment-product-analytics' } }export const SettingsEnvironmentRevenueAnalytics: Story = { args: { sectionId: 'environment-revenue-analytics' } }diff --git a/frontend/src/scenes/settings/types.ts b/frontend/src/scenes/settings/types.tsindex 878166720cba..37f1176ab112 100644--- a/frontend/src/scenes/settings/types.ts+++ b/frontend/src/scenes/settings/types.ts@@ -190,6 +190,7 @@ export type SettingId =| 'feature-previews-coming-soon'| 'group-analytics'| 'heatmaps'+ | 'heatmap-screenshot-cookie'| 'hedgehog-mode'| 'homepage'| 'human-friendly-comparison-periods'diff --git a/products/web_analytics/frontend/heatmaps/components/HeatmapHeader.tsx b/products/web_analytics/frontend/heatmaps/components/HeatmapHeader.tsxindex a3f7b7a5f77d..7cfc60c4a98e 100644--- a/products/web_analytics/frontend/heatmaps/components/HeatmapHeader.tsx+++ b/products/web_analytics/frontend/heatmaps/components/HeatmapHeader.tsx@@ -10,6 +10,7 @@ import { heatmapLogic } from '../scenes/heatmap/heatmapLogic'import { HeatmapAdvancedSettings } from './HeatmapAdvancedSettings'import { HeatmapRecordingFallback } from './HeatmapRecordingFallback'import { heatmapsBrowserLogic } from './heatmapsBrowserLogic'+import { HeatmapScreenshotAccessNotice } from './HeatmapScreenshotAccessNotice'import { HeatmapsForbiddenURL } from './HeatmapsForbiddenURL'import { HeatmapsInvalidURL } from './HeatmapsInvalidURL'@@ -111,6 +112,9 @@ export function HeatmapHeader(): JSX.Element {{displayUrl && !displayUrlIsPattern ? <HeatmapRecordingFallback url={displayUrl} /> : null}</div>)}+ {type === 'screenshot' && source !== 'toolbar' && !screenshotError && (+ <HeatmapScreenshotAccessNotice url={displayUrl} />+ )}<HeatmapAdvancedSettingsdataUrlPlaceholderFallback="Enter a URL"dataUrlHelp="Defaults to the page URL. Add * for wildcards to aggregate data from multiple pages."diff --git a/products/web_analytics/frontend/heatmaps/components/HeatmapScreenshotAccessNotice.tsx b/products/web_analytics/frontend/heatmaps/components/HeatmapScreenshotAccessNotice.tsxnew file mode 100644index 000000000000..0fa3d32d84c1--- /dev/null+++ b/products/web_analytics/frontend/heatmaps/components/HeatmapScreenshotAccessNotice.tsx@@ -0,0 +1,29 @@+import { useValues } from 'kea'++import { LemonBanner } from '@posthog/lemon-ui'++import { teamLogic } from 'scenes/teamLogic'+import { urls } from 'scenes/urls'++import { screenshotAccessNotice } from '../heatmapScreenshotCookie'+import { heatmapScreenshotSettingsLogic } from './heatmapScreenshotSettingsLogic'++export function HeatmapScreenshotAccessNotice({ url }: { url: string | null }): JSX.Element | null {+ const { currentTeamId } = useValues(teamLogic)+ const { settings, loadError } = useValues(heatmapScreenshotSettingsLogic({ teamId: currentTeamId ?? 0 }))+ const message = loadError+ ? 'Could not check screenshot access settings. You can still try the screenshot or check project settings.'+ : screenshotAccessNotice(url, settings)++ return message ? (+ <LemonBanner+ type="info"+ action={{+ children: 'Screenshot settings',+ to: urls.settings('environment-heatmaps', 'heatmap-screenshot-cookie'),+ }}+ >+ {message}+ </LemonBanner>+ ) : null+}diff --git a/products/web_analytics/frontend/heatmaps/components/HeatmapScreenshotCookieSettings.stories.tsx b/products/web_analytics/frontend/heatmaps/components/HeatmapScreenshotCookieSettings.stories.tsxnew file mode 100644index 000000000000..8a21c8364f00--- /dev/null+++ b/products/web_analytics/frontend/heatmaps/components/HeatmapScreenshotCookieSettings.stories.tsx@@ -0,0 +1,105 @@+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'++import type { Meta, StoryObj } from '@storybook/react'+import { useActions } from 'kea'+import { useEffect } from 'react'++import { OrganizationMembershipLevel } from 'lib/constants'+import { teamLogic } from 'scenes/teamLogic'++import { mswDecorator } from '~/mocks/browser'++import { HeatmapScreenshotCookieSettings } from './HeatmapScreenshotCookieSettings'++const meta: Meta<typeof HeatmapScreenshotCookieSettings> = {+ title: 'Web Analytics/Heatmaps/Screenshot cookie settings',+ component: HeatmapScreenshotCookieSettings,+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:id/heatmap_screenshot/settings/': {+ allowed_hostnames: ['example.com', 'www.example.com'],+ has_secret: true,+ cookie_delivery_enabled: true,+ },+ },+ patch: {+ '/api/projects/:id/heatmap_screenshot/settings/': async ({ request }) => [+ 200,+ { ...((await request.json()) as object), has_secret: true, cookie_delivery_enabled: true },+ ],+ },+ }),+ ],+}+export default meta+type Story = StoryObj<typeof HeatmapScreenshotCookieSettings>++export const Admin: Story = {+ render: () => {+ const { loadCurrentTeamSuccess } = useActions(teamLogic)+ useEffect(() => {+ loadCurrentTeamSuccess({+ ...MOCK_DEFAULT_TEAM,+ app_urls: ['https://example.com', 'https://www.example.com', 'https://docs.example.com'],+ heatmaps_screenshot_secret: 'phh_synthetic_example',+ })+ }, [loadCurrentTeamSuccess])+ return <HeatmapScreenshotCookieSettings />+ },+}++export const Editor: Story = {+ render: () => {+ const { loadCurrentTeamSuccess } = useActions(teamLogic)+ useEffect(() => {+ loadCurrentTeamSuccess({+ ...MOCK_DEFAULT_TEAM,+ effective_membership_level: OrganizationMembershipLevel.Member,+ heatmaps_screenshot_secret: null,+ })+ }, [loadCurrentTeamSuccess])+ return <HeatmapScreenshotCookieSettings />+ },+}++export const NeedsApproval: Story = {+ ...Admin,+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:id/heatmap_screenshot/settings/': {+ allowed_hostnames: [],+ has_secret: true,+ cookie_delivery_enabled: true,+ },+ },+ }),+ ],+}++export const Narrow: Story = {+ ...Admin,+ decorators: [+ (Story) => (+ <div className="w-128">+ <Story />+ </div>+ ),+ ],+}++export const DeliveryDisabled: Story = {+ ...Admin,+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:id/heatmap_screenshot/settings/': {+ allowed_hostnames: ['example.com'],+ has_secret: true,+ cookie_delivery_enabled: false,+ },+ },+ }),+ ],+}diff --git a/products/web_analytics/frontend/heatmaps/components/HeatmapScreenshotCookieSettings.tsx b/products/web_analytics/frontend/heatmaps/components/HeatmapScreenshotCookieSettings.tsxnew file mode 100644index 000000000000..6432d4eec68a--- /dev/null+++ b/products/web_analytics/frontend/heatmaps/components/HeatmapScreenshotCookieSettings.tsx@@ -0,0 +1,159 @@+import { useActions, useValues } from 'kea'++import { LemonBanner, LemonButton, LemonDialog, LemonInputSelect, LemonLabel, LemonSkeleton } from '@posthog/lemon-ui'++import { CodeSnippet, Language } from 'lib/components/CodeSnippet'+import { RestrictionScope, useRestrictedArea } from 'lib/components/RestrictedArea'+import { TeamMembershipLevel } from 'lib/constants'+import { teamLogic } from 'scenes/teamLogic'++import { HEATMAP_SCREENSHOT_COOKIE_NAME } from '../heatmapScreenshotCookie'+import { heatmapScreenshotSettingsLogic } from './heatmapScreenshotSettingsLogic'++export function HeatmapScreenshotCookieSettings(): JSX.Element {+ const { currentTeamId } = useValues(teamLogic)+ const logic = heatmapScreenshotSettingsLogic({ teamId: currentTeamId ?? 0 })+ const {+ settings,+ settingsLoading,+ hostnames,+ secret,+ rotatedSecretLoading,+ suggestions,+ hasChanges,+ loadError,+ saveError,+ } = useValues(logic)+ const { loadSettings, setHostnames, saveSettings, rotateSecret } = useActions(logic)+ const restrictedReason = useRestrictedArea({+ scope: RestrictionScope.Project,+ minimumAccessLevel: TeamMembershipLevel.Admin,+ })++ if (loadError) {+ return (+ <LemonBanner type="error" action={{ children: 'Retry', onClick: loadSettings }}>+ Could not load screenshot settings. Try again.+ </LemonBanner>+ )+ }+ if (!settings) {+ return <LemonSkeleton />+ }++ return (+ <div className="flex flex-col gap-3 max-w-160">+ {!settings.cookie_delivery_enabled && (+ <LemonBanner type="info">+ Screenshot cookie delivery is disabled on this installation. You can save your settings, but+ screenshots will run without the cookie. Contact your PostHog administrator to enable delivery.+ </LemonBanner>+ )}+ <p className="mb-0">+ Allow screenshots of public pages behind bot protection. Approve the hostnames that may receive this+ project's screenshot cookie, then add a matching exception in your bot protection settings.+ </p>+ {!settings.allowed_hostnames.length && (+ <LemonBanner type="info">+ No hostnames are approved, so screenshots run without a bypass cookie. Ask a project admin to+ approve each hostname that needs one, including redirect destinations.+ {settings.has_secret && (+ <p className="mb-0 mt-2">+ A value already exists. If you used it before approving hostnames, rotate it and replace the+ old value in your bot protection rule.+ </p>+ )}+ </LemonBanner>+ )}+ <div className="flex flex-col gap-2">+ <LemonLabel>Approved screenshot hostnames</LemonLabel>+ <LemonInputSelect+ mode="multiple"+ allowCustomValues+ value={hostnames}+ options={suggestions.map((hostname) => ({ key: hostname, label: hostname }))}+ onChange={setHostnames}+ placeholder="www.example.com"+ disabled={!!restrictedReason || settingsLoading || rotatedSecretLoading}+ data-attr="heatmap-screenshot-hostnames"+ />+ <p className="text-secondary mb-0">+ Enter exact hostnames without a URL or wildcard. Approving www.example.com does not approve+ example.com or its other subdomains. Toolbar URL suggestions require your selection and approval.+ </p>+ {saveError && (+ <LemonBanner type="error">+ Could not save hostnames. Check that each entry is an exact DNS hostname without a URL, port,+ wildcard, or IP address, then try again.+ </LemonBanner>+ )}+ {!restrictedReason && (+ <LemonButton+ className="self-start"+ type="primary"+ onClick={saveSettings}+ loading={settingsLoading}+ disabled={!hasChanges || rotatedSecretLoading}+ >+ Save approved hostnames+ </LemonButton>+ )}+ </div>+ <LemonLabel>Screenshot cookie</LemonLabel>+ {restrictedReason ? (+ <p className="mb-0">+ {settings.has_secret+ ? 'A screenshot value is configured. Only project admins can view or rotate it.'+ : 'No screenshot value is configured. Ask a project admin to generate one.'}+ </p>+ ) : (+ <>+ {secret && (+ <CodeSnippet+ className="ph-no-capture ph-replay-block"+ language={Language.HTTP}+ thing="cookie"+ >{`Cookie: ${HEATMAP_SCREENSHOT_COOKIE_NAME}=${secret}`}</CodeSnippet>+ )}+ <div>+ <LemonButton+ type="secondary"+ loading={rotatedSecretLoading}+ disabledReason={+ !settings.allowed_hostnames.length+ ? 'Save at least one approved hostname first.'+ : settingsLoading || hasChanges+ ? 'Save your hostname changes first.'+ : undefined+ }+ onClick={() => {+ if (!settings.has_secret) {+ rotateSecret()+ return+ }+ LemonDialog.open({+ title: 'Rotate the screenshot value?',+ description:+ 'New screenshots will use the new value. Replace the old value in your bot protection rule to restore access and revoke the old value.',+ primaryButton: { children: 'Rotate value', onClick: rotateSecret },+ secondaryButton: { children: 'Cancel' },+ })+ }}+ >+ {settings.has_secret ? 'Rotate value' : 'Generate screenshot value'}+ </LemonButton>+ </div>+ </>+ )}+ <p className="mb-0">+ Match the exact cookie value and approved hostname in your rule. Exempt only the bot checks that block+ screenshots. Keep authentication, rate limits, and other security rules enabled.+ </p>+ <p className="text-secondary mb-0">+ The rendering service and approved HTTPS hosts receive this credential. It stays usable until you remove+ it from your bot protection rule, even after rotating it here. Hostname approval does not restrict paths+ or ports. Screenshots cannot use it to log in.+ </p>+ </div>+ )+}diff --git a/products/web_analytics/frontend/heatmaps/components/heatmapScreenshotSettingsLogic.test.ts b/products/web_analytics/frontend/heatmaps/components/heatmapScreenshotSettingsLogic.test.tsnew file mode 100644index 000000000000..e3561503168a--- /dev/null+++ b/products/web_analytics/frontend/heatmaps/components/heatmapScreenshotSettingsLogic.test.ts@@ -0,0 +1,111 @@+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'++import { expectLogic } from 'kea-test-utils'++import { teamLogic } from 'scenes/teamLogic'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'++import { screenshotAccessNotice, screenshotHostnameSuggestions } from '../heatmapScreenshotCookie'+import { heatmapScreenshotSettingsLogic } from './heatmapScreenshotSettingsLogic'++describe('screenshot access settings', () => {+ it('explains when the installation has disabled cookie delivery despite complete project settings', () => {+ expect(+ screenshotAccessNotice('https://www.example.com', {+ allowed_hostnames: ['www.example.com'],+ has_secret: true,+ cookie_delivery_enabled: false,+ })+ ).toContain('cookie delivery is disabled')+ })++ it('suggests exact toolbar hostnames without expanding wildcards or shared hosting domains', () => {+ expect(+ screenshotHostnameSuggestions([+ 'https://WWW.Example.com/path',+ 'https://www.example.com',+ 'https://*.example.com',+ 'https://customer.github.io',+ 'http://127.0.0.1',+ 'invalid',+ ])+ ).toEqual(['customer.github.io', 'www.example.com'])+ })++ it.each([+ ['https://www.example.com', true, ['www.example.com'], null],+ ['https://child.www.example.com', true, ['www.example.com'], 'without a bypass cookie'],+ ['https://www.example.com', false, ['www.example.com'], 'without a bypass cookie'],+ ['https://www.example.com', true, [], 'without a bypass cookie'],+ ['http://www.example.com', true, ['www.example.com'], 'uses HTTP'],+ ] as const)('explains cookie delivery for %s, secret=%s, approvals=%j', (url, hasSecret, hostnames, expected) => {+ const notice = screenshotAccessNotice(url, {+ allowed_hostnames: [...hostnames],+ has_secret: hasSecret,+ cookie_delivery_enabled: true,+ })+ if (expected === null) {+ expect(notice).toBeNull()+ } else {+ expect(notice).toContain(expected)+ }+ })++ it('keeps toolbar suggestions unapproved until the admin saves, and preserves drafts on failure', async () => {+ useMocks({+ get: {+ '/api/projects/:id/heatmap_screenshot/settings/': {+ allowed_hostnames: [],+ has_secret: true,+ cookie_delivery_enabled: true,+ },+ },+ patch: {+ '/api/projects/:id/heatmap_screenshot/settings/': () => [+ 400,+ { type: 'validation_error', code: 'invalid_input', detail: 'Enter an exact hostname.' },+ ],+ },+ })+ initKeaTests()+ teamLogic.mount()+ teamLogic.actions.loadCurrentTeamSuccess({ ...MOCK_DEFAULT_TEAM, app_urls: ['https://www.example.com'] })+ const logic = heatmapScreenshotSettingsLogic({ teamId: MOCK_DEFAULT_TEAM.id })+ logic.mount()+ await expectLogic(logic)+ .toFinishAllListeners()+ .toMatchValues({+ hostnames: [],+ settings: { allowed_hostnames: [], has_secret: true, cookie_delivery_enabled: true },+ hasChanges: false,+ })+ logic.actions.setHostnames(['https://www.example.com'])+ await expectLogic(logic, () => logic.actions.saveSettings())+ .toDispatchActions(['saveSettingsFailure'])+ .toMatchValues({+ hostnames: ['https://www.example.com'],+ settings: { allowed_hostnames: [], has_secret: true, cookie_delivery_enabled: true },+ hasChanges: true,+ })+ useMocks({+ patch: {+ '/api/projects/:id/heatmap_screenshot/settings/': {+ allowed_hostnames: ['www.example.com'],+ has_secret: true,+ cookie_delivery_enabled: true,+ },+ },+ })+ logic.actions.setHostnames(['www.example.com'])+ await expectLogic(logic, () => logic.actions.saveSettings())+ .toDispatchActions(['saveSettingsSuccess'])+ .toMatchValues({+ settings: { allowed_hostnames: ['www.example.com'], has_secret: true, cookie_delivery_enabled: true },+ hasChanges: false,+ saveError: null,+ })+ logic.unmount()+ })+})diff --git a/products/web_analytics/frontend/heatmaps/components/heatmapScreenshotSettingsLogic.ts b/products/web_analytics/frontend/heatmaps/components/heatmapScreenshotSettingsLogic.tsnew file mode 100644index 000000000000..b6ef7c58b20e--- /dev/null+++ b/products/web_analytics/frontend/heatmaps/components/heatmapScreenshotSettingsLogic.ts@@ -0,0 +1,183 @@+import { MakeLogicType, actions, afterMount, connect, kea, key, path, props, reducers, selectors } from 'kea'+import { loaders } from 'kea-loaders'++import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'+import { isAuthenticatedTeam, teamLogic } from 'scenes/teamLogic'++import * as coreApi from '~/generated/core/api'+import type { TeamPublicType, TeamType } from '~/types'++import * as api from '../../generated/api'+import type { HeatmapScreenshotSettingsApi } from '../../generated/api.schemas'+import { screenshotHostnameSuggestions } from '../heatmapScreenshotCookie'++export interface HeatmapScreenshotSettingsLogicProps {+ teamId: number+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface heatmapScreenshotSettingsLogicValues {+ currentTeam: TeamPublicType | TeamType | null // teamLogic+ hasChanges: boolean+ hostnames: string[]+ loadError: boolean+ rotatedSecret: string | null+ rotatedSecretLoading: boolean+ saveError: string | null+ secret: string | null+ settings: HeatmapScreenshotSettingsApi | null+ settingsLoading: boolean+ suggestions: string[]+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface heatmapScreenshotSettingsLogicActions {+ loadCurrentTeam: () => any // teamLogic+ loadSettings: () => any+ loadSettingsFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ loadSettingsSuccess: (+ settings: HeatmapScreenshotSettingsApi,+ payload?: any+ ) => {+ settings: HeatmapScreenshotSettingsApi+ payload?: any+ }+ rotateSecret: () => any+ rotateSecretFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ rotateSecretSuccess: (+ rotatedSecret: string | null,+ payload?: any+ ) => {+ rotatedSecret: string | null+ payload?: any+ }+ saveSettings: () => any+ saveSettingsFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ saveSettingsSuccess: (+ settings: HeatmapScreenshotSettingsApi,+ payload?: any+ ) => {+ settings: HeatmapScreenshotSettingsApi+ payload?: any+ }+ setHostnames: (hostnames: string[]) => {+ hostnames: string[]+ }+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface heatmapScreenshotSettingsLogicMeta {+ key: number+ __keaTypeGenInternalSelectorTypes: {+ secret: (currentTeam: TeamPublicType | TeamType | null, rotatedSecret: string | null) => string | null+ suggestions: (currentTeam: TeamPublicType | TeamType | null) => string[]+ hasChanges: (settings: HeatmapScreenshotSettingsApi | null, hostnames: string[]) => boolean+ }+}++export type heatmapScreenshotSettingsLogicType = MakeLogicType<+ heatmapScreenshotSettingsLogicValues,+ heatmapScreenshotSettingsLogicActions,+ HeatmapScreenshotSettingsLogicProps,+ heatmapScreenshotSettingsLogicMeta+>++export const heatmapScreenshotSettingsLogic = kea<heatmapScreenshotSettingsLogicType>([+ props({} as HeatmapScreenshotSettingsLogicProps),+ key((props) => props.teamId),+ path((key) => ['products', 'web_analytics', 'heatmaps', 'heatmapScreenshotSettingsLogic', key]),+ connect({ values: [teamLogic, ['currentTeam']], actions: [teamLogic, ['loadCurrentTeam']] }),+ actions({ setHostnames: (hostnames: string[]) => ({ hostnames }) }),+ loaders(({ props, values, actions }) => ({+ settings: [+ null as HeatmapScreenshotSettingsApi | null,+ {+ loadSettings: async () => api.heatmapScreenshotSettingsRetrieve(String(props.teamId)),+ saveSettings: async () => {+ const result = await api.heatmapScreenshotSettingsUpdate(String(props.teamId), {+ allowed_hostnames: values.hostnames,+ })+ lemonToast.success('Approved screenshot hostnames saved.')+ return result+ },+ },+ ],+ rotatedSecret: [+ null as string | null,+ {+ rotateSecret: async () => {+ const team = values.currentTeam+ if (!isAuthenticatedTeam(team) || team.id !== props.teamId) {+ throw new Error('Project changed. Reload these settings and try again.')+ }+ const result = await coreApi.organizationsProjectsRotateHeatmapsScreenshotSecretPartialUpdate(+ team.organization,+ team.project_id+ )+ actions.loadCurrentTeam()+ actions.loadSettings()+ lemonToast.success('New value ready. Replace the old value in your bot protection rule.')+ return result.heatmaps_screenshot_secret ?? null+ },+ },+ ],+ })),+ reducers({+ hostnames: [+ [] as string[],+ {+ setHostnames: (_, { hostnames }) => hostnames,+ loadSettingsSuccess: (_, { settings }) => settings.allowed_hostnames,+ saveSettingsSuccess: (_, { settings }) => settings.allowed_hostnames,+ },+ ],+ loadError: [+ false,+ { loadSettings: () => false, loadSettingsFailure: () => true, loadSettingsSuccess: () => false },+ ],+ saveError: [+ null as string | null,+ { saveSettings: () => null, saveSettingsFailure: (_, { error }) => error, setHostnames: () => null },+ ],+ }),+ selectors({+ secret: [+ (s) => [s.currentTeam, s.rotatedSecret],+ (team: TeamPublicType | TeamType | null, rotatedSecret: string | null): string | null =>+ rotatedSecret ?? (isAuthenticatedTeam(team) ? (team.heatmaps_screenshot_secret ?? null) : null),+ ],+ suggestions: [+ (s) => [s.currentTeam],+ (team: TeamPublicType | TeamType | null): string[] =>+ screenshotHostnameSuggestions(isAuthenticatedTeam(team) ? team.app_urls : []),+ ],+ hasChanges: [+ (s) => [s.settings, s.hostnames],+ (settings: HeatmapScreenshotSettingsApi | null, hostnames: string[]): boolean =>+ JSON.stringify(settings?.allowed_hostnames) !== JSON.stringify(hostnames),+ ],+ }),+ afterMount(({ actions, props }) => {+ if (props.teamId) {+ actions.loadSettings()+ }+ }),+])diff --git a/products/web_analytics/frontend/heatmaps/components/heatmapsBrowserLogic.test.ts b/products/web_analytics/frontend/heatmaps/components/heatmapsBrowserLogic.test.tsindex 07e58d157823..8056cd187435 100644--- a/products/web_analytics/frontend/heatmaps/components/heatmapsBrowserLogic.test.ts+++ b/products/web_analytics/frontend/heatmaps/components/heatmapsBrowserLogic.test.ts@@ -49,7 +49,7 @@ describe('heatmapsBrowserLogic', () => {expect(message).toContain(expected)})- it('attributes a non-2xx to the customer host and quotes what it returned', () => {+ it('reports a non-2xx and names the cookie a bot protection rule can allow', () => {const message = preflightBannerMessage({...base,framing: 'unknown',@@ -59,7 +59,9 @@ describe('heatmapsBrowserLogic', () => {expect(message).toContain('429')expect(message).toContain('local_rate_limited')- expect(message).toContain('host or CDN')+ expect(message).toContain('__ph_heatmap_render')+ expect(message).toContain('screenshot background')+ expect(message).not.toContain('firewall rules')expect(message).not.toContain('embedding')})@@ -191,6 +193,36 @@ describe('heatmapsBrowserLogic', () => {jest.restoreAllMocks()})+ it.each(['navigated', 'loaded'] as const)('ignores a queued timeout after the iframe %s', async (state) => {+ const timers = jest.spyOn(global, 'setTimeout')+ const iframe = document.createElement('iframe')+ iframe.id = 'heatmap-iframe'+ document.body.appendChild(iframe)+ const logic = heatmapsBrowserLogic()+ const unmount = logic.mount()+ try {+ await expectLogic(logic).toFinishAllListeners()+ logic.actions.setDisplayUrl('https://previous.example.com')+ const timeout = timers.mock.calls.find(([, delay]) => delay === 7500)?.[0]+ expect(timeout).toEqual(expect.any(Function))++ if (state === 'navigated') {+ logic.actions.setDisplayUrl('https://next.example.com')+ } else {+ logic.actions.onIframeLoad()+ }+ await expectLogic(logic).toFinishAllListeners()+ ;(timeout as () => void)()++ expect(logic.values.loadTimeoutBanner).toBeNull()+ expect(logic.values.loading).toBe(state === 'navigated')+ } finally {+ unmount()+ iframe.remove()+ timers.mockRestore()+ }+ })+// A frame blocked by X-Frame-Options still fires onload, and onIframeLoad nulls the load-timeout// banner via stopTrackingLoading. Before the probe result outranked it, that wiped the explanation// and the user was left with a blank frame and no message at all.diff --git a/products/web_analytics/frontend/heatmaps/components/heatmapsBrowserLogic.ts b/products/web_analytics/frontend/heatmaps/components/heatmapsBrowserLogic.tsindex b1cc8a7207c4..48081edf7131 100644--- a/products/web_analytics/frontend/heatmaps/components/heatmapsBrowserLogic.ts+++ b/products/web_analytics/frontend/heatmaps/components/heatmapsBrowserLogic.ts@@ -39,6 +39,7 @@ import { hogql } from '~/queries/utils'import { savedPreflightCreate } from 'products/web_analytics/frontend/generated/api'import type { HeatmapPreflightResponseApi } from 'products/web_analytics/frontend/generated/api.schemas'+import { HEATMAP_SCREENSHOT_COOKIE_NAME } from '../heatmapScreenshotCookie'import {ReplayIframeData,getStoredRecordingBackground,@@ -79,8 +80,9 @@ export function preflightBannerMessage(preflight: PagePreflight | null): stringconst said = preflight.body_excerpt ? ` It said: "${preflight.body_excerpt}".` : ''return (`${host} returned ${preflight.http_status} when we tried to load this page.${said} ` +- `This came from your site's host or CDN, not from PostHog. ` +- `Check its rate limits and firewall rules, then try again.`+ `Check the page and try again. If bot protection blocks automated loads, a project admin can ` ++ `approve this HTTPS hostname and configure the "${HEATMAP_SCREENSHOT_COOKIE_NAME}" cookie under ` ++ `Heatmaps in project settings. Then use a screenshot background. The live preview cannot send this cookie.`)}@@ -754,10 +756,15 @@ export const heatmapsBrowserLogic = kea<heatmapsBrowserLogicType>([},startTrackingLoading: () => {+ const loadingUrl = values.displayUrlactions.setIframeBanner(null)cache.disposables.add(() => {const timerId = setTimeout(() => {+ // A queued timeout must not report a previous page after navigation or load.+ if (!values.loading || values.displayUrl !== loadingUrl) {+ return+ }// this timer also runs on scenes that never mount an iframe// (screenshot detail, the new-heatmap form), where a load-failure// banner would be a false positivediff --git a/products/web_analytics/frontend/heatmaps/heatmapScreenshotCookie.ts b/products/web_analytics/frontend/heatmaps/heatmapScreenshotCookie.tsnew file mode 100644index 000000000000..46c734b82a09--- /dev/null+++ b/products/web_analytics/frontend/heatmaps/heatmapScreenshotCookie.ts@@ -0,0 +1,48 @@+import type { HeatmapScreenshotSettingsApi } from '../generated/api.schemas'++export const HEATMAP_SCREENSHOT_COOKIE_NAME = '__ph_heatmap_render'++export function screenshotAccessNotice(+ url: string | null,+ settings: HeatmapScreenshotSettingsApi | null+): string | null {+ if (!url || !settings) {+ return null+ }+ if (!settings.cookie_delivery_enabled) {+ return 'This screenshot will run without a bypass cookie because cookie delivery is disabled on this installation. Contact your PostHog administrator to enable it.'+ }+ try {+ const parsed = new URL(url)+ if (!['http:', 'https:'].includes(parsed.protocol)) {+ return null+ }+ if (parsed.protocol !== 'https:') {+ return 'This screenshot will run without a bypass cookie because the page uses HTTP. Use an approved HTTPS hostname if the page needs a bot protection exception.'+ }+ if (!settings.has_secret || !settings.allowed_hostnames.includes(parsed.hostname)) {+ return 'This screenshot will run without a bypass cookie. If bot protection blocks the page, ask a project admin to approve this hostname and configure the screenshot cookie.'+ }+ } catch {+ return null+ }+ return null+}++export function screenshotHostnameSuggestions(appUrls: string[]): string[] {+ return [+ ...new Set(+ appUrls.flatMap((url) => {+ try {+ const { hostname, protocol } = new URL(url)+ return ['http:', 'https:'].includes(protocol) &&+ /^[a-z0-9-]+(?:\.[a-z0-9-]+)*\.[a-z][a-z0-9-]*$/.test(hostname)+ ? [hostname]+ : []+ } catch {+ return []+ }+ })+ ),+ ].sort()+}diff --git a/products/web_analytics/frontend/heatmaps/scenes/heatmap/HeatmapNewScene.stories.tsx b/products/web_analytics/frontend/heatmaps/scenes/heatmap/HeatmapNewScene.stories.tsxindex 5fcb547c9325..e0ad3c85a288 100644--- a/products/web_analytics/frontend/heatmaps/scenes/heatmap/HeatmapNewScene.stories.tsx+++ b/products/web_analytics/frontend/heatmaps/scenes/heatmap/HeatmapNewScene.stories.tsx@@ -118,6 +118,15 @@ const meta: Meta<typeof HeatmapNewStory> = {},msw: {mocks: {+ get: {+ '/api/projects/:team_id/heatmap_screenshot/settings/': {+ allowed_hostnames: [],+ has_secret: false,+ cookie_delivery_enabled: true,+ },+ '/api/environments/:team_id/saved': { results: [], count: 0 },+ '/api/projects/:team_id/heatmaps/': { results: [] },+ },post: {'/api/environments/:team_id/query/:kind': queryMock(24),},@@ -182,6 +191,11 @@ export const AuthenticatedWithRecordings: Story = {msw: {mocks: {get: {+ '/api/projects/:team_id/heatmap_screenshot/settings/': {+ allowed_hostnames: [],+ has_secret: false,+ cookie_delivery_enabled: true,+ },'/api/environments/:team_id/session_recordings': [200,{diff --git a/products/web_analytics/frontend/heatmaps/scenes/heatmap/HeatmapNewScene.tsx b/products/web_analytics/frontend/heatmaps/scenes/heatmap/HeatmapNewScene.tsxindex 852f5c6c3907..532d7d34c09f 100644--- a/products/web_analytics/frontend/heatmaps/scenes/heatmap/HeatmapNewScene.tsx+++ b/products/web_analytics/frontend/heatmaps/scenes/heatmap/HeatmapNewScene.tsx@@ -22,6 +22,7 @@ import { HeatmapAdvancedSettings } from '../../components/HeatmapAdvancedSettingimport { HeatmapRecording } from '../../components/HeatmapRecording'import { HeatmapRecordingFallback } from '../../components/HeatmapRecordingFallback'import { heatmapsBrowserLogic, isUrlPattern } from '../../components/heatmapsBrowserLogic'+import { HeatmapScreenshotAccessNotice } from '../../components/HeatmapScreenshotAccessNotice'import { HeatmapsEnableCapture } from '../../components/HeatmapsEnableCapture'import { HeatmapsInvalidURL } from '../../components/HeatmapsInvalidURL'import { HeatmapCreationStep, heatmapCreationLogic } from './heatmapCreationLogic'@@ -262,7 +263,7 @@ function ChoosePageStep(): JSX.Element {function PublicBackgroundChoice(): JSX.Element {const logic = heatmapLogic({ id: 'new' })- const { type } = useValues(logic)+ const { type, displayUrl } = useValues(logic)const { setType } = useActions(logic)const { isDisplayUrlAuthorized, authorizationDisabledReason, preflightMessage } = useValues(heatmapCreationLogic)const { authorizeDisplayUrl } = useActions(heatmapCreationLogic)@@ -326,14 +327,17 @@ function PublicBackgroundChoice(): JSX.Element {) : null}{type === 'screenshot' ? (- <HeatmapAdvancedSettings- dataUrlPlaceholderFallback=""- dataUrlHelp={null}- consentHelp="Ask the browser to close cookie or consent popups before capturing the screenshot. This can slow down or fail the render on some sites, so it is off by default."- showDataUrl={false}- showConsent- header="Screenshot options"- />+ <>+ <HeatmapScreenshotAccessNotice url={displayUrl} />+ <HeatmapAdvancedSettings+ dataUrlPlaceholderFallback=""+ dataUrlHelp={null}+ consentHelp="Ask the browser to close cookie or consent popups before capturing the screenshot. This can slow down or fail the render on some sites, so it is off by default."+ showDataUrl={false}+ showConsent+ header="Screenshot options"+ />+ </>) : null}</div>)diff --git a/products/web_analytics/frontend/heatmaps/scenes/heatmap/HeatmapScene.stories.tsx b/products/web_analytics/frontend/heatmaps/scenes/heatmap/HeatmapScene.stories.tsxindex 05adc1d84c47..87c4ebe31126 100644--- a/products/web_analytics/frontend/heatmaps/scenes/heatmap/HeatmapScene.stories.tsx+++ b/products/web_analytics/frontend/heatmaps/scenes/heatmap/HeatmapScene.stories.tsx@@ -38,6 +38,11 @@ const meta: Meta = {decorators: [mswDecorator({get: {+ '/api/projects/:team_id/heatmap_screenshot/settings/': {+ allowed_hostnames: [],+ has_secret: false,+ cookie_delivery_enabled: true,+ },'/api/projects/:team_id/saved/hm_gen/': generatingSaved,'/api/projects/:team_id/heatmap_screenshots/:id/content/': () => [202, generatingSaved],},