: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): move test accounts toggle to filters popover (#52155)
Lucas Ricoy3c727bc5965d
diff --git a/frontend/src/scenes/web-analytics/WebAnalyticsHeaderButtons.tsx b/frontend/src/scenes/web-analytics/WebAnalyticsHeaderButtons.tsxindex 50699b2a8702..ac7ba289be5d 100644--- a/frontend/src/scenes/web-analytics/WebAnalyticsHeaderButtons.tsx+++ b/frontend/src/scenes/web-analytics/WebAnalyticsHeaderButtons.tsx@@ -1,7 +1,7 @@import { useActions, useValues } from 'kea'import { useState } from 'react'-import { IconBolt } from '@posthog/icons'+import { IconBolt, IconPerson } from '@posthog/icons'import { LiveUserCount } from 'lib/components/LiveUserCount'import { FEATURE_FLAGS } from 'lib/constants'@@ -12,12 +12,15 @@ import { Popover } from 'lib/lemon-ui/Popover'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { copyToClipboard } from 'lib/utils/copyToClipboard'import { teamLogic } from 'scenes/teamLogic'+import { webAnalyticsLogic } from 'scenes/web-analytics/webAnalyticsLogic'import { WebAnalyticsMenu } from 'scenes/web-analytics/WebAnalyticsMenu'export function WebAnalyticsHeaderButtons(): JSX.Element {const { featureFlags } = useValues(featureFlagLogic)const { currentTeam } = useValues(teamLogic)const { updateCurrentTeam } = useActions(teamLogic)+ const { shouldFilterTestAccounts } = useValues(webAnalyticsLogic)+ const { setShouldFilterTestAccounts } = useActions(webAnalyticsLogic)const [showPopover, setShowPopover] = useState(false)const hasFeatureFlag = featureFlags[FEATURE_FLAGS.SETTINGS_WEB_ANALYTICS_PRE_AGGREGATED_TABLES]@@ -59,6 +62,17 @@ export function WebAnalyticsHeaderButtons(): JSX.Element {data-attr="web-analytics-share-button"/>)}+ <LemonButton+ type="secondary"+ size="small"+ icon={<IconPerson />}+ tooltip="Filter out internal and test users"+ tooltipPlacement="top"+ onClick={() => setShouldFilterTestAccounts(!shouldFilterTestAccounts)}+ data-attr="web-analytics-filter-test-accounts"+ >+ Filter test accounts <LemonSwitch checked={shouldFilterTestAccounts} className="ml-1" />+ </LemonButton>{hasFeatureFlag && (<Popovervisible={showPopover}diff --git a/frontend/src/scenes/web-analytics/WebAnalyticsMenu.tsx b/frontend/src/scenes/web-analytics/WebAnalyticsMenu.tsxindex dde39d2f4710..2c1496bc9a28 100644--- a/frontend/src/scenes/web-analytics/WebAnalyticsMenu.tsx+++ b/frontend/src/scenes/web-analytics/WebAnalyticsMenu.tsx@@ -31,25 +31,12 @@ const ANALYTICS_TILES = []export const WebAnalyticsMenu = (): JSX.Element => {- const {- hasSavedFocusMode,- hiddenTiles,- isFocusModeActive,- productTab,- shouldFilterTestAccounts,- showFocusMode,- useWebAnalyticsPrecompute,- } = useValues(webAnalyticsLogic)+ const { hasSavedFocusMode, hiddenTiles, isFocusModeActive, productTab, showFocusMode, useWebAnalyticsPrecompute } =+ useValues(webAnalyticsLogic)const { featureFlags } = useValues(featureFlagLogic)- const {- enterFocusMode,- exitFocusMode,- openFocusModeModal,- setShouldFilterTestAccounts,- setUseWebAnalyticsPrecompute,- setTileVisibility,- } = useActions(webAnalyticsLogic)+ const { enterFocusMode, exitFocusMode, openFocusModeModal, setUseWebAnalyticsPrecompute, setTileVisibility } =+ useActions(webAnalyticsLogic)const showTileToggles = featureFlags[FEATURE_FLAGS.WEB_ANALYTICS_TILE_TOGGLES]const availableTiles = productTab === ProductTab.ANALYTICS ? ANALYTICS_TILES : []@@ -79,31 +66,24 @@ export const WebAnalyticsMenu = (): JSX.Element => {</ButtonPrimitive>) : null)}</ScenePanelActionsSection>- <ScenePanelDivider />- <ScenePanelActionsSection>- <ButtonPrimitive- menuItem- onClick={() => {- setShouldFilterTestAccounts(!shouldFilterTestAccounts)- }}- >- <LemonSwitch checked={shouldFilterTestAccounts} size="xsmall" />- Filter out internal and test users- </ButtonPrimitive>- {featureFlags[FEATURE_FLAGS.WEB_ANALYTICS_PRECOMPUTE_TOGGLE] && (- <Tooltip title="When on, eligible web analytics tiles load from a pre-computed result instead of running a live query. Results are faster but may be a few minutes behind the latest events. Other tiles run live as usual.">- <ButtonPrimitive- menuItem- onClick={() => {- setUseWebAnalyticsPrecompute(!useWebAnalyticsPrecompute)- }}- >- <LemonSwitch checked={useWebAnalyticsPrecompute} size="xsmall" />- Allow precompute- </ButtonPrimitive>- </Tooltip>- )}- </ScenePanelActionsSection>+ {featureFlags[FEATURE_FLAGS.WEB_ANALYTICS_PRECOMPUTE_TOGGLE] && (+ <>+ <ScenePanelDivider />+ <ScenePanelActionsSection>+ <Tooltip title="When on, eligible web analytics tiles load from a pre-computed result instead of running a live query. Results are faster but may be a few minutes behind the latest events. Other tiles run live as usual.">+ <ButtonPrimitive+ menuItem+ onClick={() => {+ setUseWebAnalyticsPrecompute(!useWebAnalyticsPrecompute)+ }}+ >+ <LemonSwitch checked={useWebAnalyticsPrecompute} size="xsmall" />+ Allow precompute+ </ButtonPrimitive>+ </Tooltip>+ </ScenePanelActionsSection>+ </>+ )}{showTileToggles && availableTiles.length > 0 && (<><ScenePanelDivider />