33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import { AnalyticsApiClient } from '../../api/analytics/AnalyticsApiClient';
|
|
import { RecordPageViewOutputViewModel } from '../../view-models/RecordPageViewOutputViewModel';
|
|
import { RecordEngagementOutputViewModel } from '../../view-models/RecordEngagementOutputViewModel';
|
|
import { RecordPageViewInputDTO } from '../../types/generated/RecordPageViewInputDTO';
|
|
import { RecordEngagementInputDTO } from '../../types/generated/RecordEngagementInputDTO';
|
|
|
|
/**
|
|
* 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<RecordPageViewOutputViewModel> {
|
|
const result = await this.apiClient.recordPageView(input);
|
|
return new RecordPageViewOutputViewModel(result);
|
|
}
|
|
|
|
/**
|
|
* Record an engagement event
|
|
*/
|
|
async recordEngagement(input: RecordEngagementInputDTO): Promise<RecordEngagementOutputViewModel> {
|
|
const result = await this.apiClient.recordEngagement(input);
|
|
return new RecordEngagementOutputViewModel(result);
|
|
}
|
|
} |