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!

Better typing

Blue Mouse2670859faf1a
diff --git a/web/app/api/index.ts b/web/app/api/index.ts
index 56906ee71..f9b0e331b 100644
--- a/web/app/api/index.ts
+++ b/web/app/api/index.ts
@@ -9,7 +9,17 @@ import { Alerts } from '~/lib/models/Alerts'
import { Auth, SSOProvider } from '~/lib/models/Auth'
import { Metainfo } from '~/lib/models/Metainfo'
import { Role } from '~/lib/models/Organisation'
-import { Project, Overall, LiveStats, Funnel, Extension } from '~/lib/models/Project'
+import {
+ Project,
+ Overall,
+ LiveStats,
+ Funnel,
+ Extension,
+ SwetrixError,
+ SwetrixErrorDetails,
+ SessionDetails,
+ Session,
+} from '~/lib/models/Project'
import { Stats } from '~/lib/models/Stats'
import { Subscriber } from '~/lib/models/Subscriber'
import { User, FeatureFlag } from '~/lib/models/User'
@@ -633,7 +643,7 @@ export const getSessions = (
},
},
)
- .then((response) => response.data)
+ .then((response): { sessions: Session[]; take: number; skip: number; appliedFilters: Filter[] } => response.data)
.catch((error) => {
throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
})
@@ -661,7 +671,7 @@ export const getErrors = (
},
},
)
- .then((response) => response.data)
+ .then((response): { errors: SwetrixError[] } => response.data)
.catch((error) => {
throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
})
@@ -673,7 +683,7 @@ export const getSession = (pid: string, psid: string, timezone = '', password: s
'x-password': password,
},
})
- .then((response) => response.data)
+ .then((response): { details: SessionDetails; [key: string]: any } => response.data)
.catch((error) => {
throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
})
@@ -697,7 +707,7 @@ export const getError = (
},
},
)
- .then((response) => response.data)
+ .then((response): { details: SwetrixErrorDetails; [key: string]: any } => response.data)
.catch((error) => {
throw error.response
})
diff --git a/web/app/lib/models/Project.ts b/web/app/lib/models/Project.ts
index 923221dc8..ad7cfb5e3 100644
--- a/web/app/lib/models/Project.ts
+++ b/web/app/lib/models/Project.ts
@@ -58,6 +58,57 @@ export interface Funnel {
created: string
}
+export interface SwetrixError {
+ eid: string
+ name: string
+ message: string
+ filename: string
+ count: number
+ last_seen: string
+ status: 'active' | 'regressed' | 'fixed' | 'resolved'
+}
+
+export interface SwetrixErrorDetails extends SwetrixError {
+ colno: number
+ lineno: number
+ first_seen: string
+}
+
+export interface Session {
+ psid: string
+ cc: string | null
+ os: string | null
+ br: string | null
+ pageviews: number
+ created: string
+ isLive: 1 | 0
+ sdur?: number
+
+ sessionStart: string
+ lastActivity: string
+}
+
+export interface SessionDetails {
+ cc: string | null
+ os: string | null
+ osv: string | null
+ br: string | null
+ brv: string | null
+ lc: string | null
+ ref: string | null
+ so: string | null
+ me: string | null
+ ca: string | null
+ te: string | null
+ co: string | null
+ rg: string | null
+ ct: string | null
+ dv: string | null
+
+ sdur?: number
+ isLive?: boolean
+}
+
export interface AnalyticsFunnel {
value: string
events: number
diff --git a/web/app/pages/Project/View/Panels.tsx b/web/app/pages/Project/View/Panels.tsx
index 9022ed2dd..53bfe294a 100644
--- a/web/app/pages/Project/View/Panels.tsx
+++ b/web/app/pages/Project/View/Panels.tsx
@@ -58,7 +58,7 @@ const ENTRIES_PER_CUSTOM_EVENTS_PANEL = 6
const PANELS_WITH_BARS = ['cc', 'rg', 'ct', 'ce', 'os', 'br', 'dv', 'pg']
// function that checks if there are custom tabs for a specific type
-const checkCustomTabs = (panelID: string, customTabs: any) => {
+const checkCustomTabs = (panelID: string, customTabs: CustomTab[]) => {
if (_isEmpty(customTabs)) return false
return Boolean(_find(customTabs, (el) => el.panelID === panelID))
@@ -106,7 +106,7 @@ interface PanelContainerProps {
onExpandClick?: () => void
activeFragment: number | string
setActiveFragment: (arg: number) => void
- customTabs?: any
+ customTabs?: CustomTab[]
activeTab?: string
isCustomContent?: boolean
}
@@ -214,9 +214,7 @@ const PanelContainer = ({
if (panelID !== type) return null
const onClick = () => {
- if (onOpen) {
- onOpen()
- }
+ onOpen?.()
setActiveFragment(extensionID)
}
@@ -289,6 +287,13 @@ const getPieOptions = (customs: any, uniques: number, t: any) => {
}
}
+export type CustomTab = {
+ extensionID: string
+ panelID: string
+ onOpen?: () => void
+ tabContent?: string
+}
+
interface MetadataProps {
customs: Customs
properties: Properties
@@ -296,7 +301,7 @@ interface MetadataProps {
filters: Filter[]
getCustomEventMetadata: (event: string) => Promise<any>
getPropertyMetadata: (property: string) => Promise<any>
- customTabs: any
+ customTabs: CustomTab[]
getFilterLink: (column: string, value: string) => LinkProps['to']
}
@@ -816,7 +821,7 @@ const CustomEvents = ({
// Showing custom tabs (Extensions Marketplace)
// todo: check activeFragment for being equal to customTabs -> extensionID + panelID
if (!_isEmpty(customTabs) && typeof activeFragment === 'string') {
- const { tabContent } = _find(customTabs, (tab) => tab.extensionID === activeFragment)
+ const { tabContent } = _find(customTabs, (tab) => tab.extensionID === activeFragment) || ({} as CustomTab)
return (
<PanelContainer
@@ -1411,7 +1416,7 @@ interface PanelProps {
icon: any
id: string
hideFilters?: boolean
- customTabs?: any
+ customTabs?: CustomTab[]
onFragmentChange?: (arg: number) => void
getFilterLink?: (column: string, value: string) => LinkProps['to']
}
@@ -1579,7 +1584,7 @@ const Panel = ({
// Showing custom tabs (Extensions Marketplace)
// todo: check activeFragment for being equal to customTabs -> extensionID + panelID
if (!_isEmpty(customTabs) && typeof activeFragment === 'string' && !_isEmpty(data)) {
- const { tabContent } = _find(customTabs, (tab) => tab.extensionID === activeFragment)
+ const { tabContent } = _find(customTabs, (tab) => tab.extensionID === activeFragment) || ({} as CustomTab)
return (
<PanelContainer
@@ -1594,7 +1599,7 @@ const Panel = ({
isCustomContent
>
{/* Using this instead of dangerouslySetInnerHTML to support script tags */}
- <InnerHTML className='absolute overflow-auto' html={tabContent} />
+ {tabContent ? <InnerHTML className='absolute overflow-auto' html={tabContent} /> : null}
</PanelContainer>
)
}
diff --git a/web/app/pages/Project/View/ViewProject.helpers.tsx b/web/app/pages/Project/View/ViewProject.helpers.tsx
index 8cc413861..82b3a4b56 100644
--- a/web/app/pages/Project/View/ViewProject.helpers.tsx
+++ b/web/app/pages/Project/View/ViewProject.helpers.tsx
@@ -50,6 +50,8 @@ import { AnalyticsFunnel } from '~/lib/models/Project'
import { getTimeFromSeconds, getStringFromTime, sumArrays, nFormatter } from '~/utils/generic'
import countries from '~/utils/isoCountries'
+import { TrafficLogResponse } from './interfaces/traffic'
+
const { saveAs } = filesaver
const getAvg = (arr: any) => {
@@ -190,9 +192,9 @@ const CHART_MEASURES_MAPPING_PERF = {
// function to filter the data for the chart
const getColumns = (
- chart: Record<string, string[]>,
+ chart: TrafficLogResponse['chart'] & { [key: string]: number[] },
activeChartMetrics: Record<string, boolean>,
- compareChart?: Record<string, string[]>,
+ compareChart?: TrafficLogResponse['chart'] & { [key: string]: number[] },
) => {
const { views, bounce, viewsPerUnique, unique, trendlines, sessionDuration, occurrences, avgResponseTime } =
activeChartMetrics
@@ -242,7 +244,7 @@ const getColumns = (
if (viewsPerUnique) {
const viewsPerUniqueArray = _map(chart.visits, (el, i) => {
- if (chart.uniques[i] === '0' || chart.uniques[i] === undefined) {
+ if (chart.uniques[i] === 0 || chart.uniques[i] === undefined) {
return 0
}
return _round(_toNumber(el) / _toNumber(chart.uniques[i]), 1)
@@ -429,7 +431,7 @@ const noRegionPeriods = ['custom', 'yesterday']
// function to get the settings and data for the chart(main diagram)
const getSettings = (
- chart: any,
+ chart: TrafficLogResponse['chart'] & { [key: string]: number[] },
timeBucket: string,
activeChartMetrics: Record<string, boolean>,
applyRegions: boolean,
@@ -437,7 +439,7 @@ const getSettings = (
rotateXAxis: boolean,
chartType: string,
customEvents?: Record<string, string[]>,
- compareChart?: Record<string, string[]>,
+ compareChart?: TrafficLogResponse['chart'] & { [key: string]: number[] },
): ChartOptions => {
const xAxisSize = _size(chart.x)
const lines: GridLineOptions[] = []
@@ -757,7 +759,7 @@ const getSettingsSession = (
): ChartOptions => {
const xAxisSize = _size(chart.x)
- const columns = getColumns(chart, { views: true }, {})
+ const columns = getColumns(chart, { views: true })
return {
data: {
@@ -883,7 +885,7 @@ const getSettingsError = (
): ChartOptions => {
const xAxisSize = _size(chart.x)
- const columns = getColumns(chart, { occurrences: true }, {})
+ const columns = getColumns(chart, { occurrences: true })
let regionStart
diff --git a/web/app/pages/Project/View/ViewProject.tsx b/web/app/pages/Project/View/ViewProject.tsx
index 85696200a..9e255099d 100644
--- a/web/app/pages/Project/View/ViewProject.tsx
+++ b/web/app/pages/Project/View/ViewProject.tsx
@@ -1,6 +1,6 @@
import { MagnifyingGlassIcon, ChevronLeftIcon, GlobeAltIcon } from '@heroicons/react/24/outline'
import SwetrixSDK from '@swetrix/sdk'
-import billboard from 'billboard.js'
+import billboard, { Chart } from 'billboard.js'
import cx from 'clsx'
import dayjs from 'dayjs'
import _debounce from 'lodash/debounce'
@@ -104,7 +104,16 @@ import {
VALID_TIME_BUCKETS,
} from '~/lib/constants'
import { CountryEntry } from '~/lib/models/Entry'
-import { Funnel, AnalyticsFunnel, OverallObject, OverallPerformanceObject } from '~/lib/models/Project'
+import {
+ Funnel,
+ AnalyticsFunnel,
+ OverallObject,
+ OverallPerformanceObject,
+ SwetrixError,
+ SwetrixErrorDetails,
+ SessionDetails as SessionDetailsModel,
+ Session,
+} from '~/lib/models/Project'
import NewFunnel from '~/modals/NewFunnel'
import ViewProjectHotkeys from '~/modals/ViewProjectHotkeys'
import { useAuth } from '~/providers/AuthProvider'
@@ -153,8 +162,6 @@ import TBPeriodSelector from './components/TBPeriodSelector'
import UTMDropdown from './components/UTMDropdown'
import WaitingForAnError from './components/WaitingForAnError'
import WaitingForAnEvent from './components/WaitingForAnEvent'
-import { SwetrixError } from './interfaces/error'
-import { Session } from './interfaces/session'
import {
Customs,
Filter,
@@ -165,7 +172,7 @@ import {
Properties,
TrafficLogResponse,
} from './interfaces/traffic'
-import { Panel, Metadata } from './Panels'
+import { Panel, Metadata, type CustomTab } from './Panels'
import { FILTER_CHART_METRICS_MAPPING_FOR_COMPARE, ERROR_FILTERS_MAPPING, parseFilters } from './utils/filters'
import {
onCSVExportClick,
@@ -241,11 +248,10 @@ const ViewProject = () => {
i18n: { language },
} = useTranslation('common')
- const [customExportTypes, setCustomExportTypes] = useState<any[]>([])
- const [customPanelTabs, setCustomPanelTabs] = useState<any[]>([])
- const [sdkInstance, setSdkInstance] = useState<any>(null)
+ const [customPanelTabs, setCustomPanelTabs] = useState<CustomTab[]>([])
+ const [sdkInstance, setSdkInstance] = useState<SwetrixSDK | null>(null)
- const [activeChartMetricsCustomEvents, setActiveChartMetricsCustomEvents] = useState<any[]>([])
+ const [activeChartMetricsCustomEvents, setActiveChartMetricsCustomEvents] = useState<string[]>([])
const dashboardRef = useRef<HTMLDivElement>(null)
@@ -274,14 +280,19 @@ const ViewProject = () => {
meta?: TrafficMeta[]
// @ts-expect-error
}>({})
+ const [customExportTypes, setCustomExportTypes] = useState<
+ { label: string; onClick: (data: typeof panelsData, tFunction: typeof t) => void }[]
+ >([])
const [overall, setOverall] = useState<Partial<OverallObject>>({})
const [overallPerformance, setOverallPerformance] = useState<Partial<OverallPerformanceObject>>({})
const [isPanelsDataEmpty, setIsPanelsDataEmpty] = useState(false)
const [isNewFunnelOpened, setIsNewFunnelOpened] = useState(false)
const [isAddAViewOpened, setIsAddAViewOpened] = useState(false)
const [analyticsLoading, setAnalyticsLoading] = useState(true)
- const [chartData, setChartData] = useState<any>({})
- const [mainChart, setMainChart] = useState<any>(null)
+
+ // @ts-expect-error
+ const [chartData, setChartData] = useState<TrafficLogResponse['chart'] & { [key: string]: number[] }>({})
+ const [mainChart, setMainChart] = useState<Chart | null>(null)
const [dataLoading, setDataLoading] = useState(false)
const [activeChartMetrics, setActiveChartMetrics] = useState<Record<keyof typeof CHART_METRICS_MAPPING, boolean>>({
[CHART_METRICS_MAPPING.unique]: true,
@@ -418,9 +429,12 @@ const ViewProject = () => {
// sessions
const [sessionsSkip, setSessionsSkip] = useState(0)
const [canLoadMoreSessions, setCanLoadMoreSessions] = useState(false)
- const [sessions, setSessions] = useState<any[]>([])
+ const [sessions, setSessions] = useState<Session[]>([])
const [sessionsLoading, setSessionsLoading] = useState<boolean | null>(null) // null - not loaded, true - loading, false - loaded
- const [activeSession, setActiveSession] = useState<any>(null)
+ const [activeSession, setActiveSession] = useState<{
+ [key: string]: any
+ details: SessionDetailsModel
+ } | null>(null)
const [sessionLoading, setSessionLoading] = useState(false)
const activePSID = useMemo(() => {
return searchParams.get('psid')
@@ -429,9 +443,9 @@ const ViewProject = () => {
// errors
const [errorsSkip, setErrorsSkip] = useState(0)
const [canLoadMoreErrors, setCanLoadMoreErrors] = useState(false)
- const [errors, setErrors] = useState<any[]>([])
+ const [errors, setErrors] = useState<SwetrixError[]>([])
const [errorsLoading, setErrorsLoading] = useState<boolean | null>(null) // null - not loaded, true - loading, false - loaded
- const [activeError, setActiveError] = useState<any>(null)
+ const [activeError, setActiveError] = useState<{ details: SwetrixErrorDetails; [key: string]: any } | null>(null)
const [errorLoading, setErrorLoading] = useState(false)
const [errorStatusUpdating, setErrorStatusUpdating] = useState(false)
const activeEID = useMemo(() => {
@@ -1120,9 +1134,11 @@ const ViewProject = () => {
let data: TrafficLogResponse & {
overall?: OverallObject
}
- let dataCompare: TrafficLogResponse & {
- overall?: OverallObject
- }
+ let dataCompare:
+ | (TrafficLogResponse & {
+ overall?: OverallObject
+ })
+ | null = null
let from
let fromCompare: string | undefined
let to
@@ -1189,6 +1205,8 @@ const ViewProject = () => {
filters,
projectPassword,
)
+
+ // @ts-expect-error
dataCompare.overall = compareOverall[id]
}
}
@@ -1289,14 +1307,11 @@ const ViewProject = () => {
setSearchParams(newSearchParams)
}
- // @ts-expect-error
if (!_isEmpty(dataCompare)) {
- // @ts-expect-error
if (!_isEmpty(dataCompare?.chart)) {
setDataChartCompare(dataCompare.chart)
}
- // @ts-expect-error
if (!_isEmpty(dataCompare?.overall)) {
setOverallCompare(dataCompare.overall)
}
@@ -1307,7 +1322,7 @@ const ViewProject = () => {
} else {
const applyRegions = !_includes(noRegionPeriods, activePeriod?.period)
const bbSettings = getSettings(
- chart,
+ chart as any,
newTimebucket,
activeChartMetrics,
applyRegions,
@@ -1318,7 +1333,7 @@ const ViewProject = () => {
// @ts-expect-error
dataCompare?.chart,
)
- setChartData(chart)
+ setChartData(chart as any)
setPanelsData({
types: _keys(params),
@@ -2028,7 +2043,7 @@ const ViewProject = () => {
}, [authLoading, project, activeChartMetrics, chartData, chartDataPerf, activeChartMetricsPerf, dataChartCompare])
useEffect(() => {
- let sdk: any | null = null
+ let sdk: SwetrixSDK | null = null
const filteredExtensions = _filter(extensions, (ext) => _isString(ext.fileURL))
@@ -2066,7 +2081,7 @@ const ViewProject = () => {
onRemoveExportDataRow: (label: any) => {
setCustomExportTypes((prev) => _filter(prev, (row) => row.label !== label))
},
- onAddPanelTab: (extensionID: string, panelID: string, tabContent?: string, onOpen?: (a: any) => void) => {
+ onAddPanelTab: (extensionID: string, panelID: string, tabContent?: string, onOpen?: () => void) => {
setCustomPanelTabs((prev) => [
...prev,
{
@@ -2789,6 +2804,7 @@ const ViewProject = () => {
labelExtractor={(item) => item.label}
keyExtractor={(item) => item.label}
onSelect={(item, e) => {
+ // @ts-expect-error lookingForMore is defined as an exception above
if (item.lookingForMore) {
e?.stopPropagation()
window.open(MARKETPLACE_URL, '_blank')
@@ -3376,7 +3392,7 @@ const ViewProject = () => {
id={countryActiveTab}
getFilterLink={getFilterLink}
name={<CountryDropdown onSelect={setCountryActiveTab} title={ccPanelName} />}
- data={activeError.params[countryActiveTab]}
+ data={activeError?.params[countryActiveTab]}
rowMapper={rowMapper}
/>
)
@@ -3419,7 +3435,7 @@ const ViewProject = () => {
id={browserActiveTab}
getFilterLink={getFilterLink}
name={<BrowserDropdown onSelect={setBrowserActiveTab} title={brPanelName} />}
- data={activeError.params[browserActiveTab]}
+ data={activeError?.params[browserActiveTab]}
rowMapper={rowMapper}
/>
)
@@ -3469,7 +3485,7 @@ const ViewProject = () => {
id={osActiveTab}
getFilterLink={getFilterLink}
name={<OSDropdown onSelect={setOsActiveTab} title={osPanelName} />}
- data={activeError.params[osActiveTab]}
+ data={activeError?.params[osActiveTab]}
rowMapper={rowMapper}
/>
)
@@ -3483,7 +3499,7 @@ const ViewProject = () => {
id={type}
getFilterLink={getFilterLink}
name={panelName}
- data={activeError.params[type]}
+ data={activeError?.params[type]}
rowMapper={(entry: { name: keyof typeof deviceIconMapping }) => {
const { name: entryName } = entry
@@ -3530,7 +3546,7 @@ const ViewProject = () => {
return decodedUri
}}
- data={activeError.params[pageActiveTab]}
+ data={activeError?.params[pageActiveTab]}
name={<PageDropdown onSelect={setPageActiveTab} title={tnMapping[pageActiveTab]} />}
/>
)
@@ -3544,7 +3560,7 @@ const ViewProject = () => {
id={type}
getFilterLink={getFilterLink}
name={panelName}
- data={activeError.params[type]}
+ data={activeError?.params[type]}
rowMapper={({ name: entryName }: { name: string }) =>
getLocaleDisplayName(entryName, language)
}
@@ -3559,7 +3575,7 @@ const ViewProject = () => {
id={type}
getFilterLink={getFilterLink}
name={panelName}
- data={activeError.params[type]}
+ data={activeError?.params[type]}
/>
)
})
diff --git a/web/app/pages/Project/View/components/ErrorDetails.tsx b/web/app/pages/Project/View/components/ErrorDetails.tsx
index eef87aa49..1fd39d457 100644
--- a/web/app/pages/Project/View/components/ErrorDetails.tsx
+++ b/web/app/pages/Project/View/components/ErrorDetails.tsx
@@ -1,11 +1,10 @@
import { useMemo } from 'react'
import { useTranslation } from 'react-i18next'
+import { SwetrixErrorDetails } from '~/lib/models/Project'
import Tooltip from '~/ui/Tooltip'
import { getRelativeDateIfPossible } from '~/utils/date'
-import { SwetrixErrorDetails } from '../interfaces/error'
-
import { MetricCard } from './MetricCards'
interface ErrorDetailsProps {
diff --git a/web/app/pages/Project/View/components/Errors.tsx b/web/app/pages/Project/View/components/Errors.tsx
index 7bbe83b10..28bf51498 100644
--- a/web/app/pages/Project/View/components/Errors.tsx
+++ b/web/app/pages/Project/View/components/Errors.tsx
@@ -6,12 +6,11 @@ import { useTranslation } from 'react-i18next'
import { Link } from 'react-router'
import { ClientOnly } from 'remix-utils/client-only'
+import { SwetrixError } from '~/lib/models/Project'
import { Badge } from '~/ui/Badge'
import Loader from '~/ui/Loader'
import { getRelativeDateIfPossible } from '~/utils/date'
-import { SwetrixError } from '../interfaces/error'
-
interface ErrorsProps {
errors: SwetrixError[]
}
diff --git a/web/app/pages/Project/View/components/SessionDetails.tsx b/web/app/pages/Project/View/components/SessionDetails.tsx
index efabd4089..7f563be39 100644
--- a/web/app/pages/Project/View/components/SessionDetails.tsx
+++ b/web/app/pages/Project/View/components/SessionDetails.tsx
@@ -4,10 +4,9 @@ import _size from 'lodash/size'
import _truncate from 'lodash/truncate'
import { useTranslation } from 'react-i18next'
+import { SessionDetails as Details } from '~/lib/models/Project'
import { getLocaleDisplayName, getStringFromTime, getTimeFromSeconds } from '~/utils/generic'
-import { SessionDetails as Details } from '../interfaces/session'
-
import CCRow from './CCRow'
import { MetricCard, MetricCardSelect } from './MetricCards'
diff --git a/web/app/pages/Project/View/components/Sessions.tsx b/web/app/pages/Project/View/components/Sessions.tsx
index 10c5b6211..553ba8769 100644
--- a/web/app/pages/Project/View/components/Sessions.tsx
+++ b/web/app/pages/Project/View/components/Sessions.tsx
@@ -7,11 +7,10 @@ import { useTranslation } from 'react-i18next'
import { Link } from 'react-router'
import { ClientOnly } from 'remix-utils/client-only'
+import { Session as SessionType } from '~/lib/models/Project'
import Loader from '~/ui/Loader'
import { getStringFromTime, getTimeFromSeconds } from '~/utils/generic'
-import { Session as SessionType } from '../interfaces/session'
-
import CCRow from './CCRow'
dayjs.extend(duration)
diff --git a/web/app/pages/Project/View/interfaces/error.ts b/web/app/pages/Project/View/interfaces/error.ts
deleted file mode 100644
index cac013e4c..000000000
--- a/web/app/pages/Project/View/interfaces/error.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-export interface SwetrixError {
- eid: string
- name: string
- message: string
- filename: string
- count: number
- last_seen: string
- status: 'active' | 'regressed' | 'fixed'
-}
-
-export interface SwetrixErrorDetails extends SwetrixError {
- colno: number
- lineno: number
- first_seen: string
-}
diff --git a/web/app/pages/Project/View/interfaces/session.ts b/web/app/pages/Project/View/interfaces/session.ts
deleted file mode 100644
index d7d4b72ad..000000000
--- a/web/app/pages/Project/View/interfaces/session.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-export interface Session {
- psid: string
- cc: string | null
- os: string | null
- br: string | null
- pageviews: number
- created: string
- isLive: 1 | 0
- sdur?: number
-
- sessionStart: string
- lastActivity: string
-}
-
-export interface SessionDetails {
- cc: string | null
- os: string | null
- osv: string | null
- br: string | null
- brv: string | null
- lc: string | null
- ref: string | null
- so: string | null
- me: string | null
- ca: string | null
- te: string | null
- co: string | null
- rg: string | null
- ct: string | null
- dv: string | null
-
- sdur?: number
- isLive?: boolean
-}
diff --git a/web/app/pages/Project/View/interfaces/traffic.ts b/web/app/pages/Project/View/interfaces/traffic.ts
index b5eb0e423..aa1321064 100644
--- a/web/app/pages/Project/View/interfaces/traffic.ts
+++ b/web/app/pages/Project/View/interfaces/traffic.ts
@@ -52,7 +52,7 @@ export interface TrafficMeta {
export interface TrafficLogResponse {
params?: Params
- chart?: {
+ chart: {
x: string[]
visits: number[]
uniques: number[]
diff --git a/web/package-lock.json b/web/package-lock.json
index acaf98880..298a45d51 100644
--- a/web/package-lock.json
+++ b/web/package-lock.json
@@ -14,7 +14,7 @@
"@react-router/fs-routes": "^7.5.0",
"@react-router/node": "^7.5.0",
"@react-router/serve": "^7.5.0",
- "@swetrix/sdk": "^1.1.0",
+ "@swetrix/sdk": "^1.2.0",
"@tailwindcss/vite": "^4.1.4",
"@ua-parser-js/pro-business": "^2.0.3",
"axios": "^1.8.4",
@@ -1299,6 +1299,16 @@
"node": ">=6.0.0"
}
},
+ "node_modules/@jridgewell/source-map": {
+ "version": "0.3.6",
+ "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.6.tgz",
+ "integrity": "sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/gen-mapping": "^0.3.5",
+ "@jridgewell/trace-mapping": "^0.3.25"
+ }
+ },
"node_modules/@jridgewell/sourcemap-codec": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz",
@@ -2239,6 +2249,76 @@
}
}
},
+ "node_modules/@rollup/plugin-terser": {
+ "version": "0.4.4",
+ "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.4.tgz",
+ "integrity": "sha512-XHeJC5Bgvs8LfukDwWZp7yeqin6ns8RTl2B9avbejt6tZqsqvVoWI7ZTQrcNsfKEDWBTnTxM8nMDkO2IFFbd0A==",
+ "license": "MIT",
+ "dependencies": {
+ "serialize-javascript": "^6.0.1",
+ "smob": "^1.0.0",
+ "terser": "^5.17.4"
+ },
+ "engines": {
+ "node": ">=14.0.0"
+ },
+ "peerDependencies": {
+ "rollup": "^2.0.0||^3.0.0||^4.0.0"
+ },
+ "peerDependenciesMeta": {
+ "rollup": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@rollup/plugin-typescript": {
+ "version": "12.1.2",
+ "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-12.1.2.tgz",
+ "integrity": "sha512-cdtSp154H5sv637uMr1a8OTWB0L1SWDSm1rDGiyfcGcvQ6cuTs4MDk2BVEBGysUWago4OJN4EQZqOTl/QY3Jgg==",
+ "license": "MIT",
+ "dependencies": {
+ "@rollup/pluginutils": "^5.1.0",
+ "resolve": "^1.22.1"
+ },
+ "engines": {
+ "node": ">=14.0.0"
+ },
+ "peerDependencies": {
+ "rollup": "^2.14.0||^3.0.0||^4.0.0",
+ "tslib": "*",
+ "typescript": ">=3.7.0"
+ },
+ "peerDependenciesMeta": {
+ "rollup": {
+ "optional": true
+ },
+ "tslib": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@rollup/pluginutils": {
+ "version": "5.1.4",
+ "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.4.tgz",
+ "integrity": "sha512-USm05zrsFxYLPdWWq+K3STlWiT/3ELn3RcV5hJMghpeAIhxfsUIg6mt12CBJBInWMV4VneoV7SfGv8xIwo2qNQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/estree": "^1.0.0",
+ "estree-walker": "^2.0.2",
+ "picomatch": "^4.0.2"
+ },
+ "engines": {
+ "node": ">=14.0.0"
+ },
+ "peerDependencies": {
+ "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0"
+ },
+ "peerDependenciesMeta": {
+ "rollup": {
+ "optional": true
+ }
+ }
+ },
"node_modules/@rollup/rollup-android-arm-eabi": {
"version": "4.40.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.40.0.tgz",
@@ -2494,29 +2574,15 @@
}
},
"node_modules/@swetrix/sdk": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/@swetrix/sdk/-/sdk-1.1.0.tgz",
- "integrity": "sha512-ck5JMf5kw5gSp3G5MZJz0Y0KuBItBB4knVr7DgeHgSRdF3UWI0jIKiPWwzHT4dHrnMcbgyIP2Io6yt0DOsmYhA==",
- "dependencies": {
- "@types/node": "^18.8.5"
- },
- "funding": {
- "url": "https://ko-fi.com/andriir"
- }
- },
- "node_modules/@swetrix/sdk/node_modules/@types/node": {
- "version": "18.19.86",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.86.tgz",
- "integrity": "sha512-fifKayi175wLyKyc5qUfyENhQ1dCNI1UNjp653d8kuYcPQN5JhX3dGuP/XmvPTg/xRBn1VTLpbmi+H/Mr7tLfQ==",
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/@swetrix/sdk/-/sdk-1.2.0.tgz",
+ "integrity": "sha512-zVOV/XV+AAA8HeoXGcj41Pc6A2ZP3YqWPN1r/nJvBQiftAeptLkRFnDcgPNw2QAHkhHTy7IP0WYMNcuBDeBlJg==",
+ "license": "AGPL-3.0",
"dependencies": {
- "undici-types": "~5.26.4"
+ "@rollup/plugin-terser": "^0.4.4",
+ "@rollup/plugin-typescript": "^12.1.2"
}
},
- "node_modules/@swetrix/sdk/node_modules/undici-types": {
- "version": "5.26.5",
- "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
- "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="
- },
"node_modules/@tailwindcss/forms": {
"version": "0.5.10",
"resolved": "https://registry.npmjs.org/@tailwindcss/forms/-/forms-0.5.10.tgz",
@@ -5900,6 +5966,12 @@
"node": ">=4.0"
}
},
+ "node_modules/estree-walker": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
+ "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
+ "license": "MIT"
+ },
"node_modules/esutils": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
@@ -8270,8 +8342,7 @@
"node_modules/path-parse": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
- "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
- "devOptional": true
+ "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="
},
"node_modules/path-scurry": {
"version": "1.11.1",
@@ -8609,6 +8680,15 @@
}
]
},
+ "node_modules/randombytes": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
+ "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==",
+ "license": "MIT",
+ "dependencies": {
+ "safe-buffer": "^5.1.0"
+ }
+ },
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
@@ -8986,7 +9066,6 @@
"version": "1.22.10",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz",
"integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==",
- "devOptional": true,
"dependencies": {
"is-core-module": "^2.16.0",
"path-parse": "^1.0.7",
@@ -9253,6 +9332,15 @@
"node": ">= 0.8"
}
},
+ "node_modules/serialize-javascript": {
+ "version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz",
+ "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "randombytes": "^2.1.0"
+ }
+ },
"node_modules/serve-static": {
"version": "1.16.2",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz",
@@ -9423,6 +9511,12 @@
"url": "https://github.com/sponsors/isaacs"
}
},
+ "node_modules/smob": {
+ "version": "1.5.0",
+ "resolved": "https://registry.npmjs.org/smob/-/smob-1.5.0.tgz",
+ "integrity": "sha512-g6T+p7QO8npa+/hNx9ohv1E5pVCmWrVCUzUXJyLdMmftX6ER0oiWY/w9knEonLpnOp6b6FenKnMfR8gqwWdwig==",
+ "license": "MIT"
+ },
"node_modules/smol-toml": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.3.1.tgz",
@@ -9775,7 +9869,6 @@
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
- "devOptional": true,
"engines": {
"node": ">= 0.4"
},
@@ -9809,6 +9902,30 @@
"node": ">=6"
}
},
+ "node_modules/terser": {
+ "version": "5.39.2",
+ "resolved": "https://registry.npmjs.org/terser/-/terser-5.39.2.tgz",
+ "integrity": "sha512-yEPUmWve+VA78bI71BW70Dh0TuV4HHd+I5SHOAfS1+QBOmvmCiiffgjR8ryyEd3KIfvPGFqoADt8LdQ6XpXIvg==",
+ "license": "BSD-2-Clause",
+ "dependencies": {
+ "@jridgewell/source-map": "^0.3.3",
+ "acorn": "^8.14.0",
+ "commander": "^2.20.0",
+ "source-map-support": "~0.5.20"
+ },
+ "bin": {
+ "terser": "bin/terser"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/terser/node_modules/commander": {
+ "version": "2.20.3",
+ "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
+ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
+ "license": "MIT"
+ },
"node_modules/timezone-soft": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/timezone-soft/-/timezone-soft-1.5.2.tgz",
diff --git a/web/package.json b/web/package.json
index 01598b688..e67c0721a 100644
--- a/web/package.json
+++ b/web/package.json
@@ -28,7 +28,7 @@
"@react-router/fs-routes": "^7.5.0",
"@react-router/node": "^7.5.0",
"@react-router/serve": "^7.5.0",
- "@swetrix/sdk": "^1.1.0",
+ "@swetrix/sdk": "^1.2.0",
"@tailwindcss/vite": "^4.1.4",
"@ua-parser-js/pro-business": "^2.0.3",
"axios": "^1.8.4",