Skip to content

Commit 77b5965

Browse files
author
Call2Me
committed
v1.3.0: add EventsResource + Trusted Publisher workflow
client.events.report / client.events.query wrap POST/GET /v1/events so Python apps can forward events into the Call2Me observability pipeline without hand-rolling httpx. GitHub Actions publish.yml uses PyPI Trusted Publishing (OIDC) — future releases just need a 'v1.4.0' tag push, no tokens required.
1 parent 0ce7ab0 commit 77b5965

4 files changed

Lines changed: 79 additions & 2 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish to PyPI
2+
3+
# Tag v* push ⇒ publish. Auth via PyPI Trusted Publisher (OIDC) —
4+
# no API token in secrets. Configure at:
5+
# pypi.org → Account → Publishing → Add publisher:
6+
# Owner: call2me-app
7+
# Repository name: python-sdk
8+
# Workflow name: publish.yml
9+
# Environment name: pypi
10+
11+
on:
12+
push:
13+
tags: ["v*"]
14+
workflow_dispatch:
15+
16+
permissions:
17+
id-token: write
18+
contents: read
19+
20+
jobs:
21+
publish:
22+
runs-on: ubuntu-latest
23+
environment:
24+
name: pypi
25+
url: https://pypi.org/project/call2me/
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: actions/setup-python@v5
29+
with:
30+
python-version: "3.11"
31+
- name: Verify tag matches pyproject version
32+
run: |
33+
PV=$(grep -E '^version =' pyproject.toml | sed -E 's/version = "([^"]+)"/\1/')
34+
TV="${GITHUB_REF_NAME#v}"
35+
[ "$PV" = "$TV" ] || { echo "pyproject $PV != tag $TV"; exit 1; }
36+
- name: Build
37+
run: |
38+
python -m pip install --upgrade build
39+
python -m build
40+
- name: Publish
41+
uses: pypa/gh-action-pypi-publish@release/v1

‎call2me/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
from .client import Call2Me
44

5-
__version__ = "1.1.0"
5+
__version__ = "1.2.0"
66
__all__ = ["Call2Me", "Agent", "Call", "KnowledgeBase"]

‎call2me/client.py‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def __init__(self, api_key: str, base_url: str = "https://api.call2me.app"):
3535
self.voices = VoicesResource(self._http)
3636
self.chats = ChatsResource(self._http)
3737
self.payments = PaymentsResource(self._http)
38+
self.events = EventsResource(self._http)
3839

3940
def close(self):
4041
self._http.close()
@@ -394,3 +395,38 @@ def update_auto_charge(self, enabled: bool, threshold: float = None, amount: flo
394395
if amount is not None:
395396
data["charge_amount"] = amount
396397
return self._put("/v1/payments/auto-charge", data)
398+
399+
400+
class EventsResource(_Resource):
401+
"""Report custom events (errors, auth, payments, custom).
402+
403+
The ingest endpoint is public — it doesn't require the SDK's API key
404+
— but a key is still sent so authenticated events inherit the user's
405+
higher rate limit (100/min vs 10/min for anon).
406+
"""
407+
def report(self, type: str, message: str, source: str = "api",
408+
severity: str = None, meta: Dict = None,
409+
tenant: str = None, session_id: str = None,
410+
fingerprint: str = None) -> Dict:
411+
body = {
412+
"type": type,
413+
"source": source,
414+
"message": message,
415+
}
416+
if severity: body["severity"] = severity
417+
if tenant: body["tenant"] = tenant
418+
if session_id: body["session_id"] = session_id
419+
if fingerprint: body["fingerprint"] = fingerprint
420+
if meta: body["meta"] = meta
421+
return self._post("/v1/events", body)
422+
423+
def query(self, severity: str = None, type: str = None,
424+
fingerprint: str = None, hours: int = 24, limit: int = 50) -> Dict:
425+
"""Admin-only — JWT required rather than API key. SDK users with
426+
admin rights can call it if they authenticate via the Authorization
427+
header directly."""
428+
params = {"hours": hours, "limit": limit}
429+
if severity: params["severity"] = severity
430+
if type: params["type"] = type
431+
if fingerprint: params["fingerprint"] = fingerprint
432+
return self._get("/v1/events", **params)

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "call2me"
7-
version = "1.1.0"
7+
version = "1.3.0"
88
description = "Call2Me Python SDK — Build AI voice agents"
99
readme = "README.md"
1010
license = {text = "MIT"}

0 commit comments

Comments
 (0)