Spaces:
Sleeping

File size: 754 Bytes
358492d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""Client-side error reporting."""
from fastapi import APIRouter, Depends
from pydantic import BaseModel
from app.core.dependencies import get_current_user
from app.models.user import User
import logging

logger = logging.getLogger(__name__)
router = APIRouter(prefix="/errors", tags=["Error Reporting"])


class ErrorReport(BaseModel):
    screen: str
    error: str
    context: str = ""
    platform: str = "flutter"
    timestamp: str = ""


@router.post("/report")
async def report_error(
    body: ErrorReport,
    user: User = Depends(get_current_user),
):
    logger.warning(
        f"Client error | user={user.id} | "
        f"screen={body.screen} | error={body.error} | "
        f"context={body.context}"
    )
    return {"received": True}