Skip to content

Commit

Permalink
fix: Prevent users from toggling path cleaning if feature is not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeelaudibert committed Jan 29, 2025
1 parent 00ceebd commit 6622fcb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 6 additions & 2 deletions frontend/src/scenes/web-analytics/WebAnalyticsDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { isNotNil } from 'lib/utils'
import { addProductIntentForCrossSell, ProductIntentContext } from 'lib/utils/product-intents'
import React, { useState } from 'react'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
import { WebAnalyticsErrorTrackingTile } from 'scenes/web-analytics/tiles/WebAnalyticsErrorTracking'
import { WebAnalyticsRecordingsTile } from 'scenes/web-analytics/tiles/WebAnalyticsRecordings'
import { WebQuery } from 'scenes/web-analytics/tiles/WebAnalyticsTile'
Expand All @@ -37,7 +38,7 @@ import { navigationLogic } from '~/layout/navigation/navigationLogic'
import { dataNodeCollectionLogic } from '~/queries/nodes/DataNode/dataNodeCollectionLogic'
import { ReloadAll } from '~/queries/nodes/DataNode/Reload'
import { QuerySchema } from '~/queries/schema'
import { ProductKey, PropertyMathType } from '~/types'
import { AvailableFeature, ProductKey, PropertyMathType } from '~/types'

import { WebAnalyticsLiveUserCount } from './WebAnalyticsLiveUserCount'

Expand All @@ -52,6 +53,9 @@ const Filters = (): JSX.Element => {
const { setWebAnalyticsFilters, setDates, setCompareFilter, setWebVitalsPercentile } = useActions(webAnalyticsLogic)
const { mobileLayout } = useValues(navigationLogic)

const { hasAvailableFeature } = useValues(userLogic)
const hasAdvancedPaths = hasAvailableFeature(AvailableFeature.PATHS_ADVANCED)

const webPropertyFilters = (
<WebPropertyFilters setWebAnalyticsFilters={setWebAnalyticsFilters} webAnalyticsFilters={webAnalyticsFilters} />
)
Expand Down Expand Up @@ -91,7 +95,7 @@ const Filters = (): JSX.Element => {
/>
)}

<PathCleaningToggle />
{hasAdvancedPaths && <PathCleaningToggle />}

{/* Desktop filters, rendered to the left of the reload button */}
<div className="hidden md:block">{webPropertyFilters}</div>
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { errorTrackingQuery } from 'scenes/error-tracking/queries'
import { Scene } from 'scenes/sceneTypes'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'

import { hogqlQuery } from '~/queries/query'
import {
Expand All @@ -37,6 +38,7 @@ import {
} from '~/queries/schema/schema-general'
import { isWebAnalyticsPropertyFilters } from '~/queries/schema-guards'
import {
AvailableFeature,
BaseMathType,
Breadcrumb,
ChartDisplayType,
Expand Down Expand Up @@ -264,7 +266,7 @@ const persistConfig = { persist: true, prefix: `${teamId}__` }
export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
path(['scenes', 'webAnalytics', 'webAnalyticsSceneLogic']),
connect(() => ({
values: [featureFlagLogic, ['featureFlags'], teamLogic, ['currentTeam']],
values: [featureFlagLogic, ['featureFlags'], teamLogic, ['currentTeam'], userLogic, ['hasAvailableFeature']],
})),
actions({
setWebAnalyticsFilters: (webAnalyticsFilters: WebAnalyticsPropertyFilters) => ({ webAnalyticsFilters }),
Expand Down Expand Up @@ -424,7 +426,7 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
togglePropertyFilter: (oldTab, { tabChange }) => tabChange?.geographyTab || oldTab,
},
],
isPathCleaningEnabled: [
_isPathCleaningEnabled: [
true as boolean,
persistConfig,
{
Expand Down Expand Up @@ -557,6 +559,11 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
deviceTab: [(s) => [s._deviceTab], (deviceTab: string | null) => deviceTab || DeviceTab.DEVICE_TYPE],
pathTab: [(s) => [s._pathTab], (pathTab: string | null) => pathTab || PathTab.PATH],
geographyTab: [(s) => [s._geographyTab], (geographyTab: string | null) => geographyTab || GeographyTab.MAP],
isPathCleaningEnabled: [
(s) => [s._isPathCleaningEnabled, s.hasAvailableFeature],
(isPathCleaningEnabled, hasAvailableFeature) =>
hasAvailableFeature(AvailableFeature.PATHS_ADVANCED) && isPathCleaningEnabled,
],
tabs: [
(s) => [
s.graphsTab,
Expand Down

0 comments on commit 6622fcb

Please sign in to comment.