openreplay/frontend/app/services/SessionService.ts
2022-09-30 11:57:43 +02:00

32 lines
842 B
TypeScript

import APIClient from 'App/api_client';
import { fetchErrorCheck } from 'App/utils';
export default class SettingsService {
private client: APIClient;
constructor(client?: APIClient) {
this.client = client ? client : new APIClient();
}
initClient(client?: APIClient) {
this.client = client || new APIClient();
}
saveCaptureRate(data: any) {
return this.client.post('/sample_rate', data);
}
fetchCaptureRate() {
return this.client
.get('/sample_rate')
.then((response) => response.json())
.then((response) => response.data || 0);
}
getSessions(filter: any) {
return this.client
.post('/sessions/search', filter)
.then(fetchErrorCheck)
.then((response) => response.data || []);
}
}