Files
MyClub/frontend/src/services/errors.ts
T
Tomas Dvorak 8762bde4bf dev day #89
2025-11-11 10:29:30 +01:00

73 lines
1.7 KiB
TypeScript

import api from './api';
export interface ErrorEvent {
id: number;
origin: string;
language?: string;
severity?: string;
message: string;
stack?: string;
component?: string;
file?: string;
line?: number;
column?: number;
url?: string;
method?: string;
status?: number;
request_id?: string;
user_id?: number;
session_token?: string;
tags?: Record<string, any> | null;
context?: Record<string, any> | null;
env?: string;
version?: string;
hostname?: string;
occurred_at: string;
created_at: string;
}
export interface ErrorListResponse {
items: ErrorEvent[];
total: number;
}
export async function getErrors(params?: {
origin?: string;
severity?: string;
method?: string;
status?: string | number;
search?: string;
from?: string; // ISO
to?: string; // ISO
page?: number;
limit?: number;
}): Promise<ErrorListResponse> {
const res = await api.get('/admin/errors', { params });
return res.data as ErrorListResponse;
}
export async function getError(id: number): Promise<ErrorEvent> {
const res = await api.get(`/admin/errors/${id}`);
return res.data as ErrorEvent;
}
export async function getExternalErrors(params?: {
origin?: string;
severity?: string;
method?: string;
status?: string | number;
search?: string;
from?: string; // ISO
to?: string; // ISO
page?: number;
limit?: number;
}): Promise<ErrorListResponse> {
const res = await api.get('/admin/errors/external', { params });
return res.data as ErrorListResponse;
}
export async function getExternalError(id: number): Promise<ErrorEvent> {
const res = await api.get(`/admin/errors/external/${id}`);
return res.data as ErrorEvent;
}