Skip to content

Commit 8991538

Browse files
committed
feat(studio): project analytics behind project-analytics flag
1 parent 29f05da commit 8991538

5 files changed

Lines changed: 17 additions & 3 deletions

File tree

apps/web/src/components/layouts/sidebar/breadcrumb/BreadcrumbAnalytics.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import { BreadcrumbItem, BreadcrumbSeparator } from "@caseai-connect/ui/shad/breadcrumb"
22
import { DotIcon } from "lucide-react"
33
import { useTranslation } from "react-i18next"
4+
import { useFeatureFlags } from "@/hooks/use-feature-flags"
45
import { useIsRoute } from "@/hooks/use-is-route"
56
import { RouteNames } from "@/routes/helpers"
67

78
export function BreadcrumbAnalytics() {
9+
const { hasFeature } = useFeatureFlags()
810
const { isRoute } = useIsRoute()
911
const isAnalyticsRoute = isRoute(RouteNames.ANALYTICS)
1012
const { t } = useTranslation("analytics")
11-
if (!isAnalyticsRoute) return null
13+
if (!hasFeature("project-analytics") || !isAnalyticsRoute) return null
1214
return (
1315
<>
1416
<BreadcrumbSeparator>

apps/web/src/features/analytics/analytics.thunks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { createAsyncThunk } from "@reduxjs/toolkit"
2+
import { hasFeatureOrThrow } from "@/hooks/use-feature-flags"
23
import type { RootState, ThunkExtraArg } from "@/store"
34
import { getCurrentIds } from "../helpers"
45
import type { AnalyticsDailyPoint } from "./analytics.models"
@@ -14,6 +15,7 @@ export const loadProjectAnalytics = createAsyncThunk<
1415
ThunkConfig
1516
>("analytics/loadProject", async ({ startAt, endAt }, { extra: { services }, getState }) => {
1617
const state = getState()
18+
hasFeatureOrThrow({ state, feature: "project-analytics" })
1719
const { organizationId, projectId } = getCurrentIds({
1820
state,
1921
wantedIds: ["organizationId", "projectId"],

apps/web/src/routes/DashboardRoute.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ function SidebarFooterChildren({ project }: { project: Project }) {
100100

101101
<NavDocuments organizationId={project.organizationId} projectId={project.id} />
102102

103-
<NavAnalytics organizationId={project.organizationId} projectId={project.id} />
103+
<RestrictedFeature feature="project-analytics">
104+
<NavAnalytics organizationId={project.organizationId} projectId={project.id} />
105+
</RestrictedFeature>
104106

105107
<NavProjectMemberships organizationId={project.organizationId} projectId={project.id} />
106108
</SidebarMenu>

apps/web/src/routes/Router.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ const router = () =>
7272
},
7373
{
7474
path: buildStudioPath(RouteNames.ANALYTICS),
75-
element: <AnalyticsRoute />,
75+
element: (
76+
<RestrictedFeature feature="project-analytics">
77+
<AnalyticsRoute />
78+
</RestrictedFeature>
79+
),
7680
},
7781
{
7882
path: buildStudioPath(RouteNames.PROJECT_MEMBERSHIPS),

packages/api-contracts/src/feature-flags/feature-flags.dto.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ export const FeatureFlags = [
1212
key: "gemma",
1313
description: "Access and utilize gemma models.",
1414
},
15+
{
16+
key: "project-analytics",
17+
description: "View project-level analytics and usage charts in the studio.",
18+
},
1519
] as const
1620
export type FeatureFlagKey = (typeof FeatureFlags)[number]["key"]
1721
export type FeatureFlagsDto = FeatureFlagKey[]

0 commit comments

Comments
 (0)