AsyncNexusClient
The asynchronous Nexus client — same surface, `await`-ed.
from nexus.aio import AsyncNexusClientThe asynchronous Nexus client — same surface, await-ed.
from nexus.aio import AsyncNexusClient
nexus = AsyncNexusClient("nxs_live_xxx")
await nexus.identify("user_123", email="a@b.com")
nexus.events.track("order_placed", {"total": 42}) # buffered, no await
await nexus.realtime.emit("orders:42", "status", {"state": "shipped"})
await nexus.aclose()Buffered telemetry (events.track / logs.info) stays synchronous — it
only appends to a buffer — while everything that talks to the network is a
coroutine. Build one client per process and close it on shutdown.
AsyncNexusClient
classAn asyncio-native connection to one Nexus environment.
View sourceAsyncNexusClient
constructorAsyncNexusClient(api_key=None, *, config=None, transport=None, **options)Parameters
Prop
Type
distinct_id
propertydistinct_id: Optional[str]session_key
propertysession_key: Optional[str]pending
propertypending: intclosed
propertyclosed: boolidentify()
methodasync def identify(distinct_id, *, email=None, name=None, phone=None, traits=None, remote=True, **context_fields) -> Dict[str, Any]Bind the user to this task's context and upsert them server-side.
Parameters
Prop
Type
Returns Dict[str, Any]
reset()
methoddef reset() -> Nonecurrent_distinct_id()
methoddef current_distinct_id() -> Optional[str]Returns Optional[str]
ambient_properties()
methoddef ambient_properties() -> Mapping[str, Any]Returns Mapping[str, Any]
resolve_context()
methoddef resolve_context(**overrides) -> Dict[str, Any]Config defaults < ambient context < explicit overrides (camelCase).
Parameters
Prop
Type
Returns Dict[str, Any]
request()
methodasync def request(request) -> AnyExecute one partner-API request (raises unless silent).
Parameters
Prop
Type
Returns Any
enabled()
methoddef enabled(service) -> boolWhether a product is switched on — services / NEXUS_<SERVICE>_ENABLED.
Parameters
Prop
Type
Returns bool
enqueue_event()
methoddef enqueue_event(item, context) -> NoneParameters
Prop
Type
enqueue_log()
methoddef enqueue_log(item, context) -> NoneParameters
Prop
Type
flush_events()
methodasync def flush_events() -> Noneflush_logs()
methodasync def flush_logs() -> Noneflush()
methodasync def flush() -> NoneShip everything buffered right now.
View sourcetrack()
methoddef track(name, properties=None, **kwargs) -> NoneParameters
Prop
Type
capture_exception()
methodasync def capture_exception(exc=None, **options) -> Dict[str, Any]Parameters
Prop
Type
Returns Dict[str, Any]
emit()
methodasync def emit(room, events, payload=None) -> Dict[str, Any]Parameters
Prop
Type
Returns Dict[str, Any]
is_enabled()
methodasync def is_enabled(key, distinct_id=None, **kwargs) -> boolParameters
Prop
Type
Returns bool
aclose()
methodasync def aclose() -> NoneFlush, stop the background tasks and close the transport.
View source