Merge branch 'CLIENT-5942-month-view-screen-res' into 'main'
[ProtonMail-WebClient.git] / packages / metrics / lib / MetricsBase.ts
blob64d826ce5bcca5bf182355ac860761b734298494
1 import type IMetricsRequestService from './types/IMetricsRequestService';
3 export default class MetricsBase {
4     protected requestService: IMetricsRequestService;
6     constructor(requestService: IMetricsRequestService) {
7         this.requestService = requestService;
8     }
10     public init({ uid, clientID, appVersion }: { uid: string; clientID: string; appVersion: string }) {
11         this.setAuthHeaders(uid);
12         this.setVersionHeaders(clientID, appVersion);
13     }
15     public setVersionHeaders(clientID: string, appVersion: string) {
16         this.requestService.api.setVersionHeaders(clientID, appVersion);
17     }
19     public setAuthHeaders(uid: string, accessToken?: string) {
20         this.requestService.api.setAuthHeaders(uid, accessToken);
21     }
23     public clearAuthHeaders() {
24         this.requestService.api.setAuthHeaders('');
25     }
27     public setReportMetrics(reportMetrics: boolean) {
28         this.requestService.setReportMetrics(reportMetrics);
29     }
31     public processAllRequests() {
32         return this.requestService.processAllRequests();
33     }
35     public stopBatchingProcess() {
36         return this.requestService.stopBatchingProcess();
37     }
39     public startBatchingProcess() {
40         return this.requestService.startBatchingProcess();
41     }