📈 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
move interfaces into a separate directory
Blue Mouse250b128bdbf6
diff --git a/src/analytics/analytics.controller.ts b/src/analytics/analytics.controller.tsindex f4157ee40..c86573683 100644--- a/src/analytics/analytics.controller.ts+++ b/src/analytics/analytics.controller.ts@@ -41,7 +41,6 @@ import {isValidDate,checkIfTBAllowed,getHeartbeatKey,- IUserFlow,} from './analytics.service'import { TaskManagerService } from '../task-manager/task-manager.service'import { CurrentUserId } from '../auth/decorators/current-user-id.decorator'@@ -69,6 +68,7 @@ import {import { BotDetection } from '../common/decorators/bot-detection.decorator'import { BotDetectionGuard } from '../common/guards/bot-detection.guard'import { GetCustomEventsDto } from './dto/get-custom-events.dto'+import { IUserFlow } from './interfaces'// eslint-disable-next-line @typescript-eslint/no-var-requiresconst mysql = require('mysql2')diff --git a/src/analytics/analytics.service.ts b/src/analytics/analytics.service.tsindex a02604e87..ceadd8e36 100644--- a/src/analytics/analytics.service.ts+++ b/src/analytics/analytics.service.ts@@ -50,6 +50,15 @@ import { EventsDTO } from './dto/events.dto'import { ProjectService } from '../project/project.service'import { Project } from '../project/entity/project.entity'import { TimeBucketType } from './dto/getData.dto'+import {+ ChartCHResponse,+ CustomsCHResponse,+ IGetGroupFromTo,+ GetFiltersQuery,+ IUserFlowNode,+ IUserFlowLink,+ IUserFlow,+} from './interfaces'dayjs.extend(utc)dayjs.extend(dayjsTimezone)@@ -80,23 +89,6 @@ export const captchaColumns = ['cc', 'br', 'os', 'dv']export const perfCols = ['cc', 'pg', 'dv', 'br']-interface ChartCHResponse {- index: number- unique: number- 'count()': number-}--interface CustomsCHResponse {- ev: string- 'count()': number- index: number-}--interface IGetGroupFromTo {- groupFrom: string- groupTo: string-}-const validPeriods = ['today','yesterday',@@ -128,30 +120,6 @@ const timeBucketToDays = [// eslint-disable-next-line no-useless-escapeconst customEVvalidate = /^[a-zA-Z](?:[\w\.]){0,62}$/-interface GetFiltersQuery extends Array<string | object> {- // SQL query- 0: string- // an object that has structure like { cf_pg: '/signup', ev_exclusive: false }- 1: { [key: string]: string | boolean }- // an array of objects like [{ "column":"pg", "filter":"/signup", "isExclusive":true }]- 2: Array<{ [key: string]: string }> | []-}--interface IUserFlowNode {- id: string-}--interface IUserFlowLink {- source: string- target: string- value: number-}--export interface IUserFlow {- nodes: IUserFlowNode[]- links: IUserFlowLink[]-}-export const isValidTimezone = (timezone: string): boolean => {if (_isEmpty(timezone)) {return falsediff --git a/src/analytics/interfaces/index.ts b/src/analytics/interfaces/index.tsnew file mode 100644index 000000000..f895739af--- /dev/null+++ b/src/analytics/interfaces/index.ts@@ -0,0 +1,40 @@+export interface ChartCHResponse {+ index: number+ unique: number+ 'count()': number+}++export interface CustomsCHResponse {+ ev: string+ 'count()': number+ index: number+}++export interface IGetGroupFromTo {+ groupFrom: string+ groupTo: string+}++export interface GetFiltersQuery extends Array<string | object> {+ // SQL query+ 0: string+ // an object that has structure like { cf_pg: '/signup', ev_exclusive: false }+ 1: { [key: string]: string | boolean }+ // an array of objects like [{ "column":"pg", "filter":"/signup", "isExclusive":true }]+ 2: Array<{ [key: string]: string }> | []+}++export interface IUserFlowNode {+ id: string+}++export interface IUserFlowLink {+ source: string+ target: string+ value: number+}++export interface IUserFlow {+ nodes: IUserFlowNode[]+ links: IUserFlowLink[]+}