Skip to main content

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

TermMeaning
Group keyNamespace for a type of group — company, team, active_team.
Group IDIdentifier of one instance — acme-inc, team-uuid-123.
MembershipWhich group IDs the current user belongs to, per key. Persisted server-side; browser also mirrors to localStorage.
Active contextThe group the user is currently working in. Drives event attribution.
Group profileProperties 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

OperationBrowserNode.jsPython
set_groupTrodo.set_group('team', 'eng')trodo.set_group('user-42', 'team', 'eng')trodo.set_group("user-42", "team", "eng")
add_groupTrodo.add_group('team', 'eng')trodo.add_group('user-42', 'team', 'eng')trodo.add_group("user-42", "team", "eng")
remove_groupTrodo.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.
await Trodo.set_group('active_team', 'team-b-id');

// Or multiple ids at once
await Trodo.set_group('team', ['engineering', 'design']);

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.
await Trodo.add_group('company', 'acme-inc');
await Trodo.add_group('team', 'engineering');

remove_group

await Trodo.remove_group('team', 'design');

Most B2B apps have users belonging to multiple teams permanently but working in one team at a time. Use two separate group keys:
KeyMethodPurpose
teamadd_groupAll teams the user permanently belongs to
active_teamset_groupCurrent active workspace — drives event attribution
// On login — user joins all their teams permanently
await Trodo.add_group('team', 'team-a-id');
await Trodo.add_group('team', 'team-b-id');

// Set the currently active team
await Trodo.set_group('active_team', 'team-a-id');

// Later — user switches workspace
await Trodo.set_group('active_team', 'team-b-id');
Result in Trodo:
  • The team page for team-a shows the user as a permanent member.
  • The active_team page for team-a shows only events fired while team-a was active.
  • The active_team page for team-b shows only events fired while team-b was 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.
const team = Trodo.get_group('team', 'team-a-id');

await team.set({ name: 'Engineering', plan: 'enterprise', seat_count: 50 });
await team.set_once({ created_at: '2024-01-01' });
await team.union('tags', ['b2b', 'saas']);
await team.remove('tags', 'b2b');
await team.increment('seat_count', 5);
await team.unset('plan');
await team.delete();
MethodDescription
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)

When identify() 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

await Trodo.identify(user.id);

Trodo.people.set({ email: user.email, name: user.name, plan: user.plan });

for (const team of user.teams) {
  await Trodo.add_group('team', team.id);
}

await Trodo.set_group('active_team', user.currentTeamId);

const activeTeam = Trodo.get_group('active_team', user.currentTeamId);
await activeTeam.set({
  name: user.currentTeam.name,
  plan: user.currentTeam.plan,
  member_count: user.currentTeam.memberCount,
});

Trodo.track('dashboard_opened', { section: 'overview' });

People vs. Groups

PeopleGroups
What it describesThe end userAn org, team, or entity the user belongs to
Browser namespaceTrodo.people.*Trodo.set_group / add_group / get_group
Server (Node/Python)trodo.people.*(distinctId, ...)trodo.{set_group, add_group, get_group}(distinctId, ...)
Profile updatespeople.set({...})get_group(key, id).set({...})
MembershipSingle user, tied to identifyOne user can belong to many groups across many keys

People

User profile properties

Identify

User identity and cross-device merge

Track

Custom events

Auto-Events

Automatic event capture