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.

refactor(dashboards): remove saved views rollout flag (#100320)

Matt Pua795017d2314c
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 035f9d1d4ad1..5ac971d32e74 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -288,7 +288,6 @@ export const FEATURE_FLAGS = {
DASHBOARD_CUSTOMIZATION: 'dashboard-customization', // owner: @MattPua #team-analytics-platform
DASHBOARD_EXPORT_NUDGE: 'dashboard-export-nudge', // owner: #team-analytics-platform multivariate=control,test, nudges people who just exported a dashboard toward a recurring subscription
DASHBOARD_LAYOUT_DISCARD_PROMPT: 'dashboard-layout-discard-prompt', // owner: @cory.s #team-analytics-platform
- DASHBOARD_SAVED_VIEWS: 'dashboard-saved-views', // owner: #team-analytics-platform, target organizations for saved dashboard-list views
DASHBOARD_TEMPLATE_CHOOSER_EXPERIMENT: 'dashboard-template-chooser-experiment', // owner: @mattp #team-analytics-platform multivariate=control,simple,new
DASHBOARD_TEMPLATE_METRIC_CARD: 'dashboard-template-metric-card', // owner: #team-product-analytics multivariate=control,test
DASHBOARD_WIDGETS: 'dashboard-widgets', // owner: @mattp #team-analytics-platform
diff --git a/frontend/src/scenes/dashboard/dashboards/Dashboards.tsx b/frontend/src/scenes/dashboard/dashboards/Dashboards.tsx
index 9a6df7d18ba4..b99bfc94875d 100644
--- a/frontend/src/scenes/dashboard/dashboards/Dashboards.tsx
+++ b/frontend/src/scenes/dashboard/dashboards/Dashboards.tsx
@@ -16,7 +16,6 @@ import { newDashboardLogic } from 'scenes/dashboard/newDashboardLogic'
import { NewDashboardModal } from 'scenes/dashboard/NewDashboardModal'
import { sceneConfigurations } from 'scenes/scenes'
import { Scene, SceneExport } from 'scenes/sceneTypes'
-import { teamLogic } from 'scenes/teamLogic'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
@@ -26,7 +25,6 @@ import { AccessControlLevel, AccessControlResourceType } from '~/types'
import { dashboardsEmptyState } from 'products/dashboards/frontend/emptyState/dashboardsEmptyState'
import { DashboardSavedViews } from 'products/dashboards/frontend/saved-views/DashboardSavedViews'
-import { dashboardSavedViewsLogic } from 'products/dashboards/frontend/saved-views/dashboardSavedViewsLogic'
import { DashboardsTableContainer } from './DashboardsTable'
@@ -42,15 +40,12 @@ export function Dashboards(): JSX.Element {
const { setCurrentTab } = useActions(dashboardsLogic)
const { dashboards, currentTab, isFiltering } = useValues(dashboardsLogic)
const { showNewDashboardModal } = useActions(newDashboardLogic)
- const { currentTeamId } = useValues(teamLogic)
- const { dashboardSavedViewsEnabled } = useValues(dashboardSavedViewsLogic({ teamId: currentTeamId }))
const enabledTabs: LemonTab<DashboardsTab>[] = [
{
key: DashboardsTab.All,
label: 'All dashboards',
},
{ key: DashboardsTab.Yours, label: 'My dashboards' },
- ...(dashboardSavedViewsEnabled ? [] : [{ key: DashboardsTab.Pinned, label: 'Pinned' }]),
{
key: DashboardsTab.Templates,
label: 'Templates',
diff --git a/products/dashboards/backend/api/dashboard_saved_view.py b/products/dashboards/backend/api/dashboard_saved_view.py
index b9bab96c19ed..445045804b47 100644
--- a/products/dashboards/backend/api/dashboard_saved_view.py
+++ b/products/dashboards/backend/api/dashboard_saved_view.py
@@ -22,7 +22,6 @@ from posthog.models.team import Team
from posthog.models.user import User
from products.access_control.backend.facade.user_access_control import AccessControlLevel, UserAccessControl
-from products.dashboards.backend.feature_flags import dashboard_saved_views_enabled
from products.dashboards.backend.models.dashboard import Dashboard
from products.dashboards.backend.models.dashboard_saved_view import DashboardSavedView
@@ -239,8 +238,6 @@ class DashboardSavedViewPermission(BasePermission):
def has_permission(self, request: Request, view: APIView) -> bool:
team = self._saved_views_team(view)
- if not dashboard_saved_views_enabled(team=team):
- return False
access_level: AccessControlLevel = "viewer" if request.method in SAFE_METHODS else "editor"
return UserAccessControl(user=cast(User, request.user), team=team).check_access_level_for_resource(
"dashboard", access_level
diff --git a/products/dashboards/backend/api/test/test_dashboard_saved_views.py b/products/dashboards/backend/api/test/test_dashboard_saved_views.py
index d617d1cf15e5..7f9be7f999ec 100644
--- a/products/dashboards/backend/api/test/test_dashboard_saved_views.py
+++ b/products/dashboards/backend/api/test/test_dashboard_saved_views.py
@@ -17,11 +17,6 @@ from products.dashboards.backend.models.dashboard_saved_view import DashboardSav
class TestDashboardSavedViews(APIBaseTest):
def setUp(self) -> None:
super().setUp()
- self.saved_views_flag = patch(
- "products.dashboards.backend.api.dashboard_saved_view.dashboard_saved_views_enabled", return_value=True
- )
- self.saved_views_flag.start()
- self.addCleanup(self.saved_views_flag.stop)
self.base_url = f"/api/projects/{self.team.pk}/dashboard_saved_views/"
def _payload(self, **overrides: object) -> dict[str, object]:
@@ -32,12 +27,6 @@ class TestDashboardSavedViews(APIBaseTest):
payload.update(overrides)
return payload
- @patch("products.dashboards.backend.api.dashboard_saved_view.dashboard_saved_views_enabled", return_value=False)
- def test_rejects_requests_when_saved_views_flag_is_disabled(self, _dashboard_saved_views_enabled) -> None:
- response = self.client.get(self.base_url)
-
- assert response.status_code == status.HTTP_403_FORBIDDEN
-
@parameterized.expand(
[
("without_filters", {}, "Add at least one filter before saving a view."),
diff --git a/products/dashboards/backend/feature_flags.py b/products/dashboards/backend/feature_flags.py
index 6ba51b198c87..ed087aaf87a5 100644
--- a/products/dashboards/backend/feature_flags.py
+++ b/products/dashboards/backend/feature_flags.py
@@ -12,7 +12,6 @@ if TYPE_CHECKING:
DASHBOARD_WIDGETS_FLAG = "dashboard-widgets"
DASHBOARD_CUSTOMIZATION_FLAG = "dashboard-customization"
-DASHBOARD_SAVED_VIEWS_FLAG = "dashboard-saved-views"
def widget_flag_enabled(flag: str, *, team: Team, user: User | None = None) -> bool:
@@ -42,7 +41,3 @@ def dashboard_widgets_enabled(*, team: Team, user: User | None = None) -> bool:
def dashboard_customization_enabled(*, team: Team, user: User | None = None) -> bool:
return widget_flag_enabled(DASHBOARD_CUSTOMIZATION_FLAG, team=team, user=user)
-
-
-def dashboard_saved_views_enabled(*, team: Team) -> bool:
- return widget_flag_enabled(DASHBOARD_SAVED_VIEWS_FLAG, team=team)
diff --git a/products/dashboards/frontend/saved-views/DashboardSavedViews.tsx b/products/dashboards/frontend/saved-views/DashboardSavedViews.tsx
index 29fdbca3a16a..08498bc53752 100644
--- a/products/dashboards/frontend/saved-views/DashboardSavedViews.tsx
+++ b/products/dashboards/frontend/saved-views/DashboardSavedViews.tsx
@@ -116,7 +116,6 @@ export function DashboardSavedViews(): JSX.Element | null {
const { currentTeamId } = useValues(teamLogic)
const savedViewsLogic = dashboardSavedViewsLogic({ teamId: currentTeamId })
const {
- dashboardSavedViewsEnabled,
savedViews,
savedViewsNextCursors,
loadMoreSavedViewsLoading,
@@ -383,7 +382,7 @@ export function DashboardSavedViews(): JSX.Element | null {
}
}
- if (!dashboardSavedViewsEnabled || currentTab !== DashboardsTab.All) {
+ if (currentTab !== DashboardsTab.All) {
return null
}
diff --git a/products/dashboards/frontend/saved-views/dashboardSavedViewsLogic.test.ts b/products/dashboards/frontend/saved-views/dashboardSavedViewsLogic.test.ts
index bb84d63311eb..e9e3b39d502d 100644
--- a/products/dashboards/frontend/saved-views/dashboardSavedViewsLogic.test.ts
+++ b/products/dashboards/frontend/saved-views/dashboardSavedViewsLogic.test.ts
@@ -1,8 +1,6 @@
import { expectLogic } from 'kea-test-utils'
import { ApiError } from 'lib/api-error'
-import { FEATURE_FLAGS } from 'lib/constants'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { DashboardsTab, dashboardsLogic } from 'scenes/dashboard/dashboards/dashboardsLogic'
import { initKeaTests } from '~/test/init'
@@ -46,7 +44,6 @@ function page(views: DashboardListSavedView[], nextCursor: string | null): Pagin
describe('dashboardSavedViewsLogic', () => {
beforeEach(() => {
initKeaTests()
- featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.DASHBOARD_SAVED_VIEWS]: true })
dashboardSavedViewsList.mockReset()
})
@@ -83,45 +80,19 @@ describe('dashboardSavedViewsLogic', () => {
logic.unmount()
})
- it('does not load saved views when the feature flag is disabled', async () => {
- featureFlagLogic.actions.setFeatureFlags([], {})
- const logic = dashboardSavedViewsLogic({ teamId: 1 })
- logic.mount()
-
- await expectLogic(logic).toMatchValues({ dashboardSavedViewsEnabled: false, savedViewsLoading: false })
- expect(dashboardSavedViewsList).not.toHaveBeenCalled()
-
- logic.unmount()
- })
-
- it('loads saved views when the feature flag becomes enabled', async () => {
- featureFlagLogic.actions.setFeatureFlags([], {})
- dashboardSavedViewsList.mockImplementation(async () => page([], null))
- const logic = dashboardSavedViewsLogic({ teamId: 1 })
- logic.mount()
-
- featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.DASHBOARD_SAVED_VIEWS]: true })
-
- await expectLogic(logic).toFinishAllListeners().toMatchValues({ dashboardSavedViewsEnabled: true })
- expect(dashboardSavedViewsList).toHaveBeenCalledTimes(2)
-
- logic.unmount()
- })
-
it('keeps pinned dashboards visible when saved views replace the Pinned tab', async () => {
- featureFlagLogic.actions.setFeatureFlags([], {})
dashboardSavedViewsList.mockImplementation(async () => page([], null))
+ dashboardsLogic.mount()
+ dashboardsLogic.actions.setCurrentTab(DashboardsTab.Pinned)
const logic = dashboardSavedViewsLogic({ teamId: 1 })
logic.mount()
- dashboardsLogic.actions.setCurrentTab(DashboardsTab.Pinned)
-
- featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.DASHBOARD_SAVED_VIEWS]: true })
await expectLogic(logic).toFinishAllListeners()
expect(logic.values.currentTab).toBe(DashboardsTab.All)
expect(logic.values.filters.pinned).toBe(true)
logic.unmount()
+ dashboardsLogic.unmount()
})
it('keeps loaded saved views available when loading another page fails', async () => {
@@ -138,7 +109,6 @@ describe('dashboardSavedViewsLogic', () => {
logic.actions.loadMoreSavedViewsFailure('Could not load more saved views', new ApiError(undefined, 403))
expectLogic(logic).toMatchValues({
- dashboardSavedViewsEnabled: true,
savedViews: [savedView('private-1', 'private')],
savedViewsLoadError: false,
savedViewsLoadMoreFailed: true,
diff --git a/products/dashboards/frontend/saved-views/dashboardSavedViewsLogic.ts b/products/dashboards/frontend/saved-views/dashboardSavedViewsLogic.ts
index 8deab7055a19..274c37df14d3 100644
--- a/products/dashboards/frontend/saved-views/dashboardSavedViewsLogic.ts
+++ b/products/dashboards/frontend/saved-views/dashboardSavedViewsLogic.ts
@@ -1,10 +1,7 @@
import { deepEqual as isEqual } from 'fast-equals'
-import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
+import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path, props, reducers } from 'kea'
import posthog from 'posthog-js'
-import { ApiError } from 'lib/api-error'
-import { FEATURE_FLAGS } from 'lib/constants'
-import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { buildUserScopedPersistenceConfig } from 'lib/logic/persistence'
import {
DEFAULT_FILTERS,
@@ -39,12 +36,9 @@ export interface DashboardSavedViewsLogicProps {
export interface dashboardSavedViewsLogicValues {
currentTab: DashboardsTab // dashboardsLogic
filters: DashboardsFilters // dashboardsLogic
- featureFlags: FeatureFlagsSet // featureFlagLogic
activeSavedViewId: string | null
- dashboardSavedViewsEnabled: boolean
loadMoreSavedViewsLoading: boolean
savedViews: DashboardListSavedView[]
- savedViewsAvailable: boolean
savedViewsLoadError: boolean
savedViewsLoadMoreFailed: boolean
savedViewsLoading: boolean
@@ -62,13 +56,6 @@ export interface dashboardSavedViewsLogicActions {
setSearch: (search: string) => {
search: string
} // dashboardsLogic
- setFeatureFlags: (
- flags: string[],
- variants: Record<string, boolean | string>
- ) => {
- flags: string[]
- variants: Record<string, boolean | string>
- } // featureFlagLogic
loadMoreSavedViews: (scope: DashboardSavedViewScope) => {
scope: DashboardSavedViewScope
}
@@ -112,9 +99,6 @@ export interface dashboardSavedViewsLogicActions {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface dashboardSavedViewsLogicMeta {
key: number | 'no-team'
- __keaTypeGenInternalSelectorTypes: {
- dashboardSavedViewsEnabled: (featureFlags: FeatureFlagsSet, savedViewsAvailable: boolean) => boolean
- }
}
export type dashboardSavedViewsLogicType = MakeLogicType<
@@ -126,10 +110,6 @@ export type dashboardSavedViewsLogicType = MakeLogicType<
const emptySavedViewCursors: DashboardSavedViewCursors = { private: null, team: null }
-function isSavedViewsUnavailableError(error: unknown): boolean {
- return error instanceof ApiError && (error.status === 403 || error.status === 404)
-}
-
export function dashboardListSavedView(view: DashboardSavedViewApi): DashboardListSavedView {
return {
...view,
@@ -162,8 +142,8 @@ export const dashboardSavedViewsLogic = kea<dashboardSavedViewsLogicType>([
key((props) => props.teamId ?? 'no-team'),
path((key) => ['products', 'dashboards', 'saved-views', 'dashboardSavedViewsLogic', key]),
connect(() => ({
- values: [featureFlagLogic, ['featureFlags'], dashboardsLogic, ['currentTab', 'filters']],
- actions: [featureFlagLogic, ['setFeatureFlags'], dashboardsLogic, ['setCurrentTab', 'setFilters', 'setSearch']],
+ values: [dashboardsLogic, ['currentTab', 'filters']],
+ actions: [dashboardsLogic, ['setCurrentTab', 'setFilters', 'setSearch']],
})),
actions({
loadSavedViews: true,
@@ -191,13 +171,6 @@ export const dashboardSavedViewsLogic = kea<dashboardSavedViewsLogicType>([
},
},
],
- savedViewsAvailable: [
- true,
- {
- loadSavedViewsSuccess: () => true,
- loadSavedViewsFailure: (_, { errorObject }) => !isSavedViewsUnavailableError(errorObject),
- },
- ],
savedViewsNextCursors: [
emptySavedViewCursors,
{
@@ -216,7 +189,7 @@ export const dashboardSavedViewsLogic = kea<dashboardSavedViewsLogicType>([
false,
{
loadSavedViews: () => false,
- loadSavedViewsFailure: (_, { errorObject }) => !isSavedViewsUnavailableError(errorObject),
+ loadSavedViewsFailure: () => true,
loadSavedViewsSuccess: () => false,
},
],
@@ -256,13 +229,6 @@ export const dashboardSavedViewsLogic = kea<dashboardSavedViewsLogicType>([
},
],
})),
- selectors(({ props }) => ({
- dashboardSavedViewsEnabled: [
- (selectors) => [selectors.featureFlags, selectors.savedViewsAvailable],
- (featureFlags: FeatureFlagsSet, savedViewsAvailable: boolean): boolean =>
- props.teamId != null && !!featureFlags[FEATURE_FLAGS.DASHBOARD_SAVED_VIEWS] && savedViewsAvailable,
- ],
- })),
listeners(({ actions, props, values }) => ({
loadSavedViewsSuccess: ({ pages }) => {
const views = pages.flatMap((page) => page.views)
@@ -283,15 +249,6 @@ export const dashboardSavedViewsLogic = kea<dashboardSavedViewsLogicType>([
actions.setActiveSavedViewId(null)
}
},
- setFeatureFlags: () => {
- if (values.dashboardSavedViewsEnabled && !values.savedViewsLoading) {
- if (values.currentTab === DashboardsTab.Pinned) {
- actions.setCurrentTab(DashboardsTab.All)
- actions.setFilters({ pinned: true })
- }
- actions.loadSavedViews()
- }
- },
loadSavedViews: async (_, breakpoint) => {
if (props.teamId == null) {
actions.loadSavedViewsSuccess([])
@@ -305,9 +262,7 @@ export const dashboardSavedViewsLogic = kea<dashboardSavedViewsLogicType>([
breakpoint()
actions.loadSavedViewsSuccess(pages)
} catch (error) {
- if (!isSavedViewsUnavailableError(error)) {
- posthog.captureException(error)
- }
+ posthog.captureException(error)
actions.loadSavedViewsFailure(
error instanceof Error ? error.message : 'Could not load saved views',
error
@@ -324,9 +279,7 @@ export const dashboardSavedViewsLogic = kea<dashboardSavedViewsLogicType>([
breakpoint()
actions.loadMoreSavedViewsSuccess(page)
} catch (error) {
- if (!isSavedViewsUnavailableError(error)) {
- posthog.captureException(error)
- }
+ posthog.captureException(error)
actions.loadMoreSavedViewsFailure(
error instanceof Error ? error.message : 'Could not load more saved views',
error
@@ -335,8 +288,10 @@ export const dashboardSavedViewsLogic = kea<dashboardSavedViewsLogicType>([
},
})),
afterMount(({ actions, values }) => {
- if (values.dashboardSavedViewsEnabled) {
- actions.loadSavedViews()
+ if (values.currentTab === DashboardsTab.Pinned) {
+ actions.setCurrentTab(DashboardsTab.All)
+ actions.setFilters({ pinned: true })
}
+ actions.loadSavedViews()
}),
])