TracingGuides

Users

Attribute each run to the person it was for with a distinctId, and keep what you know about them (plan, company, country) on their profile.

Pass the user's ID on every run. Their runs then share one profile on the Users page, every view can be filtered and split by user, and evals and Lucid can say who a failure affected.

Who the run was for

Set distinctId on the wrap (or on startRun). Use an ID that stays the same for the person: your database user ID or their email.

await trodo.wrapAgent('support-agent', fn, { distinctId: user.id });
with trodo.wrap_agent("support-agent", distinct_id=user.id) as run:
    ...

A run without one gets an anonymous ID (anon_...), so each run looks like a different person. Use the same ID in every service that runs agents for that user.

Properties

Properties are what you know about the person and want to filter by: plan, company, signup date. They live on the user, so they apply to all of their runs. (For something true of one run only, use metadata.)

Send them with the run, in the same call:

await trodo.wrapAgent('support-agent', fn, {
  distinctId: user.id,
  user: {
    properties: { plan: user.plan, company: user.company },
    setOnce: { signup_source: 'partner' },             // only if not set yet
    fixedProperties: { last_location_country: 'India' },
  },
});
with trodo.wrap_agent("support-agent", distinct_id=user.id, user={
    "properties": {"plan": user.plan, "company": user.company},
    "set_once": {"signup_source": "partner"},          # only if not set yet
    "fixed_properties": {"last_location_country": "India"},
}) as run:
    ...

A property that can't be written never costs you the run.

Or set them without a run, for example at signup. users.upsert creates the user if needed and is safe to call on every request:

const result = await trodo.users.upsert(user.id, { properties: { plan: 'pro' } });
result = trodo.upsert_user(user.id, properties={"plan": "pro"})

The result says which keys were written and which were skipped, and why.

Fixed properties

Most properties are your own keys. A few are built-in profile fields the app filters on directly. From a backend you can set the location ones you actually know:

You can set from a backendSet only by the browser SDK
first_location_country, last_location_country, first_location_city, last_location_citydevice_type, browser_name, os, first_referrer, last_referrer, utm_*

A browser-only key sent from a backend is skipped (BROWSER_ONLY_PROPERTY), not an error. Where the browser SDK has already set a field, its value wins (BROWSER_OWNED_PROPERTY). Trodo never fills in a property you didn't send.

$name, $email and $phoneno are reserved; use plain keys such as name and email.

Changing one value

To change one value without resending the rest, use the people methods on a user:

const u = trodo.forUser(user.id);
await u.people.increment('agent_sessions', 1);
await u.people.append('features_used', 'export');
u = trodo.for_user(user.id)
u.people.increment("agent_sessions", 1)
u.people.append("features_used", "export")
MethodDoes
set, setOnce (set_once)Set values; setOnce only where not set yet
incrementAdd to a number
append, union, removeAdd to a list (union skips duplicates), or take a value out
unsetDelete properties
trackCharge (track_charge)Record revenue for the user

Over OpenTelemetry

Sending OTLP without the SDK? Set the user with trodo.distinct_id (or user.id) and properties with trodo.user.property.<key> attributes. See OpenTelemetry.

On this page