openreplay/frontend/app/mstore/aiSummaryStore.ts
Delirium 80f0005362
feat(ui): timeline zoom (#1982)
* feat(ui): timeline zoom

* stable draggable markers

* integrate zoom into panels, ready up ai stuff for zoom

* tabs for ai, slider styles

* fixes for zoom tabs

* code style
2024-03-22 15:17:46 +01:00

59 lines
1.3 KiB
TypeScript

import { makeAutoObservable } from 'mobx';
import { aiService } from 'App/services';
export default class AiSummaryStore {
text = '';
toggleSummary = false;
isLoading = false;
constructor() {
makeAutoObservable(this);
}
setText(text: string) {
this.text = text;
}
setToggleSummary(toggleSummary: boolean) {
this.toggleSummary = toggleSummary;
}
setLoading(loading: boolean) {
this.isLoading = loading;
}
getSummary = async (sessionId: string) => {
if (this.isLoading) return;
this.setLoading(true);
this.setText('');
try {
const respText = await aiService.getSummary(sessionId);
if (!respText) return;
this.setText(respText);
} catch (e) {
console.error(e);
} finally {
this.setLoading(false);
}
};
getDetailedSummary = async (sessionId: string, networkEvents: any[], feat: 'errors' | 'issues' | 'journey', startTs: number, endTs: number) => {
if (this.isLoading) return;
this.setLoading(true);
this.setText('');
try {
const respText = await aiService.getDetailedSummary(sessionId, networkEvents,feat, startTs, endTs);
if (!respText) return;
this.setText(respText);
} catch (e) {
console.error(e);
} finally {
this.setLoading(false);
}
}
}