📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Remove unused code
Blue Mouseee47c353b307
diff --git a/backend/apps/cloud/src/analytics/analytics.controller.ts b/backend/apps/cloud/src/analytics/analytics.controller.tsindex fe8bb73bc..c7e01e932 100644--- a/backend/apps/cloud/src/analytics/analytics.controller.ts+++ b/backend/apps/cloud/src/analytics/analytics.controller.ts@@ -894,57 +894,6 @@ export class AnalyticsController {)}- @Get('captcha/birdseye')- @Auth(true, true)- // returns overall short statistics per CAPTCHA project- async getCaptchaOverallStats(- @Query() data: GetOverallStatsDto,- @CurrentUserId() uid: string,- ) {- const {- pids,- pid,- period,- from,- to,- timezone = DEFAULT_TIMEZONE,- filters,- } = data- const pidsArray = getPIDsArray(pids, pid)-- const validPids = []-- const validationPromises = _map(pidsArray, async currentPID => {- await this.analyticsService.checkProjectAccess(currentPID, uid)-- await this.analyticsService.checkBillingAccess(currentPID)-- validPids.push(currentPID)- })-- try {- await Promise.allSettled(validationPromises)- } catch {- //- }-- if (_isEmpty(validPids)) {- throw new HttpException(- 'The data could not be loaded for the selected projects. It is possible that the projects are not accessible to you or the account owner has been suspended.',- HttpStatus.PAYMENT_REQUIRED,- )- }-- return this.analyticsService.getCaptchaSummary(- validPids,- period,- from,- to,- timezone,- filters,- )- }-@Get('performance/birdseye')@Auth(true, true)async getPerformanceOverallStats(diff --git a/backend/apps/cloud/src/analytics/analytics.service.ts b/backend/apps/cloud/src/analytics/analytics.service.tsindex 006c678ed..692f7acec 100644--- a/backend/apps/cloud/src/analytics/analytics.service.ts+++ b/backend/apps/cloud/src/analytics/analytics.service.ts@@ -90,7 +90,6 @@ import {IFunnelCHResponse,IFunnel,IOverall,- IOverallCaptcha,IOverallPerformance,IPageflow,PerfMeasure,@@ -1533,133 +1532,6 @@ export class AnalyticsService {return data[0]?.c || 0}- async getCaptchaSummary(- pids: string[],- period?: string,- from?: string,- to?: string,- timezone?: string,- filters?: string,- ): Promise<IOverallCaptcha> {- let _from: string-- let _to: string-- if (_isEmpty(period) || ['today', 'yesterday', 'custom'].includes(period)) {- const safeTimezone = this.getSafeTimezone(timezone)-- const { groupFrom, groupTo } = this.getGroupFromTo(- from,- to,- ['today', 'yesterday'].includes(period) ? TimeBucketType.HOUR : null,- period,- safeTimezone,- )-- _from = groupFrom- _to = groupTo- }-- const result = {}-- const [filtersQuery, filtersParams] = this.getFiltersQuery(- filters,- DataType.CAPTCHA,- true,- )-- const promises = pids.map(async pid => {- try {- if (period === 'all') {- const queryAll = `SELECT count(*) AS all FROM captcha WHERE pid = {pid:FixedString(12)} ${filtersQuery}`- const { data } = await clickhouse- .query({- query: queryAll,- query_params: { pid, ...filtersParams },- })- .then(resultSet => resultSet.json<Partial<BirdseyeCHResponse>>())-- result[pid] = {- current: {- all: data[0].all,- },- previous: {- all: 0,- },- change: data[0].all,- }- return- }-- let now: string- let periodFormatted: string- let periodSubtracted: string-- if (_from && _to) {- // diff may be 0 (when selecting data for 1 day), so let's make it 1 to grab some data for the prev day as well- const diff = dayjs(_to).diff(dayjs(_from), 'days') || 1-- now = _to- periodFormatted = _from- periodSubtracted = dayjs(_from)- .subtract(diff, 'days')- .format('YYYY-MM-DD HH:mm:ss')- } else {- const amountToSubtract = parseInt(period, 10)- const unit = _replace(period, /[0-9]/g, '') as dayjs.ManipulateType-- now = dayjs.utc().format('YYYY-MM-DD HH:mm:ss')- const periodRaw = dayjs.utc().subtract(amountToSubtract, unit)- periodFormatted = periodRaw.format('YYYY-MM-DD HH:mm:ss')- periodSubtracted = periodRaw- .subtract(amountToSubtract, unit)- .format('YYYY-MM-DD HH:mm:ss')- }-- const queryCurrent = `SELECT 1 AS sortOrder, count(*) AS all FROM captcha WHERE pid = {pid:FixedString(12)} AND created BETWEEN {periodFormatted:String} AND {now:String} ${filtersQuery}`- const queryPrevious = `SELECT 2 AS sortOrder, count(*) AS all FROM captcha WHERE pid = {pid:FixedString(12)} AND created BETWEEN {periodSubtracted:String} AND {periodFormatted:String} ${filtersQuery}`-- const query = `${queryCurrent} UNION ALL ${queryPrevious}`-- let { data } = await clickhouse- .query({- query,- query_params: {- pid,- periodFormatted,- periodSubtracted,- now,- ...filtersParams,- },- })- .then(resultSet => resultSet.json<Partial<BirdseyeCHResponse>>())-- data = _sortBy(data, 'sortOrder')-- const currentPeriod = data[0]- const previousPeriod = data[1]-- result[pid] = {- current: {- all: currentPeriod.all,- },- previous: {- all: previousPeriod.all,- },- change: currentPeriod.all - previousPeriod.all,- }- } catch {- throw new InternalServerErrorException(- "Can't process the provided PID. Please, try again later.",- )- }- })-- await Promise.all(promises)-- return result- }-convertSummaryToObsoleteFormat(summary: IOverall): any {const result = {}diff --git a/backend/apps/cloud/src/analytics/interfaces/index.ts b/backend/apps/cloud/src/analytics/interfaces/index.tsindex 394c15d76..d1e7c4390 100644--- a/backend/apps/cloud/src/analytics/interfaces/index.ts+++ b/backend/apps/cloud/src/analytics/interfaces/index.ts@@ -140,16 +140,6 @@ interface IOverallPeriodStats {sdur: number}-interface ICaptchaObject {- current: {- all: number- }- previous: {- all: number- }- change: number-}-interface IPerformanceObject {current: {frontend: number@@ -180,10 +170,6 @@ export interface IOverall {[key: string]: IOverallObject}-export interface IOverallCaptcha {- [key: string]: ICaptchaObject-}-export interface IOverallPerformance {[key: string]: IPerformanceObject}diff --git a/web/app/api/index.ts b/web/app/api/index.tsindex ba1d5eed8..0a5b783c0 100644--- a/web/app/api/index.ts+++ b/web/app/api/index.ts@@ -916,25 +916,6 @@ export const getPerformanceOverallStats = (throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message})-export const getOverallStatsCaptcha = (- pids: string[],- period: string,- from = '',- to = '',- timezone = 'Etc/GMT',- filters: any = '',-) =>- api- .get(- `log/captcha/birdseye?pids=[${_map(pids, (pid) => `"${pid}"`).join(- ',',- )}]&period=${period}&from=${from}&to=${to}&timezone=${timezone}&filters=${JSON.stringify(filters)}`,- )- .then((response): Overall => response.data)- .catch((error) => {- throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message- })-export const getLiveVisitors = (pids: string[], password?: string): Promise<LiveStats> =>api.get(`log/hb?pids=[${_map(pids, (pid) => `"${pid}"`).join(',')}]`, {diff --git a/web/app/lib/constants/index.ts b/web/app/lib/constants/index.tsindex 20f907f0a..f1e78deb3 100644--- a/web/app/lib/constants/index.ts+++ b/web/app/lib/constants/index.ts@@ -139,76 +139,6 @@ export const tbPeriodPairs = (},]-export const captchaTbPeriodPairs = (- t: typeof i18nextT,- tbs?: TimeBucket[] | null,- dates?: Date[] | null,- language?: string,-): TBPeriodPairsProps[] => [- {- label: t('project.thisHour'),- period: '1h',- tbs: ['minute'],- },- {- label: t('project.today'),- period: 'today',- tbs: ['hour'],- },- {- label: t('project.yesterday'),- period: 'yesterday',- tbs: ['hour'],- },- {- label: t('project.last24h'),- period: '1d',- countDays: 1,- tbs: ['hour'],- },- {- label: t('project.lastXDays', { amount: 7 }),- period: '7d',- tbs: ['hour', 'day'],- countDays: 7,- },- {- label: t('project.lastXWeeks', { amount: 4 }),- period: '4w',- tbs: ['day'],- countDays: 28,- },- {- label: t('project.lastXMonths', { amount: 3 }),- period: '3M',- tbs: ['month'],- countDays: 90,- },- {- label: t('project.lastXMonths', { amount: 12 }),- period: '12M',- tbs: ['month'],- countDays: 365,- },- {- label: t('project.lastXMonths', { amount: 24 }),- period: '24M',- tbs: ['month'],- },- {- label: t('project.all'),- period: 'all',- tbs: ['month', 'year'],- },- {- label: dates ? getCustomLabel(dates, t, language) : t('project.custom'),- dropdownLabel: t('project.custom'),- isCustomDate: true,- period: 'custom',- tbs: tbs || ['month'],- },-]-export const FILTERS_PERIOD_PAIRS = ['1d', '7d', '4w', '3M', '12M', 'custom', 'compare']// TODO: add 'custom' later after an issue with it is resolved@@ -366,7 +296,6 @@ export const MARKETPLACE_URL = 'https://marketplace.swetrix.com'export const DOCS_URL = 'https://docs.swetrix.com'export const INTEGRATIONS_URL = 'https://docs.swetrix.com/integrations'export const ERROR_TRACKING_DOCS_URL = 'https://docs.swetrix.com/error-tracking'-export const CAPTCHA_URL = 'https://captcha.swetrix.com'export const DOCS_REFERRAL_PROGRAM_URL = `${DOCS_URL}/affiliate/about`// Referral programdiff --git a/web/app/ui/Text.tsx b/web/app/ui/Text.tsxindex 31826a575..d65ea0ef0 100644--- a/web/app/ui/Text.tsx+++ b/web/app/ui/Text.tsx@@ -7,7 +7,7 @@ type TextSize = 'xs' | 'sm' | 'base' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl'type TextWeight = 'light' | 'normal' | 'medium' | 'semibold' | 'bold'type TextColour = 'primary' | 'secondary' | 'muted' | 'success' | 'warning' | 'error' | 'inherit'-export interface TextProps {+interface TextProps {children: React.ReactNodeas?: TextElementsize?: TextSize