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!

Merge branch 'main' into feature/ip-whitelist

Blue Mouseef911a1ae917
diff --cc backend/apps/cloud/src/analytics/protection/analytics-read.util.ts
index 85899c088,3c77aea97..4b5d4f24f
--- a/backend/apps/cloud/src/analytics/protection/analytics-read.util.ts
+++ b/backend/apps/cloud/src/analytics/protection/analytics-read.util.ts
@@@ -1,6 -1,14 +1,7 @@@
import _isString from 'lodash/isString'
+ import { PID_REGEX } from '../../common/constants'
-import { getIPFromHeaders } from '../../common/utils'
-
-const TRUSTED_PROXY_IPS = new Set(
- (process.env.TRUSTED_PROXY_IPS || '')
- .split(',')
- .map((entry) => entry.trim())
- .filter(Boolean),
-)
+import { getIPFromHeaders, TRUSTED_PROXY_IPS } from '../../common/utils'
const firstHeaderValue = (value: unknown): string => {
if (_isString(value) && value) {
diff --cc web/app/api/api.server.ts
index 8ba6d583f,e9a0dd13a..6d64471c7
--- a/web/app/api/api.server.ts
+++ b/web/app/api/api.server.ts
@@@ -2413,63 -1472,56 +1472,57 @@@ export async function getGoalServer
}
// ============================================================================
- // MARK: Error Sessions API
+ // MARK: Projects API
// ============================================================================
- export interface ErrorAffectedSession {
- psid: string
- profileId: string | null
- cc: string | null
- br: string | null
- os: string | null
- firstErrorAt: string
- lastErrorAt: string
- errorCount: number
- }
-
- export interface ErrorSessionsResponse {
- sessions: ErrorAffectedSession[]
- total: number
+ export interface Project {
+ id: string
+ name: string
+ origins: string[] | null
+ ipBlacklist: string[] | null
++ ipWhitelist: string[] | null
+ active: boolean
+ public: boolean
+ isPasswordProtected: boolean
+ passwordHash: string | null
+ admin: {
+ id: string
+ email: string
+ }
+ created: string
+ isOwner: boolean
+ isLocked: boolean
+ featureAccess?: ProjectFeatureAccess
+ isDataExists?: boolean
+ isErrorDataExists?: boolean
+ isCaptchaDataExists?: boolean
+ isReplayDataExists?: boolean
+ isCaptchaProject: boolean
+ isCaptchaEnabled: boolean
+ isAnalyticsProject: boolean
+ captchaSecretKey: string | null
+ role: string
+ botsProtectionLevel: string
+ isTransferring: boolean
+ share?: {
+ id: string
+ confirmed: boolean
+ role: string
+ }
+ funnels?: { id: string; name: string }[]
}
- export async function getErrorSessionsServer(
+ export async function getProjectServer(
request: Request,
pid: string,
- eid: string,
- params: {
- timeBucket?: string
- period?: string
- from?: string
- to?: string
- filters?: AnalyticsFilter[]
- timezone?: string
- take?: number
- skip?: number
- password?: string
- } = {},
- ): Promise<ServerFetchResult<ErrorSessionsResponse>> {
- const queryParams = new URLSearchParams()
- queryParams.append('pid', pid)
- queryParams.append('eid', eid)
- queryParams.append('timeBucket', params.timeBucket || 'hour')
- queryParams.append('period', params.period || '7d')
- queryParams.append('take', String(params.take || 10))
- queryParams.append('skip', String(params.skip || 0))
- queryParams.append('filters', serializeFiltersForUrl(params.filters || []))
- if (params.from) queryParams.append('from', params.from)
- if (params.to) queryParams.append('to', params.to)
- if (params.timezone) queryParams.append('timezone', params.timezone)
-
+ password?: string,
+ ): Promise<ServerFetchResult<Project>> {
const headers: Record<string, string> = {}
- if (params.password) {
- headers['x-password'] = params.password
+ if (password) {
+ headers['x-password'] = password
}
- return serverFetch<ErrorSessionsResponse>(
- request,
- `log/error-sessions?${queryParams.toString()}`,
- { headers },
- )
+ return serverFetch<Project>(request, `project/${pid}`, { headers })
}
// ============================================================================