Skip to content

📈 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!

Remove obsolete internal feature flags functionality

Blue Mouse54ad0a2185bc
diff --git a/backend/apps/cloud/src/project/project-extra.service.ts b/backend/apps/cloud/src/project/project-extra.service.ts
deleted file mode 100644
index ff0d1e22f..000000000
--- a/backend/apps/cloud/src/project/project-extra.service.ts
+++ /dev/null
@@ -1,692 +0,0 @@
-import { Injectable } from '@nestjs/common'
-import { InjectRepository } from '@nestjs/typeorm'
-import { Brackets, In, Repository } from 'typeorm'
-import dayjs from 'dayjs'
-import utc from 'dayjs/plugin/utc'
-
-import { Pagination, PaginationOptionsInterface } from '../common/pagination'
-import { Project } from './entity/project.entity'
-import { clickhouse } from '../common/integrations/clickhouse'
-import { ProjectService } from './project.service'
-
-dayjs.extend(utc)
-
-interface TrafficPaginationOptions extends PaginationOptionsInterface {
- mode?: 'high-traffic' | 'low-traffic' | 'performance' | 'lost-traffic'
- period?: '1h' | '1d' | '7d' | '4w' | '3M' | '12M' | '24M' | 'all'
- sort?:
- | 'alpha_asc'
- | 'alpha_desc'
- | 'date_asc'
- | 'date_desc'
- | 'pageviews_asc'
- | 'pageviews_desc'
- | 'last_visit_desc'
-}
-
-@Injectable()
-export class ProjectExtraService {
- constructor(
- @InjectRepository(Project)
- private projectsRepository: Repository<Project>,
- private readonly projectService: ProjectService,
- ) {}
-
- async paginateHostnameNavigation(
- options: TrafficPaginationOptions,
- userId: string,
- search?: string,
- ): Promise<Pagination<Project>> {
- const projectIds = await this.getVisibleProjectIds(userId)
-
- if (!projectIds.length) {
- return new Pagination<Project>({ results: [], total: 0 })
- }
-
- const timeFrameClause = this.getTimeFrameClause(options.period)
-
- // Process project IDs in chunks to avoid overwhelming Clickhouse
- const CHUNK_SIZE = 1000
- const chunks = []
- for (let i = 0; i < projectIds.length; i += CHUNK_SIZE) {
- chunks.push(projectIds.slice(i, i + CHUNK_SIZE))
- }
-
- // Query to get hosts and their associated PIDs
- const query = `
- WITH hostStats AS (
- SELECT
- host,
- pid,
- count() as visits
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- AND host IS NOT NULL
- AND host != ''
- ${search ? `AND host ILIKE {search:String}` : ''}
- AND created BETWEEN ${timeFrameClause.currentStart} AND ${timeFrameClause.currentEnd}
- GROUP BY host, pid
- ${options.sort === 'alpha_asc' ? 'ORDER BY host ASC' : ''}
- ${options.sort === 'alpha_desc' ? 'ORDER BY host DESC' : ''}
- ${options.sort === 'pageviews_asc' ? 'ORDER BY visits ASC' : ''}
- ${options.sort === 'pageviews_desc' ? 'ORDER BY visits DESC' : ''}
- )
- SELECT *
- FROM hostStats
- `
-
- // Execute query for each chunk and combine results
- let allResults = []
- let total = 0
-
- for (const chunk of chunks) {
- const result = await clickhouse.query({
- query,
- query_params: {
- pids: chunk,
- search: `%${search}%`,
- },
- format: 'JSONEachRow',
- })
-
- const chunkResults = await result.json()
- allResults = allResults.concat(chunkResults)
-
- if (allResults.length >= options.take) {
- break
- }
- }
-
- for (const chunk of chunks) {
- // Get total count for this chunk
- const countQuery = `
- WITH hostStats AS (
- SELECT
- host,
- pid,
- count() as visits
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- AND host IS NOT NULL
- AND host != ''
- ${search ? `AND host ILIKE {search:String}` : ''}
- AND created BETWEEN ${timeFrameClause.currentStart} AND ${timeFrameClause.currentEnd}
- GROUP BY host, pid
- )
- SELECT count() as total FROM hostStats
- `
-
- const countResult = await clickhouse.query({
- query: countQuery,
- query_params: {
- pids: chunk,
- search: `%${search}%`,
- },
- format: 'JSONEachRow',
- })
-
- const countData = await countResult.json<{ total: number }>()
- total += countData[0]?.total || 0
- }
-
- // Apply pagination to combined results
- const paginatedResults = allResults.slice(
- options.skip || 0,
- (options.skip || 0) + (options.take || 10),
- )
-
- const uniquePids = [...new Set(paginatedResults.map(r => r.pid))]
-
- // Fetch full project details for the paginated results
- const projects = await this.projectService.find({
- where: { id: In(uniquePids) },
- relations: [
- 'admin',
- 'share',
- 'share.user',
- 'organisation',
- 'organisation.members',
- 'organisation.members.user',
- ],
- })
-
- const enrichedProjects = projects
- .map(project => {
- const chResults = paginatedResults.filter(r => r.pid === project.id)
-
- return chResults.map(chResult => ({
- ...project,
- name: (chResult.host || project.name) as string,
- trafficStats: {
- visits: chResult.visits || 0,
- },
- }))
- })
- .flat()
-
- const results = new Pagination<Project>({
- results: enrichedProjects.sort((a, b) => {
- switch (options.sort) {
- case 'alpha_asc':
- return a.name.localeCompare(b.name)
- case 'alpha_desc':
- return b.name.localeCompare(a.name)
- case 'pageviews_asc':
- return (a.trafficStats?.visits || 0) - (b.trafficStats?.visits || 0)
- case 'pageviews_desc':
- default:
- return (b.trafficStats?.visits || 0) - (a.trafficStats?.visits || 0)
- }
- }),
- total,
- })
-
- return results
- }
-
- async getVisibleProjectIds(
- userId: string,
- search?: string,
- ): Promise<string[]> {
- const queryBuilder = this.projectsRepository
- .createQueryBuilder('project')
- .select('project.id')
- .leftJoin('project.admin', 'admin')
- .leftJoin('project.share', 'share')
- .leftJoin('project.organisation', 'organisation')
- .leftJoin('organisation.members', 'organisationMembers')
- .where('project.isAnalyticsProject = true')
- .where(
- new Brackets(qb => {
- qb.where('admin.id = :userId', { userId })
- .orWhere(
- new Brackets(qb2 => {
- qb2.where('share.user.id = :userId')
- }),
- )
- .orWhere(
- new Brackets(qb3 => {
- qb3
- .where('organisationMembers.user.id = :userId')
- .andWhere('organisationMembers.confirmed = true')
- }),
- )
- }),
- )
-
- if (search?.trim()) {
- queryBuilder
- .andWhere('project.name LIKE :search')
- .setParameter('search', `%${search.trim()}%`)
- }
-
- const projects = await queryBuilder.getMany()
- return projects.map(p => p.id)
- }
-
- async paginateByTraffic(
- options: TrafficPaginationOptions,
- userId: string,
- search?: string,
- isHostnameNavigationEnabled?: boolean,
- ): Promise<Pagination<Project>> {
- // Get all visible project IDs
- const projectIds = await this.getVisibleProjectIds(
- userId,
- isHostnameNavigationEnabled ? undefined : search,
- )
-
- if (!projectIds.length) {
- return new Pagination<Project>({ results: [], total: 0 })
- }
-
- // Process project IDs in chunks to avoid overwhelming Clickhouse
- const CHUNK_SIZE = 1000
- const chunks = []
- for (let i = 0; i < projectIds.length; i += CHUNK_SIZE) {
- chunks.push(projectIds.slice(i, i + CHUNK_SIZE))
- }
-
- const timeFrameClause = this.getTimeFrameClause(options.period)
- let query = ''
- let countQuery = ''
-
- if (isHostnameNavigationEnabled) {
- if (options.mode === 'performance') {
- query = `
- WITH
- currentPeriod AS (
- SELECT pid, host, count() as visits
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- AND created BETWEEN ${timeFrameClause.currentStart} AND ${timeFrameClause.currentEnd}
- AND host IS NOT NULL
- AND host != ''
- ${search ? `AND host ILIKE {search:String}` : ''}
- GROUP BY host, pid
- ),
- previousPeriod AS (
- SELECT pid, host, count() as visits
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- AND created BETWEEN ${timeFrameClause.previousStart} AND ${timeFrameClause.previousEnd}
- AND host IS NOT NULL
- AND host != ''
- ${search ? `AND host ILIKE {search:String}` : ''}
- GROUP BY host, pid
- )
- SELECT
- cp.pid,
- cp.host,
- cp.visits as current_visits,
- pp.visits as previous_visits,
- ((cp.visits - pp.visits) / pp.visits * 100) as percentage_change
- FROM currentPeriod cp
- JOIN previousPeriod pp ON cp.pid = pp.pid AND cp.host = pp.host
- WHERE pp.visits > 0
- ORDER BY abs(percentage_change) DESC
- `
-
- countQuery = `
- WITH
- currentPeriod AS (
- SELECT pid, host, count() as visits
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- AND created BETWEEN ${timeFrameClause.currentStart} AND ${timeFrameClause.currentEnd}
- AND host IS NOT NULL
- AND host != ''
- ${search ? `AND host ILIKE {search:String}` : ''}
- GROUP BY host, pid
- ),
- previousPeriod AS (
- SELECT pid, host, count() as visits
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- AND created BETWEEN ${timeFrameClause.previousStart} AND ${timeFrameClause.previousEnd}
- AND host IS NOT NULL
- AND host != ''
- ${search ? `AND host ILIKE {search:String}` : ''}
- GROUP BY host, pid
- )
- SELECT count() as total
- FROM currentPeriod cp
- JOIN previousPeriod pp ON cp.pid = pp.pid AND cp.host = pp.host
- WHERE pp.visits > 0
- `
- } else if (options.mode === 'lost-traffic') {
- query = `
- WITH last_visits AS (
- SELECT
- host,
- pid,
- max(created) as last_visit,
- count() as total_visits
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- AND host IS NOT NULL
- AND host != ''
- ${search ? `AND host ILIKE {search:String}` : ''}
- GROUP BY host, pid
- ),
- hostStats AS (
- SELECT
- host,
- pid,
- max(last_visit) as last_visit,
- sum(total_visits) as total_visits
- FROM last_visits
- GROUP BY host, pid
- )
- SELECT *
- FROM hostStats
- WHERE last_visit < (now() - INTERVAL 48 HOUR)
- AND total_visits > 0
- ${options.sort === 'alpha_asc' ? 'ORDER BY host ASC' : ''}
- ${options.sort === 'alpha_desc' ? 'ORDER BY host DESC' : ''}
- ${options.sort === 'last_visit_desc' || !options.sort ? 'ORDER BY last_visit DESC' : ''}
- `
-
- countQuery = `
- WITH last_visits AS (
- SELECT
- host,
- pid,
- max(created) as last_visit,
- count() as total_visits
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- AND host IS NOT NULL
- AND host != ''
- ${search ? `AND host ILIKE {search:String}` : ''}
- GROUP BY host, pid
- ),
- hostStats AS (
- SELECT
- host,
- pid
- FROM last_visits
- WHERE last_visit < (now() - INTERVAL 48 HOUR)
- AND total_visits > 0
- )
- SELECT count() as total FROM hostStats
- `
- } else {
- // High/Low traffic query
- query = `
- WITH hostStats AS (
- SELECT
- host,
- pid,
- count() as visits
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- AND created BETWEEN ${timeFrameClause.currentStart} AND ${timeFrameClause.currentEnd}
- AND host IS NOT NULL
- AND host != ''
- ${search ? `AND host ILIKE {search:String}` : ''}
- GROUP BY host, pid
- )
- SELECT *
- FROM hostStats
- ORDER BY visits ${options.mode === 'high-traffic' ? 'DESC' : 'ASC'}
- `
-
- countQuery = `
- WITH hostStats AS (
- SELECT
- host,
- pid
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- AND created BETWEEN ${timeFrameClause.currentStart} AND ${timeFrameClause.currentEnd}
- AND host IS NOT NULL
- AND host != ''
- ${search ? `AND host ILIKE {search:String}` : ''}
- GROUP BY host, pid
- )
- SELECT count() as total FROM hostStats
- `
- }
- } else if (options.mode === 'performance') {
- query = `
- WITH
- currentPeriod AS (
- SELECT pid, count() as visits
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- AND created BETWEEN ${timeFrameClause.currentStart} AND ${timeFrameClause.currentEnd}
- GROUP BY pid
- ),
- previousPeriod AS (
- SELECT pid, count() as visits
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- AND created BETWEEN ${timeFrameClause.previousStart} AND ${timeFrameClause.previousEnd}
- GROUP BY pid
- )
- SELECT
- cp.pid,
- cp.visits as current_visits,
- pp.visits as previous_visits,
- ((cp.visits - pp.visits) / pp.visits * 100) as percentage_change
- FROM currentPeriod cp
- JOIN previousPeriod pp ON cp.pid = pp.pid
- WHERE pp.visits > 0
- ORDER BY abs(percentage_change) DESC
- `
-
- countQuery = `
- WITH
- currentPeriod AS (
- SELECT pid, count() as visits
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- AND created BETWEEN ${timeFrameClause.currentStart} AND ${timeFrameClause.currentEnd}
- GROUP BY pid
- ),
- previousPeriod AS (
- SELECT pid, count() as visits
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- AND created BETWEEN ${timeFrameClause.previousStart} AND ${timeFrameClause.previousEnd}
- GROUP BY pid
- )
- SELECT count() as total FROM currentPeriod cp
- JOIN previousPeriod pp ON cp.pid = pp.pid
- WHERE pp.visits > 0
-
- `
- } else if (options.mode === 'lost-traffic') {
- query = `
- WITH last_visits AS (
- SELECT
- pid,
- max(created) as last_visit,
- count() as total_visits
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- GROUP BY pid
- )
- SELECT *
- FROM last_visits
- WHERE last_visit < (now() - INTERVAL 48 HOUR)
- AND total_visits > 0
- ORDER BY last_visit DESC
- `
-
- countQuery = `
- WITH last_visits AS (
- SELECT
- pid,
- max(created) as last_visit,
- count() as total_visits
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- GROUP BY pid
- HAVING last_visit < (now() - INTERVAL 48 HOUR)
- AND total_visits > 0
- )
- SELECT count() as total FROM last_visits
- `
- } else {
- // High/Low traffic query
- query = `
- SELECT
- pid,
- count() as visits
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- AND created BETWEEN ${timeFrameClause.currentStart} AND ${timeFrameClause.currentEnd}
- GROUP BY pid
- ORDER BY visits ${options.mode === 'high-traffic' ? 'DESC' : 'ASC'}
- `
-
- countQuery = `
- WITH projectStats AS (
- SELECT
- pid
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- AND created BETWEEN ${timeFrameClause.currentStart} AND ${timeFrameClause.currentEnd}
- GROUP BY pid
- )
- SELECT count() as total FROM projectStats
- `
- }
-
- // Execute query for each chunk and combine results
- let allResults = []
- let total = 0
-
- for (const chunk of chunks) {
- const result = await clickhouse.query({
- query,
- query_params: {
- pids: chunk,
- search: `%${search}%`,
- },
- format: 'JSONEachRow',
- })
-
- const chunkResults = await result.json()
- allResults = allResults.concat(chunkResults)
-
- if (allResults.length >= options.take) {
- break
- }
- }
-
- for (const chunk of chunks) {
- const countResult = await clickhouse.query({
- query: countQuery,
- query_params: {
- pids: chunk,
- search: `%${search}%`,
- },
- format: 'JSONEachRow',
- })
-
- const countData = await countResult.json<{ total: number }>()
- total += countData[0]?.total || 0
- }
-
- // Apply pagination to combined results
- const paginatedResults = allResults.slice(
- options.skip || 0,
- (options.skip || 0) + (options.take || 10),
- )
-
- const uniquePids = [...new Set(paginatedResults.map(r => r.pid))]
-
- // Fetch full project details for the paginated results
- const projects = await this.projectService.find({
- where: { id: In(uniquePids) },
- relations: [
- 'admin',
- 'share',
- 'share.user',
- 'organisation',
- 'organisation.members',
- 'organisation.members.user',
- ],
- })
-
- // Add traffic stats to projects
- const enrichedProjects = projects
- .map(project => {
- const chResults = paginatedResults.filter(r => r.pid === project.id)
-
- return chResults.map(chResult => ({
- ...project,
- name: (chResult.host || project.name) as string,
- trafficStats: {
- visits: chResult.visits || chResult.current_visits || 0,
- percentageChange: chResult.percentage_change,
- },
- }))
- })
- .flat()
-
- const results = new Pagination<Project>({
- results: enrichedProjects.sort((a, b) => {
- if (options.mode === 'performance') {
- return (
- Math.abs(b.trafficStats.percentageChange) -
- Math.abs(a.trafficStats.percentageChange)
- )
- }
-
- if (options.mode === 'high-traffic') {
- return (b.trafficStats.visits || 0) - (a.trafficStats.visits || 0)
- }
-
- if (options.mode === 'low-traffic') {
- return (a.trafficStats.visits || 0) - (b.trafficStats.visits || 0)
- }
-
- if (options.mode === 'lost-traffic' && isHostnameNavigationEnabled) {
- switch (options.sort) {
- case 'alpha_asc':
- return a.name.localeCompare(b.name)
- case 'alpha_desc':
- return b.name.localeCompare(a.name)
- default:
- return (b.trafficStats.visits || 0) - (a.trafficStats.visits || 0)
- }
- }
-
- return (b.trafficStats.visits || 0) - (a.trafficStats.visits || 0)
- }),
- total,
- })
-
- return this.projectService.processDefaultResults(results, userId)
- }
-
- private getTimeFrameClause(period: TrafficPaginationOptions['period']): {
- currentStart: string
- currentEnd: string
- previousStart?: string
- previousEnd?: string
- } {
- const now = 'now()'
-
- switch (period) {
- case '1h':
- return {
- currentStart: `${now} - INTERVAL 1 HOUR`,
- currentEnd: now,
- previousStart: `${now} - INTERVAL 2 HOUR`,
- previousEnd: `${now} - INTERVAL 1 HOUR`,
- }
- case '1d':
- return {
- currentStart: `${now} - INTERVAL 1 DAY`,
- currentEnd: now,
- previousStart: `${now} - INTERVAL 2 DAY`,
- previousEnd: `${now} - INTERVAL 1 DAY`,
- }
- case '7d':
- return {
- currentStart: `${now} - INTERVAL 7 DAY`,
- currentEnd: now,
- previousStart: `${now} - INTERVAL 14 DAY`,
- previousEnd: `${now} - INTERVAL 7 DAY`,
- }
- case '4w':
- return {
- currentStart: `${now} - INTERVAL 28 DAY`,
- currentEnd: now,
- previousStart: `${now} - INTERVAL 56 DAY`,
- previousEnd: `${now} - INTERVAL 28 DAY`,
- }
- case '3M':
- return {
- currentStart: `${now} - INTERVAL 90 DAY`,
- currentEnd: now,
- previousStart: `${now} - INTERVAL 180 DAY`,
- previousEnd: `${now} - INTERVAL 90 DAY`,
- }
- case '12M':
- return {
- currentStart: `${now} - INTERVAL 365 DAY`,
- currentEnd: now,
- previousStart: `${now} - INTERVAL 730 DAY`,
- previousEnd: `${now} - INTERVAL 365 DAY`,
- }
- case '24M':
- return {
- currentStart: `${now} - INTERVAL 730 DAY`,
- currentEnd: now,
- previousStart: `${now} - INTERVAL 1460 DAY`,
- previousEnd: `${now} - INTERVAL 730 DAY`,
- }
- default: // all time
- return {
- currentStart: "toDate('2020-01-01')", // or your earliest date
- currentEnd: now,
- }
- }
- }
-}
diff --git a/backend/apps/cloud/src/project/project.controller.ts b/backend/apps/cloud/src/project/project.controller.ts
index e7c546f8b..153b13042 100644
--- a/backend/apps/cloud/src/project/project.controller.ts
+++ b/backend/apps/cloud/src/project/project.controller.ts
@@ -114,7 +114,6 @@ import { ProjectViewIdsDto } from './dto/project-view-ids.dto'
import { OrganisationService } from '../organisation/organisation.service'
import { Organisation } from '../organisation/entity/organisation.entity'
import { ProjectOrganisationDto } from './dto/project-organisation.dto'
-import { ProjectExtraService } from './project-extra.service'
const PROJECTS_MAXIMUM = 50
@@ -137,7 +136,6 @@ export class ProjectController {
private readonly mailerService: MailerService,
private readonly projectsViewsRepository: ProjectsViewsRepository,
private readonly organisationService: OrganisationService,
- private readonly projectExtraService: ProjectExtraService,
) {}
@ApiBearerAuth()
@@ -145,11 +143,6 @@ export class ProjectController {
@ApiQuery({ name: 'take', required: false })
@ApiQuery({ name: 'skip', required: false })
@ApiQuery({ name: 'search', required: false, type: String })
- @ApiQuery({
- name: 'mode',
- required: false,
- type: String,
- })
@ApiQuery({
name: 'timeFrame',
required: false,
@@ -167,30 +160,17 @@ export class ProjectController {
@Query('take', new ParseIntPipe({ optional: true })) take?: number,
@Query('skip', new ParseIntPipe({ optional: true })) skip?: number,
@Query('search') search?: string,
- @Query('mode')
- mode?:
- | 'default'
- | 'high-traffic'
- | 'low-traffic'
- | 'performance'
- | 'lost-traffic',
@Query('period')
period: '1h' | '1d' | '7d' | '4w' | '3M' | '12M' | '24M' | 'all' = '7d',
- @Query('use-hostname-navigation')
- useHostnameNavigation: string = 'false',
@Query('sort')
sort?: 'alpha_asc' | 'alpha_desc' | 'date_asc' | 'date_desc',
): Promise<Pagination<Project> | Project[] | object> {
- const isHostnameNavigationEnabled = useHostnameNavigation === 'true'
-
this.logger.log(
{
userId,
take,
skip,
- mode,
timeFrame: period,
- useHostnameNavigation,
sort,
},
'GET /project',
@@ -204,47 +184,17 @@ export class ProjectController {
)
}
- if (!mode || mode === 'default') {
- let paginated
-
- if (isHostnameNavigationEnabled) {
- paginated = await this.projectExtraService.paginateHostnameNavigation(
- {
- take,
- skip,
- period,
- sort,
- },
- userId,
- search,
- )
- } else {
- paginated = await this.projectService.paginate(
- {
- take,
- skip,
- },
- userId,
- search,
- sort,
- )
- }
-
- return this.projectService.processDefaultResults(paginated, userId)
- }
-
- return this.projectExtraService.paginateByTraffic(
+ const paginated = await this.projectService.paginate(
{
take,
skip,
- mode,
- period,
- sort,
},
userId,
search,
- isHostnameNavigationEnabled,
+ sort,
)
+
+ return this.projectService.processDefaultResults(paginated, userId)
}
@ApiBearerAuth()
diff --git a/backend/apps/cloud/src/project/project.module.ts b/backend/apps/cloud/src/project/project.module.ts
index 3ef49fd2b..7647e850a 100644
--- a/backend/apps/cloud/src/project/project.module.ts
+++ b/backend/apps/cloud/src/project/project.module.ts
@@ -21,7 +21,6 @@ import { ProjectsViewsRepository } from './repositories/projects-views.repositor
import { ProjectViewEntity } from './entity/project-view.entity'
import { ProjectViewCustomEventEntity } from './entity/project-view-custom-event.entity'
import { OrganisationModule } from '../organisation/organisation.module'
-import { ProjectExtraService } from './project-extra.service'
@Module({
imports: [
@@ -41,18 +40,8 @@ import { ProjectExtraService } from './project-extra.service'
ActionTokensModule,
MailerModule,
],
- providers: [
- ProjectService,
- ProjectExtraService,
- ProjectsViewsRepository,
- GSCService,
- ],
- exports: [
- ProjectService,
- ProjectExtraService,
- ProjectsViewsRepository,
- GSCService,
- ],
+ providers: [ProjectService, ProjectsViewsRepository, GSCService],
+ exports: [ProjectService, ProjectsViewsRepository, GSCService],
controllers: [ProjectController, GSCController],
})
export class ProjectModule {}
diff --git a/backend/apps/cloud/src/user/entities/user.entity.ts b/backend/apps/cloud/src/user/entities/user.entity.ts
index 8a45e130e..684402676 100644
--- a/backend/apps/cloud/src/user/entities/user.entity.ts
+++ b/backend/apps/cloud/src/user/entities/user.entity.ts
@@ -221,24 +221,11 @@ export const DEFAULT_TIMEZONE = 'Etc/GMT'
export const TRIAL_DURATION = 14 // days
-export enum FeatureFlag {
- 'dashboard-period-selector' = 'dashboard-period-selector',
- 'dashboard-analytics-tabs' = 'dashboard-analytics-tabs',
- 'dashboard-hostname-cards' = 'dashboard-hostname-cards',
-}
-
@Entity()
export class User {
@PrimaryGeneratedColumn('uuid')
id: string
- @Column({
- type: 'set',
- enum: FeatureFlag,
- default: [],
- })
- featureFlags: FeatureFlag[]
-
@Column({
type: 'enum',
enum: PlanCode,
diff --git a/backend/apps/cloud/src/user/user.controller.ts b/backend/apps/cloud/src/user/user.controller.ts
index 4e2fd2093..74c3b2ae0 100644
--- a/backend/apps/cloud/src/user/user.controller.ts
+++ b/backend/apps/cloud/src/user/user.controller.ts
@@ -42,7 +42,6 @@ import {
User,
MAX_EMAIL_REQUESTS,
PlanCode,
- FeatureFlag,
OnboardingStep,
} from './entities/user.entity'
import { isDevelopment, PRODUCTION_ORIGIN } from '../common/constants'
@@ -113,15 +112,6 @@ export class UserController {
}
}
- @ApiBearerAuth()
- @Put('/feature-flags')
- async setFeatureFlags(
- @CurrentUserId() userId: string,
- @Body('featureFlags') featureFlags: FeatureFlag[],
- ) {
- await this.userService.update(userId, { featureFlags })
- }
-
@ApiBearerAuth()
@Put('/live-visitors')
async setShowLiveVisitors(
diff --git a/backend/apps/community/src/common/utils.ts b/backend/apps/community/src/common/utils.ts
index a0033c190..1a460e566 100644
--- a/backend/apps/community/src/common/utils.ts
+++ b/backend/apps/community/src/common/utils.ts
@@ -1210,22 +1210,6 @@ const unpinProjectClickhouse = async (
})
}
-const isProjectPinnedClickhouse = async (
- visitorId: string,
- projectId: string,
-): Promise<boolean> => {
- const query = `SELECT 1 FROM pinned_project WHERE visitorId = {visitorId:String} AND projectId = {projectId:FixedString(12)} LIMIT 1;`
-
- const { data } = await clickhouse
- .query({
- query,
- query_params: { visitorId, projectId },
- })
- .then(resultSet => resultSet.json())
-
- return !_isEmpty(data)
-}
-
export {
checkRateLimit,
createProjectClickhouse,
@@ -1274,5 +1258,4 @@ export {
getPinnedProjectsClickhouse,
pinProjectClickhouse,
unpinProjectClickhouse,
- isProjectPinnedClickhouse,
}
diff --git a/backend/migrations/mysql/2025_12_14_remove_internal_feature_flags.sql b/backend/migrations/mysql/2025_12_14_remove_internal_feature_flags.sql
new file mode 100644
index 000000000..91d638477
--- /dev/null
+++ b/backend/migrations/mysql/2025_12_14_remove_internal_feature_flags.sql
@@ -0,0 +1 @@
+ALTER TABLE user DROP COLUMN `featureFlags`;
diff --git a/web/app/api/index.ts b/web/app/api/index.ts
index b54c4b981..e3b75542d 100644
--- a/web/app/api/index.ts
+++ b/web/app/api/index.ts
@@ -24,7 +24,7 @@ import {
} from '~/lib/models/Project'
import { Stats } from '~/lib/models/Stats'
import { Subscriber } from '~/lib/models/Subscriber'
-import { User, FeatureFlag } from '~/lib/models/User'
+import { User } from '~/lib/models/User'
import { Filter, ProjectViewCustomEvent } from '~/pages/Project/View/interfaces/traffic'
import { getAccessToken, setAccessToken } from '~/utils/accessToken'
import { logout } from '~/utils/auth'
@@ -257,19 +257,9 @@ export const verifyShare = ({ path, id }: { path: string; id: string }) =>
throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
})
-export const getProjects = (
- take = 0,
- skip = 0,
- search = '',
- mode = 'default',
- period = '7d',
- useHostnameNavigation = false,
- sort = 'alpha_asc',
-) =>
+export const getProjects = (take = 0, skip = 0, search = '', period = '7d', sort = 'alpha_asc') =>
api
- .get(
- `/project?take=${take}&skip=${skip}&search=${search}&mode=${mode}&period=${period}&use-hostname-navigation=${useHostnameNavigation}&sort=${sort}`,
- )
+ .get(`/project?take=${take}&skip=${skip}&search=${search}&period=${period}&sort=${sort}`)
.then(
(
response,
@@ -2175,14 +2165,6 @@ export const updateErrorStatus = (pid: string, status: 'resolved' | 'active', ei
throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
})
-export const setFeatureFlags = (featureFlags: FeatureFlag[]) =>
- api
- .put('/user/feature-flags', { featureFlags })
- .then((response): User => response.data)
- .catch((error) => {
- throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
- })
-
export const updateOnboardingStep = (step: string) =>
api
.post('/user/onboarding/step', { step })
diff --git a/web/app/hooks/useFeatureFlag.ts b/web/app/hooks/useFeatureFlag.ts
deleted file mode 100644
index a3927898c..000000000
--- a/web/app/hooks/useFeatureFlag.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { FeatureFlag } from '~/lib/models/User'
-import { useAuth } from '~/providers/AuthProvider'
-
-const useFeatureFlag = (flag: FeatureFlag): boolean => {
- const { user } = useAuth()
-
- if (!user?.featureFlags) {
- return false
- }
-
- return user.featureFlags.includes(flag)
-}
-
-export default useFeatureFlag
diff --git a/web/app/lib/models/User.ts b/web/app/lib/models/User.ts
index 8b0e292bc..74e745999 100644
--- a/web/app/lib/models/User.ts
+++ b/web/app/lib/models/User.ts
@@ -22,12 +22,6 @@ enum PlanCode {
'10m' = '10m',
}
-export enum FeatureFlag {
- 'dashboard-period-selector' = 'dashboard-period-selector',
- 'dashboard-analytics-tabs' = 'dashboard-analytics-tabs',
- 'dashboard-hostname-cards' = 'dashboard-hostname-cards',
-}
-
enum OnboardingStep {
WELCOME = 'welcome',
CREATE_PROJECT = 'create_project',
@@ -39,7 +33,6 @@ enum OnboardingStep {
export interface User {
id: string
planCode: PlanCode
- featureFlags: FeatureFlag[]
nickname: string
email: string
isActive: boolean
diff --git a/web/app/pages/Dashboard/Dashboard.tsx b/web/app/pages/Dashboard/Dashboard.tsx
index f998c09a1..e971078ba 100644
--- a/web/app/pages/Dashboard/Dashboard.tsx
+++ b/web/app/pages/Dashboard/Dashboard.tsx
@@ -16,10 +16,8 @@ import EventsRunningOutBanner from '~/components/EventsRunningOutBanner'
import { withAuthentication, auth } from '~/hoc/protected'
import useBreakpoint from '~/hooks/useBreakpoint'
import useDebounce from '~/hooks/useDebounce'
-import useFeatureFlag from '~/hooks/useFeatureFlag'
import { isSelfhosted, LIVE_VISITORS_UPDATE_INTERVAL, tbPeriodPairs } from '~/lib/constants'
import { Overall, Project } from '~/lib/models/Project'
-import { FeatureFlag } from '~/lib/models/User'
import { useAuth } from '~/providers/AuthProvider'
import Input from '~/ui/Input'
import Modal from '~/ui/Modal'
@@ -35,7 +33,6 @@ import { NoProjects } from './NoProjects'
import { PeriodSelector } from './PeriodSelector'
import { ProjectCard, ProjectCardSkeleton } from './ProjectCard'
import { SortSelector, SORT_OPTIONS } from './SortSelector'
-import { DASHBOARD_TABS, Tabs } from './Tabs'
const PAGE_SIZE_OPTIONS = [12, 24, 48, 96]
@@ -51,9 +48,6 @@ const Dashboard = () => {
const { viewMode: defaultViewMode } = useLoaderData<any>()
const { user, isLoading: authLoading } = useAuth()
const navigate = useNavigate()
- const showPeriodSelector = useFeatureFlag(FeatureFlag['dashboard-period-selector'])
- const showTabs = useFeatureFlag(FeatureFlag['dashboard-analytics-tabs'])
- const isHostnameNavigationEnabled = useFeatureFlag(FeatureFlag['dashboard-hostname-cards'])
const [searchParams, setSearchParams] = useSearchParams()
const { t } = useTranslation('common')
@@ -92,12 +86,6 @@ const Dashboard = () => {
const [liveStats, setLiveStats] = useState<Record<string, number>>({})
const [overallStats, setOverallStats] = useState<Overall>({})
- const [activeTab, setActiveTab] = useState<(typeof DASHBOARD_TABS)[number]['id']>(() => {
- const tabParam = searchParams.get('tab')
- return tabParam && DASHBOARD_TABS.some((tab) => tab.id === tabParam)
- ? (tabParam as (typeof DASHBOARD_TABS)[number]['id'])
- : DASHBOARD_TABS[0].id
- })
const [activePeriod, setActivePeriod] = useState(() => {
const periodParam = searchParams.get('period')
return periodParam || '7d'
@@ -161,12 +149,6 @@ const Dashboard = () => {
updateURL({ pageSize: size.toString(), page: '1' })
}
- const handleTabChange = (newTab: (typeof DASHBOARD_TABS)[number]['id']) => {
- setActiveTab(newTab)
- setPage(1)
- updateURL({ tab: newTab, page: '1' })
- }
-
const handlePeriodChange = (period: string) => {
setActivePeriod(period)
setPage(1)
@@ -267,33 +249,17 @@ const Dashboard = () => {
}
const refetchProjects = async () => {
- await loadProjects(
- pageSize,
- (page - 1) * pageSize,
- debouncedSearch,
- activeTab,
- activePeriod,
- isHostnameNavigationEnabled,
- sortBy,
- )
+ await loadProjects(pageSize, (page - 1) * pageSize, debouncedSearch, activePeriod, sortBy)
}
- const loadProjects = async (
- take: number,
- skip: number,
- search?: string,
- tab?: string,
- period?: string,
- isHostnameNavigationEnabled?: boolean,
- sort?: string,
- ) => {
+ const loadProjects = async (take: number, skip: number, search?: string, period?: string, sort?: string) => {
if (isLoading) {
return
}
setIsLoading(true)
try {
- const result = await getProjects(take, skip, search, tab, period, isHostnameNavigationEnabled, sort)
+ const result = await getProjects(take, skip, search, period, sort)
setProjects(result.results)
setPaginationTotal(result.total)
} catch (reason: any) {
@@ -316,18 +282,10 @@ const Dashboard = () => {
return
}
- loadProjects(
- pageSize,
- (page - 1) * pageSize,
- debouncedSearch,
- activeTab,
- activePeriod,
- isHostnameNavigationEnabled,
- sortBy,
- )
+ loadProjects(pageSize, (page - 1) * pageSize, debouncedSearch, activePeriod, sortBy)
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [page, pageSize, debouncedSearch, activeTab, activePeriod, isHostnameNavigationEnabled, authLoading, sortBy])
+ }, [page, pageSize, debouncedSearch, activePeriod, authLoading, sortBy])
// Set up interval for live visitors
useEffect(() => {
@@ -344,7 +302,7 @@ const Dashboard = () => {
}
const updateOverallStats = async (projectIds: string[]) => {
- if (!projectIds.length || isHostnameNavigationEnabled) return
+ if (!projectIds.length) return
try {
const timeBucket = tbPeriodPairs(t).find((p) => p.period === activePeriod)?.tbs[0] || ''
@@ -375,7 +333,7 @@ const Dashboard = () => {
const interval = setInterval(updateLiveVisitors, LIVE_VISITORS_UPDATE_INTERVAL)
return () => clearInterval(interval)
- }, [projects, activePeriod, isHostnameNavigationEnabled, t]) // Reset interval when projects change
+ }, [projects, activePeriod, t]) // Reset interval when projects change
if (error && isLoading === false) {
return (
@@ -425,7 +383,7 @@ const Dashboard = () => {
<DashboardLockedBanner />
<div className='flex flex-col'>
<div className='mx-auto w-full max-w-7xl px-4 py-6 sm:px-6 lg:px-8'>
- <div className={cx('flex flex-wrap justify-between gap-2', showTabs ? 'mb-2' : 'mb-4')}>
+ <div className='mb-4 flex flex-wrap justify-between gap-2'>
<div className='flex items-end justify-between'>
<Text as='h2' size='3xl' weight='bold' className='mt-2 flex items-baseline gap-2'>
<span>{t('titles.dashboard')}</span>
@@ -489,21 +447,16 @@ const Dashboard = () => {
) : null}
</div>
<div className='flex flex-wrap items-center gap-2'>
- {activeTab === 'lost-traffic' ? null : showPeriodSelector ? (
- <PeriodSelector
- activePeriod={activePeriod}
- setActivePeriod={handlePeriodChange}
- isLoading={isLoading === null || isLoading}
- />
- ) : null}
- {['high-traffic', 'low-traffic', 'performance'].includes(activeTab) ? null : (
- <SortSelector
- activeTab={activeTab}
- activeSort={sortBy}
- setActiveSort={handleSortChange}
- isLoading={isLoading === null || isLoading}
- />
- )}
+ <PeriodSelector
+ activePeriod={activePeriod}
+ setActivePeriod={handlePeriodChange}
+ isLoading={isLoading === null || isLoading}
+ />
+ <SortSelector
+ activeSort={sortBy}
+ setActiveSort={handleSortChange}
+ isLoading={isLoading === null || isLoading}
+ />
<div className='hidden lg:block'>
{viewMode === DASHBOARD_VIEW.GRID ? (
<button
@@ -561,21 +514,6 @@ const Dashboard = () => {
</div>
</div>
) : null}
- {showTabs ? (
- <Tabs
- activeTab={activeTab}
- setActiveTab={(tab) => {
- if (typeof tab === 'function') {
- const newTab = tab(activeTab)
- handleTabChange(newTab)
- } else {
- handleTabChange(tab)
- }
- }}
- isLoading={isLoading === null || isLoading}
- className='mb-4'
- />
- ) : null}
{isLoading || isLoading === null ? (
<div className='min-h-min-footer bg-gray-50 dark:bg-slate-900'>
<ProjectCardSkeleton viewMode={_viewMode} />
@@ -591,7 +529,7 @@ const Dashboard = () => {
{() => (
<>
{_isEmpty(projects) ? (
- <NoProjects search={debouncedSearch} activeTab={activeTab} onClick={onNewProject} />
+ <NoProjects search={debouncedSearch} onClick={onNewProject} />
) : (
<div
className={cx(
@@ -606,12 +544,11 @@ const Dashboard = () => {
live={liveStats[project.id] ?? (_isEmpty(liveStats) ? null : 'N/A')}
overallStats={overallStats[project.id]}
activePeriod={activePeriod}
- activeTab={activeTab}
viewMode={_viewMode}
refetchProjects={refetchProjects}
/>
))}
- {_size(projects) % 12 !== 0 && activeTab === 'default' ? (
+ {_size(projects) % 12 !== 0 ? (
<AddProject sitesCount={_size(projects)} onClick={onNewProject} viewMode={_viewMode} />
) : null}
</div>
diff --git a/web/app/pages/Dashboard/NoProjects.tsx b/web/app/pages/Dashboard/NoProjects.tsx
index 1bc98790a..e055e3070 100644
--- a/web/app/pages/Dashboard/NoProjects.tsx
+++ b/web/app/pages/Dashboard/NoProjects.tsx
@@ -1,22 +1,18 @@
import { FolderPlusIcon } from '@heroicons/react/24/outline'
import { FolderInputIcon } from 'lucide-react'
-import React from 'react'
import { useTranslation } from 'react-i18next'
import { Text } from '~/ui/Text'
-import { DASHBOARD_TABS } from './Tabs'
-
interface NoProjectsProps {
onClick: () => void
- activeTab: (typeof DASHBOARD_TABS)[number]['id']
search: string
}
-export const NoProjects = ({ onClick, activeTab, search }: NoProjectsProps) => {
+export const NoProjects = ({ onClick, search }: NoProjectsProps) => {
const { t } = useTranslation('common')
- if (activeTab !== 'default' || search) {
+ if (search) {
return (
<div className='mt-5 flex flex-col py-6 sm:px-6 lg:px-8'>
<div className='mx-auto w-full max-w-6xl'>
diff --git a/web/app/pages/Dashboard/ProjectCard.tsx b/web/app/pages/Dashboard/ProjectCard.tsx
index 5e9861e2e..45b811352 100644
--- a/web/app/pages/Dashboard/ProjectCard.tsx
+++ b/web/app/pages/Dashboard/ProjectCard.tsx
@@ -3,7 +3,6 @@ import _find from 'lodash/find'
import _isNumber from 'lodash/isNumber'
import _map from 'lodash/map'
import _replace from 'lodash/replace'
-import _round from 'lodash/round'
import _size from 'lodash/size'
import { Settings2Icon, PinIcon, ChevronUpIcon, ChevronDownIcon } from 'lucide-react'
import React, { useState, useMemo, useCallback, useEffect } from 'react'
@@ -12,9 +11,7 @@ import { Link } from 'react-router'
import { toast } from 'sonner'
import { acceptProjectShare, pinProject, unpinProject } from '~/api'
-import useFeatureFlag from '~/hooks/useFeatureFlag'
import { OverallObject, Project } from '~/lib/models/Project'
-import { FeatureFlag } from '~/lib/models/User'
import { useAuth } from '~/providers/AuthProvider'
import { Badge, BadgeProps } from '~/ui/Badge'
import Spin from '~/ui/icons/Spin'
@@ -24,7 +21,6 @@ import { nFormatter, calculateRelativePercentage } from '~/utils/generic'
import routes from '~/utils/routes'
import Sparkline from './Sparkline'
-import { DASHBOARD_TABS } from './Tabs'
// Detect if device supports hover (i.e., not a touch-only device)
const useIsTouchDevice = () => {
@@ -48,7 +44,6 @@ interface ProjectCardProps {
overallStats?: OverallObject
project: Project
activePeriod: string
- activeTab: (typeof DASHBOARD_TABS)[number]['id']
viewMode: 'grid' | 'list'
refetchProjects: () => Promise<void>
}
@@ -122,14 +117,11 @@ export const ProjectCard = ({
project,
overallStats,
activePeriod,
- activeTab,
viewMode,
refetchProjects,
}: ProjectCardProps) => {
const { t } = useTranslation('common')
const [showInviteModal, setShowInviteModal] = useState(false)
- const isHostnameNavigationEnabled = useFeatureFlag(FeatureFlag['dashboard-hostname-cards'])
- const showPeriodSelector = useFeatureFlag(FeatureFlag['dashboard-period-selector'])
const { user, mergeUser } = useAuth()
const isTouchDevice = useIsTouchDevice()
@@ -257,16 +249,10 @@ export const ProjectCard = ({
const searchParams = useMemo(() => {
const params = new URLSearchParams()
- if (showPeriodSelector) {
- params.set('period', activePeriod)
- }
-
- if (isHostnameNavigationEnabled) {
- params.set('host', encodeURIComponent(project.name))
- }
+ params.set('period', activePeriod)
return params.toString()
- }, [showPeriodSelector, activePeriod, isHostnameNavigationEnabled, project.name])
+ }, [activePeriod])
// Determine if action buttons should always be visible
// Show on touch devices, or when project is pinned
@@ -335,31 +321,16 @@ export const ProjectCard = ({
</div>
</div>
<div className={cx('relative z-10 flex shrink-0 gap-5', viewMode === 'list' ? 'ml-4' : 'mt-4 px-4 pb-4')}>
- {isHostnameNavigationEnabled ? (
- <MiniCard
- labelTKey='dashboard.pageviews'
- // @ts-expect-error
- total={project?.trafficStats?.visits}
- percChange={
- activeTab === 'performance'
- ? // @ts-expect-error
- _round(project?.trafficStats?.percentageChange, 2)
- : undefined
- }
- hasData={project?.isDataExists || project?.isErrorDataExists || project?.isCaptchaDataExists}
- />
- ) : (
- <MiniCard
- labelTKey='dashboard.pageviews'
- total={live === 'N/A' ? 'N/A' : (overallStats?.current.all ?? null)}
- percChange={
- live === 'N/A'
- ? 0
- : calculateRelativePercentage(overallStats?.previous.all ?? 0, overallStats?.current.all ?? 0)
- }
- hasData={project?.isDataExists || project?.isErrorDataExists || project?.isCaptchaDataExists}
- />
- )}
+ <MiniCard
+ labelTKey='dashboard.pageviews'
+ total={live === 'N/A' ? 'N/A' : (overallStats?.current.all ?? null)}
+ percChange={
+ live === 'N/A'
+ ? 0
+ : calculateRelativePercentage(overallStats?.previous.all ?? 0, overallStats?.current.all ?? 0)
+ }
+ hasData={project?.isDataExists || project?.isErrorDataExists || project?.isCaptchaDataExists}
+ />
<MiniCard
labelTKey='dashboard.liveVisitors'
total={live}
diff --git a/web/app/pages/Dashboard/SortSelector.tsx b/web/app/pages/Dashboard/SortSelector.tsx
index ff0cacff7..32dfee492 100644
--- a/web/app/pages/Dashboard/SortSelector.tsx
+++ b/web/app/pages/Dashboard/SortSelector.tsx
@@ -6,17 +6,12 @@ import { ArrowUpDown } from 'lucide-react'
import { Fragment, useEffect, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
-import useFeatureFlag from '~/hooks/useFeatureFlag'
-import { FeatureFlag } from '~/lib/models/User'
import { useAuth } from '~/providers/AuthProvider'
-import { DASHBOARD_TABS } from './Tabs'
-
interface SortSelectorProps {
activeSort: string
setActiveSort: (sort: string) => void
isLoading: boolean
- activeTab: (typeof DASHBOARD_TABS)[number]['id']
}
export const SORT_OPTIONS = {
@@ -24,66 +19,33 @@ export const SORT_OPTIONS = {
ALPHA_DESC: 'alpha_desc',
DATE_ASC: 'date_asc',
DATE_DESC: 'date_desc',
- PAGEVIEWS_ASC: 'pageviews_asc',
- PAGEVIEWS_DESC: 'pageviews_desc',
- LAST_VISIT_DESC: 'last_visit_desc',
} as const
-export const SortSelector = ({ activeSort, setActiveSort, isLoading, activeTab }: SortSelectorProps) => {
+export const SortSelector = ({ activeSort, setActiveSort, isLoading }: SortSelectorProps) => {
const { t } = useTranslation('common')
const { isLoading: authLoading } = useAuth()
- const isHostnameNavigationEnabled = useFeatureFlag(FeatureFlag['dashboard-hostname-cards'])
-
const sortOptions = useMemo(() => {
return [
- ...(activeTab === 'lost-traffic' && !isHostnameNavigationEnabled
- ? []
- : [
- {
- label: t('dashboard.sortAlphaAsc'),
- sort: SORT_OPTIONS.ALPHA_ASC,
- },
- {
- label: t('dashboard.sortAlphaDesc'),
- sort: SORT_OPTIONS.ALPHA_DESC,
- },
- ]),
- ...(isHostnameNavigationEnabled || activeTab !== 'default'
- ? []
- : [
- {
- label: t('dashboard.sortDateAsc'),
- sort: SORT_OPTIONS.DATE_ASC,
- },
- {
- label: t('dashboard.sortDateDesc'),
- sort: SORT_OPTIONS.DATE_DESC,
- },
- ]),
- ...(!isHostnameNavigationEnabled || activeTab !== 'default'
- ? []
- : [
- {
- label: t('dashboard.pageviewsDesc'),
- sort: SORT_OPTIONS.PAGEVIEWS_DESC,
- },
- {
- label: t('dashboard.pageviewsAsc'),
- sort: SORT_OPTIONS.PAGEVIEWS_ASC,
- },
- ]),
- ...(activeTab === 'lost-traffic'
- ? [
- {
- label: t('dashboard.lastVisitDesc'),
- sort: SORT_OPTIONS.LAST_VISIT_DESC,
- },
- ]
- : []),
+ {
+ label: t('dashboard.sortAlphaAsc'),
+ sort: SORT_OPTIONS.ALPHA_ASC,
+ },
+ {
+ label: t('dashboard.sortAlphaDesc'),
+ sort: SORT_OPTIONS.ALPHA_DESC,
+ },
+ {
+ label: t('dashboard.sortDateAsc'),
+ sort: SORT_OPTIONS.DATE_ASC,
+ },
+ {
+ label: t('dashboard.sortDateDesc'),
+ sort: SORT_OPTIONS.DATE_DESC,
+ },
]
- }, [t, isHostnameNavigationEnabled, activeTab])
+ }, [t])
useEffect(() => {
if (authLoading) return
diff --git a/web/app/pages/Dashboard/Tabs.tsx b/web/app/pages/Dashboard/Tabs.tsx
deleted file mode 100644
index 05b65ae55..000000000
--- a/web/app/pages/Dashboard/Tabs.tsx
+++ /dev/null
@@ -1,84 +0,0 @@
-import cx from 'clsx'
-import _map from 'lodash/map'
-import { FlameIcon, LayoutListIcon, PowerOffIcon, TrendingDownIcon, TrendingUpIcon } from 'lucide-react'
-import React from 'react'
-
-export const DASHBOARD_TABS = [
- {
- id: 'default',
- label: 'Default view',
- icon: LayoutListIcon,
- },
- {
- id: 'high-traffic',
- label: 'High traffic',
- icon: TrendingUpIcon,
- },
- {
- id: 'low-traffic',
- label: 'Low traffic',
- icon: TrendingDownIcon,
- },
- {
- id: 'performance',
- label: 'Performance',
- icon: FlameIcon,
- },
- {
- id: 'lost-traffic',
- label: 'Abandoned / Lost Traffic',
- icon: PowerOffIcon,
- },
-] as const
-
-interface TabsProps {
- activeTab: (typeof DASHBOARD_TABS)[number]['id']
- setActiveTab: React.Dispatch<React.SetStateAction<(typeof DASHBOARD_TABS)[number]['id']>>
- isLoading: boolean
- className?: string
-}
-
-export const Tabs = ({ activeTab, setActiveTab, className, isLoading }: TabsProps) => (
- <nav className={cx('-mb-px flex space-x-4 overflow-x-auto', className)} aria-label='Tabs'>
- {_map(DASHBOARD_TABS, (tab) => {
- const isCurrent = tab.id === activeTab
-
- return (
- <button
- key={tab.id}
- type='button'
- onClick={() => {
- if (isLoading) {
- return
- }
-
- setActiveTab(tab.id)
- }}
- className={cx(
- 'text-md group inline-flex cursor-pointer items-center border-b-2 px-1 py-2 font-bold whitespace-nowrap transition-all duration-200',
- {
- 'border-slate-900 text-slate-900 dark:border-gray-50 dark:text-gray-50': isCurrent,
- 'border-transparent text-gray-500 dark:text-gray-400': !isCurrent,
- 'cursor-wait': isLoading,
- 'hover:border-gray-300 hover:text-gray-700 dark:hover:border-gray-300 dark:hover:text-gray-300':
- !isCurrent && !isLoading,
- },
- )}
- aria-current={isCurrent ? 'page' : undefined}
- >
- <tab.icon
- className={cx(
- isCurrent
- ? 'text-slate-900 dark:text-gray-50'
- : 'text-gray-500 group-hover:text-gray-500 dark:text-gray-400 dark:group-hover:text-gray-300',
- 'mr-2 -ml-0.5 h-5 w-5',
- )}
- aria-hidden='true'
- strokeWidth={1.5}
- />
- <span>{tab.label}</span>
- </button>
- )
- })}
- </nav>
-)
diff --git a/web/app/routes/feature-flags.tsx b/web/app/routes/feature-flags.tsx
deleted file mode 100644
index 7c30e629b..000000000
--- a/web/app/routes/feature-flags.tsx
+++ /dev/null
@@ -1,112 +0,0 @@
-import { Switch } from '@headlessui/react'
-import cx from 'clsx'
-import { useEffect, useState } from 'react'
-import { useTranslation } from 'react-i18next'
-import { redirect } from 'react-router'
-import { SitemapFunction } from 'remix-sitemap'
-import { toast } from 'sonner'
-
-import { setFeatureFlags } from '~/api'
-import { withAuthentication, auth } from '~/hoc/protected'
-import { isSelfhosted } from '~/lib/constants'
-import { FeatureFlag } from '~/lib/models/User'
-import { useAuth } from '~/providers/AuthProvider'
-import Loader from '~/ui/Loader'
-
-export const sitemap: SitemapFunction = () => ({
- exclude: true,
-})
-
-export async function loader() {
- if (isSelfhosted) {
- return redirect('/login', 302)
- }
-
- return null
-}
-
-const FeatureFlagsPage = () => {
- const { t } = useTranslation('common')
- const { user, isLoading, mergeUser } = useAuth()
- const [flags, setFlags] = useState<FeatureFlag[]>([])
- const [initialised, setInitialised] = useState(false)
-
- useEffect(() => {
- if (isLoading || initialised || !user) {
- return
- }
-
- setFlags(user.featureFlags ?? []) // eslint-disable-line react-hooks/set-state-in-effect -- Initializing flags from user data once
- setInitialised(true)
- }, [isLoading, user, initialised])
-
- const handleToggle = async (flag: FeatureFlag) => {
- try {
- const newFlags = flags.includes(flag) ? flags.filter((f) => f !== flag) : [...flags, flag]
-
- await setFeatureFlags(newFlags)
- setFlags(newFlags)
- mergeUser({ featureFlags: newFlags })
- toast.success(t('swetrixFeatureFlags.updated'))
- } catch (error) {
- console.error('Failed to update feature flags:', error)
- toast.error(t('swetrixFeatureFlags.error'))
- }
- }
-
- if (isLoading) {
- return (
- <div className='min-h-min-footer bg-gray-50 dark:bg-slate-900'>
- <Loader />
- </div>
- )
- }
-
- return (
- <div className='min-h-min-footer bg-gray-50 dark:bg-slate-900'>
- <div className='mx-auto max-w-7xl px-4 py-12 sm:px-6 lg:px-8'>
- <div className='mx-auto max-w-4xl'>
- <h2 className='text-3xl font-bold tracking-tight text-gray-900 dark:text-gray-50'>
- {t('swetrixswetrixFeatureFlags.title')}
- </h2>
- <p className='mt-4 text-gray-500 dark:text-gray-400'>{t('swetrixFeatureFlags.description')}</p>
-
- <div className='mt-8 divide-y divide-gray-200 dark:divide-gray-700'>
- {Object.values(FeatureFlag).map((flag) => (
- <div key={flag} className='flex items-center justify-between py-4'>
- <div>
- <h3 className='text-lg leading-6 font-medium text-gray-900 dark:text-gray-50'>
- {t(`swetrixFeatureFlags.${flag}.title`)}
- </h3>
- <p className='mt-1 text-sm text-gray-500 dark:text-gray-400'>
- {t(`swetrixFeatureFlags.${flag}.description`, {
- defaultPeriod: 7,
- })}
- </p>
- </div>
- <Switch
- checked={flags.includes(flag)}
- onChange={() => handleToggle(flag)}
- className={cx(
- flags.includes(flag) ? 'bg-indigo-600' : 'bg-gray-200 dark:bg-gray-700',
- 'relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:outline-hidden',
- )}
- >
- <span
- aria-hidden='true'
- className={cx(
- flags.includes(flag) ? 'translate-x-5' : 'translate-x-0',
- 'pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white ring-0 transition duration-200 ease-in-out',
- )}
- />
- </Switch>
- </div>
- ))}
- </div>
- </div>
- </div>
- </div>
- )
-}
-
-export default withAuthentication(FeatureFlagsPage, auth.authenticated)
diff --git a/web/app/utils/routes.ts b/web/app/utils/routes.ts
index 4ed102d78..4b5e1dd24 100644
--- a/web/app/utils/routes.ts
+++ b/web/app/utils/routes.ts
@@ -35,7 +35,6 @@ const routes = Object.freeze({
forSmallBusinesses: '/for-small-businesses',
organisations: '/organisations',
organisation: '/organisations/:id',
- feature_flags: '/feature-flags',
dataPolicy: '/data-policy',
// Free tools
diff --git a/web/app/utils/server.ts b/web/app/utils/server.ts
index 4c1463654..effdc869f 100644
--- a/web/app/utils/server.ts
+++ b/web/app/utils/server.ts
@@ -210,12 +210,6 @@ export const getPageMeta = (t: typeof i18next.t, url?: string, _pathname?: strin
}
break
- case routes.feature_flags:
- result = {
- title: t('titles.featureFlags'),
- }
- break
-
default:
break
}
diff --git a/web/public/locales/en.json b/web/public/locales/en.json
index 167dd871d..ed39a7d64 100644
--- a/web/public/locales/en.json
+++ b/web/public/locales/en.json
@@ -164,24 +164,6 @@
"details": "Details",
"unknown": "Unknown"
},
- "swetrixFeatureFlags": {
- "title": "Feature Flags",
- "description": "Enable or disable experimental features to try out new functionality before it's fully released. Feature flags allow you to test new features and provide feedback.",
- "updated": "Feature flags updated successfully",
- "error": "Failed to update feature flags",
- "dashboard-period-selector": {
- "title": "Dashboard Period Selector",
- "description": "Enables the period selector in the dashboard, allowing you to see the number of pageviews for different periods (if this feature flag is disabled, the default period is {{defaultPeriod}} days)."
- },
- "dashboard-analytics-tabs": {
- "title": "Dashboard Analytics Tabs",
- "description": "Enables analytics tabs in the dashboard, providing different views of your data such as high / low traffic sites, abandoned projects, and more."
- },
- "dashboard-hostname-cards": {
- "title": "Dashboard Hostname-based navigation",
- "description": "Replaces traditional project-based navigation with hostname-based navigation - instead of seeing individual projects, you see the hostnames from the analytics data instead. This is useful if you have a lot of websites and don't want to create a project for each one, so you can create one project and collect all the data in it."
- }
- },
"performance": {
"slogan": "End user <span>performance monitoring</span> to deliver fast websites.",
"description": "Deliver a flawless experience to your users, and we will let you know if your site is fast enough.",
@@ -850,12 +832,9 @@
"sortAlphaDesc": "Z to A",
"sortDateAsc": "Oldest first",
"sortDateDesc": "Newest first",
- "pageviewsDesc": "Most pageviews",
- "pageviewsAsc": "Least pageviews",
"page": "Page",
"event": "Event",
"noProjectsForCriteria": "No projects found for the selected criteria",
- "lastVisitDesc": "Recently visited first",
"captcha": "CAPTCHA",
"newProject": "New project",
"newFunnel": "New funnel",