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(marketing): isolate page visibility filter state (#101722)

Javier Bahamondes2bdbedea9542
diff --git a/docs/internal/marketing-page-visibility.md b/docs/internal/marketing-page-visibility.md
index 50185e40ba45..606c876b764d 100644
--- a/docs/internal/marketing-page-visibility.md
+++ b/docs/internal/marketing-page-visibility.md
@@ -12,3 +12,5 @@ Google search and crawler sections retain the existing setup requirements and em
The original Web Analytics Page performance tab keeps its existing feature flag and URL.
Marketing-specific AI tools and attached context are inactive on Page visibility because its controls use independent Web Analytics state.
+
+Page visibility keeps its filters, dates, comparison and conversion goal separate from Web Analytics, including across reloads. Each surface restores only its own URLs.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 07acd4e14a72..0679d8f8fa10 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -10445,9 +10445,9 @@ snapshots:
scenes-app-web-analytics-pageperformancemetriccard--without-sparkline--light:
hash: v1.k794b7964.e7ebd4a413d617f5c6e38419027f3affa40cd1da68af95d686ccc152860dbb5b.Fq3Sz8vrvMYKZQk1yKdN-t5SvImO0L7rvFjFf0ZyfFc
scenes-app-web-analytics-search-ai--marketing-page-visibility--dark:
- hash: v1.k794b7964.f69eb2f5c70318b379f6cc0cb56670ad4819f50de977753c33e523e011e59eea.YJfl2G5bQdVQdJFxX310xsMOjKUFHa43biO03CLtQjo
+ hash: v1.k794b7964.6e567e34e53b86f8a40faf70fda19ed4d6fe312e80fe1bfb13393fb0b7674282.0i9AuFbJaUyJ6givISUFfq-8-C2vt42R_qGBtm15vrA
scenes-app-web-analytics-search-ai--marketing-page-visibility--light:
- hash: v1.k794b7964.be220f9f6748bf9d0106a7fa300826123171387a8340375d07cba8bc26e749c9.m46u7u1aPe9ntSRmWfuB2LKSF93xDG5SmvArqb29s6g
+ hash: v1.k794b7964.c00ab05d9c344c5ad05ba2f164a3d3c751d8d0aae6703064d2c7eff651b2c0d1.Y5c0f7fvs4xXWnhne4D0Z0Ge97q6VeaSgPoOb53h_fU
scenes-app-web-analytics-search-ai--web-analytics-page-performance--dark:
hash: v1.k794b7964.68dca7f6cb1918fc9d2c5fd7382628ea8b7420354667f7d870c71317285afdba.ATRlxNrQzCTs0o8800vW-QDfwij5sum9pIg331-0jUA
scenes-app-web-analytics-search-ai--web-analytics-page-performance--light:
diff --git a/frontend/src/scenes/marketing-analytics/MarketingAnalyticsScene.tsx b/frontend/src/scenes/marketing-analytics/MarketingAnalyticsScene.tsx
index 72b90284b644..00a47260471b 100644
--- a/frontend/src/scenes/marketing-analytics/MarketingAnalyticsScene.tsx
+++ b/frontend/src/scenes/marketing-analytics/MarketingAnalyticsScene.tsx
@@ -15,10 +15,13 @@ import { urls } from 'scenes/urls'
import { QueryTile } from 'scenes/web-analytics/common'
import { PagePerformance } from 'scenes/web-analytics/PagePerformance'
import { PagePerformanceFilters } from 'scenes/web-analytics/PagePerformanceFilters'
+import { pagePerformanceLogic } from 'scenes/web-analytics/pagePerformanceLogic'
import { AttributionTab } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionTab'
import { RetentionTab } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/components/RetentionTab/RetentionTab'
import { UtmAuditTab } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/components/UtmAuditTab/UtmAuditTab'
import { WebQuery } from 'scenes/web-analytics/tiles/WebAnalyticsTile'
+import { webAnalyticsFilterLogic } from 'scenes/web-analytics/webAnalyticsFilterLogic'
+import { webAnalyticsLogic } from 'scenes/web-analytics/webAnalyticsLogic'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
@@ -304,10 +307,14 @@ const MarketingAnalyticsContent = (): JSX.Element => {
key: MarketingAnalyticsTab.PAGE_VISIBILITY,
label: 'Page visibility',
content: (
- <>
- <PagePerformanceFilters tabs={<></>} />
- <PagePerformance />
- </>
+ <BindLogic logic={webAnalyticsLogic} props={{ context: 'page-visibility' }}>
+ <BindLogic logic={webAnalyticsFilterLogic} props={{ context: 'page-visibility' }}>
+ <BindLogic logic={pagePerformanceLogic} props={{ context: 'page-visibility' }}>
+ <PagePerformanceFilters tabs={<></>} />
+ <PagePerformance />
+ </BindLogic>
+ </BindLogic>
+ </BindLogic>
),
},
]
diff --git a/frontend/src/scenes/web-analytics/PagePerformance.tsx b/frontend/src/scenes/web-analytics/PagePerformance.tsx
index 9c3f99479ea8..569213b42d93 100644
--- a/frontend/src/scenes/web-analytics/PagePerformance.tsx
+++ b/frontend/src/scenes/web-analytics/PagePerformance.tsx
@@ -165,25 +165,28 @@ const AiTrendCard = ({
query: InsightVizNode
tileId: TileId
uniqueKey: string
-}): JSX.Element => (
- <div className="@min-[48rem]/search-ai:col-span-2 min-h-88 min-w-0 flex flex-col">
- <SearchAndAiQuery
- uniqueKey={uniqueKey}
- query={query}
- insightProps={createPagePerformanceInsightProps(tileId)}
- renderQuery={(insightProps) => (
- <WebQuery
- attachTo={webAnalyticsLogic}
- uniqueKey={uniqueKey}
- query={query}
- insightProps={insightProps}
- tileId={tileId}
- headerSlot={<SearchAndAiTrendHeader title={title} />}
- />
- )}
- />
- </div>
-)
+}): JSX.Element => {
+ const logic = useMountedLogic(webAnalyticsLogic)
+ return (
+ <div className="@min-[48rem]/search-ai:col-span-2 min-h-88 min-w-0 flex flex-col">
+ <SearchAndAiQuery
+ uniqueKey={uniqueKey}
+ query={query}
+ insightProps={createPagePerformanceInsightProps(tileId)}
+ renderQuery={(insightProps) => (
+ <WebQuery
+ attachTo={logic}
+ uniqueKey={uniqueKey}
+ query={query}
+ insightProps={insightProps}
+ tileId={tileId}
+ headerSlot={<SearchAndAiTrendHeader title={title} />}
+ />
+ )}
+ />
+ </div>
+ )
+}
export const PagePerformance = (): JSX.Element => {
useMountedLogic(pagePerformanceLogic)
diff --git a/frontend/src/scenes/web-analytics/pagePerformanceLogic.ts b/frontend/src/scenes/web-analytics/pagePerformanceLogic.ts
index 57232a12c382..4d3a024ed48c 100644
--- a/frontend/src/scenes/web-analytics/pagePerformanceLogic.ts
+++ b/frontend/src/scenes/web-analytics/pagePerformanceLogic.ts
@@ -1,4 +1,7 @@
import {
+ LogicWrapper,
+ key,
+ props,
MakeLogicType,
actions,
afterMount,
@@ -64,6 +67,7 @@ import {
import { getDashboardItemId } from './insightsUtils'
import { webAnalyticsLogic } from './webAnalyticsLogic'
import type { DateFilterState } from './webAnalyticsLogic'
+import { WebAnalyticsLogicProps } from './webAnalyticsLogicProps'
const PAGE_PERFORMANCE_EVENTS = "('$pageview', '$screen', '$http_log')"
@@ -803,16 +807,18 @@ export interface pagePerformanceLogicMeta {
export type pagePerformanceLogicType = MakeLogicType<
pagePerformanceLogicValues,
pagePerformanceLogicActions,
- Record<string, any>,
+ WebAnalyticsLogicProps,
pagePerformanceLogicMeta
>
-export const pagePerformanceLogic = kea<pagePerformanceLogicType>([
- path(['scenes', 'webAnalytics', 'pagePerformanceLogic']),
- connect(() => ({
+export const pagePerformanceLogic: LogicWrapper<pagePerformanceLogicType> = kea<pagePerformanceLogicType>([
+ props({} as WebAnalyticsLogicProps),
+ key((props) => props.context ?? 'web-analytics'),
+ path((key) => ['scenes', key === 'page-visibility' ? 'pageVisibility' : 'webAnalytics', 'pagePerformanceLogic']),
+ connect((props: WebAnalyticsLogicProps) => ({
actions: [dataNodeCollectionLogic({ key: WEB_ANALYTICS_DATA_COLLECTION_NODE_ID }), ['reloadAll']],
values: [
- webAnalyticsLogic,
+ webAnalyticsLogic(props),
[
'dateFilter',
'shouldFilterTestAccounts as filterTestAccounts',
diff --git a/frontend/src/scenes/web-analytics/webAnalyticsFilterLogic.ts b/frontend/src/scenes/web-analytics/webAnalyticsFilterLogic.ts
index 5eab5ad6dc2c..d0b617b27c9a 100644
--- a/frontend/src/scenes/web-analytics/webAnalyticsFilterLogic.ts
+++ b/frontend/src/scenes/web-analytics/webAnalyticsFilterLogic.ts
@@ -1,4 +1,16 @@
-import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
+import {
+ LogicWrapper,
+ key,
+ props,
+ MakeLogicType,
+ actions,
+ connect,
+ kea,
+ listeners,
+ path,
+ reducers,
+ selectors,
+} from 'kea'
import { AuthorizedUrlListType, authorizedUrlListLogic } from 'lib/components/AuthorizedUrlList/authorizedUrlListLogic'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
@@ -15,9 +27,13 @@ import {
} from '~/types'
import { DeviceType, INITIAL_WEB_ANALYTICS_FILTER } from './common'
+import { WebAnalyticsLogicProps } from './webAnalyticsLogicProps'
const teamId = window.POSTHOG_APP_CONTEXT?.current_team?.id
-const persistConfig = { persist: true, prefix: `${teamId}__` }
+const persistConfig = (props: WebAnalyticsLogicProps): { persist: true; prefix: string } => ({
+ persist: true as const,
+ prefix: `${teamId}__${props.context === 'page-visibility' ? 'page_visibility__' : ''}`,
+})
const eventFilter = (key: string, value: string | string[]): WebAnalyticsPropertyFilter => ({
type: PropertyFilterType.Event,
@@ -123,6 +139,7 @@ export interface webAnalyticsFilterLogicActions {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface webAnalyticsFilterLogicMeta {
+ key: 'page-visibility' | 'web-analytics'
__keaTypeGenInternalSelectorTypes: {
hasHostFilter: (rawWebAnalyticsFilters: WebAnalyticsPropertyFilters) => boolean
authorizedDomains: (rawAuthorizedUrls: string[]) => string[]
@@ -141,12 +158,14 @@ export interface webAnalyticsFilterLogicMeta {
export type webAnalyticsFilterLogicType = MakeLogicType<
webAnalyticsFilterLogicValues,
webAnalyticsFilterLogicActions,
- Record<string, any>,
+ WebAnalyticsLogicProps,
webAnalyticsFilterLogicMeta
>
-export const webAnalyticsFilterLogic = kea<webAnalyticsFilterLogicType>([
- path(['scenes', 'webAnalytics', 'webAnalyticsFilterLogic']),
+export const webAnalyticsFilterLogic: LogicWrapper<webAnalyticsFilterLogicType> = kea<webAnalyticsFilterLogicType>([
+ props({} as WebAnalyticsLogicProps),
+ key((props) => props.context ?? 'web-analytics'),
+ path((key) => ['scenes', key === 'page-visibility' ? 'pageVisibility' : 'webAnalytics', 'webAnalyticsFilterLogic']),
connect(() => ({
values: [
authorizedUrlListLogic({
@@ -181,10 +200,10 @@ export const webAnalyticsFilterLogic = kea<webAnalyticsFilterLogicType>([
loadPreset: (filters: WebAnalyticsFiltersConfig) => ({ filters }),
clearFilters: true,
}),
- reducers({
+ reducers(({ props }) => ({
rawWebAnalyticsFilters: [
INITIAL_WEB_ANALYTICS_FILTER,
- persistConfig,
+ persistConfig(props),
{
setWebAnalyticsFilters: (_, { webAnalyticsFilters }) => webAnalyticsFilters,
clearFilters: () => INITIAL_WEB_ANALYTICS_FILTER,
@@ -265,7 +284,7 @@ export const webAnalyticsFilterLogic = kea<webAnalyticsFilterLogicType>([
],
domainFilter: [
null as string | null,
- persistConfig,
+ persistConfig(props),
{
setDomainFilter: (_: string | null, payload: { domain: string | null }) => {
const { domain } = payload
@@ -288,7 +307,7 @@ export const webAnalyticsFilterLogic = kea<webAnalyticsFilterLogicType>([
],
deviceTypeFilter: [
null as DeviceType | null,
- persistConfig,
+ persistConfig(props),
{
setDeviceTypeFilter: (_: DeviceType | null, { deviceType }: { deviceType: DeviceType | null }) =>
deviceType,
@@ -298,7 +317,7 @@ export const webAnalyticsFilterLogic = kea<webAnalyticsFilterLogicType>([
],
countryFilter: [
null as string | null,
- persistConfig,
+ persistConfig(props),
{
setCountryFilter: (_: string | null, { countryCode }: { countryCode: string | null }) => countryCode,
clearFilters: () => null,
@@ -307,7 +326,7 @@ export const webAnalyticsFilterLogic = kea<webAnalyticsFilterLogicType>([
],
referrerFilter: [
null as string | null,
- persistConfig,
+ persistConfig(props),
{
setReferrerFilter: (_: string | null, { referrer }: { referrer: string | null }) => referrer,
clearFilters: () => null,
@@ -316,14 +335,14 @@ export const webAnalyticsFilterLogic = kea<webAnalyticsFilterLogicType>([
],
compareFilter: [
{ compare: true } as CompareFilter,
- persistConfig,
+ persistConfig(props),
{
setCompareFilter: (_, { compareFilter }) => compareFilter,
clearFilters: () => ({ compare: true }),
loadPreset: (_, { filters }) => (filters.compareFilter as CompareFilter) ?? { compare: true },
},
],
- }),
+ })),
selectors({
hasHostFilter: [
(s) => [s.rawWebAnalyticsFilters],
diff --git a/frontend/src/scenes/web-analytics/webAnalyticsLogic.test.ts b/frontend/src/scenes/web-analytics/webAnalyticsLogic.test.ts
index 24f44f307076..ed07877c4792 100644
--- a/frontend/src/scenes/web-analytics/webAnalyticsLogic.test.ts
+++ b/frontend/src/scenes/web-analytics/webAnalyticsLogic.test.ts
@@ -16,6 +16,7 @@ import { botAnalyticsLogic } from './botAnalyticsLogic'
import { GraphsTab, ProductTab, TileId } from './common'
import { FOCUS_MODE_TILE_IDS } from './focus-mode/focusModeMapping'
import { WebAnalyticsConcern, getFocusModeOnboardingSeenKey } from './focus-mode/types'
+import { pagePerformanceLogic } from './pagePerformanceLogic'
import {
MarketingAnalyticsTab,
marketingAnalyticsLogic,
@@ -553,6 +554,11 @@ describe('webAnalyticsLogic URL restoration', () => {
['/web/page-performance', {}, FEATURE_FLAGS.WEB_ANALYTICS_PAGE_PERFORMANCE],
['/marketing', { tab: 'page-visibility' }, FEATURE_FLAGS.MARKETING_ANALYTICS_NEW_DASHBOARD],
])('keeps all page performance controls in the shareable URL at %s', async (pathname, searchParams, flag) => {
+ if (pathname === '/marketing') {
+ logic.unmount()
+ logic = webAnalyticsLogic({ context: 'page-visibility' })
+ logic.mount()
+ }
featureFlagLogic.actions.setFeatureFlags([flag], { [flag]: true })
router.actions.push(pathname, searchParams)
await expectLogic(logic).toFinishAllListeners()
@@ -655,6 +661,11 @@ describe('webAnalyticsLogic URL restoration', () => {
['/web/page-performance', {}, FEATURE_FLAGS.WEB_ANALYTICS_PAGE_PERFORMANCE],
['/marketing', { tab: 'page-visibility' }, FEATURE_FLAGS.MARKETING_ANALYTICS_NEW_DASHBOARD],
])('applies property filters from a shared page performance URL at %s', async (pathname, searchParams, flag) => {
+ if (pathname === '/marketing') {
+ logic.unmount()
+ logic = webAnalyticsLogic({ context: 'page-visibility' })
+ logic.mount()
+ }
featureFlagLogic.actions.setFeatureFlags([flag], { [flag]: true })
router.actions.push(pathname, { ...searchParams, filters: [FILTER_A] })
await expectLogic(logic).toFinishAllListeners()
@@ -674,6 +685,81 @@ describe('webAnalyticsLogic URL restoration', () => {
}
})
+ it('isolates page visibility state, URLs and persistence from Web Analytics in both directions', async () => {
+ featureFlagLogic.actions.setFeatureFlags(
+ [FEATURE_FLAGS.MARKETING_ANALYTICS_NEW_DASHBOARD, FEATURE_FLAGS.WEB_ANALYTICS_PAGE_PERFORMANCE],
+ {
+ [FEATURE_FLAGS.MARKETING_ANALYTICS_NEW_DASHBOARD]: true,
+ [FEATURE_FLAGS.WEB_ANALYTICS_PAGE_PERFORMANCE]: true,
+ }
+ )
+ const marketing = webAnalyticsLogic({ context: 'page-visibility' })
+ let unmountMarketing = marketing.mount()
+ try {
+ router.actions.push('/web/page-performance')
+ logic.actions.setDates('-30d', null)
+ logic.actions.setWebAnalyticsFilters([FILTER_A])
+ logic.actions.setCountryFilter('US')
+ logic.actions.setConversionGoal({ actionId: 42 })
+ logic.actions.setCompareFilter({ compare: false })
+ await expectLogic(logic).toFinishAllListeners()
+
+ router.actions.push('/marketing', {
+ tab: 'page-visibility',
+ date_from: '-14d',
+ interval: 'week',
+ filters: [FILTER_B],
+ country: 'CL',
+ 'conversionGoal.actionId': 43,
+ compare_filter: { compare: true },
+ })
+ await expectLogic(marketing).toFinishAllListeners()
+ expect(marketing.values.dateFilter).toMatchObject({ dateFrom: '-14d', interval: 'week' })
+ expect(marketing.values.rawWebAnalyticsFilters).toEqual([FILTER_B])
+ expect(logic.values.dateFilter.dateFrom).toBe('-30d')
+ expect(logic.values.rawWebAnalyticsFilters).toEqual([FILTER_A])
+ expect(logic.values.countryFilter).toBe('US')
+ expect(logic.values.conversionGoal).toEqual({ actionId: 42 })
+ expect(logic.values.rawCompareFilter).toEqual({ compare: false })
+
+ const report = pagePerformanceLogic.build({ context: 'page-visibility' })
+ expect(report.values.pageCandidateQuery.dateRange?.date_from).toBe('-14d')
+ expect(report.values.pageCandidateQuery.properties).toEqual(marketing.values.webAnalyticsFilters)
+ expect(report.values.conversionGoal).toEqual({ actionId: 43 })
+
+ marketing.actions.setCountryFilter(null)
+ marketing.actions.setDates('-7d', null)
+ await expectLogic(marketing).toFinishAllListeners()
+ expect(router.values.location.pathname.endsWith('/marketing')).toBe(true)
+ expect(router.values.searchParams.country).toBeUndefined()
+ expect(logic.values.countryFilter).toBe('US')
+
+ unmountMarketing()
+ unmountMarketing = marketing.mount()
+ expect(marketing.values.dateFilter.dateFrom).toBe('-7d')
+ expect(marketing.values.countryFilter).toBeNull()
+
+ router.actions.push('/web/page-performance', { date_from: '-90d', filters: [FILTER_A] })
+ logic.actions.setCountryFilter('CA')
+ logic.actions.setWebAnalyticsFilters([FILTER_A, FILTER_B])
+ await expectLogic(logic).toFinishAllListeners()
+ expect(marketing.values.dateFilter.dateFrom).toBe('-7d')
+ expect(marketing.values.rawWebAnalyticsFilters).toEqual([FILTER_B])
+ expect(marketing.values.countryFilter).toBeNull()
+ expect(marketing.values.conversionGoal).toEqual({ actionId: 43 })
+ expect(marketing.values.rawCompareFilter).toEqual({ compare: true })
+ expect(router.values.location.pathname.endsWith('/web/page-performance')).toBe(true)
+
+ logic.unmount()
+ logic = webAnalyticsLogic()
+ logic.mount()
+ expect(logic.values.dateFilter.dateFrom).toBe('-90d')
+ expect(logic.values.countryFilter).toBe('CA')
+ } finally {
+ unmountMarketing()
+ }
+ })
+
const enableBackNavReset = (): void => {
featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.WEB_ANALYTICS_BACK_NAVIGATION_RESET], {
[FEATURE_FLAGS.WEB_ANALYTICS_BACK_NAVIGATION_RESET]: true,
diff --git a/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx b/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
index 855adcb37275..d0b65b24c3fb 100644
--- a/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
+++ b/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
@@ -1,4 +1,7 @@
import {
+ LogicWrapper,
+ key,
+ props,
MakeLogicType,
BreakPointFunction,
actions,
@@ -12,6 +15,7 @@ import {
} from 'kea'
import { loaders } from 'kea-loaders'
import { router, urlToAction } from 'kea-router'
+import { UrlToActionPayload } from 'kea-router/lib/types'
import { subscriptions } from 'kea-subscriptions'
import { windowValues } from 'kea-window-values'
import posthog from 'posthog-js'
@@ -136,6 +140,7 @@ import { webAnalyticsHealthLogic } from './health'
import { IncludeHostToggle } from './IncludeHostToggle'
import { getDashboardItemId, getNewInsightUrlFactory } from './insightsUtils'
import { webAnalyticsFilterLogic } from './webAnalyticsFilterLogic'
+import { WebAnalyticsLogicProps } from './webAnalyticsLogicProps'
export interface DateFilterState {
dateFrom: string | null
@@ -522,6 +527,7 @@ export interface webAnalyticsLogicActions {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface webAnalyticsLogicMeta {
+ key: 'page-visibility' | 'web-analytics'
__keaTypeGenInternalSelectorTypes: {
compareFilter: (rawCompareFilter: CompareFilter, dateFilter: DateFilterState) => CompareFilter
preAggregatedEnabled: (
@@ -685,13 +691,15 @@ export interface webAnalyticsLogicMeta {
export type webAnalyticsLogicType = MakeLogicType<
webAnalyticsLogicValues,
webAnalyticsLogicActions,
- Record<string, any>,
+ WebAnalyticsLogicProps,
webAnalyticsLogicMeta
>
-export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
- path(['scenes', 'webAnalytics', 'webAnalyticsSceneLogic']),
- connect(() => ({
+export const webAnalyticsLogic: LogicWrapper<webAnalyticsLogicType> = kea<webAnalyticsLogicType>([
+ props({} as WebAnalyticsLogicProps),
+ key((props) => props.context ?? 'web-analytics'),
+ path((key) => ['scenes', key === 'page-visibility' ? 'pageVisibility' : 'webAnalytics', 'webAnalyticsSceneLogic']),
+ connect((props: WebAnalyticsLogicProps) => ({
values: [
featureFlagLogic,
['featureFlags'],
@@ -708,7 +716,7 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
productTourId: null,
}),
['authorizedUrls', 'showProposedURLForm', 'isProposedUrlSubmitting', 'suggestions as urlSuggestions'],
- webAnalyticsFilterLogic,
+ webAnalyticsFilterLogic(props),
[
'rawWebAnalyticsFilters',
'domainFilter',
@@ -736,7 +744,7 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
'newUrl as newAuthorizedUrl',
'cancelProposingUrl as cancelProposingAuthorizedUrl',
],
- webAnalyticsFilterLogic,
+ webAnalyticsFilterLogic(props),
[
'setWebAnalyticsFilters',
'togglePropertyFilter',
@@ -853,8 +861,10 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
},
},
})),
- reducers(() => {
- const persistConfig = buildTeamScopedPersistenceConfig()
+ reducers(({ props }) => {
+ const persistConfig = buildTeamScopedPersistenceConfig(
+ props.context === 'page-visibility' ? 'page_visibility__' : ''
+ )
// The precompute toggle changed from opt-in (default `false`) to a tri-state where
// `null` means "use the team default". Legacy users persisted the old `false`, which
// would now read as an explicit opt-out. A versioned prefix orphans that stale value so
@@ -3075,7 +3085,7 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
actions.loadShouldShowGeoIPQueries()
}),
- trackedActionToUrl(({ values, cache }) => {
+ trackedActionToUrl(({ values, cache, props }) => {
const buildStateUrl = (): string => {
const urlParams = new URLSearchParams(router.values.location.search)
@@ -3182,8 +3192,7 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
urlParams.delete('referrer')
}
const basePath =
- router.values.location.pathname.endsWith('/marketing') &&
- router.values.searchParams.tab === 'page-visibility'
+ props.context === 'page-visibility'
? urls.marketingAnalyticsApp()
: urls.webAnalyticsPagePerformance()
return `${basePath}${urlParams.toString() ? '?' + urlParams.toString() : ''}`
@@ -3301,7 +3310,13 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
// tells kea-router to skip the write, breaking the actionToUrl <-> urlToAction cascade that
// otherwise fires a burst of redundant evaluations and trips the rapid-URL-change detector.
// A single corrective write is emitted afterwards by `reconcileUrlAfterRestore`.
- if (cache.applyUrlStateDepth > 0) {
+ const isMarketingRoute = router.values.location.pathname.endsWith('/marketing')
+ if (
+ (props.context === 'page-visibility'
+ ? !isMarketingRoute || router.values.searchParams.tab !== 'page-visibility'
+ : isMarketingRoute) ||
+ cache.applyUrlStateDepth > 0
+ ) {
return undefined
}
return buildStateUrl()
@@ -3333,7 +3348,7 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
}
}),
- urlToAction(({ actions, values, cache }) => {
+ urlToAction(({ actions, values, cache, props }): UrlToActionPayload<webAnalyticsLogicType> => {
const applyUrlState = (
{ productTab = ProductTab.ANALYTICS }: { productTab?: ProductTab },
{
@@ -3391,8 +3406,7 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
productTab === ProductTab.PAGE_PERFORMANCE &&
!values.featureFlags[FEATURE_FLAGS.WEB_ANALYTICS_PAGE_PERFORMANCE] &&
!(
- router.values.location.pathname.endsWith('/marketing') &&
- router.values.searchParams.tab === 'page-visibility' &&
+ props.context === 'page-visibility' &&
values.featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_NEW_DASHBOARD]
)
) {
@@ -3604,12 +3618,17 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
}
}
+ if (props.context === 'page-visibility') {
+ return {
+ '/marketing': (_, searchParams) => {
+ if (searchParams.tab === 'page-visibility') {
+ toAction({ productTab: ProductTab.PAGE_PERFORMANCE }, searchParams)
+ }
+ },
+ }
+ }
+
return {
- '/marketing': (_, searchParams) => {
- if (searchParams.tab === 'page-visibility') {
- toAction({ productTab: ProductTab.PAGE_PERFORMANCE }, searchParams)
- }
- },
'/web': toAction,
'/web/bots': (_, searchParams) => {
toAction({ productTab: ProductTab.BOT_ANALYTICS }, searchParams)
diff --git a/frontend/src/scenes/web-analytics/webAnalyticsLogicProps.ts b/frontend/src/scenes/web-analytics/webAnalyticsLogicProps.ts
new file mode 100644
index 000000000000..0e6e8828c1f1
--- /dev/null
+++ b/frontend/src/scenes/web-analytics/webAnalyticsLogicProps.ts
@@ -0,0 +1,3 @@
+export interface WebAnalyticsLogicProps {
+ context?: 'web-analytics' | 'page-visibility'
+}