services refactor

This commit is contained in:
2025-12-17 22:17:02 +01:00
parent 26f7a2b6aa
commit 055a7f67b5
93 changed files with 7434 additions and 659 deletions

View File

@@ -1,9 +1,36 @@
import { api as api } from '../../api';
import { AnalyticsApiClient } from '../../api/analytics/AnalyticsApiClient';
import type { RecordPageViewInputDto, RecordPageViewOutputDto, RecordEngagementInputDto, RecordEngagementOutputDto } from '../../dtos';
export async function recordPageView(input: any): Promise<any> {
return await api.analytics.recordPageView(input);
}
/**
* Analytics Service
*
* Orchestrates analytics operations by coordinating API calls.
* All dependencies are injected via constructor.
*/
export class AnalyticsService {
constructor(
private readonly apiClient: AnalyticsApiClient
) {}
export async function recordEngagement(input: any): Promise<any> {
return await api.analytics.recordEngagement(input);
/**
* Record a page view
*/
async recordPageView(input: RecordPageViewInputDto): Promise<RecordPageViewOutputDto> {
try {
return await this.apiClient.recordPageView(input);
} catch (error) {
throw error;
}
}
/**
* Record an engagement event
*/
async recordEngagement(input: RecordEngagementInputDto): Promise<RecordEngagementOutputDto> {
try {
return await this.apiClient.recordEngagement(input);
} catch (error) {
throw error;
}
}
}