What these SDKs do
The trodo-node and trodo-python packages send analytics from your servers to Trodo’s write API (the same HTTP surface as the browser SDK’sapiHost). They are built for:
- API services, workers, and background jobs
- Correlating backend actions with the same site as your web or mobile app
- People and groups updates without loading the browser bundle
Architecture
Production traffic goes to the dedicated ingestion host:| Concept | Default value |
|---|---|
| API base URL | https://sdkapi.trodo.ai |
| Site identification | HTTP header X-Trodo-Site-Id: <your site id> (same ID as the frontend site-id) |
| Payload format | JSON (Content-Type: application/json) |
docs/BACKEND_SPLIT.md), point apiBase / api_base at http://localhost:8001.
Under the hood, the SDKs call routes such as:
POST /api/sdk/track— register the server session (once per in-memory session)POST /api/events— single custom eventPOST /api/events/bulk— batched events (when batching is enabled)POST /api/sdk/identify,/reset,/wallet-addressPOST /api/sdk/people/*andPOST /api/sdk/groups/*
Install
- Node.js (trodo-node)
- Python (trodo-python)
fetch). On Node 17 and older, install optional node-fetch (see package peer dependency).The published package name is trodo-node. Import the client class or the default singleton-style export.Initialize the client
Both SDKs support:TrodoClient/TrodoClientinstance — explicit, testable, multiple instances if needed- Module-level singleton —
init(...)thenforUser/for_user(mirrors the frontend pattern)
- Node.js
- Python
Configuration reference
| Option | Node (TrodoConfig) | Python (TrodoClient.__init__) | Notes |
|---|---|---|---|
| Site ID | siteId | site_id | Required |
| API base | apiBase | api_base | Default https://sdkapi.trodo.ai |
| HTTP timeout (seconds) | timeout (ms) | timeout (seconds) | Node default 10000 ms; Python default 10 s |
| Retries | retries | retries | Backoff on network errors and 5xx |
| Batch mode | batchEnabled | batch_enabled | Uses POST /api/events/bulk |
| Batch size | batchSize | batch_size | Flush when queue reaches this count |
| Flush interval | batchFlushIntervalMs | batch_flush_interval | Periodic flush (seconds in Python) |
| Auto error events | autoEvents | auto_events | See People, groups & lifecycle |
| Error callback | onError | on_error | Invoked after retries exhausted (Node: Error; Python: any exception) |
| Debug logging | debug | debug | Logs requests/errors to stderr |
Primary API shape: forUser / for_user
The recommended pattern is to obtain a user-scoped context once per logical user (your distinct_id), then call track, identify, people, and groups on that context.
- Node.js
- Python
sessionId / session_id so backend events attach to the same session as the web SDK when possible.
There is also a direct-call style on TrodoClient (e.g. track(distinctId, eventName, ...), people_set, set_group) for concise one-off calls. Behavior matches the user context API.
Naming conventions
- Node uses camelCase for methods and options (
forUser,batchFlushIntervalMs). - Python uses snake_case (
for_user,batch_flush_interval).
Next steps
- Tracking, sessions & identity —
track, batching,identify,reset,walletAddress, error capture - People, groups & lifecycle — profile APIs, auto-events,
flush/shutdown