event.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from datetime import datetime
  2. from typing import Annotated, Any, Literal, Optional, Union
  3. from pydantic import WrapValidator
  4. from .base import LaxIngestSchema
  5. from .utils import invalid_to_none
  6. Level = Literal["fatal", "error", "warning", "info", "debug"]
  7. class EventBreadcrumb(LaxIngestSchema):
  8. type: Optional[str] = "default"
  9. category: Optional[str] = None
  10. message: Optional[str] = None
  11. data: Optional[dict[str, Any]] = None
  12. level: Annotated[Optional[Level], WrapValidator(invalid_to_none)] = "info"
  13. timestamp: Optional[datetime] = None
  14. ListKeyValue = list[list[Optional[str]]]
  15. """
  16. dict[str, list[str]] but stored as a list[list[:2]] for OSS Sentry compatibility
  17. [["animal", "cat"], ["animal", "dog"], ["thing": "kettle"]]
  18. This format is often used for http needs including headers and querystrings
  19. """
  20. class BaseRequest(LaxIngestSchema):
  21. """Base Request class for event ingest and issue event API"""
  22. api_target: Optional[str] = None
  23. body_size: Optional[int] = None
  24. cookies: Optional[
  25. Union[str, list[list[Optional[str]]], dict[str, Optional[str]]]
  26. ] = None
  27. data: Optional[Union[str, dict, list, Any]] = None
  28. env: Optional[dict[str, Any]] = None
  29. fragment: Optional[str] = None
  30. method: Optional[str] = None
  31. protocol: Optional[str] = None
  32. url: Optional[str] = None
  33. class BaseIssueEvent(LaxIngestSchema):
  34. """
  35. Base Issue Event for fields present from the SDK data, json event, and api event
  36. """
  37. platform: Optional[str] = None