SDK methods

Every SDK has the same small set of methods. The examples use the browser SDK (the traceiq singleton from traceiq-sdk-js); the last section lists the names in the other SDKs.

identify()Who is this?Ties events to a signed-in person and saves their traits to a profile.
track()What did they do?Records an action, such as checkout_started, with its details.
page()Where are they?Records a page view. Single-page apps call it on every route change.
group()Which account are they in?Puts the person in a company, team, school or department.
alias()Same person, new ID?Links an old ID (for example a guest ID) to the new one.
captureException()What broke?Reports an error you caught. Uncaught errors are captured for you.
log()What happened inside?Sends a structured log line to Logs.

How TraceIQ tracks a person

On the first visit the SDK creates an anonymous ID and keeps it in localStorage, so every event from that browser is connected even before sign-in. When you call identify(), the events that follow carry your user ID, and TraceIQ links the anonymous history to the same profile.

The signed-in user and their group live in memory, not in storage. Call identify() and group() every time your app loads with a signed-in user (for example where your auth state resolves), not only on the sign-in screen. Otherwise events after a page refresh are recorded as anonymous.

ts
// e.g. in your auth provider, once the session is known
if (session?.user) {
  traceiq.identify({
    userId: session.user.id,
    traits: { email: session.user.email, name: session.user.name, plan: session.user.plan }
  });
  traceiq.group({
    organizationId: session.user.departmentId,
    traits: { name: session.user.departmentName }
  });
}

identify()

ts
traceiq.identify({ userId: 'user_123', traits: { email: 'ada@example.com', name: 'Ada', plan: 'pro' } });
userIdrequiredYour own stable ID for the person, such as the database ID. Avoid email addresses: they change.
traitsoptionalFacts about the person (name, email, plan, role). Shown on their profile in Users.

The first call creates the person's profile in Users; later calls merge new traits into it, so a trait you send again replaces the old value and traits you leave out are kept. Traits that look like secrets (password, token, api_key, card details) are dropped before they are stored. Calling identify() again with the same ID is cheap, so it is safe to call on every load.

track()

ts
traceiq.track('checkout_started', { cartValue: 4200, currency: 'NGN', items: 3 });
eventNamerequiredWhat happened, in object_action form: signup_completed, result_viewed, course_registered.
propertiesoptionalDetails you want to filter or break down by later. Keep values flat: strings, numbers, booleans.

Events appear in Events within seconds and can be counted in Insights, chained in Funnels and compared in Retention. Pick names once and keep them stable, because a renamed event starts a new series. Names starting with $ are reserved for events the SDK sends itself ($page, $identify, $group, $exception, $api_request).

page()

ts
traceiq.page();                         // uses document.title
traceiq.page('Pricing', { plan: 'pro' }); // custom name and extra properties

Sends a $page event with the URL, path, referrer and title; it powers Web analytics and page breakdowns elsewhere. autoTrackPageViews: true only records the first page, so single-page apps (React, Next.js, Vue) should also call page() when the route changes:

tsx
'use client';
import { usePathname } from 'next/navigation';
import { useEffect } from 'react';
import { traceiq } from 'traceiq-sdk-js';

export function PageViews() {
  const pathname = usePathname();
  useEffect(() => { traceiq.page(); }, [pathname]);
  return null;
}

group()

A group is the account a person belongs to: the company in a B2B product, a team, a school, or a department in a university portal. group() tells TraceIQ which group the signed-in person is in, so you can see activity per account and not only per person.

ts
traceiq.group({
  organizationId: 'dept_csc',              // your stable ID for the account
  traits: { name: 'Computer Science', faculty: 'COLPHYS', plan: 'campus' }
});
organizationIdrequiredYour own stable ID for the account (database ID or slug). The same account must always send the same ID.
traitsoptionalFacts about the account. name labels it on the Groups page; any other traits are shown with it.

What you get

Each group appears on the Groups page (under Analytics) as soon as its first group() call arrives. The list shows its members, how many were active in the chosen range, their event count and when they were last active. Opening a group shows its traits, a daily activity chart, its top events and every member, linked to their user timeline.

How it works

  • Members — Anyone who called group() for that organizationId becomes a member. Call identify() first, so the member is the signed-in user and not an anonymous ID.
  • Activity — Every event a member sends counts toward the group: their page views, tracked events, errors and API calls. The $group, $identify and $alias events themselves are not counted.
  • Traits — The group shows the traits from its most recent group() call that included any. They describe the account and never change the person’s own profile.
  • Several groups — A person can be in more than one group: call group() once for each. Their activity then counts toward each of them.

Setting it up

  1. Decide what an account is in your product (company, team, department) and which ID identifies it.
  2. Where your app learns who is signed in, call identify() and then group(), on every load.
  3. Pass a name trait, or the Groups page shows the raw ID.
  4. Open Groups and check the account is listed, then open it to see its members.

From a server or another SDK

Server SDKs have no session, so pass the person as well. This is also how to backfill memberships for people who will not open the app soon:

ts
// traceiq-node
traceiq.group({ organizationId: 'dept_csc', userId: 'user_123', traits: { name: 'Computer Science' } });
python
# traceiq-py
client.group("dept_csc", user_id="user_123", traits={"name": "Computer Science"})

The Flutter SDK has no group() yet. Send the same event with track(); TraceIQ reads it the same way:

dart
await TraceIQ.track(r'$group', properties: {
  'organizationId': 'dept_csc',
  'traits': {'name': 'Computer Science'},
});

alias()

ts
traceiq.alias('user_123', 'guest_8f2c'); // the new ID first, then the old one

identify() already links the browser's anonymous ID, so most apps never need alias(). Use it when one person has had two of your user IDs, such as a guest checkout ID that later becomes an account. previousId defaults to the current ID in the browser; server SDKs take both IDs. TraceIQ records the link as an $alias event today; merging the two profiles in reports is coming in a later release.

captureException()

ts
try {
  await pay(order);
} catch (error) {
  traceiq.captureException(error, { orderId: order.id });
  showPaymentError();
}

Uncaught errors and unhandled promise rejections are captured automatically (autoCaptureExceptions). Use captureException() for errors you catch and handle, which would otherwise go unseen. Each one becomes a $exception event, grouped into issues on the Errors page; the extra properties show on each occurrence. Set the release option and upload source maps to see the original code in stack traces.

log()

ts
traceiq.log('warn', 'Payment provider slow', { provider: 'paystack', ms: 4200 });
traceiq.log('error', 'Result upload failed', { error, courseId: 'CSC201' });

Sends a structured line to Logs, tagged with the session and user. Levels are debug, info, warn and error. Lines are sent in small batches, and any left are flushed when the page is hidden. Pass error to attach its stack, or service to name the source.

Names in other SDKs

Node, Python, Rustcapture(), identify(), group(), alias()No session or stored user: pass userId (or anonymousId) on every call.
GoCapture(), Identify(), CaptureError()Events are queued and flushed by a background goroutine; call Shutdown before exit.
Kotlin, Swiftcapture(), identify(), group()Same payloads as the other SDKs; pass userId to group().
React Nativecapture(), screen(), identify(), group(), alias(), reset()screen() replaces page(). reset() on sign-out.
Fluttertrack(), screen(), identify(), alias(), captureException(), reset()No group() yet: track the $group event as shown above.

Feature flags, experiments, surveys and session replay have their own pages in the sidebar.