📈 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
lint fixes
Blue Moused9df715ee0e0
diff --git a/backend/apps/cloud/src/experiment/bayesian.ts b/backend/apps/cloud/src/experiment/bayesian.tsindex 733782bc9..580cc9f1b 100644--- a/backend/apps/cloud/src/experiment/bayesian.ts+++ b/backend/apps/cloud/src/experiment/bayesian.ts@@ -5,7 +5,7 @@* the probability of each variant being the best.*/-export interface VariantData {+interface VariantData {key: stringexposures: numberconversions: number@@ -184,97 +184,3 @@ export function calculateBayesianProbabilities(return probabilities}--/**- * Calculate credible interval for a variant's conversion rate- *- * @param conversions - Number of conversions- * @param exposures - Number of exposures- * @param credibleLevel - Credible level (default: 0.95 for 95%)- * @returns [lower, upper] bounds of the credible interval- */-export function calculateCredibleInterval(- conversions: number,- exposures: number,- credibleLevel: number = 0.95,-): [number, number] {- if (exposures === 0) {- return [0, 1]- }-- const alpha = conversions + 1- const beta = exposures - conversions + 1-- // Use numerical approximation for Beta distribution quantiles- // Sample many times and find percentiles- const samples: number[] = []- const random = mulberry32(- seedFromVariants([{ key: 'v', exposures, conversions }], 10000),- )- for (let i = 0; i < 10000; i++) {- samples.push(sampleBeta(alpha, beta, random))- }- samples.sort((a, b) => a - b)-- const lowerIdx = Math.floor(((1 - credibleLevel) / 2) * samples.length)- const upperIdx = Math.floor(((1 + credibleLevel) / 2) * samples.length) - 1-- return [samples[lowerIdx], samples[upperIdx]]-}--/**- * Calculate the expected lift of test variant over control- *- * @param controlConversions - Control variant conversions- * @param controlExposures - Control variant exposures- * @param testConversions - Test variant conversions- * @param testExposures - Test variant exposures- * @param simulations - Number of Monte Carlo simulations- * @returns Expected relative improvement (e.g., 0.15 for 15% improvement)- */-export function calculateExpectedLift(- controlConversions: number,- controlExposures: number,- testConversions: number,- testExposures: number,- simulations: number = 10000,-): number {- if (controlExposures === 0 || testExposures === 0) {- return 0- }-- const controlAlpha = controlConversions + 1- const controlBeta = controlExposures - controlConversions + 1- const testAlpha = testConversions + 1- const testBeta = testExposures - testConversions + 1-- let totalLift = 0- const random = mulberry32(- seedFromVariants(- [- {- key: 'c',- exposures: controlExposures,- conversions: controlConversions,- },- {- key: 't',- exposures: testExposures,- conversions: testConversions,- },- ],- simulations,- ),- )-- for (let i = 0; i < simulations; i++) {- const controlRate = sampleBeta(controlAlpha, controlBeta, random)- const testRate = sampleBeta(testAlpha, testBeta, random)-- if (controlRate > 0) {- totalLift += (testRate - controlRate) / controlRate- }- }-- return totalLift / simulations-}diff --git a/backend/apps/cloud/src/experiment/dto/experiment.dto.ts b/backend/apps/cloud/src/experiment/dto/experiment.dto.tsindex 3cf12eaf2..74811c8f2 100644--- a/backend/apps/cloud/src/experiment/dto/experiment.dto.ts+++ b/backend/apps/cloud/src/experiment/dto/experiment.dto.ts@@ -323,14 +323,3 @@ export class ExperimentResultsDto {})timeBucket?: string[]}--export class ExperimentStatsDto {- @ApiProperty()- exposures: number-- @ApiProperty()- conversions: number-- @ApiProperty()- conversionRate: number-}diff --git a/backend/apps/cloud/src/feature-flag/dto/feature-flag.dto.ts b/backend/apps/cloud/src/feature-flag/dto/feature-flag.dto.tsindex 1ba50d2c3..f5719f2db 100644--- a/backend/apps/cloud/src/feature-flag/dto/feature-flag.dto.ts+++ b/backend/apps/cloud/src/feature-flag/dto/feature-flag.dto.ts@@ -18,7 +18,7 @@ import { Type } from 'class-transformer'import { FeatureFlagType, TargetingRule } from '../entity/feature-flag.entity'// Valid targeting rule columns (attribute keys)-export const VALID_TARGETING_COLUMNS = [+const VALID_TARGETING_COLUMNS = ['cc', // country code'ct', // city'rg', // regiondiff --git a/backend/apps/cloud/src/feature-flag/entity/feature-flag.entity.ts b/backend/apps/cloud/src/feature-flag/entity/feature-flag.entity.tsindex d85f9da7c..43aee23ea 100644--- a/backend/apps/cloud/src/feature-flag/entity/feature-flag.entity.ts+++ b/backend/apps/cloud/src/feature-flag/entity/feature-flag.entity.ts@@ -9,14 +9,10 @@ import {} from 'typeorm'import { ApiProperty } from '@nestjs/swagger'import { Project } from '../../project/entity/project.entity'-import {- FeatureFlagType,- TargetingRule,- EvaluatableFeatureFlag,-} from '../evaluation'+import { FeatureFlagType, TargetingRule } from '../evaluation'// Re-export types for backward compatibility-export { FeatureFlagType, TargetingRule, EvaluatableFeatureFlag }+export { FeatureFlagType, TargetingRule }@Entity()@Unique(['project', 'key'])diff --git a/backend/apps/cloud/src/feature-flag/evaluation.ts b/backend/apps/cloud/src/feature-flag/evaluation.tsindex dceb79c03..392288669 100644--- a/backend/apps/cloud/src/feature-flag/evaluation.ts+++ b/backend/apps/cloud/src/feature-flag/evaluation.ts@@ -21,7 +21,7 @@ export interface TargetingRule {* Minimal feature flag interface required for evaluation* Both cloud (TypeORM entity) and community (ClickHouse) flags should satisfy this*/-export interface EvaluatableFeatureFlag {+interface EvaluatableFeatureFlag {key: stringenabled: booleanflagType: FeatureFlagType@@ -87,7 +87,7 @@ export function evaluateFlag(* Checks if visitor attributes match the targeting rules* Rules are evaluated as AND (all rules must match)*/-export function matchesTargetingRules(+function matchesTargetingRules(rules: TargetingRule[],attributes?: Record<string, string>,): boolean {@@ -130,10 +130,7 @@ export function matchesTargetingRules(* Checks if an attribute value matches a filter value* Supports case-insensitive matching*/-export function matchesRule(- attributeValue: string,- filterValue: string,-): boolean {+function matchesRule(attributeValue: string, filterValue: string): boolean {// Case-insensitive exact matchreturn attributeValue.toLowerCase() === filterValue.toLowerCase()}@@ -142,7 +139,7 @@ export function matchesRule(* Determines if a visitor is within the rollout percentage* Uses consistent hashing based on flag key and profile ID*/-export function isInRolloutPercentage(+function isInRolloutPercentage(flagKey: string,percentage: number,profileId: string,@@ -173,7 +170,7 @@ export function isInRolloutPercentage(/*** Experiment variant interface*/-export interface ExperimentVariant {+interface ExperimentVariant {key: stringrolloutPercentage: number}diff --git a/backend/apps/cloud/src/feature-flag/feature-flag.service.ts b/backend/apps/cloud/src/feature-flag/feature-flag.service.tsindex cf9f4a4de..39d0eb67f 100644--- a/backend/apps/cloud/src/feature-flag/feature-flag.service.ts+++ b/backend/apps/cloud/src/feature-flag/feature-flag.service.ts@@ -1,6 +1,6 @@import { Injectable } from '@nestjs/common'import { InjectRepository } from '@nestjs/typeorm'-import { FindManyOptions, FindOneOptions, Repository, ILike } from 'typeorm'+import { FindManyOptions, FindOneOptions, Repository } from 'typeorm'import { Pagination, PaginationOptionsInterface } from '../common/pagination'import { FeatureFlag } from './entity/feature-flag.entity'import {diff --git a/backend/apps/community/src/feature-flag/dto/feature-flag.dto.ts b/backend/apps/community/src/feature-flag/dto/feature-flag.dto.tsindex 1ba50d2c3..f5719f2db 100644--- a/backend/apps/community/src/feature-flag/dto/feature-flag.dto.ts+++ b/backend/apps/community/src/feature-flag/dto/feature-flag.dto.ts@@ -18,7 +18,7 @@ import { Type } from 'class-transformer'import { FeatureFlagType, TargetingRule } from '../entity/feature-flag.entity'// Valid targeting rule columns (attribute keys)-export const VALID_TARGETING_COLUMNS = [+const VALID_TARGETING_COLUMNS = ['cc', // country code'ct', // city'rg', // regiondiff --git a/backend/apps/community/src/feature-flag/entity/feature-flag.entity.ts b/backend/apps/community/src/feature-flag/entity/feature-flag.entity.tsindex e640fb350..01267849a 100644--- a/backend/apps/community/src/feature-flag/entity/feature-flag.entity.ts+++ b/backend/apps/community/src/feature-flag/entity/feature-flag.entity.ts@@ -5,7 +5,7 @@ import {} from '../evaluation'// Re-export types for backward compatibility-export { FeatureFlagType, TargetingRule, EvaluatableFeatureFlag }+export { FeatureFlagType, TargetingRule }export interface FeatureFlag extends EvaluatableFeatureFlag {id: stringdiff --git a/backend/apps/community/src/feature-flag/evaluation.ts b/backend/apps/community/src/feature-flag/evaluation.tsindex 4af27dc9d..eac9c8115 100644--- a/backend/apps/community/src/feature-flag/evaluation.ts+++ b/backend/apps/community/src/feature-flag/evaluation.ts@@ -87,7 +87,7 @@ export function evaluateFlag(* Checks if visitor attributes match the targeting rules* Rules are evaluated as AND (all rules must match)*/-export function matchesTargetingRules(+function matchesTargetingRules(rules: TargetingRule[],attributes?: Record<string, string>,): boolean {@@ -130,10 +130,7 @@ export function matchesTargetingRules(* Checks if an attribute value matches a filter value* Supports case-insensitive matching*/-export function matchesRule(- attributeValue: string,- filterValue: string,-): boolean {+function matchesRule(attributeValue: string, filterValue: string): boolean {// Case-insensitive exact matchreturn attributeValue.toLowerCase() === filterValue.toLowerCase()}@@ -142,7 +139,7 @@ export function matchesRule(* Determines if a visitor is within the rollout percentage* Uses consistent hashing based on flag key and profile ID*/-export function isInRolloutPercentage(+function isInRolloutPercentage(flagKey: string,percentage: number,profileId: string,diff --git a/web/app/api/index.ts b/web/app/api/index.tsindex 4462b5f2d..656c06d17 100644--- a/web/app/api/index.ts+++ b/web/app/api/index.ts@@ -773,7 +773,7 @@ export const getError = (throw error.response})-export interface ErrorOverviewStats {+interface ErrorOverviewStats {totalErrors: numberuniqueErrors: numberaffectedSessions: number@@ -781,7 +781,7 @@ export interface ErrorOverviewStats {errorRate: number}-export interface MostFrequentError {+interface MostFrequentError {eid: stringname: stringmessage: string@@ -790,7 +790,7 @@ export interface MostFrequentError {lastSeen: string}-export interface ErrorOverviewChart {+interface ErrorOverviewChart {x: string[]occurrences: number[]affectedUsers: number[]@@ -1467,7 +1467,7 @@ export interface FeatureFlagProfile {export const DEFAULT_FEATURE_FLAG_PROFILES_TAKE = 15-export type FeatureFlagResultFilter = 'all' | 'true' | 'false'+type FeatureFlagResultFilter = 'all' | 'true' | 'false'export const getFeatureFlagProfiles = (flagId: string,@@ -1567,7 +1567,7 @@ export interface ExperimentResults {timeBucket?: string[]}-export interface CreateExperiment {+interface CreateExperiment {pid: stringname: stringdescription?: string@@ -2238,6 +2238,7 @@ export const getGSCKeywords = (response,): {keywords: { name: string; count: number; impressions: number; position: number; ctr: number }[]+ notConnected?: boolean} => response.data,).catch((error) => {diff --git a/web/app/hooks/useAnnotations.ts b/web/app/hooks/useAnnotations.tsindex 47a6a4b23..6fd7b329d 100644--- a/web/app/hooks/useAnnotations.ts+++ b/web/app/hooks/useAnnotations.ts@@ -158,12 +158,7 @@ interface UseAnnotationsReturn {closeContextMenu: () => void}-interface UseAnnotationsOptions {- allowedToManage?: boolean-}--export const useAnnotations = (options: UseAnnotationsOptions = {}): UseAnnotationsReturn => {- const { allowedToManage = true } = options+export const useAnnotations = (): UseAnnotationsReturn => {const { id, project } = useCurrentProject()const projectPassword = useProjectPassword(id)const { t } = useTranslation('common')diff --git a/web/app/pages/Project/Alerts/Settings/ProjectAlertsSettings.tsx b/web/app/pages/Project/Alerts/Settings/ProjectAlertsSettings.tsxindex e0daab217..4ead00948 100644--- a/web/app/pages/Project/Alerts/Settings/ProjectAlertsSettings.tsx+++ b/web/app/pages/Project/Alerts/Settings/ProjectAlertsSettings.tsx@@ -1,5 +1,4 @@import { ExclamationTriangleIcon, XCircleIcon } from '@heroicons/react/24/outline'-import { clsx as cx } from 'clsx'import _findKey from 'lodash/findKey'import _isEmpty from 'lodash/isEmpty'import _keys from 'lodash/keys'diff --git a/web/app/pages/Project/Alerts/Settings/index.tsx b/web/app/pages/Project/Alerts/Settings/index.tsxdeleted file mode 100644index a8f557fee..000000000--- a/web/app/pages/Project/Alerts/Settings/index.tsx+++ /dev/null@@ -1,3 +0,0 @@-import ProjectAlertsSettings from './ProjectAlertsSettings'--export default ProjectAlertsSettingsdiff --git a/web/app/pages/Project/Alerts/View/ProjectAlertsView.tsx b/web/app/pages/Project/Alerts/View/ProjectAlertsView.tsxindex 7bbb4df6f..4323f464f 100644--- a/web/app/pages/Project/Alerts/View/ProjectAlertsView.tsx+++ b/web/app/pages/Project/Alerts/View/ProjectAlertsView.tsx@@ -21,6 +21,7 @@ import { useCurrentProject } from '~/providers/CurrentProjectProvider'import { Badge, type BadgeProps } from '~/ui/Badge'import Button from '~/ui/Button'import Loader from '~/ui/Loader'+import LoadingBar from '~/ui/LoadingBar'import Modal from '~/ui/Modal'import Pagination from '~/ui/Pagination'import routes from '~/utils/routes'@@ -394,6 +395,7 @@ const ProjectAlerts = () => {return (<>+ {isLoading && !_isEmpty(alerts) ? <LoadingBar /> : null}<div className='mt-4'>{_isEmpty(alerts) ? (<div className='mt-5 rounded-xl bg-gray-700 p-5'>diff --git a/web/app/pages/Project/Funnels/View/FunnelsView.tsx b/web/app/pages/Project/Funnels/View/FunnelsView.tsxindex 0328e72a2..08122092a 100644--- a/web/app/pages/Project/Funnels/View/FunnelsView.tsx+++ b/web/app/pages/Project/Funnels/View/FunnelsView.tsx@@ -21,6 +21,7 @@ import { getFormatDate } from '~/pages/Project/View/ViewProject.helpers'import { useAuth } from '~/providers/AuthProvider'import { useCurrentProject, useProjectPassword } from '~/providers/CurrentProjectProvider'import Loader from '~/ui/Loader'+import LoadingBar from '~/ui/LoadingBar'import { Text } from '~/ui/Text'import { nLocaleFormatter } from '~/utils/generic'import routes from '~/utils/routes'@@ -29,8 +30,7 @@ const FunnelsView = () => {const { id, project, mergeProject, allowedToManage } = useCurrentProject()const projectPassword = useProjectPassword(id)const { isAuthenticated } = useAuth()- const { timezone, period, dateRange, activePeriod, periodPairs, updatePeriod, refCalendar, funnelsRefreshTrigger } =- useViewProjectContext()+ const { timezone, period, dateRange, periodPairs, funnelsRefreshTrigger } = useViewProjectContext()// Filter periods to only include those valid for funnelsconst timeBucketSelectorItems = useMemo(() => {@@ -39,7 +39,7 @@ const FunnelsView = () => {})}, [periodPairs])const { t } = useTranslation('common')- const [searchParams, setSearchParams] = useSearchParams()+ const [searchParams] = useSearchParams()const isMountedRef = useRef(true)@@ -216,19 +216,6 @@ const FunnelsView = () => {}}, [funnelAnalytics])- const refreshStats = async (_isManual: boolean = true) => {- if (!dataLoading) {- await loadFunnelsData()- }- }-- const resetDateRange = () => {- const newSearchParams = new URLSearchParams(searchParams.toString())- newSearchParams.delete('from')- newSearchParams.delete('to')- setSearchParams(newSearchParams)- }-// Load funnels data when activeFunnel changesuseEffect(() => {if (!project) return@@ -266,6 +253,7 @@ const FunnelsView = () => {</Text>}/>+ {dataLoading && funnelAnalytics ? <LoadingBar /> : null}{/* Funnel Chart */}<divdiff --git a/web/app/pages/Project/Performance/View/PerformanceView.tsx b/web/app/pages/Project/Performance/View/PerformanceView.tsxindex 6751d19d1..cc4d7d15f 100644--- a/web/app/pages/Project/Performance/View/PerformanceView.tsx+++ b/web/app/pages/Project/Performance/View/PerformanceView.tsx@@ -18,8 +18,8 @@ import { CountryEntry } from '~/lib/models/Entry'import { OverallPerformanceObject } from '~/lib/models/Project'import AnnotationModal from '~/modals/AnnotationModal'import CCRow from '~/pages/Project/View/components/CCRow'-import DashboardHeader from '~/pages/Project/View/components/DashboardHeader'import { ChartContextMenu } from '~/pages/Project/View/components/ChartContextMenu'+import DashboardHeader from '~/pages/Project/View/components/DashboardHeader'import Filters from '~/pages/Project/View/components/Filters'import { PerformanceMetricCards } from '~/pages/Project/View/components/MetricCards'import NoEvents from '~/pages/Project/View/components/NoEvents'@@ -36,6 +36,7 @@ import { useCurrentProject, useProjectPassword } from '~/providers/CurrentProjecimport { useTheme } from '~/providers/ThemeProvider'import Dropdown from '~/ui/Dropdown'import Loader from '~/ui/Loader'+import LoadingBar from '~/ui/LoadingBar'import { getStringFromTime, getTimeFromSeconds } from '~/utils/generic'const InteractiveMap = lazy(() => import('~/pages/Project/View/components/InteractiveMap'))@@ -174,7 +175,7 @@ const PerformanceView = ({ tnMapping }: PerformanceViewProps) => {closeAnnotationModal,handleChartContextMenu,closeContextMenu,- } = useAnnotations({ allowedToManage })+ } = useAnnotations()const {t,i18n: { language },@@ -545,6 +546,7 @@ const PerformanceView = ({ tnMapping }: PerformanceViewProps) => {return (<><DashboardHeader />+ {dataLoading && !isPanelsDataEmpty ? <LoadingBar /> : null}<div className={cx('pt-2', { hidden: isPanelsDataEmpty || analyticsLoading })}><div className='relative overflow-hidden rounded-lg border border-gray-300 bg-white p-4 dark:border-slate-800/60 dark:bg-slate-800/25'><div className='mb-3 flex w-full items-center justify-end gap-2 lg:absolute lg:top-2 lg:right-2 lg:mb-0 lg:w-auto lg:justify-normal'>diff --git a/web/app/pages/Project/Profiles/View/ProfilesView.tsx b/web/app/pages/Project/Profiles/View/ProfilesView.tsxindex 8875b27ab..afa67355b 100644--- a/web/app/pages/Project/Profiles/View/ProfilesView.tsx+++ b/web/app/pages/Project/Profiles/View/ProfilesView.tsx@@ -15,6 +15,7 @@ import { useViewProjectContext } from '~/pages/Project/View/ViewProject'import { getFormatDate } from '~/pages/Project/View/ViewProject.helpers'import { useCurrentProject, useProjectPassword } from '~/providers/CurrentProjectProvider'import Loader from '~/ui/Loader'+import LoadingBar from '~/ui/LoadingBar'const SESSIONS_TAKE = 30@@ -310,17 +311,6 @@ const ProfilesView = ({ chartType }: ProfilesViewProps) => {// eslint-disable-next-line react-hooks/exhaustive-deps}, [profilesRefreshTrigger])- // Handle refresh - exposed via ref or can be called from parent- const handleRefresh = async () => {- if (activeProfileId) {- await loadProfile(activeProfileId)- return- }-- setProfilesSkip(0)- loadProfiles(0, true)- }-// Profile detail viewif (activeProfileId) {const backSearchParams = (() => {@@ -357,6 +347,7 @@ const ProfilesView = ({ chartType }: ProfilesViewProps) => {return (<><DashboardHeader showLiveVisitors />+ {profilesLoading && !_isEmpty(profiles) ? <LoadingBar /> : null}<UsersFilterprofileType={profileTypeFilter}onProfileTypeChange={(type) => {diff --git a/web/app/pages/Project/Sessions/View/SessionsView.tsx b/web/app/pages/Project/Sessions/View/SessionsView.tsxindex 6a50e0647..bff8309e5 100644--- a/web/app/pages/Project/Sessions/View/SessionsView.tsx+++ b/web/app/pages/Project/Sessions/View/SessionsView.tsx@@ -18,6 +18,7 @@ import { getFormatDate } from '~/pages/Project/View/ViewProject.helpers'import { useCurrentProject, useProjectPassword } from '~/providers/CurrentProjectProvider'import Spin from '~/ui/icons/Spin'import Loader from '~/ui/Loader'+import LoadingBar from '~/ui/LoadingBar'import routes from '~/utils/routes'const SESSIONS_TAKE = 30@@ -235,15 +236,6 @@ const SessionsView = ({ tnMapping, chartType, rotateXAxis }: SessionsViewProps)// eslint-disable-next-line react-hooks/exhaustive-deps}, [sessionsRefreshTrigger])- const refreshStats = () => {- if (activePSID) {- loadSession(activePSID)- } else {- setSessionsSkip(0)- loadSessions(0, true)- }- }-if (error && sessionsLoading === false) {return (<div className='bg-gray-50 px-4 py-16 sm:px-6 sm:py-24 md:grid md:place-items-center lg:px-8 dark:bg-slate-900'>@@ -302,6 +294,7 @@ const SessionsView = ({ tnMapping, chartType, rotateXAxis }: SessionsViewProps)return (<><DashboardHeader showLiveVisitors />+ {sessionsLoading && !_isEmpty(sessions) ? <LoadingBar /> : null}<div className='mt-4'>{!_isEmpty(sessions) ? <Filters tnMapping={tnMapping} /> : null}{(sessionsLoading === null || sessionsLoading) && _isEmpty(sessions) ? <Loader /> : null}diff --git a/web/app/pages/Project/Traffic/View/TrafficView.tsx b/web/app/pages/Project/Traffic/View/TrafficView.tsxindex 00501ec04..acca2e71a 100644--- a/web/app/pages/Project/Traffic/View/TrafficView.tsx+++ b/web/app/pages/Project/Traffic/View/TrafficView.tsx@@ -28,16 +28,16 @@ import { CountryEntry, Entry } from '~/lib/models/Entry'import { OverallObject } from '~/lib/models/Project'import AnnotationModal from '~/modals/AnnotationModal'import CCRow from '~/pages/Project/View/components/CCRow'-import DashboardHeader from '~/pages/Project/View/components/DashboardHeader'import { ChartContextMenu } from '~/pages/Project/View/components/ChartContextMenu'import CustomMetrics from '~/pages/Project/View/components/CustomMetrics'+import DashboardHeader from '~/pages/Project/View/components/DashboardHeader'import Filters from '~/pages/Project/View/components/Filters'import { MetricCard, MetricCards } from '~/pages/Project/View/components/MetricCards'import NoEvents from '~/pages/Project/View/components/NoEvents'-import WaitingForAnEvent from '~/pages/Project/View/components/WaitingForAnEvent'import RefRow from '~/pages/Project/View/components/RefRow'import { TrafficChart } from '~/pages/Project/View/components/TrafficChart'import UserFlow from '~/pages/Project/View/components/UserFlow'+import WaitingForAnEvent from '~/pages/Project/View/components/WaitingForAnEvent'import {Customs,TrafficMeta,@@ -61,6 +61,7 @@ import { useTheme } from '~/providers/ThemeProvider'import Checkbox from '~/ui/Checkbox'import Dropdown from '~/ui/Dropdown'import Loader from '~/ui/Loader'+import LoadingBar from '~/ui/LoadingBar'import { periodToCompareDate } from '~/utils/compareConvertDate'import { getLocaleDisplayName, nLocaleFormatter } from '~/utils/generic'import { groupRefEntries } from '~/utils/referrers'@@ -83,7 +84,6 @@ type KeywordEntry = Entry & { impressions: number; position: number; ctr: numberinterface TrafficViewProps {tnMapping: Record<string, string>customMetrics: ProjectViewCustomEvent[]- onCustomMetric: (metrics: ProjectViewCustomEvent[]) => voidonRemoveCustomMetric: (metricId: string) => voidresetCustomMetrics: () => voidmode: 'periodical' | 'cumulative'@@ -94,7 +94,6 @@ interface TrafficViewProps {const TrafficView = ({tnMapping,customMetrics,- onCustomMetric,onRemoveCustomMetric,resetCustomMetrics,mode,@@ -151,7 +150,7 @@ const TrafficView = ({closeAnnotationModal,handleChartContextMenu,closeContextMenu,- } = useAnnotations({ allowedToManage })+ } = useAnnotations()// Traffic-specific stateconst [dataLoading, setDataLoading] = useState(false)@@ -756,6 +755,7 @@ const TrafficView = ({return (<><DashboardHeader rightContent={headerRightContent} />+ {dataLoading && !isPanelsDataEmpty ? <LoadingBar /> : null}<div className={cx({ hidden: isPanelsDataEmpty || analyticsLoading })}><div className='relative overflow-hidden rounded-lg border border-gray-300 bg-white p-4 dark:border-slate-800/60 dark:bg-slate-800/25'><div className='mb-3 flex w-full items-center justify-end gap-2 lg:absolute lg:top-2 lg:right-2 lg:mb-0 lg:w-auto lg:justify-normal'>diff --git a/web/app/pages/Project/View/ViewProject.tsx b/web/app/pages/Project/View/ViewProject.tsxindex 9ac449f2a..8a647020a 100644--- a/web/app/pages/Project/View/ViewProject.tsx+++ b/web/app/pages/Project/View/ViewProject.tsx@@ -1384,7 +1384,6 @@ const ViewProjectContent = () => {<TrafficViewtnMapping={tnMapping}customMetrics={customMetrics}- onCustomMetric={onCustomMetric}onRemoveCustomMetric={onRemoveCustomMetric}resetCustomMetrics={resetCustomMetrics}mode={mode}diff --git a/web/app/pages/Project/View/components/DashboardHeader.tsx b/web/app/pages/Project/View/components/DashboardHeader.tsxindex aab9b5817..10bbdcb41 100644--- a/web/app/pages/Project/View/components/DashboardHeader.tsx+++ b/web/app/pages/Project/View/components/DashboardHeader.tsx@@ -6,7 +6,7 @@ import React from 'react'import { useTranslation } from 'react-i18next'import { useSearchParams } from 'react-router'-import { MAX_MONTHS_IN_PAST, PERIOD_PAIRS_COMPARE } from '~/lib/constants'+import { MAX_MONTHS_IN_PAST, PERIOD_PAIRS_COMPARE, TBPeriodPairsProps } from '~/lib/constants'import { useAuth } from '~/providers/AuthProvider'import DatePicker from '~/ui/Datepicker'import Dropdown from '~/ui/Dropdown'@@ -25,7 +25,7 @@ interface DashboardHeaderProps {showSearchButton?: booleanshowPeriodSelector?: booleanhideTimeBucket?: boolean- timeBucketSelectorItems?: { period: string; label: string; tbs: string[] }[]+ timeBucketSelectorItems?: TBPeriodPairsProps[]// Back button link (when provided, shows a back button on the far left)backLink?: string@@ -38,7 +38,7 @@ interface DashboardHeaderProps {rightContent?: React.ReactNode}-export const DashboardHeader = ({+const DashboardHeader = ({showLiveVisitors = true,showRefreshButton = true,showSearchButton = true,diff --git a/web/app/pages/Project/View/components/Errors.tsx b/web/app/pages/Project/View/components/Errors.tsxdeleted file mode 100644index 94a7122f6..000000000--- a/web/app/pages/Project/View/components/Errors.tsx+++ /dev/null@@ -1,138 +0,0 @@-import { ChevronRightIcon } from '@heroicons/react/24/outline'-import cx from 'clsx'-import _map from 'lodash/map'-import React, { useMemo } from 'react'-import { useTranslation } from 'react-i18next'-import { Link, useLocation } from 'react-router'-import { ClientOnly } from 'remix-utils/client-only'--import { SwetrixError } from '~/lib/models/Project'-import { Badge } from '~/ui/Badge'-import Loader from '~/ui/Loader'-import { Text } from '~/ui/Text'-import { getRelativeDateIfPossible } from '~/utils/date'--interface ErrorsProps {- errors: SwetrixError[]-}--interface ErrorItemProps {- error: SwetrixError-}--interface SeparatorProps {- className?: string-}--const Separator = ({ className }: SeparatorProps) => (- <svg viewBox='0 0 2 2' className={cx('h-0.5 w-0.5 flex-none fill-gray-400', className)}>- <circle cx={1} cy={1} r={1} />- </svg>-)--const ErrorItem = ({ error }: ErrorItemProps) => {- const {- t,- i18n: { language },- } = useTranslation('common')- const location = useLocation()- const lastSeen = useMemo(() => {- return getRelativeDateIfPossible(error.last_seen, language)- }, [error.last_seen, language])- const status: {- label: string- colour: 'red' | 'yellow' | 'slate'- } = useMemo(() => {- if (error.status === 'active') {- return {- label: t('error.status.active'),- colour: 'red',- }- }-- if (error.status === 'regressed') {- return {- label: t('error.status.regressed'),- colour: 'yellow',- }- }-- return {- label: t('error.status.resolved'),- colour: 'slate',- }- }, [error.status, t])-- const params = new URLSearchParams(location.search)- params.set('eid', error.eid)-- return (- <Link to={{ search: params.toString() }}>- <li className='relative mb-3 flex cursor-pointer justify-between gap-x-6 overflow-hidden rounded-xl border border-gray-200 bg-gray-50 px-4 py-4 transition-colors hover:bg-gray-200/70 sm:px-6 dark:border-slate-800/25 dark:bg-slate-800/70 dark:hover:bg-slate-700/60'>- <div className='flex min-w-0 gap-x-4'>- <div className='min-w-0 flex-auto'>- <p className='flex items-center gap-x-2 leading-6 font-semibold'>- <Text size='sm' weight='bold' className='pb-0.5'>- {error.name}- </Text>- {error.filename ? (- <>- <Separator className='self-center' />- <Text size='xs' weight='normal' colour='muted' className='mx-1 break-all'>- {error.filename}- </Text>- </>- ) : null}- </p>- {error.message ? (- <Text as='p' size='sm' colour='muted' className='mt-1 flex leading-5'>- {error.message}- </Text>- ) : null}- <p className='mt-1 flex items-center gap-x-2 text-sm leading-5 text-gray-500 dark:text-gray-300'>- <Badge className='mr-2 sm:hidden' label={status.label} colour={status.colour} />- {lastSeen}- <Separator className='sm:hidden' />- <span className='sm:hidden'>- {t('dashboard.xOccurrences', {- x: error.count,- })}- </span>- </p>- </div>- </div>- <div className='flex shrink-0 items-center gap-x-4'>- <div className='hidden sm:flex sm:flex-col sm:items-end'>- <Text as='p' size='sm' className='leading-6'>- {t('dashboard.xOccurrences', {- x: error.count,- })}- </Text>- <Badge label={status.label} colour={status.colour} />- </div>- <ChevronRightIcon className='h-5 w-5 flex-none text-gray-400' aria-hidden='true' />- </div>- </li>- </Link>- )-}--export const Errors = ({ errors }: ErrorsProps) => {- return (- <ClientOnly- fallback={- <div className='bg-gray-50 dark:bg-slate-900'>- <Loader />- </div>- }- >- {() => (- <ul className='mt-4'>- {_map(errors, (error) => (- <ErrorItem key={error.eid} error={error} />- ))}- </ul>- )}- </ClientOnly>- )-}diff --git a/web/app/pages/Project/View/components/SessionDetailView.tsx b/web/app/pages/Project/View/components/SessionDetailView.tsxindex 6826d7d46..150585803 100644--- a/web/app/pages/Project/View/components/SessionDetailView.tsx+++ b/web/app/pages/Project/View/components/SessionDetailView.tsx@@ -136,7 +136,7 @@ export const SessionDetailView = ({}return 0- }, [activeSession?.details?.sdur, activeSession?.pages])+ }, [activeSession])const resetZoom = () => {setZoomedTimeRange(null)diff --git a/web/app/pages/Project/View/components/SessionDetails.tsx b/web/app/pages/Project/View/components/SessionDetails.tsxdeleted file mode 100644index 79946002b..000000000--- a/web/app/pages/Project/View/components/SessionDetails.tsx+++ /dev/null@@ -1,230 +0,0 @@-import cx from 'clsx'-import dayjs from 'dayjs'-import _capitalize from 'lodash/capitalize'-import _isEmpty from 'lodash/isEmpty'-import _size from 'lodash/size'-import _truncate from 'lodash/truncate'-import { useMemo } from 'react'-import { useTranslation } from 'react-i18next'--import { SessionDetails as Details } from '~/lib/models/Project'-import { getLocaleDisplayName, getStringFromTime, getTimeFromSeconds } from '~/utils/generic'--import CCRow from './CCRow'-import { MetricCard, MetricCardSelect } from './MetricCards'--interface PageflowItem {- type: 'pageview' | 'event' | 'error'- value: string- created: string-}--interface SessionDetailsProps {- details: Details- pages?: PageflowItem[]-}--export const SessionDetails = ({ details, pages }: SessionDetailsProps) => {- const {- t,- i18n: { language },- } = useTranslation('common')-- // Calculate session duration from pages if sdur is 0 or not available- const sessionDuration = useMemo(() => {- if (details.sdur && details.sdur > 0) {- return details.sdur- }-- // Fallback: calculate duration from pageview timestamps only (for consistency with session list)- if (!_isEmpty(pages)) {- const pageviews = pages!.filter((p) => p.type === 'pageview')- if (pageviews.length >= 1) {- const firstPageview = pageviews[0]- const lastPageview = pageviews[pageviews.length - 1]- const diffSeconds = dayjs(lastPageview.created).diff(dayjs(firstPageview.created), 'seconds')- if (diffSeconds > 0) {- return diffSeconds- }- }- }-- return 0- }, [details.sdur, pages])-- const geo = [- {- label: t('project.mapping.cc'),- value: details.cc,- },- {- label: t('project.mapping.rg'),- value: details.rg,- },- {- label: t('project.mapping.ct'),- value: details.ct,- },- ]-- const browser = [- {- label: t('project.mapping.br'),- value: details.br || 'N/A',- },- {- label: t('project.mapping.brv'),- value: details.brv || 'N/A',- },- ]-- const os = [- {- label: t('project.mapping.os'),- value: details.os || 'N/A',- },- {- label: t('project.mapping.osv'),- value: details.osv || 'N/A',- },- ]-- const utm = [- {- label: t('project.mapping.so'),- value: details.so || 'N/A',- },- {- label: t('project.mapping.me'),- value: details.me || 'N/A',- },- {- label: t('project.mapping.ca'),- value: details.ca || 'N/A',- },- {- label: t('project.mapping.te'),- value: details.te || 'N/A',- },- {- label: t('project.mapping.co'),- value: details.co || 'N/A',- },- ]-- return (- <div className='mb-5 flex flex-wrap justify-center gap-5 lg:justify-start'>- <MetricCardSelect- classes={{- value: 'max-md:text-xl md:text-2xl',- label: '[&_span]:!text-slate-800 dark:[&_span]:!text-gray-200',- }}- values={geo}- selectLabel={t('project.geo')}- valueMapper={({ value }, index) => {- if (index !== 0) {- return value || 'N/A'- }-- if (!value) {- return t('project.unknownCountry')- }-- return (- <div className='flex items-center'>- <CCRow size={26} cc={value} language={language} />- </div>- )- }}- />- <MetricCardSelect- classes={{- value: 'max-md:text-xl md:text-2xl',- label: '[&_span]:!text-slate-800 dark:[&_span]:!text-gray-200',- }}- values={os}- selectLabel={t('project.osInfo')}- />- <MetricCard- classes={{- value: 'max-md:text-xl md:text-2xl',- label: '[&_span]:!text-slate-800 dark:[&_span]:!text-gray-200',- }}- label={t('project.mapping.dv')}- value={details.dv || 'N/A'}- valueMapper={(value) => _capitalize(value)}- />- <MetricCardSelect- classes={{- value: 'max-md:text-xl md:text-2xl',- label: '[&_span]:!text-slate-800 dark:[&_span]:!text-gray-200',- }}- values={browser}- selectLabel={t('project.browserInfo')}- />- <MetricCard- classes={{- value: 'max-md:text-xl md:text-2xl',- label: '[&_span]:!text-slate-800 dark:[&_span]:!text-gray-200',- }}- label={t('project.mapping.lc')}- value={details.lc || 'N/A'}- valueMapper={(value) => {- if (value === 'N/A') {- return value- }-- return getLocaleDisplayName(value, language)- }}- />- <MetricCard- classes={{- value: 'max-md:text-xl md:text-2xl',- label: '[&_span]:!text-slate-800 dark:[&_span]:!text-gray-200',- }}- label={t('project.mapping.ref')}- value={details.ref || 'N/A'}- valueMapper={(value) => {- if (_size(value) < 20) {- return value- }-- return (- <span title={value}>- {_truncate(value, {- length: 20,- })}- </span>- )- }}- />- <MetricCardSelect- classes={{- value: 'max-md:text-xl md:text-2xl',- label: '[&_span]:!text-slate-800 dark:[&_span]:!text-gray-200',- }}- values={utm}- selectLabel={t('project.campaigns')}- />- <MetricCard- classes={{- value: cx('max-md:text-xl md:text-2xl', details.isLive ? '!text-red-500 font-semibold' : ''),- label: '[&_span]:!text-slate-800 dark:[&_span]:!text-gray-200',- }}- label={t('dashboard.sessionDuration')}- value={- details.isLive ? (- <span className='flex items-center'>- <span className='mr-1.5 h-2.5 w-2.5 animate-pulse rounded-full bg-red-500' />- {t('dashboard.live').toUpperCase()}- </span>- ) : sessionDuration > 0 ? (- getStringFromTime(getTimeFromSeconds(sessionDuration))- ) : (- 'N/A'- )- }- />- </div>- )-}diff --git a/web/app/pages/Project/View/components/TrafficHeaderActions.tsx b/web/app/pages/Project/View/components/TrafficHeaderActions.tsxindex 61962fec6..9abd1411f 100644--- a/web/app/pages/Project/View/components/TrafficHeaderActions.tsx+++ b/web/app/pages/Project/View/components/TrafficHeaderActions.tsx@@ -7,7 +7,6 @@ import { useTranslation } from 'react-i18next'import { useSearchParams } from 'react-router'import { isSelfhosted, MARKETPLACE_URL } from '~/lib/constants'-import { useCurrentProject } from '~/providers/CurrentProjectProvider'import Dropdown from '~/ui/Dropdown'import { Text } from '~/ui/Text'import { trackCustom } from '~/utils/analytics'@@ -41,7 +40,7 @@ interface TrafficHeaderActionsProps {panelsData: any}-export const TrafficHeaderActions = ({+const TrafficHeaderActions = ({projectViews,projectViewsLoading,projectViewDeleting,@@ -58,7 +57,6 @@ export const TrafficHeaderActions = ({panelsData,}: TrafficHeaderActionsProps) => {const { t } = useTranslation('common')- const { id } = useCurrentProject()const [searchParams, setSearchParams] = useSearchParams()return (diff --git a/web/app/ui/FilterValueInput.tsx b/web/app/ui/FilterValueInput.tsxindex 3371e253a..20b163403 100644--- a/web/app/ui/FilterValueInput.tsx+++ b/web/app/ui/FilterValueInput.tsx@@ -67,8 +67,7 @@ export const filterCategoryIcons: Record<string, ReactNode> = {dv: <TabletSmartphoneIcon className='size-4' strokeWidth={1.5} />,}-// Device icon mapping-export const deviceIconMapping: Record<string, ReactNode> = {+const deviceIconMapping: Record<string, ReactNode> = {desktop: <MonitorIcon className='size-4' strokeWidth={1.5} />,mobile: <SmartphoneIcon className='size-4' strokeWidth={1.5} />,tablet: <TabletIcon className='size-4' strokeWidth={1.5} />,@@ -79,7 +78,7 @@ export const deviceIconMapping: Record<string, ReactNode> = {}// Special separator for combined version values (e.g., "Chrome|||120.5")-export const VERSION_SEPARATOR = '|||'+const VERSION_SEPARATOR = '|||'// Helper to create combined version valueexport const createVersionValue = (parent: string, version: string) => `${parent}${VERSION_SEPARATOR}${version}`@@ -91,7 +90,7 @@ export const parseVersionValue = (value: string): { parent: string; version: strreturn { parent, version }}-export interface FilterValueInputProps {+interface FilterValueInputProps {items: string[]value: stringonChange: (value: string) => voiddiff --git a/web/app/ui/Switch.tsx b/web/app/ui/Switch.tsxindex d22d4b401..44169dd35 100644--- a/web/app/ui/Switch.tsx+++ b/web/app/ui/Switch.tsx@@ -1,4 +1,5 @@import cx from 'clsx'+import { useId } from 'react'import { Text } from '~/ui/Text'@@ -12,7 +13,8 @@ interface SwitchProps {}export const Switch = ({ checked, onChange, disabled = false, className, label, id }: SwitchProps) => {- const switchId = id || `switch-${Math.random().toString(36).substr(2, 9)}`+ const generatedId = useId()+ const switchId = id || generatedIdreturn (<div className={cx('inline-flex items-center', className)}>