People (user profiles)
Unified behavior: all people operations go toPOST /api/sdk/people/<action> with JSON bodies including siteId and userId (the current distinct id). Rate limits apply per site and user (see backend rateLimits.people).
Supported operations align with the browser People reference:
| Action | HTTP path | Purpose |
|---|---|---|
| Set | /people/set | Merge properties (overwrite keys) |
| Set once | /people/set_once | Set only if missing |
| Unset | /people/unset | Remove keys |
| Increment | /people/increment | Numeric delta |
| Append | /people/append | Append to list properties |
| Union | /people/union | Set union on list properties |
| Remove | /people/remove | Remove values from lists |
| Track charge | /people/track_charge | Revenue / charge tracking |
| Clear charges | /people/clear_charges | Clear charge history |
| Delete user | /people/delete_user | Delete profile data for user |
Via UserContext
- Node.js
- Python
Direct shortcuts on TrodoClient
Node exposes client.people.set(distinctId, props) (and siblings). Python uses people_set, people_increment, etc., on TrodoClient.
Groups (accounts, organizations)
Unified behavior: group membership and group profiles usePOST /api/sdk/groups/*. Workflows match Groups (browser).
Membership
- Node.js
- Python
set_group / add_group / remove_group; Python set_group, add_group, remove_group on TrodoClient.
Group profile (scoped object)
Obtained viaget_group(groupKey, groupId). Returns a profile object with set, set_once, union, remove, unset, increment, append, delete.
- Node.js
- Python
GroupProfile uses snake_case method names (set_once matches the HTTP route segment). Node GroupProfile uses set_once as well (aligned with wire naming).
Auto-events (global error tracking)
WhenautoEvents: true / auto_events: true is set on the client or you call enableAutoEvents / enable_auto_events, the SDK registers process-wide hooks that send a server_error auto event for uncaught failures.
| Runtime | What gets hooked |
|---|---|
| Node | process.on('uncaughtException'), process.on('unhandledRejection') |
| Python | sys.excepthook, threading.excepthook (3.8+) |
server_global and include runtime: nodejs or runtime: python, plus message and stack fields.
- Node.js
- Python
UserContext with enableAutoEvents / disableAutoEvents (Node) or enable_auto_events / disable_auto_events (Python).
Flush and shutdown
| Method | Node | Python |
|---|---|---|
| Flush queue | await client.flush() | client.flush() |
| Stop timers, flush, disable auto hooks | await client.shutdown() | client.shutdown() |
shutdown() before terminating the process when batching or auto-events are enabled.
Python async HTTP (advanced)
Thetrodo-python[async] extra installs httpx and provides AsyncHttpClient in trodo.api.async_client, exposing post_track, post_event, post_bulk_events, post_identify, people/group helpers — same paths and headers as the sync client. There is no separate high-level async TrodoClient in the package today; use AsyncHttpClient if you need async/await at the HTTP layer and wire calls yourself, or run the sync client in a thread pool.
Error handling and retries
- HTTP clients retry failed requests with exponential backoff on network errors and 5xx responses (see
retriesin Overview). - After retries are exhausted, failures are passed to
onError(if set) and may return empty result objects for call sites that expect JSON. - Session confirmation (
POST /api/sdk/track) failures are treated as non-fatal so your app does not block on analytics.
GDPR and privacy APIs
The write service also exposes GDPR-related routes (/api/sdk/gdpr/*, GET /api/sdk/privacy/policy) for export, delete, and anonymize flows. These are HTTP endpoints rather than first-class methods on trodo-node / trodo-python; call them with your server’s HTTP client if you integrate compliance automation. See Privacy and compliance for product context.