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 improvement/views

Andrii Romasiunffce69bc0be9
diff --cc apps/production/src/project/project.service.ts
index da98628f6,7442a2eb1..775ffc0cb
--- a/apps/production/src/project/project.service.ts
+++ b/apps/production/src/project/project.service.ts
@@@ -71,7 -72,8 +75,9 @@@ import
import { ReportFrequency } from './enums'
import { nFormatter } from '../common/utils'
import { browserArgs } from '../og-image/og-image.service'
+import { CreateProjectViewDto } from './dto/create-project-view.dto'
+ import { TimeFrameQueryEnum } from './dto/get-prediction-query.dto'
+ import { AppLoggerService } from '../logger/logger.service'
dayjs.extend(utc)
@@@ -1350,18 -1354,24 +1358,39 @@@ export class ProjectService
return this.projectsRepository.findOne({ relations, where: { id } })
}
+ filterUnsupportedColumns(
+ filters: CreateProjectViewDto['filters'],
+ ): CreateProjectViewDto['filters'] {
+ if (!filters) {
+ return []
+ }
+
+ return _filter(
+ filters,
+ ({ column }) =>
+ _includes(ALL_COLUMNS, column) ||
+ _includes(TRAFFIC_METAKEY_COLUMNS, column),
+ )
+ }
++
+ async sendPredictAiRequest(id: string, timeframe: TimeFrameQueryEnum) {
+ try {
+ const { data } = await firstValueFrom(
+ this.httpService.get('/predict/', {
+ params: { pid: id, timeframe },
+ }),
+ )
+ return data
+ } catch (error) {
+ if (error instanceof AxiosError && error.response?.status === 404) {
+ throw new NotFoundException(
+ 'Data not found. Prediction is not available for this timeframe.',
+ )
+ }
+ this.logger.error(
+ `Error receiving prediction from AI service: ${error.message}`,
+ )
+ return null
+ }
+ }
}