services refactor
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user