Documentation Index
Fetch the complete documentation index at: https://docs.trodo.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Groups let you model B2B-style relationships: companies, workspaces, teams, departments, or any entity your product has. You assign the current user to groups, track events in the context of a specific group, and optionally set persistent properties on the group itself (similar to People, but scoped to the group entity).Backend is stateless. Node.js and Python require
distinctId / distinct_id as the first argument on every group call. The browser SDK uses the stored identity automatically.Core concepts
| Term | Meaning |
|---|---|
| Group key | Namespace for a type of group — company, team, active_team. |
| Group ID | Identifier of one instance — acme-inc, team-uuid-123. |
| Membership | Which group IDs the current user belongs to, per key. Persisted server-side; browser also mirrors to localStorage. |
| Active context | The group the user is currently working in. Drives event attribution. |
| Group profile | Properties on a (groupKey, groupId) pair, updated via get_group(...) helpers. |
How event attribution works
Every event fired after a group call gets stamped with the user’s current group context — that’s how Trodo knows which group’s timeline it belongs to.add_group→ appends a membership. Subsequent events are attributed to all current memberships for that key.set_group→ replaces the active context for that key. Events fired after the switch use the new context.- Event attribution changes only for events fired after the call. No historical rewrite.
Method map
| Operation | Browser | Node.js | Python |
|---|---|---|---|
| set_group | Trodo.set_group('team', 'eng') | trodo.set_group('user-42', 'team', 'eng') | trodo.set_group("user-42", "team", "eng") |
| add_group | Trodo.add_group('team', 'eng') | trodo.add_group('user-42', 'team', 'eng') | trodo.add_group("user-42", "team", "eng") |
| remove_group | Trodo.remove_group('team', 'eng') | trodo.remove_group('user-42', 'team', 'eng') | trodo.remove_group("user-42", "team", "eng") |
| get_group (profile) | Trodo.get_group('team', 'eng') | trodo.forUser('user-42').get_group('team', 'eng') | trodo.for_user("user-42").get_group("team", "eng") |
Group membership
set_group — switch active context
Use when the user switches which group they’re working in. Accepts a single id or an array.- JavaScript (browser)
- Node.js
- Python
add_group — permanent membership
Use when a user joins a group they’ll always belong to. Idempotent — adding the same id twice is a no-op.- JavaScript (browser)
- Node.js
- Python
remove_group
- JavaScript (browser)
- Node.js
- Python
Recommended pattern for multi-team SaaS apps
Most B2B apps have users belonging to multiple teams permanently but working in one team at a time. Use two separate group keys:| Key | Method | Purpose |
|---|---|---|
team | add_group | All teams the user permanently belongs to |
active_team | set_group | Current active workspace — drives event attribution |
- JavaScript (browser)
- Node.js
- Python
- The
teampage forteam-ashows the user as a permanent member. - The
active_teampage forteam-ashows only events fired whileteam-awas active. - The
active_teampage forteam-bshows only events fired whileteam-bwas active.
Group profile — properties per group
get_group(groupKey, groupId) returns a handle with profile methods. Each call writes to the group entity itself — not to the user, and not to event attribution.
- JavaScript (browser)
- Node.js
- Python
| Method | Description |
|---|---|
set(properties) | Set or overwrite group properties |
set_once(properties) | Set only if the property is not already set |
union(listName, values) | Add unique values to a list property |
remove(listName, value) | Remove a value from a list property |
append(property, value) | Append to a list (allows duplicates) |
increment(property, value) | Increment a numeric property |
unset(property) | Remove one property from the group profile |
delete() | Delete the entire group profile |
get_group is only for profile operations. It has no effect on event attribution — use set_group or add_group for that.identify() and cross-device membership (browser)
Whenidentify() completes on the browser, the server returns group_memberships and the SDK hydrates local state from that payload. The same user gets consistent group assignments across devices. Backend SDKs don’t mirror state — they only write, so this doesn’t apply.
See Identify.
Full example — SaaS login flow
- JavaScript (browser)
- Node.js
- Python
People vs. Groups
| People | Groups | |
|---|---|---|
| What it describes | The end user | An org, team, or entity the user belongs to |
| Browser namespace | Trodo.people.* | Trodo.set_group / add_group / get_group |
| Server (Node/Python) | trodo.people.*(distinctId, ...) | trodo.{set_group, add_group, get_group}(distinctId, ...) |
| Profile updates | people.set({...}) | get_group(key, id).set({...}) |
| Membership | Single user, tied to identify | One user can belong to many groups across many keys |
Related
People
User profile properties
Identify
User identity and cross-device merge
Track
Custom events
Auto-Events
Automatic event capture