Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ skip-magic-trailing-comma = false
line-ending = "auto"

[tool.mypy]
plugins = ["pydantic.mypy"]
mypy_path = "src"
explicit_package_bases = true
namespace_packages = true
Expand All @@ -82,15 +81,10 @@ check_untyped_defs = true
no_implicit_reexport = true
disallow_untyped_defs = false

[tool.pydantic-mypy]
init_forbid_extra = true
init_typed = true
warn_required_dynamic_aliases = true

[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = "test_*.py"
addopts = "-ra -q --cov=src/uipath --cov-report=term-missing"
addopts = "-ra -q --cov=src/aptabase --cov-report=term-missing"
asyncio_default_fixture_loop_scope = "function"
asyncio_mode = "auto"

Expand Down
10 changes: 5 additions & 5 deletions src/aptabase/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def __init__(
flush_interval: float = 10.0,
timeout: float = 30.0,
) -> None:
"""
Initialize the Aptabase client.
"""Initialize the Aptabase client.

Args:
app_key: Your Aptabase app key (format: A-{REGION}-{ID})
Expand Down Expand Up @@ -63,7 +62,7 @@ def __init__(
self._event_queue: list[Event] = []
self._queue_lock = asyncio.Lock()
self._client: httpx.AsyncClient | None = None
self._flush_task: asyncio.Task | None = None
self._flush_task: asyncio.Task[Any] | None = None
self._session_id: str | None = None

def _get_base_url(self, app_key: str) -> str:
Expand Down Expand Up @@ -123,8 +122,7 @@ async def track(
*,
session_id: str | None = None,
) -> None:
"""
Track an analytics event.
"""Track an analytics event.

Args:
event_name: Name of the event to track
Expand Down Expand Up @@ -172,6 +170,8 @@ async def _flush_events(self) -> None:

async def _send_events(self, events: list[Event]) -> None:
"""Send events to the Aptabase API."""
assert self._client is not None, "HTTP client is not initialized"

if not events:
return

Expand Down
3 changes: 2 additions & 1 deletion src/aptabase/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class ConfigurationError(AptabaseError):
class NetworkError(AptabaseError):
"""Raised when network requests fail."""

def __init__(self, message: str, status_code: int = None) -> None:
def __init__(self, message: str, status_code: int | None = None) -> None:
"""Initialize the NetworkError exception."""
super().__init__(message)
self.status_code = status_code

Expand Down
4 changes: 2 additions & 2 deletions src/aptabase/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class Event:
"""Represents an analytics event to be sent to Aptabase."""

name: str
props: dict[str, Any] | None = None
timestamp: datetime | None = None
session_id: str | None = None
props: dict[str, Any] | None = None

def __post_init__(self) -> None:
"""Set default values after initialization."""
Expand All @@ -55,7 +55,7 @@ def __post_init__(self) -> None:
def to_dict(self, system_props: SystemProperties) -> dict[str, Any]:
"""Convert to dictionary format for API requests."""
return {
"timestamp": self.timestamp.isoformat() + "Z",
"timestamp": self.timestamp.isoformat() + "Z" if self.timestamp else None,
"sessionId": self.session_id,
"eventName": self.name,
"systemProps": system_props.to_dict(),
Expand Down
3 changes: 3 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Test suite for Aptabase Python SDK.
"""
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Shared pytest fixtures for all tests."""
2 changes: 2 additions & 0 deletions tests/test_dummy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_dummy():
assert True