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!

PR review fixes

Blue Mouse67e0cd79b574
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 4bbc83dd1..523a0649b 100644
--- a/backend/apps/cloud/src/analytics/v2/dto/entities.dto.ts
+++ b/backend/apps/cloud/src/analytics/v2/dto/entities.dto.ts
@@ -79,7 +79,13 @@ export class V2ErrorsQueryDto extends V2EntityListDto {
description: 'Include resolved error groups in the list',
})
@IsOptional()
- @Transform(({ value }) => value === true || value === 'true')
+ @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()
show_resolved?: boolean
}
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 4bbc83dd1..523a0649b 100644
--- a/backend/apps/community/src/analytics/v2/dto/entities.dto.ts
+++ b/backend/apps/community/src/analytics/v2/dto/entities.dto.ts
@@ -79,7 +79,13 @@ export class V2ErrorsQueryDto extends V2EntityListDto {
description: 'Include resolved error groups in the list',
})
@IsOptional()
- @Transform(({ value }) => value === true || value === 'true')
+ @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()
show_resolved?: boolean
}
diff --git a/web/app/api/v2/endpoints.ts b/web/app/api/v2/endpoints.ts
index ad1550576..9d2da8bfd 100644
--- a/web/app/api/v2/endpoints.ts
+++ b/web/app/api/v2/endpoints.ts
@@ -166,14 +166,23 @@ export const getErrorDetails = (
params: Common & { timeBucket?: string },
signal?: AbortSignal,
) =>
- fetchV2<Record<string, any>>(`projects/${pid}/errors/${eid}`, params, signal)
+ fetchV2<Record<string, any>>(
+ `projects/${pid}/errors/${encodeURIComponent(eid)}`,
+ params,
+ signal,
+ )
export const getErrorSessions = (
pid: string,
eid: string,
params: Common & { limit?: number; offset?: number },
signal?: AbortSignal,
-) => fetchV2<any[]>(`projects/${pid}/errors/${eid}/sessions`, params, signal)
+) =>
+ fetchV2<any[]>(
+ `projects/${pid}/errors/${encodeURIComponent(eid)}/sessions`,
+ params,
+ signal,
+ )
export const getSessionsList = (
pid: string,
@@ -192,7 +201,7 @@ export const getSessionDetails = (
signal?: AbortSignal,
) =>
fetchV2<Record<string, any>>(
- `projects/${pid}/sessions/${psid}`,
+ `projects/${pid}/sessions/${encodeURIComponent(psid)}`,
params,
signal,
)
@@ -261,7 +270,7 @@ export const getDimensionValues = (
signal?: AbortSignal,
) =>
fetchV2<DimensionValues>(
- `projects/${pid}/dimensions/${dimension}/values`,
+ `projects/${pid}/dimensions/${encodeURIComponent(dimension)}/values`,
params,
signal,
)
diff --git a/web/app/pages/Project/View/components/AddAViewModal.tsx b/web/app/pages/Project/View/components/AddAViewModal.tsx
index a9d137ba3..790e9cce5 100644
--- a/web/app/pages/Project/View/components/AddAViewModal.tsx
+++ b/web/app/pages/Project/View/components/AddAViewModal.tsx
@@ -14,24 +14,17 @@ import Input from '~/ui/Input'
import Modal from '~/ui/Modal'
import Select from '~/ui/Select'
import { Text } from '~/ui/Text'
-import { legacyFilterToV2, v2FilterToLegacy } from '~/utils/analyticsUrl'
+import { v2FilterToLegacy } from '~/utils/analyticsUrl'
import {
ProjectView,
ProjectViewCustomEvent,
ProjectViewCustomEventMetaValueType,
} from '../interfaces/traffic'
+import { projectViewFiltersToV2 } from '../utils/projectViewSegments'
import FilterRowsEditor from './FilterRowsEditor'
-// Saved project views keep the legacy filter shape server-side; convert to
-// the v2 shape at this boundary (unmappable legacy filters are dropped).
-const projectViewFiltersToV2 = (view?: ProjectView): V2Filter[] =>
- (view?.filters || []).flatMap((filter) => {
- const converted = legacyFilterToV2(filter)
- return converted ? [converted] : []
- })
-
interface AddAViewModalProps {
onSubmit: () => void
showModal: boolean
diff --git a/web/app/pages/Project/View/components/ProjectViewHeaderActions.tsx b/web/app/pages/Project/View/components/ProjectViewHeaderActions.tsx
index bf79a4f25..6090a5642 100644
--- a/web/app/pages/Project/View/components/ProjectViewHeaderActions.tsx
+++ b/web/app/pages/Project/View/components/ProjectViewHeaderActions.tsx
@@ -17,10 +17,10 @@ import { ProjectViewActionData } from '~/routes/projects.$id'
import Dropdown from '~/ui/Dropdown'
import { Text } from '~/ui/Text'
import { trackCustom } from '~/utils/analytics'
-import { legacyFilterToV2 } from '~/utils/analyticsUrl'
import { ProjectView } from '../interfaces/traffic'
import {
+ projectViewFiltersToV2,
splitProjectViewFiltersByTab,
supportsProjectViewSegments,
} from '../utils/projectViewSegments'
@@ -59,14 +59,6 @@ const isAddViewItem = (item: ProjectViewMenuItem): item is AddViewItem =>
const isEmptyViewItem = (item: ProjectViewMenuItem): item is EmptyViewItem =>
'notClickable' in item
-// Saved project views keep the legacy filter shape server-side; convert to
-// the v2 shape at this boundary (unmappable legacy filters are dropped).
-const projectViewFiltersToV2 = (view: ProjectView): V2Filter[] =>
- (view.filters || []).flatMap((filter) => {
- const converted = legacyFilterToV2(filter)
- return converted ? [converted] : []
- })
-
const iconButtonClassName =
'rounded-md p-1 hover:bg-gray-50 hover:text-gray-900 dark:hover:bg-slate-900 dark:hover:text-slate-200'
diff --git a/web/app/pages/Project/View/utils/projectViewSegments.ts b/web/app/pages/Project/View/utils/projectViewSegments.ts
index 97c1e19ed..a0e478e29 100644
--- a/web/app/pages/Project/View/utils/projectViewSegments.ts
+++ b/web/app/pages/Project/View/utils/projectViewSegments.ts
@@ -1,9 +1,20 @@
import { V2Filter } from '~/api/v2/types'
import { PROJECT_TABS } from '~/lib/constants'
import { VALID_DIMENSIONS_BY_TYPE } from '~/lib/v2Dimensions'
+import { legacyFilterToV2 } from '~/utils/analyticsUrl'
+
+import { ProjectView } from '../interfaces/traffic'
type ProjectTab = keyof typeof PROJECT_TABS
+// Saved project views keep the legacy filter shape server-side; convert to
+// the v2 shape at this boundary (unmappable legacy filters are dropped).
+export const projectViewFiltersToV2 = (view?: ProjectView): V2Filter[] =>
+ (view?.filters || []).flatMap((filter) => {
+ const converted = legacyFilterToV2(filter)
+ 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.
diff --git a/web/app/pages/Project/tabs/Funnels/FunnelsView.tsx b/web/app/pages/Project/tabs/Funnels/FunnelsView.tsx
index 2d1d710ab..ec154ad05 100644
--- a/web/app/pages/Project/tabs/Funnels/FunnelsView.tsx
+++ b/web/app/pages/Project/tabs/Funnels/FunnelsView.tsx
@@ -176,11 +176,10 @@ const FunnelsView = ({ tnMapping }: FunnelsViewProps) => {
{ method: 'POST', action: projectPath },
)
- // Steps may have changed - drop cached funnel analytics
+ // 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'] })
- queryClient.invalidateQueries({
- queryKey: ['v2', id, 'funnel-sessions'],
- })
} else if (intent === 'delete-funnel') {
toast.success(t('apiNotifications.funnelDeleted'))
fetcher.submit(
diff --git a/web/app/pages/Project/tabs/Goals/GoalSettingsModal.tsx b/web/app/pages/Project/tabs/Goals/GoalSettingsModal.tsx
index 37c21cbec..39f559cb6 100644
--- a/web/app/pages/Project/tabs/Goals/GoalSettingsModal.tsx
+++ b/web/app/pages/Project/tabs/Goals/GoalSettingsModal.tsx
@@ -349,6 +349,27 @@ 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
+
+ conditionFilters.forEach((filter) => {
+ const condition = filterToCondition(filter)
+ if (condition) {
+ mappedConditions.push(condition)
+ } else {
+ hasUnmappableCondition = true
+ }
+ })
+
+ if (definitionMode === 'conditions' && hasUnmappableCondition) {
+ toast.error(t('goals.conditionValueRequired'))
+ return
+ }
+
const formData = new FormData()
formData.set('intent', isNew ? 'create-goal' : 'update-goal')
formData.set('name', name)
@@ -362,9 +383,6 @@ const GoalSettingsModal = ({
),
)
- const mappedConditions = conditionFilters
- .map(filterToCondition)
- .filter((condition): condition is GoalCondition => Boolean(condition))
const goalConditions: GoalConditions | null =
definitionMode === 'conditions' &&
(mappedConditions.length > 0 || unmappedConditions.length > 0)
diff --git a/web/app/routes/api.v2.$.ts b/web/app/routes/api.v2.$.ts
index 3f144442c..62c9a106d 100644
--- a/web/app/routes/api.v2.$.ts
+++ b/web/app/routes/api.v2.$.ts
@@ -11,12 +11,21 @@ import {
// 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, '.')
+ return normalized === '.' || normalized === '..'
+ })
+
export async function loader({ request, params }: LoaderFunctionArgs) {
const path = params['*'] || ''
const match = path.match(V2_PATH_REGEX)
- if (!match) {
+ if (!match || hasTraversalSegment(path)) {
return data({ error: 'Invalid v2 API path' }, { status: 400 })
}
diff --git a/web/public/locales/en.json b/web/public/locales/en.json
index 6bba4a941..488d8fa2a 100644
--- a/web/public/locales/en.json
+++ b/web/public/locales/en.json
@@ -1341,7 +1341,8 @@
"noMetadataFilters": "No metadata filters added. Click 'Add filter' to filter by event metadata.",
"conversions": "Conversions",
"noData": "No conversion data yet",
- "noChartData": "No chart data available for the selected period"
+ "noChartData": "No chart data available for the selected period",
+ "conditionValueRequired": "Goal conditions need a specific value. Remove or set a value for filters marked as \"not set\"."
},
"featureFlags": {
"title": "Feature flags",