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!

Clean-up useless comments

Blue Mouse79112aaa6c2f
diff --git a/backend/apps/cloud/src/analytics/protection/analytics-read.util.ts b/backend/apps/cloud/src/analytics/protection/analytics-read.util.ts
index fdad92f29..3c77aea97 100644
--- a/backend/apps/cloud/src/analytics/protection/analytics-read.util.ts
+++ b/backend/apps/cloud/src/analytics/protection/analytics-read.util.ts
@@ -41,7 +41,6 @@ export const getSinglePid = (
query: Record<string, unknown>,
params?: Record<string, unknown>,
): string | null => {
- // v2 routes carry the pid as a path param (/v2/projects/:pid/...)
const paramPid = params?.pid
if (_isString(paramPid) && PID_REGEX.test(paramPid)) {
@@ -50,11 +49,6 @@ export const getSinglePid = (
const { pid, pids } = query
- // v1 treats a request carrying BOTH ?pid and ?pids as invalid (getPIDsArray
- // rejects it). Mirror that here so the publicness/cache decision is never
- // judged against one project while the handler queries another. Returning
- // null makes callers fall back to their safe default (skip caching / skip
- // the public-project rate limit).
if (pid !== undefined && pids !== undefined) {
return null
}
diff --git a/backend/apps/cloud/src/analytics/protection/cacheable-analytics.decorator.ts b/backend/apps/cloud/src/analytics/protection/cacheable-analytics.decorator.ts
index 3e34cd2ef..8a69a7d25 100644
--- a/backend/apps/cloud/src/analytics/protection/cacheable-analytics.decorator.ts
+++ b/backend/apps/cloud/src/analytics/protection/cacheable-analytics.decorator.ts
@@ -2,10 +2,5 @@ import { SetMetadata } from '@nestjs/common'
export const CACHEABLE_ANALYTICS_KEY = 'cacheable_analytics'
-/**
- * Opt a v2 analytics GET handler into the public-project Redis cache
- * (PublicProjectCacheInterceptor). v1 routes are matched by the
- * CACHEABLE_ROUTES set instead and don't need this decorator.
- */
export const CacheableAnalytics = () =>
SetMetadata(CACHEABLE_ANALYTICS_KEY, true)
diff --git a/backend/apps/cloud/src/analytics/protection/public-project-cache.interceptor.ts b/backend/apps/cloud/src/analytics/protection/public-project-cache.interceptor.ts
index e284d8662..1f7587d56 100644
--- a/backend/apps/cloud/src/analytics/protection/public-project-cache.interceptor.ts
+++ b/backend/apps/cloud/src/analytics/protection/public-project-cache.interceptor.ts
@@ -59,8 +59,6 @@ export class PublicProjectCacheInterceptor implements NestInterceptor {
return next.handle()
}
- // v2 handlers opt in via @CacheableAnalytics(); v1 routes are matched
- // against the static route set
const isCacheableV2 = this.reflector.get<boolean>(
CACHEABLE_ANALYTICS_KEY,
context.getHandler(),
diff --git a/backend/apps/cloud/src/analytics/v2/__tests__/breakdown-query.builder.spec.ts b/backend/apps/cloud/src/analytics/v2/__tests__/breakdown-query.builder.spec.ts
index 75f684dd0..710fae981 100644
--- a/backend/apps/cloud/src/analytics/v2/__tests__/breakdown-query.builder.spec.ts
+++ b/backend/apps/cloud/src/analytics/v2/__tests__/breakdown-query.builder.spec.ts
@@ -95,7 +95,6 @@ describe('buildBreakdownQuery', () => {
expect(query).toContain('cc AS country')
expect(query).toContain('rgc AS region_code')
expect(query).toContain('GROUP BY value, country, region_code')
- // region is in the v1 EXCLUDE_NULL_FOR list
expect(query).toContain('AND rg IS NOT NULL')
})
@@ -126,7 +125,6 @@ describe('buildBreakdownQuery', () => {
}),
)
- // solve_time resolves to a multiIf bucket expression, not a plain column
expect(query).toContain('multiIf(')
expect(query).toContain("= 'pass'")
@@ -141,7 +139,6 @@ describe('buildBreakdownQuery', () => {
}),
)
- // country/browser/os/device only count passed captchas (v1 parity)
expect(countryQuery).toContain("= 'pass'")
})
diff --git a/backend/apps/cloud/src/analytics/v2/__tests__/filters.translator.spec.ts b/backend/apps/cloud/src/analytics/v2/__tests__/filters.translator.spec.ts
index f2ff9239c..7039e6cb6 100644
--- a/backend/apps/cloud/src/analytics/v2/__tests__/filters.translator.spec.ts
+++ b/backend/apps/cloud/src/analytics/v2/__tests__/filters.translator.spec.ts
@@ -132,7 +132,6 @@ describe('toV1FiltersJson', () => {
]),
)
- // error_name is not a traffic dimension
expect(() => toV1FiltersJson(filters, 'traffic')).toThrow(
UnprocessableEntityException,
)
diff --git a/backend/apps/cloud/src/analytics/v2/__tests__/ioredis.stub.ts b/backend/apps/cloud/src/analytics/v2/__tests__/ioredis.stub.ts
index c1b956f81..734d69d92 100644
--- a/backend/apps/cloud/src/analytics/v2/__tests__/ioredis.stub.ts
+++ b/backend/apps/cloud/src/analytics/v2/__tests__/ioredis.stub.ts
@@ -1,8 +1,3 @@
-/**
- * Minimal ioredis stand-in so importing analytics.service.ts (which pulls in
- * common/constants and its module-level Redis client) doesn't open network
- * connections during unit tests.
- */
class RedisStub {
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
constructor(..._args: unknown[]) {}
diff --git a/backend/apps/cloud/src/analytics/v2/__tests__/registry.spec.ts b/backend/apps/cloud/src/analytics/v2/__tests__/registry.spec.ts
index 7194022d3..bd907ebec 100644
--- a/backend/apps/cloud/src/analytics/v2/__tests__/registry.spec.ts
+++ b/backend/apps/cloud/src/analytics/v2/__tests__/registry.spec.ts
@@ -9,9 +9,6 @@ import {
V2_DIMENSIONS,
} from '../registry'
-// Keep the registry in lockstep with the v1 filter column allowlists
-// (common/constants.ts). If a column is added there, the registry must learn
-// about it too.
const {
TRAFFIC_COLUMNS,
PERFORMANCE_COLUMNS,
@@ -67,7 +64,6 @@ describe('dimension lookups', () => {
expect(() => getBreakdownDimension('event', 'traffic')).toThrow(
UnprocessableEntityException,
)
- // valid dimension, wrong data type
expect(() => getBreakdownDimension('referrer', 'performance')).toThrow(
UnprocessableEntityException,
)
diff --git a/backend/apps/cloud/src/analytics/v2/analytics-v2.service.ts b/backend/apps/cloud/src/analytics/v2/analytics-v2.service.ts
index 81ba8069d..0bda4fdbe 100644
--- a/backend/apps/cloud/src/analytics/v2/analytics-v2.service.ts
+++ b/backend/apps/cloud/src/analytics/v2/analytics-v2.service.ts
@@ -70,7 +70,6 @@ const ALL_TIME_EVENT_TYPES: Record<V2DataType, readonly EventsAllTimeType[]> = {
errors: ['error'],
}
-/** Traffic metrics computable per time bucket by the v1 chart query */
const TRAFFIC_TIMESERIES_METRICS = [
'visitors',
'pageviews',
@@ -79,7 +78,6 @@ const TRAFFIC_TIMESERIES_METRICS = [
'concurrency',
]
-/** Performance metrics computable per time bucket (v2 name -> v1 chart key) */
const PERFORMANCE_TIMESERIES_METRICS: Record<string, string> = {
dns: 'dns',
tls: 'tls',
@@ -90,7 +88,6 @@ const PERFORMANCE_TIMESERIES_METRICS: Record<string, string> = {
ttfb: 'ttfb',
}
-/** Captcha counters computable per time bucket (v2 name -> v1 chart key) */
const CAPTCHA_TIMESERIES_METRICS: Record<string, string> = {
generated: 'generated',
passed: 'passed',
@@ -106,10 +103,8 @@ export interface ResolvedTimeframe {
timeBucket: TimeBucketType | null
allowedTimeBuckets: TimeBucketType[] | null
safeTimezone: string
- /** Timezone-shifted bounds (YYYY-MM-DD HH:mm:ss) */
groupFrom: string
groupTo: string
- /** UTC bounds used as ClickHouse query params */
groupFromUTC: string
groupToUTC: string
}
@@ -140,11 +135,6 @@ export class AnalyticsV2Service {
await this.analyticsService.checkBillingAccess(pid)
}
- /**
- * Resolve period/from/to/timeBucket/timezone into concrete query bounds.
- * Centralizes the v1 `period=all` dance (first-event lookup -> diff ->
- * allowed time buckets) in a single place.
- */
async resolveTimeframe(opts: {
pid: string
dataType: V2DataType
@@ -153,7 +143,6 @@ export class AnalyticsV2Service {
to?: string
timeBucket?: TimeBucketType
timezone?: string
- /** Override the event types used for the period=all first-event lookup */
allTimeEventTypes?: readonly EventsAllTimeType[]
}): Promise<ResolvedTimeframe> {
const { pid, dataType, from, to, timezone } = opts
@@ -291,13 +280,10 @@ export class AnalyticsV2Service {
measure?: PerfMeasure,
): Promise<V2Envelope<Record<string, unknown>[]>> {
const dimension = getBreakdownDimension(dto.dimension, dataType)
- // Session-scoped virtual dimensions (entry/exit page) only support
- // 'visitors', so the per-type defaults don't apply to them
const metrics =
dimension.virtual && !dto.metrics
? [getMetric('visitors', dataType)]
: parseMetricsParam(dto.metrics, dataType)
- // v1 parity: performance and error queries ignore custom-event filters
const filters = this.prepareFilters(
dto.filters,
dataType,
@@ -484,8 +470,6 @@ export class AnalyticsV2Service {
const mode = dto.mode || ChartRenderMode.PERIODICAL
- // Concurrency (live visitors over time) runs an extra ClickHouse query, so
- // it is only reconstructed when the metric is explicitly requested
const includeConcurrency = metrics.some(
(metric) => metric.api === 'concurrency',
)
@@ -752,8 +736,6 @@ export class AnalyticsV2Service {
allTimeEventTypes: ['pageview'],
})
- // v1 parity: the user-flow query compares `created` against the
- // timezone-shifted bounds directly
const flow = await this.analyticsService.getUserFlow(
{
pid,
@@ -858,7 +840,6 @@ export class AnalyticsV2Service {
this.analyticsService.checkIfPerfMeasureIsValid(measure)
- // v1 parity: quantiles is a timeseries-only measure; birdseye maps it to median
if (measure === 'quantiles') {
measure = 'median'
}
@@ -1039,7 +1020,6 @@ export class AnalyticsV2Service {
{ params: baseParams },
)
- // Previous period of the same length (v1 parity; skipped for period=all)
let previousPromise: Promise<object | null> = Promise.resolve(null)
if (timeframe.period !== 'all') {
@@ -1142,8 +1122,6 @@ export class AnalyticsV2Service {
const mode = dto.mode || ChartRenderMode.PERIODICAL
- // v1 parity: error occurrences are bucketed in UTC, labels are shifted
- // to the requested timezone afterwards
const { x, format } = this.analyticsService.generateUTCXAxis(
timeframe.timeBucket,
timeframe.groupFromUTC,
@@ -1221,8 +1199,6 @@ export class AnalyticsV2Service {
const dataType: V2DataType = 'errors'
const filters = this.prepareFilters(dto.filters, dataType, true)
- // Session-scoped stats inside the overview run against traffic data;
- // error-specific filters are dropped for that part (v1 parity)
const sessionV1FiltersJson = toV1FiltersJson(
filters.appliedFilters,
'traffic',
@@ -1651,8 +1627,6 @@ export class AnalyticsV2Service {
.filter(Boolean)
}
- // A '__proto__' series key would mutate the response object's prototype
- // instead of adding a series
events = events.filter((event) => event && event !== '__proto__')
if (events.length === 0) {
@@ -1756,8 +1730,6 @@ export class AnalyticsV2Service {
filters.filtersQuery,
)
} catch (reason) {
- // Step details are best-effort (v1 parity); dev-only logging as
- // the raw error may embed funnel query params
this.logger.log(reason, 'AnalyticsV2Service -> getFunnelStepDetails')
}
})(),
@@ -1848,11 +1820,6 @@ export class AnalyticsV2Service {
return this.analyticsService.getPagesArray(dto.steps, dto.funnelId, pid)
}
- /**
- * Funnel time bounds mirror v1 exactly: no time bucket, timezone-shifted
- * bounds as ClickHouse params, and a period=all diff based on the max of
- * pageview / custom_event first-seen.
- */
private async resolveFunnelContext(
pid: string,
dto: V2BaseQueryDto,
@@ -2005,7 +1972,6 @@ export class AnalyticsV2Service {
)
}
- // Browser / OS versions return { name, version } pairs
if (dimension.column === 'brv' || dimension.column === 'osv') {
const values = await this.analyticsService.getVersionFilters(
pid,
@@ -2016,8 +1982,6 @@ export class AnalyticsV2Service {
return envelope(values, { pid, dimension: dimensionApi, type })
}
- // Entry/exit page values come from the session-scoped virtual-column
- // path in getFilters; getErrorsFilters cannot resolve them
const values =
type === 'errors' && !dimension.virtual
? await this.analyticsService.getErrorsFilters(pid, dimension.column)
@@ -2026,7 +1990,6 @@ export class AnalyticsV2Service {
return envelope(values, { pid, dimension: dimensionApi, type })
}
- /** Validate a metric name exists for the data type (helper for controllers) */
validateMetric(api: string, dataType: V2DataType): V2MetricDef {
return getMetric(api, dataType)
}
diff --git a/backend/apps/cloud/src/analytics/v2/controllers/errors-v2.controller.ts b/backend/apps/cloud/src/analytics/v2/controllers/errors-v2.controller.ts
index 926c498ec..902f3bdd8 100644
--- a/backend/apps/cloud/src/analytics/v2/controllers/errors-v2.controller.ts
+++ b/backend/apps/cloud/src/analytics/v2/controllers/errors-v2.controller.ts
@@ -37,8 +37,6 @@ import {
V2TimeseriesDto,
} from '../dto/v2-base.dto'
-// NOTE: static routes (overview, timeseries, breakdown) MUST be declared
-// before the :eid routes β€” NestJS matches routes in declaration order.
@ApiTags('Analytics v2')
@ApiBearerAuth()
@ApiSecurity('apiKey')
diff --git a/backend/apps/cloud/src/analytics/v2/dto/entities.dto.ts b/backend/apps/cloud/src/analytics/v2/dto/entities.dto.ts
index 523a0649b..b8579e767 100644
--- a/backend/apps/cloud/src/analytics/v2/dto/entities.dto.ts
+++ b/backend/apps/cloud/src/analytics/v2/dto/entities.dto.ts
@@ -82,8 +82,6 @@ export class V2ErrorsQueryDto extends V2EntityListDto {
@Transform(({ value }) => {
if (value === true || value === 'true') return true
if (value === false || value === 'false') return false
- // Leave anything else untouched so @IsBoolean() rejects it instead of
- // silently coercing invalid input to false.
return value
})
@IsBoolean()
diff --git a/backend/apps/cloud/src/analytics/v2/mappers/entity.mapper.ts b/backend/apps/cloud/src/analytics/v2/mappers/entity.mapper.ts
index 39a85c290..c63c303b9 100644
--- a/backend/apps/cloud/src/analytics/v2/mappers/entity.mapper.ts
+++ b/backend/apps/cloud/src/analytics/v2/mappers/entity.mapper.ts
@@ -1,7 +1,3 @@
-/**
- * Key renames applied to v1 entity payloads (sessions, profiles, session
- * details) so v2 responses use human-readable field names.
- */
const KEY_RENAMES: Record<string, string> = {
cc: 'country',
rg: 'region',
diff --git a/backend/apps/cloud/src/analytics/v2/mappers/summary.mapper.ts b/backend/apps/cloud/src/analytics/v2/mappers/summary.mapper.ts
index 5f0ddef2f..b2b2219f6 100644
--- a/backend/apps/cloud/src/analytics/v2/mappers/summary.mapper.ts
+++ b/backend/apps/cloud/src/analytics/v2/mappers/summary.mapper.ts
@@ -48,10 +48,6 @@ const mapPeriod = (period: V1SummaryPeriod): TrafficSummaryPeriod => ({
session_duration: toNullableNumber(period.sdur),
})
-/**
- * Reshape a single project's v1 birdseye payload (getAnalyticsSummary) into
- * the v2 summary format with human-readable metric names.
- */
export const mapTrafficSummary = (
v1Summary: V1TrafficSummary,
): TrafficSummaryData => ({
diff --git a/backend/apps/cloud/src/analytics/v2/mappers/timeseries.mapper.ts b/backend/apps/cloud/src/analytics/v2/mappers/timeseries.mapper.ts
index 53494268a..b0f80e876 100644
--- a/backend/apps/cloud/src/analytics/v2/mappers/timeseries.mapper.ts
+++ b/backend/apps/cloud/src/analytics/v2/mappers/timeseries.mapper.ts
@@ -12,24 +12,12 @@ export type TimeseriesRow = { timestamp: string } & Record<
string | number | null
>
-/**
- * Convert a v1 timezone-shifted x-axis label (e.g. '2026-07-01',
- * '2026-07-01 13:00:00', '2026-07') into an ISO-8601 timestamp carrying the
- * requested timezone's UTC offset.
- */
export const toIsoTimestamp = (value: string, timezone: string): string => {
const zone = timezone || DEFAULT_TIMEZONE
return dayjs.tz(value, zone).format()
}
-/**
- * Zip v1's columnar chart output ({ x: [...], seriesA: [...], seriesB: [...] })
- * into self-describing rows of objects β€” the v2 timeseries format.
- *
- * `series` maps v2 metric names to v1 arrays; missing/undefined series are
- * skipped. Array values falling outside the x range are ignored.
- */
export const zipTimeseries = (
x: string[],
series: Record<string, (number | null)[] | undefined>,
@@ -51,10 +39,6 @@ export const zipTimeseries = (
})
}
-/**
- * Per-bucket bounce rate (%) from v1's raw bounces + uniques arrays,
- * mirroring v1's calculateBounceRate (bounces / uniques * 100).
- */
export const computeBounceRateSeries = (
bounces: number[] | undefined,
uniques: number[] | undefined,
diff --git a/backend/apps/cloud/src/analytics/v2/query/breakdown-query.builder.ts b/backend/apps/cloud/src/analytics/v2/query/breakdown-query.builder.ts
index 1c17653ca..645f15f9a 100644
--- a/backend/apps/cloud/src/analytics/v2/query/breakdown-query.builder.ts
+++ b/backend/apps/cloud/src/analytics/v2/query/breakdown-query.builder.ts
@@ -18,7 +18,6 @@ export interface BreakdownQueryOptions {
dataType: V2DataType
dimension: V2DimensionDef
metrics: V2MetricDef[]
- /** 'FROM events WHERE ...' fragment, incl. filters and time range params */
subQuery: string
ctx: V2MetricCtx
sort: BreakdownSort
@@ -52,11 +51,6 @@ export const parseSortParam = (
return { field, direction }
}
-/**
- * Multi-metric generalization of v1's generateParamsQuery: one dimension,
- * N metric aggregates, ORDER BY + LIMIT/OFFSET pagination and a windowed
- * total. Expects `v2_limit` and `v2_offset` in the query params.
- */
export const buildBreakdownQuery = (opts: BreakdownQueryOptions): string => {
const { dataType, dimension, metrics, subQuery, ctx, sort } = opts
diff --git a/backend/apps/cloud/src/analytics/v2/query/filters.translator.ts b/backend/apps/cloud/src/analytics/v2/query/filters.translator.ts
index 9b6f21d19..833cb0900 100644
--- a/backend/apps/cloud/src/analytics/v2/query/filters.translator.ts
+++ b/backend/apps/cloud/src/analytics/v2/query/filters.translator.ts
@@ -19,7 +19,6 @@ export interface V2Filter {
dimension: string
operator: V2FilterOperator
value: string | null | (string | null)[]
- /** meta.key for event_metadata / page_property filters */
key?: string
}
@@ -62,8 +61,6 @@ const resolveColumn = (
)
}
- // With a key: filter values of that meta key. Without: filter the
- // meta keys themselves.
return key ? `${keyedFamily.v1Prefix}${key}` : keyedFamily.v1KeyColumn
}
@@ -82,10 +79,6 @@ const resolveColumn = (
return def.column
}
-/**
- * Parse and validate a v2 `filters` query param.
- * v2 filter shape: { dimension, operator: is|is_not|contains|contains_not, value, key? }
- */
export const parseV2Filters = (filters: string | undefined): V2Filter[] => {
if (!filters || filters === '""') {
return []
@@ -163,12 +156,6 @@ export const parseV2Filters = (filters: string | undefined): V2Filter[] => {
})
}
-/**
- * Translate parsed v2 filters into the exact v1 filters JSON string consumed
- * by AnalyticsService.getFiltersQuery β€” all v1 special-case SQL (refn domain
- * expansion, entry/exit page psid subqueries, meta-array filters,
- * customEVFilterApplied detection) is inherited unchanged.
- */
export const toV1FiltersJson = (
filters: V2Filter[],
type: V2DataType,
@@ -183,9 +170,6 @@ export const toV1FiltersJson = (
for (const filter of filters) {
const column = resolveColumn(filter, type, Boolean(options.lenient))
- // Lenient mode drops filters that don't apply to the data type instead
- // of rejecting the request (used when one endpoint queries several
- // data types with the same filter set)
if (column === null) {
continue
}
@@ -203,15 +187,6 @@ export const toV1FiltersJson = (
return JSON.stringify(v1Filters)
}
-/**
- * Normalise a `filters` query param that may be in EITHER the v2 shape
- * ({ dimension, operator, value, key? }) or the legacy v1 shape
- * ({ column, filter, isExclusive, isContains }) into the v1 filters JSON string
- * consumed by AnalyticsService.getFiltersQuery.
- *
- * Used by endpoints that are also part of the public v1 API, so existing API
- * clients sending v1 filters keep working while the dashboard sends v2.
- */
export const normalizeFiltersToV1Json = (
filters: string | undefined,
type: V2DataType,
@@ -225,7 +200,6 @@ export const normalizeFiltersToV1Json = (
try {
parsed = JSON.parse(filters)
} catch {
- // Leave malformed input to getFiltersQuery, which logs and ignores it.
return filters
}
@@ -233,8 +207,6 @@ export const normalizeFiltersToV1Json = (
return ''
}
- // Legacy v1 clients key filters by `column`; pass those straight through.
- // v2 clients (and the dashboard) send `dimension` and are translated.
const isLegacyV1 = parsed.every(
(filter) =>
filter &&
diff --git a/backend/apps/cloud/src/analytics/v2/registry/dimensions.ts b/backend/apps/cloud/src/analytics/v2/registry/dimensions.ts
index 64d78ed77..22858d453 100644
--- a/backend/apps/cloud/src/analytics/v2/registry/dimensions.ts
+++ b/backend/apps/cloud/src/analytics/v2/registry/dimensions.ts
@@ -183,8 +183,6 @@ export const V2_DIMENSIONS: V2DimensionDef[] = [
description:
'Custom event name (filter-only; use /traffic/custom-events for a breakdown)',
},
- // Errors-only, filter-only dimensions. Columns are the v1 public filter
- // names β€” getFiltersQuery maps them to error_name/error_message/error_filename.
{
api: 'error_name',
column: 'name',
@@ -206,8 +204,6 @@ export const V2_DIMENSIONS: V2DimensionDef[] = [
filterOnly: true,
description: 'Source file the error originated from',
},
- // Captcha meta dimensions. Per-dimension WHERE guards mirror v1
- // generateParamsQuery captcha handling.
{
api: 'captcha_event',
column: 'captcha_event',
@@ -237,7 +233,6 @@ export const V2_DIMENSIONS: V2DimensionDef[] = [
},
]
-// Captcha country/browser/os/device breakdowns only count passed captchas (v1 parity)
const CAPTCHA_PASS_GUARD = `AND ${CAPTCHA_EVENT_SQL} = 'pass'`
export const captchaExtraWhere = (dim: V2DimensionDef): string | undefined => {
@@ -252,10 +247,6 @@ export const captchaExtraWhere = (dim: V2DimensionDef): string | undefined => {
return undefined
}
-/**
- * Filter-only dimension families that carry a `key` (meta.key) and translate
- * to v1's `ev:key:<key>` / `tag:key:<key>` filter columns.
- */
export const V2_KEYED_FILTER_DIMENSIONS: Record<
string,
{ v1Prefix: string; v1KeyColumn: string; types: V2DimensionDef['types'] }
diff --git a/backend/apps/cloud/src/analytics/v2/registry/index.ts b/backend/apps/cloud/src/analytics/v2/registry/index.ts
index 6b2d94bdd..7fd13aa32 100644
--- a/backend/apps/cloud/src/analytics/v2/registry/index.ts
+++ b/backend/apps/cloud/src/analytics/v2/registry/index.ts
@@ -33,10 +33,6 @@ export const findDimension = (
(dimension) => dimension.api === api && dimension.types.includes(type),
)
-/**
- * Resolve a dimension usable as ?dimension= (i.e. for breakdowns).
- * Throws a descriptive 422 for unknown or filter-only dimensions.
- */
export const getBreakdownDimension = (
api: string,
type: V2DataType,
@@ -80,10 +76,6 @@ export const getMetric = (api: string, type: V2DataType): V2MetricDef => {
export const getDefaultMetrics = (type: V2DataType): V2MetricDef[] =>
listMetrics(type).filter((metric) => metric.isDefault)
-/**
- * Parse a `metrics` CSV query param into validated metric definitions.
- * Returns the per-type defaults when the param is empty.
- */
export const parseMetricsParam = (
metrics: string | undefined,
type: V2DataType,
diff --git a/backend/apps/cloud/src/analytics/v2/registry/metrics.ts b/backend/apps/cloud/src/analytics/v2/registry/metrics.ts
index b41f0f7b6..84b715f91 100644
--- a/backend/apps/cloud/src/analytics/v2/registry/metrics.ts
+++ b/backend/apps/cloud/src/analytics/v2/registry/metrics.ts
@@ -1,10 +1,5 @@
import { V2MetricDef } from './types'
-/**
- * Local copy of the v1 MEASURES_MAP (analytics.service.ts). Duplicated on
- * purpose β€” the v2 registry is self-contained and these four entries are the
- * public API contract for the `measure` parameter.
- */
const MEASURES_MAP_V2: Record<string, string> = {
average: 'avg',
median: 'median',
@@ -22,12 +17,9 @@ const perfExpr =
}
export const V2_METRICS: V2MetricDef[] = [
- // --- traffic ---
{
api: 'visitors',
types: ['traffic'],
- // v1 semantics preserved: with a custom-event filter applied the base
- // event set is custom_event rows and "visitors" degrades to count(*)
sqlExpr: ({ customEVFilterApplied }) =>
customEVFilterApplied ? 'count(*)' : 'count(DISTINCT psid)',
isDefault: true,
@@ -70,15 +62,12 @@ export const V2_METRICS: V2MetricDef[] = [
{
api: 'concurrency',
types: ['traffic'],
- // Reconstructed from session intervals, which carry no dimension columns,
- // so it is a timeseries-only series that cannot respect filters
sqlExpr: () => null,
requiresSessionsJoin: true,
format: 'integer',
description:
'Concurrent live visitors over time (timeseries only; ignores filters)',
},
- // --- performance (values in seconds; `measure` selects the aggregate) ---
{
api: 'load_time',
types: ['performance'],
@@ -136,7 +125,6 @@ export const V2_METRICS: V2MetricDef[] = [
format: 'seconds',
description: 'DOM content load time',
},
- // --- errors ---
{
api: 'occurrences',
types: ['errors'],
@@ -152,7 +140,6 @@ export const V2_METRICS: V2MetricDef[] = [
format: 'integer',
description: 'Distinct users affected',
},
- // --- captcha ---
{
api: 'events',
types: ['captcha'],
@@ -161,8 +148,6 @@ export const V2_METRICS: V2MetricDef[] = [
format: 'integer',
description: 'Captcha events matching the dimension scope',
},
- // Timeseries/summary-only captcha counters (computed by the captcha
- // aggregation query, not the generic breakdown builder)
{
api: 'generated',
types: ['captcha'],
diff --git a/backend/apps/cloud/src/analytics/v2/registry/types.ts b/backend/apps/cloud/src/analytics/v2/registry/types.ts
index d4240e58c..49ee973b5 100644
--- a/backend/apps/cloud/src/analytics/v2/registry/types.ts
+++ b/backend/apps/cloud/src/analytics/v2/registry/types.ts
@@ -3,38 +3,18 @@ import { PerfMeasure } from '../../interfaces'
export type V2DataType = 'traffic' | 'performance' | 'captcha' | 'errors'
interface V2DimensionExtraField {
- /** Public API name of the sibling field, e.g. 'country' */
api: string
- /** ClickHouse column of the sibling field, e.g. 'cc' */
column: string
}
export interface V2DimensionDef {
- /** Public API name, snake_case: 'country', 'browser_version' */
api: string
- /**
- * v1 filter column / ClickHouse column: 'cc', 'brv'. For captcha meta
- * dimensions this is the v1 virtual column name ('captcha_event',
- * 'solve_time') which getFiltersQuery resolves to a SQL expression.
- * For errors-only filter dimensions this is the v1 public name ('name',
- * 'message', 'filename') which getFiltersQuery maps to error_* columns.
- */
column: string
- /** Data types this dimension is valid for */
types: V2DataType[]
- /** Sibling columns returned with each row, e.g. region -> country + region_code */
extraFields?: V2DimensionExtraField[]
- /** Mirrors v1 EXCLUDE_NULL_FOR behavior */
excludeNull?: boolean
- /** Usable in ?filters but not as ?dimension= */
filterOnly?: boolean
- /** Needs a dedicated query path instead of the generic breakdown builder */
virtual?: 'entry_page' | 'exit_page'
- /**
- * Extra WHERE fragment (starting with 'AND ...') appended to the breakdown
- * query. Used by captcha dimensions to scope rows to the relevant
- * captcha lifecycle event, mirroring v1 generateParamsQuery.
- */
extraWhere?: string
description: string
}
@@ -45,19 +25,10 @@ export interface V2MetricCtx {
}
export interface V2MetricDef {
- /** Public API name, snake_case: 'visitors', 'bounce_rate' */
api: string
- /** Data types this metric is valid for */
types: V2DataType[]
- /**
- * ClickHouse aggregate expression, or null when the metric cannot be
- * computed by the generic breakdown builder (e.g. it needs the sessions
- * join, or it only exists on timeseries/summary queries).
- */
sqlExpr: (ctx: V2MetricCtx) => string | null
- /** Metric needs the sessions-table join β€” timeseries/summary only */
requiresSessionsJoin?: boolean
- /** Included when no ?metrics= is provided */
isDefault?: boolean
format?: 'integer' | 'seconds' | 'percent'
description: string
diff --git a/backend/apps/cloud/src/common/constants.ts b/backend/apps/cloud/src/common/constants.ts
index 4eeeafd9c..6d77523fe 100644
--- a/backend/apps/cloud/src/common/constants.ts
+++ b/backend/apps/cloud/src/common/constants.ts
@@ -107,10 +107,6 @@ const TRAFFIC_METAKEY_COLUMNS = ['tag:key', 'tag:value']
const ALL_COLUMNS = [...TRAFFIC_COLUMNS, 'ev', 'entryPage', 'exitPage']
-// v2 dimension names allowed in a saved-view filter. Mirrors the traffic
-// dimensions in analytics/v2/registry/dimensions.ts β€” duplicated here because
-// project.service cannot import the registry without creating an
-// analytics.service <-> project.service import cycle.
const V2_VIEW_FILTER_DIMENSIONS = [
'country',
'region',
@@ -137,7 +133,6 @@ const V2_VIEW_FILTER_DIMENSIONS = [
'entry_page',
'exit_page',
'event',
- // errors-only filter dimensions (error-tab segments persist these)
'error_name',
'error_message',
'error_filename',
diff --git a/backend/apps/cloud/src/goal/goal.controller.ts b/backend/apps/cloud/src/goal/goal.controller.ts
index 8d264580d..8e8632a4b 100644
--- a/backend/apps/cloud/src/goal/goal.controller.ts
+++ b/backend/apps/cloud/src/goal/goal.controller.ts
@@ -83,12 +83,7 @@ const clampPagination = (take?: number, skip?: number) => {
return { take: safeTake, skip: safeSkip }
}
-// Maps a goal condition `field` to its ClickHouse column. New goals store v2
-// dimension names (page, country, utm_source, ...); the legacy v1 short codes
-// (pg, cc, so, ...) are kept so conditions saved before the v2 migration still
-// resolve.
const GOAL_CONDITION_COLUMNS: Record<string, string> = {
- // v2 dimension names
page: 'pg',
event: 'event_name',
host: 'host',
@@ -102,7 +97,6 @@ const GOAL_CONDITION_COLUMNS: Record<string, string> = {
utm_campaign: 'ca',
utm_term: 'te',
utm_content: 'co',
- // legacy v1 short codes (existing goals)
pg: 'pg',
event_name: 'event_name',
ref: 'ref',
diff --git a/backend/apps/cloud/src/project/dto/create-project-view.dto.ts b/backend/apps/cloud/src/project/dto/create-project-view.dto.ts
index d787d3015..8e903cb5b 100644
--- a/backend/apps/cloud/src/project/dto/create-project-view.dto.ts
+++ b/backend/apps/cloud/src/project/dto/create-project-view.dto.ts
@@ -47,9 +47,6 @@ export class ProjectViewCustomEventDto {
metaValueType: ProjectViewCustomEventMetaValueType
}
-// Saved-view filters are persisted as opaque JSON. New views store the v2
-// filter shape; older views may still hold the legacy { column, filter,
-// isExclusive } shape, which the web normalises on read.
export interface Filter {
dimension: string
operator: 'is' | 'is_not' | 'contains' | 'contains_not'
@@ -59,8 +56,6 @@ export interface Filter {
export const MAX_METRICS_IN_VIEW = 3
-// Mirrors MAX_FILTERS in analytics.service β€” the cap applied when filters run
-// against ClickHouse, so a saved view can never hold more than a query accepts.
const MAX_FILTERS_IN_VIEW = 100
export class CreateProjectViewDto {
diff --git a/backend/apps/cloud/src/project/gsc.service.ts b/backend/apps/cloud/src/project/gsc.service.ts
index 2721dccd0..41eff7995 100644
--- a/backend/apps/cloud/src/project/gsc.service.ts
+++ b/backend/apps/cloud/src/project/gsc.service.ts
@@ -539,14 +539,10 @@ export class GSCService {
isContains?: unknown
}
- // Accept both the v2 shape ({ dimension, operator, value }) and the
- // legacy v1 shape ({ column, filter, isExclusive, isContains }).
const isV2 = typeof raw.dimension === 'string'
const filterDimension = isV2 ? raw.dimension : raw.column
const value = isV2 ? raw.value : raw.filter
- // GSC only supports single-value string filters; skip null/array values
- // and dimensions it doesn't understand.
if (typeof filterDimension !== 'string' || typeof value !== 'string') {
continue
}
diff --git a/backend/apps/community/src/analytics/protection/analytics-read.guard.ts b/backend/apps/community/src/analytics/protection/analytics-read.guard.ts
index 14b1e1919..6c4aec190 100644
--- a/backend/apps/community/src/analytics/protection/analytics-read.guard.ts
+++ b/backend/apps/community/src/analytics/protection/analytics-read.guard.ts
@@ -11,9 +11,9 @@ import { checkRateLimit, getIPDetails } from '../../common/utils'
import { AppLoggerService } from '../../logger/logger.service'
import { getTrustworthyIp, getSinglePid } from './analytics-read.util'
-const READ_RATE_LIMIT = 300 // requests per rate window
-const AUTHED_READ_RATE_LIMIT = 3000 // requests per rate window
-const READ_RATE_WINDOW = 60 // seconds
+const READ_RATE_LIMIT = 300
+const AUTHED_READ_RATE_LIMIT = 3000
+const READ_RATE_WINDOW = 60
const BLOCK_DATACENTER_READS =
process.env.ANALYTICS_BLOCK_DATACENTER_READS === 'true'
@@ -28,17 +28,14 @@ export class AnalyticsReadGuard implements CanActivate {
async canActivate(context: ExecutionContext): Promise<boolean> {
const req = context.switchToHttp().getRequest()
- // Only police read (GET) traffic
if (req.method !== 'GET') {
return true
}
- // API-key requests are metered separately, per plan
if (req.headers['x-api-key']) {
return true
}
- // Logged-in requests - limiting by userId on a more generous limit
const uid = req.user?.sub || req.user?.id || null
if (uid) {
if (AUTHED_READ_RATE_LIMIT > 0) {
@@ -71,9 +68,6 @@ export class AnalyticsReadGuard implements CanActivate {
return true
}
- // --- Public-project protections only below this line ---
-
- // Bot user-agents never legitimately view a public dashboard
const userAgent = String(req.headers['user-agent'] || '')
if (userAgent && isbot(userAgent)) {
throw new ForbiddenException(
@@ -81,8 +75,6 @@ export class AnalyticsReadGuard implements CanActivate {
)
}
- // The real visitor IP, or '' when only a proxy IP is visible (so we never
- // rate-limit or geo-check the shared proxy address)
const ip = getTrustworthyIp(req)
if (BLOCK_DATACENTER_READS && ip) {
@@ -96,11 +88,9 @@ export class AnalyticsReadGuard implements CanActivate {
if (reason instanceof ForbiddenException) {
throw reason
}
- // GeoIP lookup failed β€” ignore, fail open.
}
}
- // Opt-in per-IP limit, public projects only, real client IP only.
if (READ_RATE_LIMIT && ip) {
await checkRateLimit(
ip,
diff --git a/backend/apps/community/src/analytics/protection/analytics-read.util.ts b/backend/apps/community/src/analytics/protection/analytics-read.util.ts
index fdad92f29..3c77aea97 100644
--- a/backend/apps/community/src/analytics/protection/analytics-read.util.ts
+++ b/backend/apps/community/src/analytics/protection/analytics-read.util.ts
@@ -41,7 +41,6 @@ export const getSinglePid = (
query: Record<string, unknown>,
params?: Record<string, unknown>,
): string | null => {
- // v2 routes carry the pid as a path param (/v2/projects/:pid/...)
const paramPid = params?.pid
if (_isString(paramPid) && PID_REGEX.test(paramPid)) {
@@ -50,11 +49,6 @@ export const getSinglePid = (
const { pid, pids } = query
- // v1 treats a request carrying BOTH ?pid and ?pids as invalid (getPIDsArray
- // rejects it). Mirror that here so the publicness/cache decision is never
- // judged against one project while the handler queries another. Returning
- // null makes callers fall back to their safe default (skip caching / skip
- // the public-project rate limit).
if (pid !== undefined && pids !== undefined) {
return null
}
diff --git a/backend/apps/community/src/analytics/protection/cacheable-analytics.decorator.ts b/backend/apps/community/src/analytics/protection/cacheable-analytics.decorator.ts
index 3e34cd2ef..8a69a7d25 100644
--- a/backend/apps/community/src/analytics/protection/cacheable-analytics.decorator.ts
+++ b/backend/apps/community/src/analytics/protection/cacheable-analytics.decorator.ts
@@ -2,10 +2,5 @@ import { SetMetadata } from '@nestjs/common'
export const CACHEABLE_ANALYTICS_KEY = 'cacheable_analytics'
-/**
- * Opt a v2 analytics GET handler into the public-project Redis cache
- * (PublicProjectCacheInterceptor). v1 routes are matched by the
- * CACHEABLE_ROUTES set instead and don't need this decorator.
- */
export const CacheableAnalytics = () =>
SetMetadata(CACHEABLE_ANALYTICS_KEY, true)
diff --git a/backend/apps/community/src/analytics/protection/public-project-cache.interceptor.ts b/backend/apps/community/src/analytics/protection/public-project-cache.interceptor.ts
index e284d8662..d9184132f 100644
--- a/backend/apps/community/src/analytics/protection/public-project-cache.interceptor.ts
+++ b/backend/apps/community/src/analytics/protection/public-project-cache.interceptor.ts
@@ -14,12 +14,12 @@ import { redis } from '../../common/constants'
import { getSinglePid, getAnalyticsRoute } from './analytics-read.util'
import { CACHEABLE_ANALYTICS_KEY } from './cacheable-analytics.decorator'
-const CACHE_TTL = Number(process.env.PUBLIC_PROJECT_CACHE_TTL) || 10 // seconds
+const CACHE_TTL = Number(process.env.PUBLIC_PROJECT_CACHE_TTL) || 10
-const CACHE_PREFIX = 'arc' // analytics read cache
+const CACHE_PREFIX = 'arc'
const CACHEABLE_ROUTES = new Set([
- '', // getData - dashboard overview
+ '',
'chart',
'birdseye',
'performance',
@@ -38,9 +38,6 @@ const CACHEABLE_ROUTES = new Set([
'gsc-details',
])
-/**
- * Caches read responses for PUBLIC projects in Redis for a short window.
- */
@Injectable()
export class PublicProjectCacheInterceptor implements NestInterceptor {
constructor(
@@ -59,8 +56,6 @@ export class PublicProjectCacheInterceptor implements NestInterceptor {
return next.handle()
}
- // v2 handlers opt in via @CacheableAnalytics(); v1 routes are matched
- // against the static route set
const isCacheableV2 = this.reflector.get<boolean>(
CACHEABLE_ANALYTICS_KEY,
context.getHandler(),
diff --git a/backend/apps/community/src/analytics/v2/__tests__/breakdown-query.builder.spec.ts b/backend/apps/community/src/analytics/v2/__tests__/breakdown-query.builder.spec.ts
index 75f684dd0..710fae981 100644
--- a/backend/apps/community/src/analytics/v2/__tests__/breakdown-query.builder.spec.ts
+++ b/backend/apps/community/src/analytics/v2/__tests__/breakdown-query.builder.spec.ts
@@ -95,7 +95,6 @@ describe('buildBreakdownQuery', () => {
expect(query).toContain('cc AS country')
expect(query).toContain('rgc AS region_code')
expect(query).toContain('GROUP BY value, country, region_code')
- // region is in the v1 EXCLUDE_NULL_FOR list
expect(query).toContain('AND rg IS NOT NULL')
})
@@ -126,7 +125,6 @@ describe('buildBreakdownQuery', () => {
}),
)
- // solve_time resolves to a multiIf bucket expression, not a plain column
expect(query).toContain('multiIf(')
expect(query).toContain("= 'pass'")
@@ -141,7 +139,6 @@ describe('buildBreakdownQuery', () => {
}),
)
- // country/browser/os/device only count passed captchas (v1 parity)
expect(countryQuery).toContain("= 'pass'")
})
diff --git a/backend/apps/community/src/analytics/v2/__tests__/filters.translator.spec.ts b/backend/apps/community/src/analytics/v2/__tests__/filters.translator.spec.ts
index f2ff9239c..7039e6cb6 100644
--- a/backend/apps/community/src/analytics/v2/__tests__/filters.translator.spec.ts
+++ b/backend/apps/community/src/analytics/v2/__tests__/filters.translator.spec.ts
@@ -132,7 +132,6 @@ describe('toV1FiltersJson', () => {
]),
)
- // error_name is not a traffic dimension
expect(() => toV1FiltersJson(filters, 'traffic')).toThrow(
UnprocessableEntityException,
)
diff --git a/backend/apps/community/src/analytics/v2/__tests__/registry.spec.ts b/backend/apps/community/src/analytics/v2/__tests__/registry.spec.ts
index dc5e5ff27..34ae77bfc 100644
--- a/backend/apps/community/src/analytics/v2/__tests__/registry.spec.ts
+++ b/backend/apps/community/src/analytics/v2/__tests__/registry.spec.ts
@@ -10,9 +10,6 @@ import {
V2_KEYED_FILTER_DIMENSIONS,
} from '../registry'
-// Keep the registry in lockstep with the v1 filter column allowlists
-// (common/constants.ts). If a column is added there, the registry must learn
-// about it too.
const {
TRAFFIC_COLUMNS,
PERFORMANCE_COLUMNS,
@@ -54,9 +51,6 @@ describe('registry <-> v1 column allowlist lockstep', () => {
})
describe('V2_VIEW_FILTER_DIMENSIONS <-> registry parity', () => {
- // Saved-view filters (project.service.filterUnsupportedColumns) span traffic,
- // performance and errors data β€” every such dimension the UI can offer must be
- // preserved, and no captcha-only or stale name may leak into the allowlist.
const expected = [
...V2_DIMENSIONS.filter((dimension) =>
dimension.types.some((type) => type !== 'captcha'),
@@ -85,7 +79,6 @@ describe('dimension lookups', () => {
expect(() => getBreakdownDimension('event', 'traffic')).toThrow(
UnprocessableEntityException,
)
- // valid dimension, wrong data type
expect(() => getBreakdownDimension('referrer', 'performance')).toThrow(
UnprocessableEntityException,
)
diff --git a/backend/apps/community/src/analytics/v2/analytics-v2.service.ts b/backend/apps/community/src/analytics/v2/analytics-v2.service.ts
index e3f936840..04bdd555d 100644
--- a/backend/apps/community/src/analytics/v2/analytics-v2.service.ts
+++ b/backend/apps/community/src/analytics/v2/analytics-v2.service.ts
@@ -70,7 +70,6 @@ const ALL_TIME_EVENT_TYPES: Record<V2DataType, readonly EventsAllTimeType[]> = {
errors: ['error'],
}
-/** Traffic metrics computable per time bucket by the v1 chart query */
const TRAFFIC_TIMESERIES_METRICS = [
'visitors',
'pageviews',
@@ -79,7 +78,6 @@ const TRAFFIC_TIMESERIES_METRICS = [
'concurrency',
]
-/** Performance metrics computable per time bucket (v2 name -> v1 chart key) */
const PERFORMANCE_TIMESERIES_METRICS: Record<string, string> = {
dns: 'dns',
tls: 'tls',
@@ -90,7 +88,6 @@ const PERFORMANCE_TIMESERIES_METRICS: Record<string, string> = {
ttfb: 'ttfb',
}
-/** Captcha counters computable per time bucket (v2 name -> v1 chart key) */
const CAPTCHA_TIMESERIES_METRICS: Record<string, string> = {
generated: 'generated',
passed: 'passed',
@@ -106,10 +103,8 @@ export interface ResolvedTimeframe {
timeBucket: TimeBucketType | null
allowedTimeBuckets: TimeBucketType[] | null
safeTimezone: string
- /** Timezone-shifted bounds (YYYY-MM-DD HH:mm:ss) */
groupFrom: string
groupTo: string
- /** UTC bounds used as ClickHouse query params */
groupFromUTC: string
groupToUTC: string
}
@@ -139,11 +134,6 @@ export class AnalyticsV2Service {
await this.analyticsService.checkProjectAccess(pid, uid, password)
}
- /**
- * Resolve period/from/to/timeBucket/timezone into concrete query bounds.
- * Centralizes the v1 `period=all` dance (first-event lookup -> diff ->
- * allowed time buckets) in a single place.
- */
async resolveTimeframe(opts: {
pid: string
dataType: V2DataType
@@ -152,7 +142,6 @@ export class AnalyticsV2Service {
to?: string
timeBucket?: TimeBucketType
timezone?: string
- /** Override the event types used for the period=all first-event lookup */
allTimeEventTypes?: readonly EventsAllTimeType[]
}): Promise<ResolvedTimeframe> {
const { pid, dataType, from, to, timezone } = opts
@@ -290,13 +279,10 @@ export class AnalyticsV2Service {
measure?: PerfMeasure,
): Promise<V2Envelope<Record<string, unknown>[]>> {
const dimension = getBreakdownDimension(dto.dimension, dataType)
- // Session-scoped virtual dimensions (entry/exit page) only support
- // 'visitors', so the per-type defaults don't apply to them
const metrics =
dimension.virtual && !dto.metrics
? [getMetric('visitors', dataType)]
: parseMetricsParam(dto.metrics, dataType)
- // v1 parity: performance and error queries ignore custom-event filters
const filters = this.prepareFilters(
dto.filters,
dataType,
@@ -483,8 +469,6 @@ export class AnalyticsV2Service {
const mode = dto.mode || ChartRenderMode.PERIODICAL
- // Concurrency (live visitors over time) runs an extra ClickHouse query, so
- // it is only reconstructed when the metric is explicitly requested
const includeConcurrency = metrics.some(
(metric) => metric.api === 'concurrency',
)
@@ -751,8 +735,6 @@ export class AnalyticsV2Service {
allTimeEventTypes: ['pageview'],
})
- // v1 parity: the user-flow query compares `created` against the
- // timezone-shifted bounds directly
const flow = await this.analyticsService.getUserFlow(
{
pid,
@@ -857,7 +839,6 @@ export class AnalyticsV2Service {
this.analyticsService.checkIfPerfMeasureIsValid(measure)
- // v1 parity: quantiles is a timeseries-only measure; birdseye maps it to median
if (measure === 'quantiles') {
measure = 'median'
}
@@ -1038,7 +1019,6 @@ export class AnalyticsV2Service {
{ params: baseParams },
)
- // Previous period of the same length (v1 parity; skipped for period=all)
let previousPromise: Promise<object | null> = Promise.resolve(null)
if (timeframe.period !== 'all') {
@@ -1141,8 +1121,6 @@ export class AnalyticsV2Service {
const mode = dto.mode || ChartRenderMode.PERIODICAL
- // v1 parity: error occurrences are bucketed in UTC, labels are shifted
- // to the requested timezone afterwards
const { x, format } = this.analyticsService.generateUTCXAxis(
timeframe.timeBucket,
timeframe.groupFromUTC,
@@ -1220,8 +1198,6 @@ export class AnalyticsV2Service {
const dataType: V2DataType = 'errors'
const filters = this.prepareFilters(dto.filters, dataType, true)
- // Session-scoped stats inside the overview run against traffic data;
- // error-specific filters are dropped for that part (v1 parity)
const sessionV1FiltersJson = toV1FiltersJson(
filters.appliedFilters,
'traffic',
@@ -1650,8 +1626,6 @@ export class AnalyticsV2Service {
.filter(Boolean)
}
- // A '__proto__' series key would mutate the response object's prototype
- // instead of adding a series
events = events.filter((event) => event && event !== '__proto__')
if (events.length === 0) {
@@ -1755,8 +1729,6 @@ export class AnalyticsV2Service {
filters.filtersQuery,
)
} catch (reason) {
- // Step details are best-effort (v1 parity); dev-only logging as
- // the raw error may embed funnel query params
this.logger.log(reason, 'AnalyticsV2Service -> getFunnelStepDetails')
}
})(),
@@ -1847,11 +1819,6 @@ export class AnalyticsV2Service {
return this.analyticsService.getPagesArray(dto.steps, dto.funnelId, pid)
}
- /**
- * Funnel time bounds mirror v1 exactly: no time bucket, timezone-shifted
- * bounds as ClickHouse params, and a period=all diff based on the max of
- * pageview / custom_event first-seen.
- */
private async resolveFunnelContext(
pid: string,
dto: V2BaseQueryDto,
@@ -2004,7 +1971,6 @@ export class AnalyticsV2Service {
)
}
- // Browser / OS versions return { name, version } pairs
if (dimension.column === 'brv' || dimension.column === 'osv') {
const values = await this.analyticsService.getVersionFilters(
pid,
@@ -2015,8 +1981,6 @@ export class AnalyticsV2Service {
return envelope(values, { pid, dimension: dimensionApi, type })
}
- // Entry/exit page values come from the session-scoped virtual-column
- // path in getFilters; getErrorsFilters cannot resolve them
const values =
type === 'errors' && !dimension.virtual
? await this.analyticsService.getErrorsFilters(pid, dimension.column)
@@ -2025,7 +1989,6 @@ export class AnalyticsV2Service {
return envelope(values, { pid, dimension: dimensionApi, type })
}
- /** Validate a metric name exists for the data type (helper for controllers) */
validateMetric(api: string, dataType: V2DataType): V2MetricDef {
return getMetric(api, dataType)
}
diff --git a/backend/apps/community/src/analytics/v2/controllers/errors-v2.controller.ts b/backend/apps/community/src/analytics/v2/controllers/errors-v2.controller.ts
index 926c498ec..902f3bdd8 100644
--- a/backend/apps/community/src/analytics/v2/controllers/errors-v2.controller.ts
+++ b/backend/apps/community/src/analytics/v2/controllers/errors-v2.controller.ts
@@ -37,8 +37,6 @@ import {
V2TimeseriesDto,
} from '../dto/v2-base.dto'
-// NOTE: static routes (overview, timeseries, breakdown) MUST be declared
-// before the :eid routes β€” NestJS matches routes in declaration order.
@ApiTags('Analytics v2')
@ApiBearerAuth()
@ApiSecurity('apiKey')
diff --git a/backend/apps/community/src/analytics/v2/dto/entities.dto.ts b/backend/apps/community/src/analytics/v2/dto/entities.dto.ts
index 523a0649b..b8579e767 100644
--- a/backend/apps/community/src/analytics/v2/dto/entities.dto.ts
+++ b/backend/apps/community/src/analytics/v2/dto/entities.dto.ts
@@ -82,8 +82,6 @@ export class V2ErrorsQueryDto extends V2EntityListDto {
@Transform(({ value }) => {
if (value === true || value === 'true') return true
if (value === false || value === 'false') return false
- // Leave anything else untouched so @IsBoolean() rejects it instead of
- // silently coercing invalid input to false.
return value
})
@IsBoolean()
diff --git a/backend/apps/community/src/analytics/v2/mappers/entity.mapper.ts b/backend/apps/community/src/analytics/v2/mappers/entity.mapper.ts
index 39a85c290..c63c303b9 100644
--- a/backend/apps/community/src/analytics/v2/mappers/entity.mapper.ts
+++ b/backend/apps/community/src/analytics/v2/mappers/entity.mapper.ts
@@ -1,7 +1,3 @@
-/**
- * Key renames applied to v1 entity payloads (sessions, profiles, session
- * details) so v2 responses use human-readable field names.
- */
const KEY_RENAMES: Record<string, string> = {
cc: 'country',
rg: 'region',
diff --git a/backend/apps/community/src/analytics/v2/mappers/summary.mapper.ts b/backend/apps/community/src/analytics/v2/mappers/summary.mapper.ts
index 5f0ddef2f..b2b2219f6 100644
--- a/backend/apps/community/src/analytics/v2/mappers/summary.mapper.ts
+++ b/backend/apps/community/src/analytics/v2/mappers/summary.mapper.ts
@@ -48,10 +48,6 @@ const mapPeriod = (period: V1SummaryPeriod): TrafficSummaryPeriod => ({
session_duration: toNullableNumber(period.sdur),
})
-/**
- * Reshape a single project's v1 birdseye payload (getAnalyticsSummary) into
- * the v2 summary format with human-readable metric names.
- */
export const mapTrafficSummary = (
v1Summary: V1TrafficSummary,
): TrafficSummaryData => ({
diff --git a/backend/apps/community/src/analytics/v2/mappers/timeseries.mapper.ts b/backend/apps/community/src/analytics/v2/mappers/timeseries.mapper.ts
index 53494268a..b0f80e876 100644
--- a/backend/apps/community/src/analytics/v2/mappers/timeseries.mapper.ts
+++ b/backend/apps/community/src/analytics/v2/mappers/timeseries.mapper.ts
@@ -12,24 +12,12 @@ export type TimeseriesRow = { timestamp: string } & Record<
string | number | null
>
-/**
- * Convert a v1 timezone-shifted x-axis label (e.g. '2026-07-01',
- * '2026-07-01 13:00:00', '2026-07') into an ISO-8601 timestamp carrying the
- * requested timezone's UTC offset.
- */
export const toIsoTimestamp = (value: string, timezone: string): string => {
const zone = timezone || DEFAULT_TIMEZONE
return dayjs.tz(value, zone).format()
}
-/**
- * Zip v1's columnar chart output ({ x: [...], seriesA: [...], seriesB: [...] })
- * into self-describing rows of objects β€” the v2 timeseries format.
- *
- * `series` maps v2 metric names to v1 arrays; missing/undefined series are
- * skipped. Array values falling outside the x range are ignored.
- */
export const zipTimeseries = (
x: string[],
series: Record<string, (number | null)[] | undefined>,
@@ -51,10 +39,6 @@ export const zipTimeseries = (
})
}
-/**
- * Per-bucket bounce rate (%) from v1's raw bounces + uniques arrays,
- * mirroring v1's calculateBounceRate (bounces / uniques * 100).
- */
export const computeBounceRateSeries = (
bounces: number[] | undefined,
uniques: number[] | undefined,
diff --git a/backend/apps/community/src/analytics/v2/query/breakdown-query.builder.ts b/backend/apps/community/src/analytics/v2/query/breakdown-query.builder.ts
index 1c17653ca..645f15f9a 100644
--- a/backend/apps/community/src/analytics/v2/query/breakdown-query.builder.ts
+++ b/backend/apps/community/src/analytics/v2/query/breakdown-query.builder.ts
@@ -18,7 +18,6 @@ export interface BreakdownQueryOptions {
dataType: V2DataType
dimension: V2DimensionDef
metrics: V2MetricDef[]
- /** 'FROM events WHERE ...' fragment, incl. filters and time range params */
subQuery: string
ctx: V2MetricCtx
sort: BreakdownSort
@@ -52,11 +51,6 @@ export const parseSortParam = (
return { field, direction }
}
-/**
- * Multi-metric generalization of v1's generateParamsQuery: one dimension,
- * N metric aggregates, ORDER BY + LIMIT/OFFSET pagination and a windowed
- * total. Expects `v2_limit` and `v2_offset` in the query params.
- */
export const buildBreakdownQuery = (opts: BreakdownQueryOptions): string => {
const { dataType, dimension, metrics, subQuery, ctx, sort } = opts
diff --git a/backend/apps/community/src/analytics/v2/query/filters.translator.ts b/backend/apps/community/src/analytics/v2/query/filters.translator.ts
index 9b6f21d19..833cb0900 100644
--- a/backend/apps/community/src/analytics/v2/query/filters.translator.ts
+++ b/backend/apps/community/src/analytics/v2/query/filters.translator.ts
@@ -19,7 +19,6 @@ export interface V2Filter {
dimension: string
operator: V2FilterOperator
value: string | null | (string | null)[]
- /** meta.key for event_metadata / page_property filters */
key?: string
}
@@ -62,8 +61,6 @@ const resolveColumn = (
)
}
- // With a key: filter values of that meta key. Without: filter the
- // meta keys themselves.
return key ? `${keyedFamily.v1Prefix}${key}` : keyedFamily.v1KeyColumn
}
@@ -82,10 +79,6 @@ const resolveColumn = (
return def.column
}
-/**
- * Parse and validate a v2 `filters` query param.
- * v2 filter shape: { dimension, operator: is|is_not|contains|contains_not, value, key? }
- */
export const parseV2Filters = (filters: string | undefined): V2Filter[] => {
if (!filters || filters === '""') {
return []
@@ -163,12 +156,6 @@ export const parseV2Filters = (filters: string | undefined): V2Filter[] => {
})
}
-/**
- * Translate parsed v2 filters into the exact v1 filters JSON string consumed
- * by AnalyticsService.getFiltersQuery β€” all v1 special-case SQL (refn domain
- * expansion, entry/exit page psid subqueries, meta-array filters,
- * customEVFilterApplied detection) is inherited unchanged.
- */
export const toV1FiltersJson = (
filters: V2Filter[],
type: V2DataType,
@@ -183,9 +170,6 @@ export const toV1FiltersJson = (
for (const filter of filters) {
const column = resolveColumn(filter, type, Boolean(options.lenient))
- // Lenient mode drops filters that don't apply to the data type instead
- // of rejecting the request (used when one endpoint queries several
- // data types with the same filter set)
if (column === null) {
continue
}
@@ -203,15 +187,6 @@ export const toV1FiltersJson = (
return JSON.stringify(v1Filters)
}
-/**
- * Normalise a `filters` query param that may be in EITHER the v2 shape
- * ({ dimension, operator, value, key? }) or the legacy v1 shape
- * ({ column, filter, isExclusive, isContains }) into the v1 filters JSON string
- * consumed by AnalyticsService.getFiltersQuery.
- *
- * Used by endpoints that are also part of the public v1 API, so existing API
- * clients sending v1 filters keep working while the dashboard sends v2.
- */
export const normalizeFiltersToV1Json = (
filters: string | undefined,
type: V2DataType,
@@ -225,7 +200,6 @@ export const normalizeFiltersToV1Json = (
try {
parsed = JSON.parse(filters)
} catch {
- // Leave malformed input to getFiltersQuery, which logs and ignores it.
return filters
}
@@ -233,8 +207,6 @@ export const normalizeFiltersToV1Json = (
return ''
}
- // Legacy v1 clients key filters by `column`; pass those straight through.
- // v2 clients (and the dashboard) send `dimension` and are translated.
const isLegacyV1 = parsed.every(
(filter) =>
filter &&
diff --git a/backend/apps/community/src/analytics/v2/registry/dimensions.ts b/backend/apps/community/src/analytics/v2/registry/dimensions.ts
index 64d78ed77..22858d453 100644
--- a/backend/apps/community/src/analytics/v2/registry/dimensions.ts
+++ b/backend/apps/community/src/analytics/v2/registry/dimensions.ts
@@ -183,8 +183,6 @@ export const V2_DIMENSIONS: V2DimensionDef[] = [
description:
'Custom event name (filter-only; use /traffic/custom-events for a breakdown)',
},
- // Errors-only, filter-only dimensions. Columns are the v1 public filter
- // names β€” getFiltersQuery maps them to error_name/error_message/error_filename.
{
api: 'error_name',
column: 'name',
@@ -206,8 +204,6 @@ export const V2_DIMENSIONS: V2DimensionDef[] = [
filterOnly: true,
description: 'Source file the error originated from',
},
- // Captcha meta dimensions. Per-dimension WHERE guards mirror v1
- // generateParamsQuery captcha handling.
{
api: 'captcha_event',
column: 'captcha_event',
@@ -237,7 +233,6 @@ export const V2_DIMENSIONS: V2DimensionDef[] = [
},
]
-// Captcha country/browser/os/device breakdowns only count passed captchas (v1 parity)
const CAPTCHA_PASS_GUARD = `AND ${CAPTCHA_EVENT_SQL} = 'pass'`
export const captchaExtraWhere = (dim: V2DimensionDef): string | undefined => {
@@ -252,10 +247,6 @@ export const captchaExtraWhere = (dim: V2DimensionDef): string | undefined => {
return undefined
}
-/**
- * Filter-only dimension families that carry a `key` (meta.key) and translate
- * to v1's `ev:key:<key>` / `tag:key:<key>` filter columns.
- */
export const V2_KEYED_FILTER_DIMENSIONS: Record<
string,
{ v1Prefix: string; v1KeyColumn: string; types: V2DimensionDef['types'] }
diff --git a/backend/apps/community/src/analytics/v2/registry/index.ts b/backend/apps/community/src/analytics/v2/registry/index.ts
index 6b2d94bdd..7fd13aa32 100644
--- a/backend/apps/community/src/analytics/v2/registry/index.ts
+++ b/backend/apps/community/src/analytics/v2/registry/index.ts
@@ -33,10 +33,6 @@ export const findDimension = (
(dimension) => dimension.api === api && dimension.types.includes(type),
)
-/**
- * Resolve a dimension usable as ?dimension= (i.e. for breakdowns).
- * Throws a descriptive 422 for unknown or filter-only dimensions.
- */
export const getBreakdownDimension = (
api: string,
type: V2DataType,
@@ -80,10 +76,6 @@ export const getMetric = (api: string, type: V2DataType): V2MetricDef => {
export const getDefaultMetrics = (type: V2DataType): V2MetricDef[] =>
listMetrics(type).filter((metric) => metric.isDefault)
-/**
- * Parse a `metrics` CSV query param into validated metric definitions.
- * Returns the per-type defaults when the param is empty.
- */
export const parseMetricsParam = (
metrics: string | undefined,
type: V2DataType,
diff --git a/backend/apps/community/src/analytics/v2/registry/metrics.ts b/backend/apps/community/src/analytics/v2/registry/metrics.ts
index b41f0f7b6..84b715f91 100644
--- a/backend/apps/community/src/analytics/v2/registry/metrics.ts
+++ b/backend/apps/community/src/analytics/v2/registry/metrics.ts
@@ -1,10 +1,5 @@
import { V2MetricDef } from './types'
-/**
- * Local copy of the v1 MEASURES_MAP (analytics.service.ts). Duplicated on
- * purpose β€” the v2 registry is self-contained and these four entries are the
- * public API contract for the `measure` parameter.
- */
const MEASURES_MAP_V2: Record<string, string> = {
average: 'avg',
median: 'median',
@@ -22,12 +17,9 @@ const perfExpr =
}
export const V2_METRICS: V2MetricDef[] = [
- // --- traffic ---
{
api: 'visitors',
types: ['traffic'],
- // v1 semantics preserved: with a custom-event filter applied the base
- // event set is custom_event rows and "visitors" degrades to count(*)
sqlExpr: ({ customEVFilterApplied }) =>
customEVFilterApplied ? 'count(*)' : 'count(DISTINCT psid)',
isDefault: true,
@@ -70,15 +62,12 @@ export const V2_METRICS: V2MetricDef[] = [
{
api: 'concurrency',
types: ['traffic'],
- // Reconstructed from session intervals, which carry no dimension columns,
- // so it is a timeseries-only series that cannot respect filters
sqlExpr: () => null,
requiresSessionsJoin: true,
format: 'integer',
description:
'Concurrent live visitors over time (timeseries only; ignores filters)',
},
- // --- performance (values in seconds; `measure` selects the aggregate) ---
{
api: 'load_time',
types: ['performance'],
@@ -136,7 +125,6 @@ export const V2_METRICS: V2MetricDef[] = [
format: 'seconds',
description: 'DOM content load time',
},
- // --- errors ---
{
api: 'occurrences',
types: ['errors'],
@@ -152,7 +140,6 @@ export const V2_METRICS: V2MetricDef[] = [
format: 'integer',
description: 'Distinct users affected',
},
- // --- captcha ---
{
api: 'events',
types: ['captcha'],
@@ -161,8 +148,6 @@ export const V2_METRICS: V2MetricDef[] = [
format: 'integer',
description: 'Captcha events matching the dimension scope',
},
- // Timeseries/summary-only captcha counters (computed by the captcha
- // aggregation query, not the generic breakdown builder)
{
api: 'generated',
types: ['captcha'],
diff --git a/backend/apps/community/src/analytics/v2/registry/types.ts b/backend/apps/community/src/analytics/v2/registry/types.ts
index d4240e58c..49ee973b5 100644
--- a/backend/apps/community/src/analytics/v2/registry/types.ts
+++ b/backend/apps/community/src/analytics/v2/registry/types.ts
@@ -3,38 +3,18 @@ import { PerfMeasure } from '../../interfaces'
export type V2DataType = 'traffic' | 'performance' | 'captcha' | 'errors'
interface V2DimensionExtraField {
- /** Public API name of the sibling field, e.g. 'country' */
api: string
- /** ClickHouse column of the sibling field, e.g. 'cc' */
column: string
}
export interface V2DimensionDef {
- /** Public API name, snake_case: 'country', 'browser_version' */
api: string
- /**
- * v1 filter column / ClickHouse column: 'cc', 'brv'. For captcha meta
- * dimensions this is the v1 virtual column name ('captcha_event',
- * 'solve_time') which getFiltersQuery resolves to a SQL expression.
- * For errors-only filter dimensions this is the v1 public name ('name',
- * 'message', 'filename') which getFiltersQuery maps to error_* columns.
- */
column: string
- /** Data types this dimension is valid for */
types: V2DataType[]
- /** Sibling columns returned with each row, e.g. region -> country + region_code */
extraFields?: V2DimensionExtraField[]
- /** Mirrors v1 EXCLUDE_NULL_FOR behavior */
excludeNull?: boolean
- /** Usable in ?filters but not as ?dimension= */
filterOnly?: boolean
- /** Needs a dedicated query path instead of the generic breakdown builder */
virtual?: 'entry_page' | 'exit_page'
- /**
- * Extra WHERE fragment (starting with 'AND ...') appended to the breakdown
- * query. Used by captcha dimensions to scope rows to the relevant
- * captcha lifecycle event, mirroring v1 generateParamsQuery.
- */
extraWhere?: string
description: string
}
@@ -45,19 +25,10 @@ export interface V2MetricCtx {
}
export interface V2MetricDef {
- /** Public API name, snake_case: 'visitors', 'bounce_rate' */
api: string
- /** Data types this metric is valid for */
types: V2DataType[]
- /**
- * ClickHouse aggregate expression, or null when the metric cannot be
- * computed by the generic breakdown builder (e.g. it needs the sessions
- * join, or it only exists on timeseries/summary queries).
- */
sqlExpr: (ctx: V2MetricCtx) => string | null
- /** Metric needs the sessions-table join β€” timeseries/summary only */
requiresSessionsJoin?: boolean
- /** Included when no ?metrics= is provided */
isDefault?: boolean
format?: 'integer' | 'seconds' | 'percent'
description: string
diff --git a/backend/apps/community/src/common/constants.ts b/backend/apps/community/src/common/constants.ts
index fc04ac187..b2d7632bf 100644
--- a/backend/apps/community/src/common/constants.ts
+++ b/backend/apps/community/src/common/constants.ts
@@ -133,10 +133,6 @@ const ERROR_COLUMNS = [
const ALL_COLUMNS = [...TRAFFIC_COLUMNS, 'ev', 'entryPage', 'exitPage']
-// v2 dimension names allowed in a saved-view filter. Mirrors the traffic
-// dimensions in analytics/v2/registry/dimensions.ts β€” duplicated here because
-// project.service cannot import the registry without creating an
-// analytics.service <-> project.service import cycle.
const V2_VIEW_FILTER_DIMENSIONS = [
'country',
'region',
@@ -163,7 +159,6 @@ const V2_VIEW_FILTER_DIMENSIONS = [
'entry_page',
'exit_page',
'event',
- // errors-only filter dimensions (error-tab segments persist these)
'error_name',
'error_message',
'error_filename',
diff --git a/backend/apps/community/src/goal/goal.controller.ts b/backend/apps/community/src/goal/goal.controller.ts
index 2641fe998..69d9fced6 100644
--- a/backend/apps/community/src/goal/goal.controller.ts
+++ b/backend/apps/community/src/goal/goal.controller.ts
@@ -70,12 +70,7 @@ const clampPagination = (take?: number, skip?: number) => {
return { take: safeTake, skip: safeSkip }
}
-// Maps a goal condition `field` to its ClickHouse column. New goals store v2
-// dimension names (page, country, utm_source, ...); the legacy v1 short codes
-// (pg, cc, so, ...) are kept so conditions saved before the v2 migration still
-// resolve.
const GOAL_CONDITION_COLUMNS: Record<string, string> = {
- // v2 dimension names
page: 'pg',
event: 'event_name',
host: 'host',
@@ -89,7 +84,6 @@ const GOAL_CONDITION_COLUMNS: Record<string, string> = {
utm_campaign: 'ca',
utm_term: 'te',
utm_content: 'co',
- // legacy v1 short codes (existing goals)
pg: 'pg',
event_name: 'event_name',
ref: 'ref',
diff --git a/backend/apps/community/src/project/dto/create-project-view.dto.ts b/backend/apps/community/src/project/dto/create-project-view.dto.ts
index d787d3015..8e903cb5b 100644
--- a/backend/apps/community/src/project/dto/create-project-view.dto.ts
+++ b/backend/apps/community/src/project/dto/create-project-view.dto.ts
@@ -47,9 +47,6 @@ export class ProjectViewCustomEventDto {
metaValueType: ProjectViewCustomEventMetaValueType
}
-// Saved-view filters are persisted as opaque JSON. New views store the v2
-// filter shape; older views may still hold the legacy { column, filter,
-// isExclusive } shape, which the web normalises on read.
export interface Filter {
dimension: string
operator: 'is' | 'is_not' | 'contains' | 'contains_not'
@@ -59,8 +56,6 @@ export interface Filter {
export const MAX_METRICS_IN_VIEW = 3
-// Mirrors MAX_FILTERS in analytics.service β€” the cap applied when filters run
-// against ClickHouse, so a saved view can never hold more than a query accepts.
const MAX_FILTERS_IN_VIEW = 100
export class CreateProjectViewDto {
diff --git a/backend/apps/community/src/project/gsc.service.ts b/backend/apps/community/src/project/gsc.service.ts
index 50e90b4d7..b2a751f52 100644
--- a/backend/apps/community/src/project/gsc.service.ts
+++ b/backend/apps/community/src/project/gsc.service.ts
@@ -597,14 +597,10 @@ export class GSCService {
isContains?: unknown
}
- // Accept both the v2 shape ({ dimension, operator, value }) and the
- // legacy v1 shape ({ column, filter, isExclusive, isContains }).
const isV2 = typeof raw.dimension === 'string'
const filterDimension = isV2 ? raw.dimension : raw.column
const value = isV2 ? raw.value : raw.filter
- // GSC only supports single-value string filters; skip null/array values
- // and dimensions it doesn't understand.
if (typeof filterDimension !== 'string' || typeof value !== 'string') {
continue
}
diff --git a/web/app/api/v2/client.ts b/web/app/api/v2/client.ts
index 6ba5f437a..35a95614b 100644
--- a/web/app/api/v2/client.ts
+++ b/web/app/api/v2/client.ts
@@ -28,7 +28,6 @@ const serializeParams = (params: V2QueryParams): string => {
continue
}
- // filters (objects) -> JSON; plain values (metrics, events) -> CSV
if (typeof value[0] === 'object') {
searchParams.set(key, JSON.stringify(value))
} else {
@@ -49,12 +48,6 @@ const serializeParams = (params: V2QueryParams): string => {
return qs ? `?${qs}` : ''
}
-/**
- * Fetches a v2 analytics API endpoint through the /api/v2 proxy route
- * (which attaches auth and project-password headers server-side).
- *
- * `path` is relative to /v2/, e.g. `projects/<pid>/traffic/breakdown`.
- */
export async function fetchV2<T>(
path: string,
params: V2QueryParams = {},
@@ -67,9 +60,7 @@ export async function fetchV2<T>(
let body: any = null
try {
body = await response.json()
- } catch {
- // non-JSON error response
- }
+ } catch {}
if (!response.ok) {
const message =
diff --git a/web/app/api/v2/types.ts b/web/app/api/v2/types.ts
index 0a04c0f51..bb9d8ec7f 100644
--- a/web/app/api/v2/types.ts
+++ b/web/app/api/v2/types.ts
@@ -6,7 +6,6 @@ export interface V2Filter {
dimension: string
operator: V2FilterOperator
value: string | null | (string | null)[]
- /** Required for event_metadata / page_property filters */
key?: string
}
@@ -17,18 +16,15 @@ interface V2Meta {
to?: string
timezone?: string
appliedFilters?: V2Filter[]
- /** Breakdown / list endpoints */
total?: number
limit?: number
offset?: number
sort?: string
dimension?: string
metrics?: string[]
- /** Timeseries endpoints */
timeBucket?: string
allowedTimeBuckets?: string[] | null
mode?: string
- /** Live visitors */
windowMinutes?: number
[key: string]: unknown
}
@@ -46,13 +42,11 @@ export type V2CommonParams = {
filters?: V2Filter[]
}
-/** { value: 'US', country?: ..., visitors: 119, pageviews: 267, ... } */
export interface BreakdownRow {
value: string | null
[metricOrExtraField: string]: unknown
}
-/** { timestamp: '2026-07-01T00:00:00Z', visitors: 120, ... } */
export interface TimeseriesRow {
timestamp: string
[metric: string]: number | string
diff --git a/web/app/hooks/useInViewOnce.ts b/web/app/hooks/useInViewOnce.ts
index 22b742c1e..bba14ce09 100644
--- a/web/app/hooks/useInViewOnce.ts
+++ b/web/app/hooks/useInViewOnce.ts
@@ -2,18 +2,9 @@ import { useEffect, useRef, useState } from 'react'
interface UseInViewOnceOptions {
rootMargin?: string
- /** Skip observing entirely (treated as already in view) */
disabled?: boolean
}
-/**
- * Latching IntersectionObserver hook: `hasBeenInView` flips to true the first
- * time the element comes near the viewport and stays true afterwards, so
- * queries gated on it keep refetching normally once loaded.
- *
- * Renders `false` on the server and on the first client render (no hydration
- * mismatch), then flips on mount for elements already in view.
- */
export const useInViewOnce = <T extends HTMLElement = HTMLDivElement>({
rootMargin = '400px 0px',
disabled,
diff --git a/web/app/hooks/v2/useV2Queries.ts b/web/app/hooks/v2/useV2Queries.ts
index a9fa691af..051e21d1e 100644
--- a/web/app/hooks/v2/useV2Queries.ts
+++ b/web/app/hooks/v2/useV2Queries.ts
@@ -12,11 +12,6 @@ import { VALID_DIMENSIONS_BY_TYPE } from '~/lib/v2Dimensions'
import { useViewProjectContext } from '~/pages/Project/View/ViewProject'
import { useCurrentProject } from '~/providers/CurrentProjectProvider'
-/**
- * Stable, normalized common params (time range + timezone + filters valid for
- * the given data type) derived from the project view context. Embedded in
- * every query key, so any change refetches exactly the affected queries.
- */
export const useV2CommonParams = (dataType: V2DataType) => {
const { id: pid } = useCurrentProject()
const { period, timezone, filters } = useViewProjectContext()
@@ -43,7 +38,6 @@ export const useV2CommonParams = (dataType: V2DataType) => {
}, [pid, dataType, period, from, to, timezone, filters])
}
-/** Compare range (from/to) when compare mode is active, null otherwise */
const useCompareParams = () => {
const { isActiveCompare } = useViewProjectContext()
const [searchParams] = useSearchParams()
@@ -81,7 +75,6 @@ export const useSummaryQuery = <T extends V2DataType>(
})
}
-/** Summary over the compare range; disabled when compare mode is off */
export const useCompareSummaryQuery = <T extends V2DataType>(
dataType: T,
opts: { measure?: string; enabled?: boolean } = {},
@@ -161,7 +154,6 @@ interface BreakdownOpts {
offset?: number
sort?: string
measure?: string
- /** Extra filters merged on top of the shared ones (e.g. version drill-down) */
extraFilters?: V2Filter[]
enabled?: boolean
}
@@ -194,7 +186,6 @@ export const useBreakdownQuery = (
const DETAILS_PAGE_SIZE = 100
-/** Infinite offset-paged breakdown for the details modal */
export const useBreakdownDetailsQuery = (
dataType: V2DataType,
opts: Omit<BreakdownOpts, 'limit' | 'offset'>,
@@ -261,7 +252,6 @@ export const useCustomEventsTimeseriesQuery = (
})
}
-/** Project-view custom metrics (sum/avg of numeric event metadata) cards */
export const useCustomMetricsQuery = (
customMetrics: unknown[],
opts: { enabled?: boolean } = {},
diff --git a/web/app/lib/v2Dimensions.ts b/web/app/lib/v2Dimensions.ts
index 6e2bd7c16..d9a1a5d25 100644
--- a/web/app/lib/v2Dimensions.ts
+++ b/web/app/lib/v2Dimensions.ts
@@ -1,8 +1,5 @@
import { V2DataType } from '~/api/v2/types'
-// Frontend mirror of backend/apps/*/src/analytics/v2/registry/dimensions.ts.
-// v1 short codes are kept only as URL aliases so old shared links keep working.
-
export const V1_TO_V2_DIMENSION: Record<string, string> = {
cc: 'country',
rg: 'region',
@@ -31,7 +28,6 @@ export const V1_TO_V2_DIMENSION: Record<string, string> = {
ev: 'event',
}
-/** Keyed filter families: URL key `event_metadata:<key>` (legacy `ev:key:<key>`) */
export const KEYED_DIMENSIONS = ['event_metadata', 'page_property'] as const
export const V1_KEYED_PREFIX_TO_V2: Record<string, string> = {
@@ -126,7 +122,6 @@ export const VALID_DIMENSIONS_BY_TYPE: Record<V2DataType, string[]> = {
captcha: CAPTCHA_DIMENSIONS,
}
-/** Every dimension name that may appear as a URL filter key */
export const ALL_VALID_DIMENSIONS = Array.from(
new Set([
...TRAFFIC_DIMENSIONS,
diff --git a/web/app/pages/Project/View/Panels.tsx b/web/app/pages/Project/View/Panels.tsx
index 2ea1d9489..aafb0538b 100644
--- a/web/app/pages/Project/View/Panels.tsx
+++ b/web/app/pages/Project/View/Panels.tsx
@@ -221,7 +221,6 @@ interface PanelContainerProps {
activeTabId?: string
onDetailsClick?: () => void
dropdownPlaceholder?: string
- /** Background refetch in progress β€” show a subtle top bar, keep stale data */
isRefetching?: boolean
}
@@ -1826,11 +1825,8 @@ interface PanelProps {
rowTooltipRenderer?: (entry: Entry) => React.ReactNode
/** When true with rowTooltipRenderer, tooltip is fixed to the cursor (chart-style) instead of Radix anchor positioning. */
rowTooltipFollowCursor?: boolean
- /** Background refetch in progress β€” subtle top bar, stale data stays visible */
isRefetching?: boolean
- /** Total number of dimension values on the server (may exceed loaded rows) */
serverTotal?: number
- /** Loads the next page of entries into the details table */
onLoadMore?: () => void
loadingMore?: boolean
}
diff --git a/web/app/pages/Project/View/ViewProject.tsx b/web/app/pages/Project/View/ViewProject.tsx
index 4934271b1..049e24320 100644
--- a/web/app/pages/Project/View/ViewProject.tsx
+++ b/web/app/pages/Project/View/ViewProject.tsx
@@ -548,7 +548,6 @@ const ViewProjectContent = () => {
) => {
const filterParams = new URLSearchParams(searchParams.toString())
- // Apply both the parent (browser/os) and version filters together
filterParams.set(panelType, parent ?? 'null')
filterParams.set(`${panelType}_version`, version ?? 'null')
@@ -884,7 +883,6 @@ const ViewProjectContent = () => {
[dataLoading, searchParams, setSearchParams],
)
- // Tabs fully served by the v2 per-dimension API: refresh = invalidate queries
const V2_TABS = useMemo(
() =>
new Set<keyof typeof PROJECT_TABS>([
@@ -936,7 +934,6 @@ const ViewProjectContent = () => {
}
if (activeTab === PROJECT_TABS.seo) {
- // The SEO tab mixes GSC data (trigger-driven) with v2 referral data
await queryClient.invalidateQueries({ queryKey: ['v2', id] })
setSeoRefreshTrigger((prev) => prev + 1)
return
@@ -1032,7 +1029,6 @@ const ViewProjectContent = () => {
return daysDiff > 1
}, [period, dateRange, isTouchDevice])
- // `dimension` is a v2 dimension name, optionally keyed (`event_metadata:plan`)
const getFilterLink = useCallback(
(dimension: string, value: string | null): LinkProps['to'] => {
const urlValue = value ?? 'null'
diff --git a/web/app/pages/Project/View/components/FilterRowsEditor.tsx b/web/app/pages/Project/View/components/FilterRowsEditor.tsx
index 47e584608..8f70d4a12 100644
--- a/web/app/pages/Project/View/components/FilterRowsEditor.tsx
+++ b/web/app/pages/Project/View/components/FilterRowsEditor.tsx
@@ -66,9 +66,6 @@ const OPERATORS: { value: V2FilterOperator; labelKey: string }[] = [
{ value: 'contains_not', labelKey: 'project.contains.not' },
]
-// A row's `column` is a v2 dimension name, optionally with a metadata key
-// (`event_metadata:plan`). A bare keyed dimension (`event_metadata`) means
-// "has this metadata key" β€” its value is the key itself.
const parseRowColumn = (
column: string,
): { dimension: string; key?: string } => {
@@ -328,8 +325,6 @@ const FilterRowsEditor = ({
async (column: string) => {
const { dimension, key } = parseRowColumn(column)
- // No autocomplete for keyed columns with a fixed key
- // (event_metadata:plan) or dimensions the API doesn't know about.
if (key || !VALID_DIMENSIONS_BY_TYPE[type].includes(dimension)) {
setFilterValuesCache((prev) =>
prev[column] ? prev : { ...prev, [column]: [] },
diff --git a/web/app/pages/Project/View/components/Filters.tsx b/web/app/pages/Project/View/components/Filters.tsx
index 7f7ad26f4..a7ed71818 100644
--- a/web/app/pages/Project/View/components/Filters.tsx
+++ b/web/app/pages/Project/View/components/Filters.tsx
@@ -50,11 +50,6 @@ const operatorLabel = (
return t(`common.${operator === 'is_not' ? 'isNot' : 'is'}`)
}
-/**
- * Returns true if a URL search param entry represents the given filter. Legacy
- * v1 keys (cc, pg, ...) parse to the same shape, so old shared links can be
- * removed / toggled too.
- */
const isFilterUrlEntry = (
filter: V2Filter,
rawKey: string,
diff --git a/web/app/pages/Project/View/components/ProjectViewHeaderActions.tsx b/web/app/pages/Project/View/components/ProjectViewHeaderActions.tsx
index 6090a5642..8e657e069 100644
--- a/web/app/pages/Project/View/components/ProjectViewHeaderActions.tsx
+++ b/web/app/pages/Project/View/components/ProjectViewHeaderActions.tsx
@@ -294,8 +294,6 @@ const ProjectViewHeaderActions = ({
newParams.delete('metrics')
- // override=true replaces every filter param (including legacy
- // aliases) with the segment's filters
newParams = getFiltersUrlParams(filters, supported, true, newParams)
if (hasTrafficMetrics) {
diff --git a/web/app/pages/Project/View/interfaces/traffic.ts b/web/app/pages/Project/View/interfaces/traffic.ts
index 6e94a8d9e..2311213ad 100644
--- a/web/app/pages/Project/View/interfaces/traffic.ts
+++ b/web/app/pages/Project/View/interfaces/traffic.ts
@@ -1,8 +1,6 @@
import { TimeBucket } from '~/lib/constants'
import { V2Filter } from '~/api/v2/types'
-// Legacy (v1) filter shape β€” views saved before the v2 migration still persist
-// this; newer views persist the v2 shape (see ProjectView.filters).
interface Filter {
column: string
filter: string
diff --git a/web/app/pages/Project/View/utils/projectViewSegments.ts b/web/app/pages/Project/View/utils/projectViewSegments.ts
index 3142b181b..c19b5fb8c 100644
--- a/web/app/pages/Project/View/utils/projectViewSegments.ts
+++ b/web/app/pages/Project/View/utils/projectViewSegments.ts
@@ -7,9 +7,6 @@ import { ProjectView } from '../interfaces/traffic'
type ProjectTab = keyof typeof PROJECT_TABS
-// New project views persist the v2 filter shape; views saved before the v2
-// migration still hold the legacy shape, so normalise both here (unmappable
-// legacy filters are dropped).
export const projectViewFiltersToV2 = (view?: ProjectView): V2Filter[] =>
(view?.filters || []).flatMap((filter) => {
if ('dimension' in filter) {
@@ -19,13 +16,8 @@ export const projectViewFiltersToV2 = (view?: ProjectView): V2Filter[] =>
return converted ? [converted] : []
})
-// Dimensions that carry a key (event_metadata:plan) are never offered in the
-// filter editors directly β€” they're only created from panel clicks β€” but they
-// are supported when applying segments / rendering chips.
const KEYED_FILTER_DIMENSIONS = ['event_metadata', 'page_property']
-// referrer_name shares a display label with referrer, so offering both in the
-// column dropdown would be confusing.
const HIDDEN_FILTER_OPTIONS = [...KEYED_FILTER_DIMENSIONS, 'referrer_name']
const TRAFFIC_FILTER_OPTIONS = VALID_DIMENSIONS_BY_TYPE.traffic.filter(
diff --git a/web/app/pages/Project/View/v2/BreakdownPanel.tsx b/web/app/pages/Project/View/v2/BreakdownPanel.tsx
index b23e953ab..b5086bd39 100644
--- a/web/app/pages/Project/View/v2/BreakdownPanel.tsx
+++ b/web/app/pages/Project/View/v2/BreakdownPanel.tsx
@@ -16,38 +16,27 @@ import { Panel, PanelContainer } from '../Panels'
import { groupVersionRows, mapBreakdownRows } from './adapters'
export interface BreakdownSubTab {
- /** Sub-tab id β€” the v2 dimension name, or a sentinel like 'map' / 'userFlow' */
id: string
label: string
- /** v2 dimension to query; omit for sentinel tabs rendered via `render` */
dimension?: string
- /** Custom body for sentinel tabs (map, user flow) β€” data-independent */
render?: () => React.ReactNode
- /** Lazily fetch a version drill-down breakdown for this sub-tab */
versionsDimension?: 'browser_version' | 'os_version'
versionsParentField?: 'browser' | 'os'
}
interface BreakdownPanelProps {
dataType: V2DataType
- /** Stable panel identity for sub-tab persistence (e.g. 'location', 'pages') */
panelId: string
name: string
icon: React.ReactNode
- /** Nested arrays render as a dropdown tab group (PanelContainer semantics) */
subTabs: (BreakdownSubTab | BreakdownSubTab[])[]
- /** Metric used for row counts / sorting (visitors, load_time, occurrences, events) */
primaryMetric?: string
metrics?: string[]
- /** Performance measure (median / average / p75 / p95) */
measure?: string
rowMapper?: (entry: Entry, subTabId: string) => React.ReactNode
valueMapper?: (value: number, subTabId: string) => number
- /** Post-process fetched entries (e.g. group referrers by domain) */
transformEntries?: (entries: Entry[], subTabId: string) => Entry[]
- /** Sub-tab ids whose entries render capitalized */
capitalize?: string[]
- /** Override filter link building (defaults to context getFilterLink) */
getFilterLink?: (
dimension: string,
value: string | null,
@@ -66,11 +55,6 @@ interface BreakdownPanelProps {
const subTabStorageKey = (dataType: string, panelId: string) =>
`v2PanelTab:${dataType}:${panelId}`
-/**
- * One dashboard breakdown card: owns its own v2 breakdown query (gated on
- * viewport visibility), sub-tab switching, lazy version drill-down and
- * paginated details, and renders the existing Panel visuals.
- */
export const BreakdownPanel = ({
dataType,
panelId,
@@ -153,7 +137,6 @@ export const BreakdownPanel = ({
const total = query.data?.pages[0]?.meta.total
- // A single sub-tab is just the dimension itself β€” no tab bar needed
const containerTabs =
flatSubTabs.length > 1
? subTabs.map((tab) =>
@@ -181,8 +164,6 @@ export const BreakdownPanel = ({
}
if (query.isLoading || (!hasBeenInView && !query.data)) {
- // Empty body while the panel first loads β€” content fills in when ready
- // (no skeleton). The panel frame + header stay put, so no layout shift.
return (
<div ref={ref}>
<PanelContainer
diff --git a/web/app/pages/Project/View/v2/TrafficMap.tsx b/web/app/pages/Project/View/v2/TrafficMap.tsx
index c7aadd8c7..d0656be37 100644
--- a/web/app/pages/Project/View/v2/TrafficMap.tsx
+++ b/web/app/pages/Project/View/v2/TrafficMap.tsx
@@ -13,10 +13,6 @@ const InteractiveMap = lazy(
const MAP_CLICK_TYPE_TO_DIMENSION = { cc: 'country', rg: 'region' } as const
-/**
- * Interactive location map fed by its own country + region breakdown queries
- * (deduped with the location panel's queries via react-query cache).
- */
export const TrafficMap = ({ isFullscreen }: { isFullscreen: boolean }) => {
const navigate = useNavigate()
const { getFilterLink, setIsMapFullscreen } = useViewProjectContext()
diff --git a/web/app/pages/Project/View/v2/adapters.ts b/web/app/pages/Project/View/v2/adapters.ts
index 0eea5498b..a75701b0b 100644
--- a/web/app/pages/Project/View/v2/adapters.ts
+++ b/web/app/pages/Project/View/v2/adapters.ts
@@ -8,11 +8,6 @@ import {
import { Entry } from '~/lib/models/Entry'
import { OverallObject } from '~/lib/models/Project'
-// Adapters that pivot v2 API responses into the shapes the existing UI
-// components (Panel, DetailsTable, InteractiveMap, billboard chart pipeline)
-// already consume, so those components stay untouched.
-
-/** Breakdown rows -> Panel entries ({ value, <metric> } -> { name, count }) */
export const mapBreakdownRows = (
rows: BreakdownRow[] | undefined,
primaryMetric = 'visitors',
@@ -27,10 +22,6 @@ export const mapBreakdownRows = (
}))
}
-/**
- * Version breakdown rows (browser_version / os_version, which carry their
- * parent as an extra field) -> { parent: Entry[] } map for Panel drill-down.
- */
export const groupVersionRows = (
rows: BreakdownRow[] | undefined,
parentField: 'browser' | 'os',
@@ -55,19 +46,16 @@ export const groupVersionRows = (
return grouped
}
-/** Metadata rows -> the { result } shape KVTableContainer consumes */
export const metadataToResult = (rows: MetadataRow[] | undefined) => ({
result: rows || [],
})
-/** True when a custom-event filter is applied (metric cards collapse to Events) */
export const hasCustomEventFilter = (filters: V2Filter[]): boolean =>
filters.some(
(filter) =>
filter.dimension === 'event' || filter.dimension === 'event_metadata',
)
-/** v2 traffic summary -> the OverallObject shape MetricCards consumes */
export const summaryToOverall = (
summary: TrafficSummaryData | undefined,
customEVFilterApplied = false,
@@ -94,12 +82,6 @@ export const summaryToOverall = (
}
}
-/**
- * v2 ISO timestamp -> the 'YYYY-MM-DD HH:mm:ss' wall-time string the chart
- * pipeline expects. The timestamp is already in the requested timezone, so we
- * take its literal date-time part instead of letting Date/dayjs re-shift it
- * into the browser timezone.
- */
const toChartX = (timestamp: string): string =>
timestamp.slice(0, 19).replace('T', ' ')
@@ -113,12 +95,6 @@ export interface TrafficChartData {
[key: string]: number[] | string[]
}
-/**
- * Traffic timeseries rows -> the columnar chart shape getColumns()/getSettings()
- * consume. `bounces` is reconstructed as a count because getColumns computes
- * the percentage from bounces/uniques. `concurrency` (live visitors over time)
- * is only non-zero when the `concurrency` metric was requested.
- */
export const pivotTrafficTimeseries = (
rows: TimeseriesRow[] | undefined,
): TrafficChartData => {
@@ -142,7 +118,6 @@ export const pivotTrafficTimeseries = (
return { x, visits, uniques, sdur, bounces, concurrency }
}
-/** Custom events timeseries rows -> { x, events } for the stacked chart */
export const pivotCustomEventsTimeseries = (
rows: TimeseriesRow[] | undefined,
events: string[],
diff --git a/web/app/pages/Project/View/v2/loading.tsx b/web/app/pages/Project/View/v2/loading.tsx
index 3fd32e451..4ba496957 100644
--- a/web/app/pages/Project/View/v2/loading.tsx
+++ b/web/app/pages/Project/View/v2/loading.tsx
@@ -1,10 +1,5 @@
import cx from 'clsx'
-// Subtle refetch indicator for the v2 per-dimension dashboard. On refetch we
-// keep the previous data visible (react-query keepPreviousData) and only show
-// a thin progress bar β€” no skeleton placeholders.
-
-/** Thin indeterminate progress bar pinned to the top edge of a card */
export const RefetchIndicator = ({ className }: { className?: string }) => (
<div
aria-hidden
diff --git a/web/app/pages/Project/tabs/Captcha/CaptchaView.tsx b/web/app/pages/Project/tabs/Captcha/CaptchaView.tsx
index 02a6b30ef..bb35a0706 100644
--- a/web/app/pages/Project/tabs/Captcha/CaptchaView.tsx
+++ b/web/app/pages/Project/tabs/Captcha/CaptchaView.tsx
@@ -88,7 +88,6 @@ const CaptchaView = (_props: CaptchaViewProps) => {
i18n: { language },
} = useTranslation('common')
- // Track if we've ever shown actual content to prevent NoCaptchaEvents flash
const hasShownContentRef = useRef(false)
const summaryQuery = useSummaryQuery('captcha')
@@ -97,8 +96,6 @@ const CaptchaView = (_props: CaptchaViewProps) => {
const summary = summaryQuery.data?.data
const summaryData = summary?.current ?? null
- // Custom compare range when compare mode is active; otherwise the previous
- // period returned alongside the summary (null for period=all)
const summaryCompareData =
compareSummaryQuery.data?.data.current ?? summary?.previous ?? null
diff --git a/web/app/pages/Project/tabs/Captcha/adapters.ts b/web/app/pages/Project/tabs/Captcha/adapters.ts
index 519925747..af521173b 100644
--- a/web/app/pages/Project/tabs/Captcha/adapters.ts
+++ b/web/app/pages/Project/tabs/Captcha/adapters.ts
@@ -1,11 +1,5 @@
import { TimeseriesRow } from '~/api/v2/types'
-/**
- * v2 ISO timestamp -> the 'YYYY-MM-DD HH:mm:ss' wall-time string the chart
- * pipeline expects. The timestamp is already in the requested timezone, so we
- * take its literal date-time part instead of letting Date/dayjs re-shift it
- * into the browser timezone.
- */
const toChartX = (timestamp: string): string =>
timestamp.slice(0, 19).replace('T', ' ')
@@ -18,7 +12,6 @@ export interface CaptchaChartData {
replayed: number[]
}
-/** Captcha timeseries rows -> the columnar shape getSettingsCaptcha consumes */
export const pivotCaptchaTimeseries = (
rows: TimeseriesRow[] | undefined,
): CaptchaChartData => {
diff --git a/web/app/pages/Project/tabs/Errors/ErrorsMap.tsx b/web/app/pages/Project/tabs/Errors/ErrorsMap.tsx
index 0b44dbbc7..12ba38c0d 100644
--- a/web/app/pages/Project/tabs/Errors/ErrorsMap.tsx
+++ b/web/app/pages/Project/tabs/Errors/ErrorsMap.tsx
@@ -14,17 +14,10 @@ const InteractiveMap = lazy(
const MAP_CLICK_TYPE_TO_DIMENSION = { cc: 'country', rg: 'region' } as const
interface ErrorsMapProps {
- /** Static per-error data (details view); when set, no queries are fired */
staticCountryData?: Entry[]
staticRegionData?: Entry[]
}
-/**
- * Error occurrences location map. Project-wide it feeds itself via country +
- * region breakdown queries (deduped with the location panel's queries through
- * the react-query cache); on the error-details view it renders the per-error
- * `params` payload passed in statically.
- */
export const ErrorsMap = ({
staticCountryData,
staticRegionData,
diff --git a/web/app/pages/Project/tabs/Errors/ErrorsView.tsx b/web/app/pages/Project/tabs/Errors/ErrorsView.tsx
index 3450fb5db..bec9e2267 100644
--- a/web/app/pages/Project/tabs/Errors/ErrorsView.tsx
+++ b/web/app/pages/Project/tabs/Errors/ErrorsView.tsx
@@ -294,8 +294,6 @@ const getErrorTrendsChartSettings = (
}
}
-// Sub-tab ids (v2 dimension names) -> keys of the per-error `params` payload
-// (still v1-keyed in the details response)
const PER_ERROR_SUBTAB_TO_V1: Record<string, string> = {
country: 'cc',
region: 'rg',
@@ -325,11 +323,6 @@ interface PerErrorPanelsProps {
isRefetching: boolean
}
-/**
- * Breakdown panels scoped to ONE error group. The v2 error-details response
- * still ships the per-error `params` payload (eid is not a filterable
- * dimension), so these are fed statically instead of via BreakdownPanel.
- */
const PerErrorPanels = ({
params,
locationSubTabs,
@@ -704,8 +697,6 @@ const ErrorsViewInner = () => {
const activeEID = useMemo(() => searchParams.get('eid'), [searchParams])
- // --- v2 queries ---
-
const errorsListQuery = useErrorsListQuery({
showResolved,
enabled: !activeEID,
@@ -782,8 +773,6 @@ const ErrorsViewInner = () => {
]
}, [t, errorOptions])
- // The overview chart is bucketed by the backend-resolved time bucket, which
- // may differ from the currently selected one
const overviewTimeBucket = overview?.timeBucket || timeBucket
const handleOverviewDataPointClick = useCallback(
@@ -879,8 +868,6 @@ const ErrorsViewInner = () => {
[t],
)
- // --- Breakdown panels (error details view) ---
-
const locationSubTabs = useMemo<BreakdownSubTab[]>(
() => [
{ id: 'country', label: t('project.mapping.cc'), dimension: 'country' },
@@ -997,9 +984,7 @@ const ErrorsViewInner = () => {
try {
decodedUri = decodeURIComponent(entryName)
- } catch {
- // do nothing
- }
+ } catch {}
if (subTabId === 'page' && project?.websiteUrl) {
return (
@@ -1233,7 +1218,6 @@ const ErrorsViewInner = () => {
/>
) : null
- // List view - Initial loading state
if (isInitialLoading) {
return (
<div>
diff --git a/web/app/pages/Project/tabs/Errors/types.ts b/web/app/pages/Project/tabs/Errors/types.ts
index 84f95fad7..2ec9ec085 100644
--- a/web/app/pages/Project/tabs/Errors/types.ts
+++ b/web/app/pages/Project/tabs/Errors/types.ts
@@ -1,9 +1,3 @@
-// Local response shapes for the v2 errors endpoints
-// (GET /v2/projects/:pid/errors, /errors/overview, /errors/:eid, /errors/:eid/sessions).
-// The overview and details charts are already columnar ({ x, occurrences,
-// affectedUsers }) with labels shifted to the requested timezone, so no
-// pivoting is needed before handing them to ErrorChart.
-
interface ErrorsChartData {
x: string[]
occurrences: number[]
@@ -54,13 +48,11 @@ interface ErrorMetadataRow {
export interface ErrorDetailsData {
details: ErrorDetailsInfo
metadata: ErrorMetadataRow[]
- /** Per-dimension breakdowns scoped to the error group, keyed by v1 names (cc, rg, br, ...) */
params: Record<string, { name: string | null; count: number }[]>
chart: ErrorsChartData
timeBucket: string
}
-/** Rows of GET /errors/:eid/sessions β€” entity keys renamed to v2 names */
export interface ErrorSessionItem {
psid: string
profileId: string | null
diff --git a/web/app/pages/Project/tabs/Funnels/FunnelsView.tsx b/web/app/pages/Project/tabs/Funnels/FunnelsView.tsx
index ec154ad05..ea1790eeb 100644
--- a/web/app/pages/Project/tabs/Funnels/FunnelsView.tsx
+++ b/web/app/pages/Project/tabs/Funnels/FunnelsView.tsx
@@ -84,8 +84,6 @@ const FunnelsView = ({ tnMapping }: FunnelsViewProps) => {
const funnelQuery = useFunnelQuery(activeFunnel?.id ?? null)
- // keepPreviousData keeps data visible on period/filter refetch, but a stale
- // chart of ANOTHER funnel should not flash while switching between funnels
const displayedFunnelIdRef = useRef<string | null>(null)
if (funnelQuery.data && !funnelQuery.isPlaceholderData) {
displayedFunnelIdRef.current = activeFunnel?.id ?? null
@@ -176,9 +174,6 @@ const FunnelsView = ({ tnMapping }: FunnelsViewProps) => {
{ method: 'POST', action: projectPath },
)
- // Steps may have changed - drop cached funnel analytics.
- // (funnel-sessions isn't cached in react-query; SessionsDrawer loads
- // it imperatively, so there's nothing to invalidate for that key.)
queryClient.invalidateQueries({ queryKey: ['v2', id, 'funnel'] })
} else if (intent === 'delete-funnel') {
toast.success(t('apiNotifications.funnelDeleted'))
diff --git a/web/app/pages/Project/tabs/Goals/GoalSettingsModal.tsx b/web/app/pages/Project/tabs/Goals/GoalSettingsModal.tsx
index 1738fde77..df44a7296 100644
--- a/web/app/pages/Project/tabs/Goals/GoalSettingsModal.tsx
+++ b/web/app/pages/Project/tabs/Goals/GoalSettingsModal.tsx
@@ -47,8 +47,6 @@ const CONDITION_RELATIONS: { value: GoalConditionRelation; label: string }[] = [
{ value: 'OR', label: 'OR' },
]
-// v2 dimension names; the bare keyed dimensions (page_property /
-// event_metadata) mean "has this metadata key" β€” the value is the key itself.
const GOAL_CONDITION_FILTER_OPTIONS = [
'page',
'event',
@@ -114,7 +112,6 @@ const filterToCondition = (filter: V2Filter): GoalCondition | null => {
filter.dimension === 'event_metadata' ? 'custom_event' : 'pageview'
if (!filter.key) {
- // bare keyed dimension = "has this metadata key"; value is the key
return {
id: createConditionId(),
eventType,
@@ -134,7 +131,6 @@ const filterToCondition = (filter: V2Filter): GoalCondition | null => {
}
}
- // goal conditions store the v2 dimension name directly in `field`
return {
id: createConditionId(),
eventType: filter.dimension === 'page' ? 'pageview' : 'any',
@@ -183,8 +179,6 @@ const conditionToFilter = (condition: GoalCondition): V2Filter | null => {
const operator = conditionOperatorToV2Operator(condition.operator)
- // `field` holds a v2 dimension name for goals saved after the v2 migration,
- // or a legacy v1 short code for older goals β€” normalise both to the v2 name.
const dimension = V1_TO_V2_DIMENSION[condition.field] ?? condition.field
if (!ALL_VALID_DIMENSIONS.includes(dimension)) {
return null
@@ -350,10 +344,6 @@ const GoalSettingsModal = ({
e.preventDefault()
processedRef.current = null
- // Map each edited filter to a goal condition. `filterToCondition` returns
- // null for filters the GoalCondition model can't represent (e.g. a "not
- // set" / null value) β€” surface that instead of silently dropping the
- // user's condition.
const mappedConditions: GoalCondition[] = []
let hasUnmappableCondition = false
diff --git a/web/app/pages/Project/tabs/Performance/PerformanceMap.tsx b/web/app/pages/Project/tabs/Performance/PerformanceMap.tsx
index f418356e6..d16de3cda 100644
--- a/web/app/pages/Project/tabs/Performance/PerformanceMap.tsx
+++ b/web/app/pages/Project/tabs/Performance/PerformanceMap.tsx
@@ -12,11 +12,6 @@ const InteractiveMap = lazy(
const MAP_CLICK_TYPE_TO_DIMENSION = { cc: 'country', rg: 'region' } as const
-/**
- * Interactive location map fed by its own country + region performance
- * breakdown queries (deduped with the location panel's queries via the
- * react-query cache).
- */
export const PerformanceMap = ({
isFullscreen,
measure,
diff --git a/web/app/pages/Project/tabs/Performance/PerformanceView.tsx b/web/app/pages/Project/tabs/Performance/PerformanceView.tsx
index c3def8415..1086a1d8e 100644
--- a/web/app/pages/Project/tabs/Performance/PerformanceView.tsx
+++ b/web/app/pages/Project/tabs/Performance/PerformanceView.tsx
@@ -121,7 +121,6 @@ const PerformanceViewInner = ({ tnMapping }: PerformanceViewProps) => {
label: string
} | null>(null)
- // Track if we've ever shown actual content to prevent NoEvents flash
const hasShownContentRef = useRef(false)
// Get chart metrics and measure from URL params (SSR-friendly)
@@ -143,8 +142,6 @@ const PerformanceViewInner = ({ tnMapping }: PerformanceViewProps) => {
setSearchParams(newParams)
}
- // The 'quantiles' allocation is a timeseries-only measure driven by the
- // metric dropdown; everywhere else we fall back to the regular measure.
const effectiveMeasure =
activeChartMetrics === CHART_METRICS_MAPPING_PERF.quantiles
? CHART_MEASURES_MAPPING_PERF.quantiles
@@ -154,8 +151,6 @@ const PerformanceViewInner = ({ tnMapping }: PerformanceViewProps) => {
? CHART_MEASURES_MAPPING_PERF.median
: activeMeasure
- // --- v2 queries ---
-
const summaryQuery = useSummaryQuery('performance', {
measure: activeMeasure,
})
@@ -206,7 +201,6 @@ const PerformanceViewInner = ({ tnMapping }: PerformanceViewProps) => {
hasShownContentRef.current = true
}
- // Don't show NoEvents if we've previously shown content (prevents flash during tab switch)
const isPanelsDataEmpty = isPanelsDataEmptyRaw && !hasShownContentRef.current
const isInitialLoading =
@@ -327,8 +321,6 @@ const PerformanceViewInner = ({ tnMapping }: PerformanceViewProps) => {
[t],
)
- // --- Panels ---
-
const locationSubTabs = useMemo<BreakdownSubTab[]>(
() => [
{ id: 'country', label: t('project.mapping.cc'), dimension: 'country' },
@@ -424,9 +416,7 @@ const PerformanceViewInner = ({ tnMapping }: PerformanceViewProps) => {
try {
decodedUri = decodeURIComponent(entryName)
- } catch {
- // do nothing
- }
+ } catch {}
if (subTabId === 'page' && project?.websiteUrl) {
return (
@@ -467,9 +457,6 @@ const PerformanceViewInner = ({ tnMapping }: PerformanceViewProps) => {
[t],
)
- // Panel values are load times in seconds -> render as '1.2s' / '350ms'.
- // Panel's valueMapper is typed as number -> number but has always accepted
- // display strings at runtime (v1 did the same via @ts-expect-error).
const loadTimeValueMapper = useCallback(
(value: number) =>
getStringFromTime(getTimeFromSeconds(value), true) as unknown as number,
diff --git a/web/app/pages/Project/tabs/Performance/perfAdapters.ts b/web/app/pages/Project/tabs/Performance/perfAdapters.ts
index 3a69ae6f2..200522155 100644
--- a/web/app/pages/Project/tabs/Performance/perfAdapters.ts
+++ b/web/app/pages/Project/tabs/Performance/perfAdapters.ts
@@ -1,11 +1,6 @@
import { PerformanceSummaryData, TimeseriesRow } from '~/api/v2/types'
import { OverallPerformanceObject } from '~/lib/models/Project'
-// Adapters that pivot v2 performance API responses into the shapes the
-// existing UI components (PerformanceMetricCards, getColumnsPerf chart
-// pipeline) already consume, so those components stay untouched.
-
-/** v2 performance summary -> the shape PerformanceMetricCards consumes */
export const perfSummaryToOverall = (
summary: PerformanceSummaryData | undefined,
): Partial<OverallPerformanceObject> => {
@@ -20,22 +15,9 @@ export const perfSummaryToOverall = (
}
}
-/**
- * v2 ISO timestamp -> the 'YYYY-MM-DD HH:mm:ss' wall-time string the chart
- * pipeline expects. The timestamp is already in the requested timezone, so we
- * take its literal date-time part instead of letting Date/dayjs re-shift it
- * into the browser timezone.
- */
const toChartX = (timestamp: string): string =>
timestamp.slice(0, 19).replace('T', ' ')
-/**
- * Performance timeseries rows -> the columnar shape getColumnsPerf() consumes:
- * { x, dns, tls, conn, response, render, domLoad, ttfb } (note the key renames
- * connection -> conn, dom_load -> domLoad), or { x, p50, p75, p95 } when
- * measure === 'quantiles'. The chart pipeline is typed Record<string, string[]>
- * but has always carried numbers at runtime (v1 did the same), hence the cast.
- */
export const pivotPerformanceTimeseries = (
rows: TimeseriesRow[] | undefined,
measure: string,
diff --git a/web/app/pages/Project/tabs/Profiles/ProfilesView.tsx b/web/app/pages/Project/tabs/Profiles/ProfilesView.tsx
index e1bbee186..c10fb6f59 100644
--- a/web/app/pages/Project/tabs/Profiles/ProfilesView.tsx
+++ b/web/app/pages/Project/tabs/Profiles/ProfilesView.tsx
@@ -57,8 +57,6 @@ const ProfilesView = ({ tnMapping }: ProfilesViewProps) => {
(page) => page.data,
) as unknown as Profile[]
- // Deduplicate by profileId: offset-based pages may overlap when new
- // profiles arrive between page loads
const seen = new Set<string>()
return rows.filter((profile) => {
if (seen.has(profile.profileId)) {
@@ -77,7 +75,6 @@ const ProfilesView = ({ tnMapping }: ProfilesViewProps) => {
[profileSessionsQuery.data],
)
- // Track if we've shown content in the current data set to prevent NoProfiles flash
const hasShownContentRef = useRef(false)
if (profilesQuery.data) {
diff --git a/web/app/pages/Project/tabs/Sessions/SessionsView.tsx b/web/app/pages/Project/tabs/Sessions/SessionsView.tsx
index a591fdb8e..51ba6ceb2 100644
--- a/web/app/pages/Project/tabs/Sessions/SessionsView.tsx
+++ b/web/app/pages/Project/tabs/Sessions/SessionsView.tsx
@@ -80,8 +80,6 @@ const SessionsViewInner = ({ tnMapping, rotateXAxis }: SessionsViewProps) => {
(page) => page.data,
) as unknown as SessionType[]
- // Deduplicate by psid: offset-based pages may overlap when new sessions
- // arrive between page loads
const seen = new Set<string>()
return rows.filter((session) => {
if (seen.has(session.psid)) {
@@ -92,14 +90,12 @@ const SessionsViewInner = ({ tnMapping, rotateXAxis }: SessionsViewProps) => {
})
}, [listQuery.data])
- // Track if we've shown content in the current data set to prevent NoSessions flash
const hasShownContentRef = useRef(false)
if (listQuery.data) {
hasShownContentRef.current = !_isEmpty(sessions)
}
- // Session detail - derived from the v2 details query
const activeSession = useMemo(() => {
const data = detailsQuery.data?.data as SessionDetailsData | undefined
if (!data) {
diff --git a/web/app/pages/Project/tabs/Traffic/SessionsDrawer.tsx b/web/app/pages/Project/tabs/Traffic/SessionsDrawer.tsx
index 8dc1a8c38..578113a48 100644
--- a/web/app/pages/Project/tabs/Traffic/SessionsDrawer.tsx
+++ b/web/app/pages/Project/tabs/Traffic/SessionsDrawer.tsx
@@ -49,11 +49,6 @@ interface ErrorAffectedSession {
type DrawerSession = SessionType | ErrorAffectedSession
-/**
- * Goal and journey sessions have no v2 endpoint yet, so they still go through
- * the v1 analytics proxy. The response uses v1 short keys - map them to the v2
- * readable keys the shared <Session /> renderer expects.
- */
const mapV1SessionKeys = (session: Record<string, any>): SessionType =>
({
...session,
@@ -261,8 +256,6 @@ export const SessionsDrawer = ({
): Promise<boolean> => {
let newSessions: DrawerSession[] = []
- // v2 accepts ISO datetimes for from/to; fall back to the period
- // otherwise (backend defaults 'custom' without a range)
const commonParams = {
...(from && to ? { from, to } : { period }),
timezone,
diff --git a/web/app/pages/Project/tabs/Traffic/TrafficView.tsx b/web/app/pages/Project/tabs/Traffic/TrafficView.tsx
index b6f26d9b0..2d53d2667 100644
--- a/web/app/pages/Project/tabs/Traffic/TrafficView.tsx
+++ b/web/app/pages/Project/tabs/Traffic/TrafficView.tsx
@@ -184,7 +184,6 @@ const TrafficViewInner = ({
const [searchParams, setSearchParams] = useSearchParams()
const { pid, common } = useV2CommonParams('traffic')
- // Track if we've ever shown actual content to prevent NoEvents flash
const hasShownContentRef = useRef(false)
const {
@@ -229,7 +228,6 @@ const TrafficViewInner = ({
[timeBucket, timeFormat, timezone],
)
- // Chart metrics state
const [activeChartMetrics, setActiveChartMetrics] = useState({
[CHART_METRICS_MAPPING.unique]: true,
[CHART_METRICS_MAPPING.views]: false,
@@ -248,8 +246,6 @@ const TrafficViewInner = ({
return param ? param.split(',').filter(Boolean) : []
}, [searchParams])
- // --- v2 queries ---
-
const summaryQuery = useSummaryQuery('traffic')
const compareSummaryQuery = useCompareSummaryQuery('traffic')
@@ -343,7 +339,6 @@ const TrafficViewInner = ({
[customEventsTimeseriesQuery.data, activeChartMetricsCustomEvents],
)
- // Revenue state (still fetched via the v1 proxy β€” no v2 equivalent)
const [isRevenueConnected, setIsRevenueConnected] = useState(false)
const [revenueOverlay, setRevenueOverlay] = useState<{
revenue: number[]
@@ -573,9 +568,6 @@ const TrafficViewInner = ({
[isConflicted, t],
)
- // Live visitors cannot be filtered β€” concurrency is reconstructed from
- // session intervals which carry no dimension data, so turn it off if a filter
- // gets applied while it's active (the toggle is disabled in that state)
useEffect(() => {
if (
!_isEmpty(filters) &&
@@ -612,7 +604,6 @@ const TrafficViewInner = ({
[searchParams, setSearchParams],
)
- // Load revenue data when the revenue metric is enabled
const loadRevenueData = useCallback(async () => {
if (
!project ||
@@ -708,8 +699,6 @@ const TrafficViewInner = ({
[filters],
)
- // --- Panels ---
-
const locationSubTabs = useMemo<BreakdownSubTab[]>(
() => [
{ id: 'country', label: t('project.mapping.cc'), dimension: 'country' },
@@ -881,9 +870,7 @@ const TrafficViewInner = ({
try {
decodedUri = decodeURIComponent(entryName)
- } catch {
- // do nothing
- }
+ } catch {}
if (subTabId === 'page' && project?.websiteUrl) {
return (
@@ -950,7 +937,6 @@ const TrafficViewInner = ({
const sourcesGetFilterLink = useCallback(
(dimension: string, value: string | null, subTabId: string) => {
if (subTabId === 'referrer') {
- // If grouped by name/domain (no referrer_name filter active) -> filter by referrer_name
return getFilterLink(
hasRefNameFilter || value === null ? 'referrer' : 'referrer_name',
value,
diff --git a/web/app/root.tsx b/web/app/root.tsx
index dee313967..3cfb67985 100644
--- a/web/app/root.tsx
+++ b/web/app/root.tsx
@@ -489,7 +489,6 @@ const Body = () => {
initialUser={user}
initialTotalMonthlyEvents={totalMonthlyEvents}
>
- {/* Drops transform-based motion (keeps opacity) for prefers-reduced-motion users */}
<MotionConfig reducedMotion='user'>
<AppWrapper />
</MotionConfig>
diff --git a/web/app/routes/api.v2.$.ts b/web/app/routes/api.v2.$.ts
index 62c9a106d..21c8698bd 100644
--- a/web/app/routes/api.v2.$.ts
+++ b/web/app/routes/api.v2.$.ts
@@ -6,14 +6,8 @@ import {
getProjectPasswordCookie,
} from '~/utils/session.server'
-// Proxies GET /api/v2/projects/<pid>/... to the backend /v2/projects/<pid>/...
-// analytics API. Keeps auth tokens (httpOnly cookies -> Bearer, with refresh)
-// and the per-project password cookie (-> x-password) server-side.
const V2_PATH_REGEX = /^projects\/([a-zA-Z0-9-]{1,64})(\/|$)/
-// A dot / dot-dot path segment, literal or percent-encoded (%2e). `fetch`'s URL
-// parser normalises these, so `..` could escape the /v2/ prefix and reach other
-// backend routes β€” reject them before building the upstream request.
const hasTraversalSegment = (path: string): boolean =>
path.split('/').some((segment) => {
const normalized = segment.replace(/%2e/gi, '.')
diff --git a/web/app/routes/projects.$id.tsx b/web/app/routes/projects.$id.tsx
index 918c16442..d10a9c710 100644
--- a/web/app/routes/projects.$id.tsx
+++ b/web/app/routes/projects.$id.tsx
@@ -45,7 +45,6 @@ import {
const GOAL_CONDITION_RELATIONS = new Set(['AND', 'OR'])
const GOAL_CONDITION_COMMON_FIELDS = [
- // v2 dimension names written by the goal settings modal after the v2 migration
'host',
'country',
'device',
@@ -57,7 +56,6 @@ const GOAL_CONDITION_COMMON_FIELDS = [
'utm_campaign',
'utm_term',
'utm_content',
- // legacy v1 short codes (older goals / preserved unmapped conditions)
'ref',
'so',
'me',
@@ -371,19 +369,12 @@ export interface ProjectLoaderData {
project: Project | null
isPasswordRequired: boolean
error?: string
- // Session replays (v1 - no v2 equivalent yet)
replaysData?: Promise<SessionReplaysResponse | null>
- // Feature Flags data
featureFlagsData?: Promise<FeatureFlagsResponse | null>
- // Goals data
goalsData?: Promise<GoalsResponse | null>
- // Data import
hasImportedData?: Promise<boolean>
}
-// Tabs whose data still comes from this loader (v1 endpoints). All other tabs
-// fetch client-side via the v2 API, so URL param changes (period, filters,
-// timeBucket, ...) must not re-run the loader for them.
const LOADER_BACKED_TABS = new Set<string>([
PROJECT_TABS.replays,
PROJECT_TABS.featureFlags,
@@ -396,8 +387,6 @@ export function shouldRevalidate({
formAction,
defaultShouldRevalidate,
}: ShouldRevalidateFunctionArgs) {
- // Route actions (goal/funnel/view CRUD, password submission) may change
- // loader data
if (formAction) {
return defaultShouldRevalidate
}
@@ -424,7 +413,6 @@ export function shouldRevalidate({
return defaultShouldRevalidate
}
- // The traffic tab's "has imported data" indicator depends on the period
if (
nextTab === PROJECT_TABS.traffic &&
(nextUrl.searchParams.get('period') !==
@@ -499,8 +487,6 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
}
}
- // Parse URL params (most analytics are fetched client-side via the v2 API;
- // the loader only feeds the tabs still on v1: replays, feature flags, goals)
const tab =
(url.searchParams.get('tab') as keyof typeof PROJECT_TABS) ||
PROJECT_TABS.traffic
diff --git a/web/app/ui/FilterValueInput.tsx b/web/app/ui/FilterValueInput.tsx
index 759690b3e..1bc336037 100644
--- a/web/app/ui/FilterValueInput.tsx
+++ b/web/app/ui/FilterValueInput.tsx
@@ -56,7 +56,6 @@ import countries from '~/utils/isoCountries'
const ITEM_HEIGHT = 36
-// Icon mapping for filter categories (keyed by v2 dimension names)
export const filterCategoryIcons: Record<string, ReactNode> = {
country: <MapPinIcon className='size-4' />,
region: <MapTrifoldIcon className='size-4' />,
diff --git a/web/app/utils/analyticsUrl.ts b/web/app/utils/analyticsUrl.ts
index 94474fbe2..04a231819 100644
--- a/web/app/utils/analyticsUrl.ts
+++ b/web/app/utils/analyticsUrl.ts
@@ -6,18 +6,6 @@ import {
V1_TO_V2_DIMENSION,
} from '~/lib/v2Dimensions'
-// Filters live in the URL as `<prefix><dimension>=<value>` search params:
-// country=US -> { dimension: 'country', operator: 'is', value: 'US' }
-// !country=US -> is_not
-// ~page=/blog -> contains
-// ^page=/blog -> contains_not
-// Keyed dimensions carry their key after a colon:
-// event_metadata:plan=free
-// The literal value `null` (or an empty value) means "unknown" and maps to
-// v2 `value: null` β€” same convention v1 links used.
-// v1 short codes (`cc`, `pg`, `ev:key:plan`, ...) are accepted on parse only,
-// so old shared links keep working.
-
const OPERATOR_BY_PREFIX: Record<string, V2FilterOperator> = {
'!': 'is_not',
'~': 'contains',
@@ -37,7 +25,6 @@ interface ParsedFilterKey {
operator: V2FilterOperator
}
-/** Parses a URL search param key into { dimension, key?, operator }, or null */
export const parseFilterKey = (rawKey: string): ParsedFilterKey | null => {
let operator: V2FilterOperator = 'is'
let key = rawKey
@@ -48,7 +35,6 @@ export const parseFilterKey = (rawKey: string): ParsedFilterKey | null => {
key = key.substring(1)
}
- // legacy keyed filters: ev:key:<k> / tag:key:<k>
for (const [prefix, dimension] of Object.entries(V1_KEYED_PREFIX_TO_V2)) {
if (key.startsWith(prefix)) {
const metaKey = key.substring(prefix.length)
@@ -57,7 +43,6 @@ export const parseFilterKey = (rawKey: string): ParsedFilterKey | null => {
}
}
- // keyed filters: event_metadata:<k> / page_property:<k>
for (const dimension of KEYED_DIMENSIONS) {
if (key.startsWith(`${dimension}:`)) {
const metaKey = key.substring(dimension.length + 1)
@@ -66,7 +51,6 @@ export const parseFilterKey = (rawKey: string): ParsedFilterKey | null => {
}
}
- // legacy v1 short codes
const aliased = V1_TO_V2_DIMENSION[key]
if (aliased) {
return { dimension: aliased, operator }
@@ -76,8 +60,6 @@ export const parseFilterKey = (rawKey: string): ParsedFilterKey | null => {
return { dimension: key, operator }
}
- // Not a v2 dimension, but a valid filter on tabs with their own data source
- // (GSC keywords on the SEO tab). Never sent to the v2 API.
if (key === 'keywords') {
return { dimension: key, operator }
}
@@ -85,7 +67,6 @@ export const parseFilterKey = (rawKey: string): ParsedFilterKey | null => {
return null
}
-/** Builds the canonical URL search param key for a filter */
export const filterToUrlKey = (
filter: Pick<V2Filter, 'dimension' | 'operator' | 'key'>,
): string => {
@@ -103,7 +84,6 @@ export const filterToUrlValue = (filter: V2Filter): string => {
return filter.value ?? 'null'
}
-/** Parses all filters from URL search params into the v2 filter shape */
export const parseFiltersFromUrl = (
searchParams: URLSearchParams,
): V2Filter[] => {
@@ -127,14 +107,9 @@ export const parseFiltersFromUrl = (
return filters
}
-/**
- * Returns true if the given URL search param key is a filter (used to strip
- * or toggle filters without touching unrelated params like `period`).
- */
export const isFilterUrlKey = (rawKey: string): boolean =>
parseFilterKey(rawKey) !== null
-/** Legacy saved-view filter shape (kept server-side; converted at the edges) */
export interface LegacyFilter {
column: string
filter: string