36 lines
972 B
TypeScript
36 lines
972 B
TypeScript
import { AnalyticsApiClient } from '../../api/analytics/AnalyticsApiClient';
|
|
import type { RecordPageViewInputDto, RecordPageViewOutputDto, RecordEngagementInputDto, RecordEngagementOutputDto } from '../../dtos';
|
|
|
|
/**
|
|
* Analytics Service
|
|
*
|
|
* Orchestrates analytics operations by coordinating API calls.
|
|
* All dependencies are injected via constructor.
|
|
*/
|
|
export class AnalyticsService {
|
|
constructor(
|
|
private readonly apiClient: AnalyticsApiClient
|
|
) {}
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
}
|
|
} |