📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Gate Plus / Enterprise features
Blue Mousea2f5a8b38451
diff --git a/backend/apps/cloud/src/ai/ai.service.ts b/backend/apps/cloud/src/ai/ai.service.tsindex 35aa6114e..7f5bf377c 100644--- a/backend/apps/cloud/src/ai/ai.service.ts+++ b/backend/apps/cloud/src/ai/ai.service.ts@@ -25,6 +25,7 @@ import { AppLoggerService } from '../logger/logger.service'import { clickhouse } from '../common/integrations/clickhouse'import { Project } from '../project/entity/project.entity'import { TimeBucketType } from '../analytics/dto/getData.dto'+import { PlanFeatureCode } from '../user/entities/user.entity'const OPENROUTER_BASE_URL = 'https://openrouter.ai/api/v1'@@ -652,6 +653,14 @@ Chart "link" field (REQUIRED whenever the chart corresponds to data the user can.describe('End of custom range (YYYY-MM-DD or full ISO datetime). Pair with "from".',)+ const canAccessFeatureFlags = this.projectService.projectOwnerHasFeature(+ project,+ PlanFeatureCode.featureFlags,+ )+ const canAccessExperiments = this.projectService.projectOwnerHasFeature(+ project,+ PlanFeatureCode.experiments,+ )return {getProjectInfo: tool({@@ -901,6 +910,12 @@ Filter modifiers:{ pid: project.id, flagId: params.flagId },'Tool: getFeatureFlagStats called',)+ if (!canAccessFeatureFlags) {+ return {+ error:+ 'Feature flags are not available on the current project owner plan.',+ }+ }try {return await this.getFeatureFlagStats(project.id, params, timezone)} catch (error) {@@ -932,6 +947,12 @@ Filter modifiers:{ pid: project.id, experimentId: params.experimentId },'Tool: getExperimentResults called',)+ if (!canAccessExperiments) {+ return {+ error:+ 'Experiments are not available on the current project owner plan.',+ }+ }try {return await this.getExperimentResults(project.id, params, timezone)} catch (error) {@@ -1012,14 +1033,26 @@ Filter modifiers:}private async getProjectInfo(project: Project) {+ const canAccessFeatureFlags = this.projectService.projectOwnerHasFeature(+ project,+ PlanFeatureCode.featureFlags,+ )+ const canAccessExperiments = this.projectService.projectOwnerHasFeature(+ project,+ PlanFeatureCode.experiments,+ )const [funnels, goals, featureFlags, experiments] = await Promise.all([this.projectService.getFunnels(project.id),this.goalService.find({where: { project: { id: project.id }, active: true },order: { name: 'ASC' },}),- this.featureFlagService.findByProject(project.id).catch(() => []),- this.experimentService.findByProject(project.id).catch(() => []),+ canAccessFeatureFlags+ ? this.featureFlagService.findByProject(project.id).catch(() => [])+ : [],+ canAccessExperiments+ ? this.experimentService.findByProject(project.id).catch(() => [])+ : [],])return {@@ -1046,6 +1079,7 @@ Filter modifiers:rolloutPercentage: f.rolloutPercentage,enabled: f.enabled,})),+ featureFlagsAvailable: canAccessFeatureFlags,experiments: _map(experiments, (e) => ({id: e.id,name: e.name,@@ -1061,6 +1095,7 @@ Filter modifiers:})),goalId: e.goal?.id || null,})),+ experimentsAvailable: canAccessExperiments,}}diff --git a/backend/apps/cloud/src/experiment/experiment.controller.ts b/backend/apps/cloud/src/experiment/experiment.controller.tsindex c71267d4e..1d77f79af 100644--- a/backend/apps/cloud/src/experiment/experiment.controller.ts+++ b/backend/apps/cloud/src/experiment/experiment.controller.ts@@ -37,7 +37,7 @@ import dayjsTimezone from 'dayjs/plugin/timezone'import { UserService } from '../user/user.service'import { ProjectService } from '../project/project.service'import { AppLoggerService } from '../logger/logger.service'-import { PlanCode } from '../user/entities/user.entity'+import { PlanCode, PlanFeatureCode } from '../user/entities/user.entity'import {AnalyticsService,DataType,@@ -149,6 +149,10 @@ export class ExperimentController {}this.projectService.allowedToView(project, userId)+ this.projectService.assertProjectOwnerFeatureAccess(+ project,+ PlanFeatureCode.experiments,+ )const safeTake =typeof take === 'number' ? Math.min(Math.max(take, 1), 200) : undefined@@ -199,6 +203,10 @@ export class ExperimentController {)this.projectService.allowedToView(project, userId)+ this.projectService.assertProjectOwnerFeatureAccess(+ project,+ PlanFeatureCode.experiments,+ )return {..._omit(experiment, ['project', 'goal', 'featureFlag']),@@ -249,19 +257,23 @@ export class ExperimentController {uid,'You are not allowed to add experiments to this project',)+ this.projectService.assertProjectOwnerFeatureAccess(+ project,+ PlanFeatureCode.experiments,+ )const experimentsCount = await this.experimentService.count({where: { project: { id: experimentDto.pid } },})- if (user.planCode === PlanCode.none) {+ if (project.admin?.planCode === PlanCode.none) {throw new HttpException('You cannot create new experiments due to no active subscription. Please upgrade your account plan to continue.',HttpStatus.PAYMENT_REQUIRED,)}- if (user.isAccountBillingSuspended) {+ if (project.admin?.isAccountBillingSuspended) {throw new HttpException('The account that owns this site is currently suspended, this is because of a billing issue. Please resolve the issue to continue.',HttpStatus.PAYMENT_REQUIRED,@@ -439,6 +451,10 @@ export class ExperimentController {uid,'You are not allowed to manage this experiment',)+ this.projectService.assertProjectOwnerFeatureAccess(+ experiment.project,+ PlanFeatureCode.experiments,+ )if (experiment.status === ExperimentStatus.RUNNING) {throw new BadRequestException(@@ -665,6 +681,10 @@ export class ExperimentController {uid,'You are not allowed to manage this experiment',)+ this.projectService.assertProjectOwnerFeatureAccess(+ experiment.project,+ PlanFeatureCode.experiments,+ )if (experiment.featureFlag) {if (experiment.featureFlagMode === FeatureFlagMode.CREATE) {@@ -711,6 +731,10 @@ export class ExperimentController {uid,'You are not allowed to manage this experiment',)+ this.projectService.assertProjectOwnerFeatureAccess(+ experiment.project,+ PlanFeatureCode.experiments,+ )if (experiment.status === ExperimentStatus.RUNNING) {throw new BadRequestException('Experiment is already running')@@ -836,6 +860,10 @@ export class ExperimentController {uid,'You are not allowed to manage this experiment',)+ this.projectService.assertProjectOwnerFeatureAccess(+ experiment.project,+ PlanFeatureCode.experiments,+ )if (experiment.status !== ExperimentStatus.RUNNING) {throw new BadRequestException('Can only pause a running experiment')@@ -890,6 +918,10 @@ export class ExperimentController {uid,'You are not allowed to manage this experiment',)+ this.projectService.assertProjectOwnerFeatureAccess(+ experiment.project,+ PlanFeatureCode.experiments,+ )if (experiment.status !== ExperimentStatus.RUNNING &&@@ -952,6 +984,10 @@ export class ExperimentController {experiment.project.id,)this.projectService.allowedToView(project, userId)+ this.projectService.assertProjectOwnerFeatureAccess(+ project,+ PlanFeatureCode.experiments,+ )const safeTimezone = this.analyticsService.getSafeTimezone(timezone)diff --git a/backend/apps/cloud/src/feature-flag/feature-flag.controller.ts b/backend/apps/cloud/src/feature-flag/feature-flag.controller.tsindex 7f8291c09..90c932d21 100644--- a/backend/apps/cloud/src/feature-flag/feature-flag.controller.ts+++ b/backend/apps/cloud/src/feature-flag/feature-flag.controller.ts@@ -31,7 +31,7 @@ import _round from 'lodash/round'import { UserService } from '../user/user.service'import { ProjectService } from '../project/project.service'import { AppLoggerService } from '../logger/logger.service'-import { PlanCode } from '../user/entities/user.entity'+import { PlanCode, PlanFeatureCode } from '../user/entities/user.entity'import {AnalyticsService,getLowestPossibleTimeBucket,@@ -282,6 +282,10 @@ export class FeatureFlagController {}this.projectService.allowedToView(project, userId)+ this.projectService.assertProjectOwnerFeatureAccess(+ project,+ PlanFeatureCode.featureFlags,+ )const safeTake =typeof take === 'number' && Number.isFinite(take)@@ -329,6 +333,10 @@ export class FeatureFlagController {const project = await this.projectService.getFullProject(flag.project.id)this.projectService.allowedToView(project, userId)+ this.projectService.assertProjectOwnerFeatureAccess(+ project,+ PlanFeatureCode.featureFlags,+ )await this.featureFlagService.applyDueScheduledChanges(flag.project.id)@@ -382,19 +390,23 @@ export class FeatureFlagController {uid,'You are not allowed to add feature flags to this project',)+ this.projectService.assertProjectOwnerFeatureAccess(+ project,+ PlanFeatureCode.featureFlags,+ )const flagsCount = await this.featureFlagService.count({where: { project: { id: flagDto.pid } },})- if (user.planCode === PlanCode.none) {+ if (project.admin?.planCode === PlanCode.none) {throw new HttpException('You cannot create new feature flags due to no active subscription. Please upgrade your account plan to continue.',HttpStatus.PAYMENT_REQUIRED,)}- if (user.isAccountBillingSuspended) {+ if (project.admin?.isAccountBillingSuspended) {throw new HttpException('The account that owns this site is currently suspended, this is because of a billing issue. Please resolve the issue to continue.',HttpStatus.PAYMENT_REQUIRED,@@ -510,6 +522,15 @@ export class FeatureFlagController {return { flags: {} }}+ if (+ !this.projectService.projectOwnerHasFeature(+ project,+ PlanFeatureCode.featureFlags,+ )+ ) {+ return { flags: {}, experiments: {} }+ }+this.analyticsService.checkIpBlacklist(project, ip)this.analyticsService.checkOrigin(project, origin)this.analyticsService.checkIfAccountSuspended(project)@@ -721,6 +742,10 @@ export class FeatureFlagController {uid,'You are not allowed to manage this feature flag',)+ this.projectService.assertProjectOwnerFeatureAccess(+ flag.project,+ PlanFeatureCode.featureFlags,+ )// Check for duplicate key if key is being changedif (flagDto.key && flagDto.key !== flag.key) {@@ -797,6 +822,10 @@ export class FeatureFlagController {uid,'You are not allowed to manage this feature flag',)+ this.projectService.assertProjectOwnerFeatureAccess(+ flag.project,+ PlanFeatureCode.featureFlags,+ )await this.featureFlagService.applyDueScheduledChanges(flag.project.id)@@ -847,6 +876,10 @@ export class FeatureFlagController {uid,'You are not allowed to manage this feature flag',)+ this.projectService.assertProjectOwnerFeatureAccess(+ flag.project,+ PlanFeatureCode.featureFlags,+ )await this.featureFlagService.applyDueScheduledChanges(flag.project.id)@@ -896,6 +929,10 @@ export class FeatureFlagController {uid,'You are not allowed to manage this feature flag',)+ this.projectService.assertProjectOwnerFeatureAccess(+ flag.project,+ PlanFeatureCode.featureFlags,+ )await this.featureFlagService.delete(id)@@ -930,6 +967,10 @@ export class FeatureFlagController {const project = await this.projectService.getFullProject(flag.project.id)this.projectService.allowedToView(project, userId)+ this.projectService.assertProjectOwnerFeatureAccess(+ project,+ PlanFeatureCode.featureFlags,+ )const safeTimezone = this.analyticsService.getSafeTimezone(timezone)const timeBucket = getLowestPossibleTimeBucket(period, from, to)@@ -1039,6 +1080,10 @@ export class FeatureFlagController {const project = await this.projectService.getFullProject(flag.project.id)this.projectService.allowedToView(project, userId)+ this.projectService.assertProjectOwnerFeatureAccess(+ project,+ PlanFeatureCode.featureFlags,+ )const safeTimezone = this.analyticsService.getSafeTimezone(timezone)const timeBucket = getLowestPossibleTimeBucket(period, from, to)diff --git a/backend/apps/cloud/src/project/project.controller.ts b/backend/apps/cloud/src/project/project.controller.tsindex bf3ac11f4..d732edb75 100644--- a/backend/apps/cloud/src/project/project.controller.ts+++ b/backend/apps/cloud/src/project/project.controller.ts@@ -2002,6 +2002,7 @@ export class ProjectController {brandKeywords: parseBrandKeywords(project.brandKeywords),isAccessConfirmed,isLocked: !!project.admin?.dashboardBlockReason,+ featureAccess: this.projectService.getProjectFeatureAccess(project),isDataExists,isErrorDataExists,isCaptchaDataExists,diff --git a/backend/apps/cloud/src/project/project.service.ts b/backend/apps/cloud/src/project/project.service.tsindex beffa5434..b37f9920e 100644--- a/backend/apps/cloud/src/project/project.service.ts+++ b/backend/apps/cloud/src/project/project.service.ts@@ -7,6 +7,8 @@ import {InternalServerErrorException,ConflictException,NotFoundException,+ HttpException,+ HttpStatus,} from '@nestjs/common'import { InjectRepository } from '@nestjs/typeorm'import {@@ -79,6 +81,10 @@ import { ReportFrequency } from './enums'import { CreateProjectViewDto } from './dto/create-project-view.dto'import { Organisation } from '../organisation/entity/organisation.entity'import { OrganisationRole } from '../organisation/entity/organisation-member.entity'+import {+ PlanFeatureCode,+ userHasPlanFeature,+} from '../user/entities/user.entity'dayjs.extend(utc)@@ -197,6 +203,8 @@ export class ProjectService {'admin.id','admin.dashboardBlockReason','admin.isAccountBillingSuspended',+ 'admin.planCode',+ 'admin.planType','organisation.id','organisationMembers.role','organisationMembers.confirmed',@@ -267,6 +275,7 @@ export class ProjectService {dashboardBlockReason: true,isAccountBillingSuspended: true,planCode: true,+ planType: true,},organisation: {id: true,@@ -295,6 +304,8 @@ export class ProjectService {'project','admin.id','admin.dashboardBlockReason',+ 'admin.planCode',+ 'admin.planType','share.id','share.role','share.confirmed',@@ -556,6 +567,40 @@ export class ProjectService {return this.projectsRepository.find(options)}+ getProjectFeatureAccess(project: Project | null | undefined) {+ return {+ [PlanFeatureCode.featureFlags]: this.projectOwnerHasFeature(+ project,+ PlanFeatureCode.featureFlags,+ ),+ [PlanFeatureCode.experiments]: this.projectOwnerHasFeature(+ project,+ PlanFeatureCode.experiments,+ ),+ }+ }++ projectOwnerHasFeature(+ project: Project | null | undefined,+ feature: PlanFeatureCode,+ ) {+ return userHasPlanFeature(project?.admin, feature)+ }++ assertProjectOwnerFeatureAccess(+ project: Project | null | undefined,+ feature: PlanFeatureCode,+ ) {+ if (this.projectOwnerHasFeature(project, feature)) {+ return+ }++ throw new HttpException(+ 'This feature is not available on the current project owner plan.',+ HttpStatus.PAYMENT_REQUIRED,+ )+ }+allowedToView(project: Project,uid: string | null,@@ -1479,6 +1524,7 @@ export class ProjectService {...project,isAccessConfirmed,isLocked: !!project.admin?.dashboardBlockReason,+ featureAccess: this.getProjectFeatureAccess(project),isDataExists: _includes(pidsWithData, project?.id),isErrorDataExists: _includes(pidsWithErrorData, project?.id),organisationId: project?.organisation?.id,diff --git a/backend/apps/cloud/src/user/entities/user.entity.ts b/backend/apps/cloud/src/user/entities/user.entity.tsindex 64271b3be..f115ec065 100644--- a/backend/apps/cloud/src/user/entities/user.entity.ts+++ b/backend/apps/cloud/src/user/entities/user.entity.ts@@ -39,6 +39,11 @@ export enum PlanType {enterprise = 'enterprise',}+export enum PlanFeatureCode {+ featureFlags = 'featureFlags',+ experiments = 'experiments',+}+export enum DashboardBlockReason {'exceeding_plan_limits' = 'exceeding_plan_limits','trial_ended' = 'trial_ended',@@ -79,6 +84,17 @@ export const PLAN_TYPE_ENTITLEMENTS = {},} as const+export const PLAN_TYPE_RANK = {+ [PlanType.standard]: 1,+ [PlanType.plus]: 2,+ [PlanType.enterprise]: 3,+} as const++export const PLAN_FEATURE_REQUIRED_PLAN = {+ [PlanFeatureCode.featureFlags]: PlanType.plus,+ [PlanFeatureCode.experiments]: PlanType.plus,+} as const+export const getEffectivePlanType = (user?: {planCode?: PlanCode | null@@ -107,6 +123,31 @@ export const getPlanTypeEntitlements = (planType?: PlanType | null,) => PLAN_TYPE_ENTITLEMENTS[planType || PlanType.standard]+export const planTypeHasFeature = (+ planType: PlanType | null | undefined,+ feature: PlanFeatureCode,+) => {+ if (!planType) {+ return false+ }++ return (+ PLAN_TYPE_RANK[planType] >=+ PLAN_TYPE_RANK[PLAN_FEATURE_REQUIRED_PLAN[feature]]+ )+}++export const userHasPlanFeature = (+ user:+ | {+ planCode?: PlanCode | null+ planType?: PlanType | null+ }+ | null+ | undefined,+ feature: PlanFeatureCode,+) => planTypeHasFeature(getEffectivePlanType(user), feature)+export const ACCOUNT_PLANS = {[PlanCode.none]: {id: PlanCode.none,diff --git a/web/app/api/api.server.ts b/web/app/api/api.server.tsindex 3f4c51c9a..13523244b 100644--- a/web/app/api/api.server.ts+++ b/web/app/api/api.server.ts@@ -1,5 +1,6 @@import { Auth } from '~/lib/models/Auth'import { User } from '~/lib/models/User'+import type { ProjectFeatureAccess } from '~/lib/pricing/features'import {getAccessToken,getRefreshToken,@@ -2075,6 +2076,7 @@ export interface Project {created: stringisOwner: booleanisLocked: boolean+ featureAccess?: ProjectFeatureAccessisCaptchaProject: booleanisCaptchaEnabled: booleanisAnalyticsProject: booleandiff --git a/web/app/components/pricing/MarketingPricing.tsx b/web/app/components/pricing/MarketingPricing.tsxindex 146765c3f..487980c49 100644--- a/web/app/components/pricing/MarketingPricing.tsx+++ b/web/app/components/pricing/MarketingPricing.tsx@@ -309,20 +309,6 @@ const MarketingPricing = ({return (selectedTierIndex / (eventTierOptionLabels.length - 1)) * 100}, [selectedTierIndex])- const proMonthlyPrice = isCustomEventTier- ? null- : getPlanPrice('standard', selectedTier, 'monthly', currencyCode)?.amount- const proYearlyPrice = isCustomEventTier- ? null- : getPlanPrice('standard', selectedTier, 'yearly', currencyCode)?.amount- const yearlyDiscount =- proMonthlyPrice && proYearlyPrice- ? Math.round(- ((proMonthlyPrice * 12 - proYearlyPrice) / (proMonthlyPrice * 12)) *- 100,- )- : 0-const toggleBillingFrequency = () => {setBillingFrequency((currentFrequency) =>currentFrequency === 'yearly' ? 'monthly' : 'yearly',@@ -388,17 +374,16 @@ const MarketingPricing = ({<Text as='span' size='sm' weight='medium' colour='primary'>{t('pricing.billedYearly')}</Text>- {yearlyDiscount > 0 ? (- <Text- as='span'- size='xs'- weight='semibold'- colour='success'- className='rounded-md bg-emerald-500/20 px-1.5 py-0.5'- >- -{yearlyDiscount} %- </Text>- ) : null}+ <Text+ as='span'+ size='xs'+ weight='semibold'+ colour='success'+ className='rounded-md bg-emerald-500/20 px-1.5 py-0.5'+ >+ {/* 2 months free */}+ -17 %+ </Text><BillingFrequencySwitch checked={isYearly} /></button></div>diff --git a/web/app/hooks/useProjectFeatureAccess.ts b/web/app/hooks/useProjectFeatureAccess.tsnew file mode 100644index 000000000..c03bc0cee--- /dev/null+++ b/web/app/hooks/useProjectFeatureAccess.ts@@ -0,0 +1,18 @@+import { useMemo } from 'react'++import { isSelfhosted } from '~/lib/constants'+import type { PlanFeatureCode } from '~/lib/pricing/features'+import { useCurrentProject } from '~/providers/CurrentProjectProvider'++export const useProjectFeatureAccess = (feature: PlanFeatureCode) => {+ const { project } = useCurrentProject()++ return useMemo(() => {+ const isOwner = project?.role === 'owner'++ return {+ hasAccess: isSelfhosted || project?.featureAccess?.[feature] === true,+ isOwner,+ }+ }, [feature, project])+}diff --git a/web/app/lib/constants/index.ts b/web/app/lib/constants/index.tsindex 460ec9f75..3c2d372dc 100644--- a/web/app/lib/constants/index.ts+++ b/web/app/lib/constants/index.ts@@ -537,7 +537,7 @@ export const localisePath = (pathname: string, lang: string): string => {// Increase this counter every time some major change is done within localisation files// This will prevent cached version or raw locale strings being displayed in production-export const I18N_CACHE_BREAKER = 40+export const I18N_CACHE_BREAKER = 41export const roles: Role[] = ['admin', 'viewer']diff --git a/web/app/lib/models/Project.ts b/web/app/lib/models/Project.tsindex 1b3df89cb..7ffcefb39 100644--- a/web/app/lib/models/Project.ts+++ b/web/app/lib/models/Project.ts@@ -1,4 +1,5 @@import { Organisation, Role } from './Organisation'+import type { ProjectFeatureAccess } from '~/lib/pricing/features'interface OverallPeriodStats {all: number@@ -250,6 +251,7 @@ export interface Project {isDataExists: booleanisErrorDataExists: booleanisCaptchaDataExists: boolean+ featureAccess?: ProjectFeatureAccessbotsProtectionLevel: 'off' | 'basic' | 'strict'role?: RolegscPropertyUri?: string | nulldiff --git a/web/app/lib/pricing/features.ts b/web/app/lib/pricing/features.tsnew file mode 100644index 000000000..c5091c6ce--- /dev/null+++ b/web/app/lib/pricing/features.ts@@ -0,0 +1,24 @@+import { PLAN_TYPES, type PlanTypeCode } from './catalog'++export type PlanFeatureCode = 'featureFlags' | 'experiments'++export type ProjectFeatureAccess = Record<PlanFeatureCode, boolean>++export const PLAN_FEATURE_REQUIRED_PLAN = {+ featureFlags: 'plus',+ experiments: 'plus',+} as const satisfies Record<PlanFeatureCode, PlanTypeCode>++export const planTypeHasFeature = (+ planType: PlanTypeCode | null | undefined,+ feature: PlanFeatureCode,+) => {+ if (!planType) {+ return false+ }++ return (+ PLAN_TYPES[planType].sortOrder >=+ PLAN_TYPES[PLAN_FEATURE_REQUIRED_PLAN[feature]].sortOrder+ )+}diff --git a/web/app/pages/Project/View/ViewProject.tsx b/web/app/pages/Project/View/ViewProject.tsxindex 7d8bbd6d9..1bd7c5113 100644--- a/web/app/pages/Project/View/ViewProject.tsx+++ b/web/app/pages/Project/View/ViewProject.tsx@@ -47,6 +47,7 @@ import { toast } from 'sonner'import Footer from '~/components/Footer'import Header from '~/components/Header'+import { useProjectFeatureAccess } from '~/hooks/useProjectFeatureAccess'import useSize from '~/hooks/useSize'import { changeLanguage } from '~/i18n'import {@@ -101,6 +102,7 @@ const AskAIView = lazy(() => import('../tabs/AskAI'))const CaptchaView = lazy(() => import('../tabs/Captcha/CaptchaView'))import LockedDashboard from './components/LockedDashboard'import PasswordRequiredModal from './components/PasswordRequiredModal'+import PlanFeatureLocked from './components/PlanFeatureLocked'import ProjectSidebar, {MobileSidebarTrigger,} from './components/ProjectSidebar'@@ -293,6 +295,8 @@ const ViewProjectContent = () => {submitPassword,} = useCurrentProject()const projectPassword = useProjectPassword(id)+ const experimentsAccess = useProjectFeatureAccess('experiments')+ const featureFlagsAccess = useProjectFeatureAccess('featureFlags')const { theme, setTheme } = useTheme()@@ -1609,28 +1613,44 @@ const ViewProjectContent = () => {/>) : null}{activeTab === PROJECT_TABS.experiments ? (- <ExperimentsView- period={period}- from={- dateRange ? getFormatDate(dateRange[0]) : ''- }- to={- dateRange ? getFormatDate(dateRange[1]) : ''- }- timezone={timezone}- />+ experimentsAccess.hasAccess ? (+ <ExperimentsView+ period={period}+ from={+ dateRange+ ? getFormatDate(dateRange[0])+ : ''+ }+ to={+ dateRange+ ? getFormatDate(dateRange[1])+ : ''+ }+ timezone={timezone}+ />+ ) : (+ <PlanFeatureLocked feature='experiments' />+ )) : null}{activeTab === PROJECT_TABS.featureFlags ? (- <FeatureFlagsView- period={period}- from={- dateRange ? getFormatDate(dateRange[0]) : ''- }- to={- dateRange ? getFormatDate(dateRange[1]) : ''- }- timezone={timezone}- />+ featureFlagsAccess.hasAccess ? (+ <FeatureFlagsView+ period={period}+ from={+ dateRange+ ? getFormatDate(dateRange[0])+ : ''+ }+ to={+ dateRange+ ? getFormatDate(dateRange[1])+ : ''+ }+ timezone={timezone}+ />+ ) : (+ <PlanFeatureLocked feature='featureFlags' />+ )) : null}{activeTab === PROJECT_TABS.captcha ? (<CaptchaView projectId={id} />diff --git a/web/app/pages/Project/View/components/PlanFeatureLocked.tsx b/web/app/pages/Project/View/components/PlanFeatureLocked.tsxnew file mode 100644index 000000000..f0c2bc087--- /dev/null+++ b/web/app/pages/Project/View/components/PlanFeatureLocked.tsx@@ -0,0 +1,49 @@+import { LockIcon } from '@phosphor-icons/react'+import { useTranslation } from 'react-i18next'++import { useProjectFeatureAccess } from '~/hooks/useProjectFeatureAccess'+import type { PlanFeatureCode } from '~/lib/pricing/features'+import Button from '~/ui/Button'+import { Text } from '~/ui/Text'+import routes from '~/utils/routes'++interface PlanFeatureLockedProps {+ feature: PlanFeatureCode+}++const PlanFeatureLocked = ({ feature }: PlanFeatureLockedProps) => {+ const { t } = useTranslation('common')+ const { isOwner } = useProjectFeatureAccess(feature)+ const audience = isOwner ? 'owner' : 'viewer'++ return (+ <div className='mx-auto w-full max-w-2xl py-16 text-center'>+ <div className='mx-auto mb-6 flex size-14 items-center justify-center rounded-xl bg-gray-100 dark:bg-slate-900'>+ <LockIcon+ className='size-7 text-yellow-500 dark:text-yellow-400'+ aria-hidden='true'+ />+ </div>+ <Text as='h3' size='xl' weight='medium' tracking='tight'>+ {t(`project.featureAccess.${feature}.${audience}Title`)}+ </Text>+ <Text+ as='p'+ size='sm'+ colour='secondary'+ className='mx-auto mt-2 max-w-md whitespace-pre-line'+ >+ {t(`project.featureAccess.${audience}Description`)}+ </Text>+ {isOwner ? (+ <div className='mt-6 flex justify-center'>+ <Button to={routes.billing_choose_plan}>+ {t('project.featureAccess.upgradePlan')}+ </Button>+ </div>+ ) : null}+ </div>+ )+}++export default PlanFeatureLockeddiff --git a/web/app/routes/projects.$id.tsx b/web/app/routes/projects.$id.tsxindex 1bb845ece..fd4919200 100644--- a/web/app/routes/projects.$id.tsx+++ b/web/app/routes/projects.$id.tsx@@ -752,7 +752,10 @@ export async function loader({ request, params }: LoaderFunctionArgs) {analyticsParams,).then((res) => res.data)}- } else if (tab === PROJECT_TABS.featureFlags) {+ } else if (+ tab === PROJECT_TABS.featureFlags &&+ (isSelfhosted || project.featureAccess?.featureFlags === true)+ ) {featureFlagsData = getProjectFeatureFlagsServer(request, projectId).then((res) => res.data,)diff --git a/web/public/locales/en.json b/web/public/locales/en.jsonindex b5717d48d..6c2a16fdf 100644--- a/web/public/locales/en.json+++ b/web/public/locales/en.json@@ -1990,6 +1990,19 @@"resolve": "We are still counting your stats and have not deleted any data. Once the billing issue is fixed, dashboard access will be restored right away.","manageSubscription": "Manage subscription"},+ "featureAccess": {+ "featureFlags": {+ "ownerTitle": "Feature Flags are not available on your plan",+ "viewerTitle": "Feature Flags are not available for this project"+ },+ "experiments": {+ "ownerTitle": "Experiments are not available on your plan",+ "viewerTitle": "Experiments are not available for this project"+ },+ "ownerDescription": "This feature is included in Plus and Enterprise. Upgrade your plan to use it in this project.",+ "viewerDescription": "The project owner does not have access to this feature on their current plan. Contact them to upgrade the project plan.",+ "upgradePlan": "Upgrade plan"+ },"waiting": {"title": "No events yet","desc": "No events have been tracked yet. Follow the installation steps below to start collecting data. Still not working? Try <turl>troubleshooting</turl> your integration or <curl>contact us</curl> for setup help."