Product activity
Users & sessions › Activity connects product usage with operational evidence. Start with
stable events such as signup.completed, report.exported, or checkout.failed.
Tag a feature and screen so people can find the part of the product involved.
Emit successful outcomes where your application actually confirms success.
Existing named events appear immediately. Requests, named events, identified users and verified outcomes are different measures. To count the moments that matter most every day, such as a sign-up or a checkout, define them as key events: a key event defined on an event your app already sends counts the stored history too.
This view is the Activity view of Users & sessions (/users?view=activity); it shows needs-attention outcomes, feature outcomes and the usage map.
What Heystack stores
Each product event your app sends is kept as its own record, with its name, feature, screen, action, outcome, person, visit and release pulled out so views can find it quickly. Individual events are kept for 30 days; daily counts per event and per key event are kept for 13 months.
Before anything is stored, for each app:
- Erased people stay erased. Events from a person you erased are dropped.
- Automatic capture keeps only its known fields. Clicks and page views captured automatically may carry only the fields the SDK defines (the element, the page path, the screen and a few others). Anything else is removed and counted. Values are checked too: an element id or name that looks like it identifies someone, a query-string value that does, or a value of the wrong shape is removed, and query-string parameters your app did not allow in its settings are removed even if a client sends them.
- Property rules. In Users & sessions › Key events › Event catalogue, an admin can choose which event properties are kept. With no rules, events your app sends keep the properties its own allow-list sends, and automatically captured events keep only their known fields. Once an app has rules, only properties marked Keep are stored, and Drop removes a property.
- Daily event budget. Each app keeps up to 200,000 events a day (UTC) by default; an admin can change this in the event catalogue (1,000 to 5,000,000). Past the budget, automatically captured events are dropped first, then events your app sends. Key events Heystack derives from requests and events from your sign-in or payment provider are never dropped. The budget is checked against a count that can be up to a minute old, so a busy app can go slightly over it. Every drop is counted, by reason and by sender, and shown in the event catalogue.
Each app keeps up to 500 event names. Events with a new name past that are dropped and counted.
Defining things later. A key event defined on an event your app already sends counts that event's stored history straight away. A key event defined on a request or a page click counts the last 30 days once, in the background (up to 20,000 matches; Backfill earlier continues further back). Adding instrumentation to your app only enriches activity from then on: Heystack can't know about an action your app never reported.
JavaScript and TypeScript
Available in @heystack/otel/product from version 0.17.0. This runtime-safe entry
works alongside your existing Node, Next.js, Workers or browser instrumentation.
It sends explicit events through the existing log collection path.
import { createProductAnalytics } from "@heystack/otel/product";
const activity = createProductAnalytics({
apiKey: process.env.HEYSTACK_API_KEY!,
service: "my-api",
version: "2.4.0",
environment: "production",
allowedProperties: ["plan"],
});
// Create a separate immutable context for each request. Never mutate global identity.
const requestActivity = activity.withContext({
userId: "pseudonymous-user-id",
sessionId: "session-id-from-your-app",
feature: "signup",
surface: "welcome",
});
requestActivity.track({
name: "signup.completed",
action: "create-account",
outcome: "succeeded",
properties: { plan: "starter" },
});
await activity.flush();
track() returns whether an event was queued. flush() returns whether the
snapshot of queued batches was accepted over HTTP, not whether it has appeared
in the console. On Workers, hand activity.flush() to ctx.waitUntil() before
returning. Events are best effort; do not use them as a billing ledger.
feature("search") records feature.used; screen("workspace") records
screen.viewed. Both accept optional event context. An active trace is attached
when available, or pass explicit traceId and spanId. Do not infer a trace from
the timestamp alone.
Browser sessions and replay
Use one UUID for your browser session and provide it to both collectors. Keep
createProductAnalytics initialisation before instrumentWeb so it captures the
original browser fetch. If tracing was already installed, supply the original
fetch explicitly. Browser collection is opt-in and does not capture clicks,
form contents or page text automatically.
import { createProductAnalytics } from "@heystack/otel/product";
import { instrumentWeb } from "@heystack/otel/web";
const sessionId = crypto.randomUUID();
// Browser config uses the public, write-only Browser key (hs_web_…) — never the
// sk_live_ server key. Product events go to /v1/logs, which a Browser key may use.
const browserIngestConfig = { apiKey: import.meta.env.VITE_HEYSTACK_WEB_KEY, service: "my-web-app" };
const activity = createProductAnalytics({ ...browserIngestConfig, flushIntervalMs: 5000 });
const stopReplay = await instrumentWeb({ ...browserIngestConfig, sessionId });
const session = activity.withContext({ sessionId, userId: pseudonymousUserId });
session.screen("workspace");
session.feature("search", { outcome: "succeeded" });
On logout, stop the old replay collector, shut down the old activity collector, discard the bound tracker and create a new anonymous session UUID. Do not reuse another person's bound tracker. Replay remains subject to its sampling and privacy settings. Shared session IDs correlate records; they do not guarantee a replay was recorded. Server events need the same app-owned session identifier to connect across surfaces; it is a correlation value, never an authorisation token.
iOS / Swift
Swift SDK 0.3.0 adds ProductAnalytics, ProductContext, Heystack.sessionID,
Heystack.resetSession() and HeystackOptions(sessionID:). Start the SDK after
analytics consent. Recreate any bound product context when accounts change.
import Foundation
import Heystack
// After SDK start and identity consent:
Heystack.resetSession() // rotate on account change; clears previous global user
Heystack.setUser(id: opaqueUserID)
let activity = ProductAnalytics(
context: .init(userID: opaqueUserID, sessionID: Heystack.sessionID,
feature: "reports", surface: "report-detail"),
allowedProperties: ["format"]
)
activity.screen("report-detail")
let attemptID = UUID().uuidString
activity.track("report.export", attemptID: attemptID, outcome: .started)
// Only after your app/server confirms the export succeeded:
activity.track("report.export", attemptID: attemptID, outcome: .succeeded,
properties: ["format": .string("pdf")])
await Heystack.flush()
// Logout: discard activity and all other bound contexts.
Heystack.resetSession() // new session, no global user
Events inside Heystack.tracer.withSpan inherit the active trace/span. The SDK
snapshots global identity when each signal is emitted, before asynchronous
export. A reset does not rewrite already-emitted events. Spans are emitted when
they end: finish or cancel user work before rotating accounts. The normal native
spool/flush lifecycle applies; a successful track means handed to the logger,
not confirmed server delivery. Calling the SDK before Heystack.start is a no-op.
Native withContext replaces the complete context; it is an immutable value.
Display names require allowUserProfiles: true and a ProductContext containing
userID, displayName and profileSource (app or clerk). Property names are
allowlisted, values bounded, and sensitive-name properties refused. No screen,
form text or native replay is collected automatically.
Direct collection contract
Native and direct collection clients can emit the same contract using their
existing log API. Set event.name, event.domain=product, a unique event.id,
enduser.id, session.id, heystack.feature, heystack.surface,
heystack.action, and heystack.outcome. Identity is taken from each record
before falling back to shared resource identity. Use native trace/span fields
for trace correlation and resource fields for service/release/environment.
Existing native clients can emit these attributes with the logger API. The
Swift 0.3.0 ProductAnalytics helper below provides the same contract directly.
Privacy, limits and interpretation
Names accept letters, digits, dots, underscores and hyphens (128 characters, starting with a letter). Context values are capped at 256 characters. Properties must be explicitly allowlisted, with at most 20 keys and 256 characters per string. Common sensitive property names are refused, but this is not a complete PII detector: only allow data you intend to collect. Use opaque identifiers and stable feature/screen names; never include credentials, personal contact information, prompt contents or URLs with customer data.
The queue holds at most 200 events and exports batches of 50. A failed flush returns false and retains a bounded batch for a later retry. Retries can duplicate records, and sampling or failed collection can omit them. Counts describe the received telemetry, not exact conversion or revenue. Missing user IDs display as unknown coverage rather than invented users. Features show observed usage; an observed session sequence is not a complete funnel or causal analysis.
Use Users & sessions › Activity to select a feature/event, then pivot to a user or session. Open technical evidence or copy a fix handoff. In Issues, assign an owner, save notes and change triage status. A resolved status records your triage decision; it does not independently establish recovery.
The identified-user and observed-session totals open their ranked breakdowns. Select an identifier to see its activity; the error-event total opens an error-filtered activity view. These views preserve app, service and time scope.
Required telemetry for maps, outcomes and investigation
Instrument the same stable feature/surface names across web and iOS. The SDKs emit the wire fields below; direct OTLP clients must supply them explicitly.
| Field | When required | Meaning |
|---|---|---|
event.name | Every event | Stable action name; no IDs or user input in the name |
event.domain | Every product event | Exactly product |
event.id | Every occurrence | Unique occurrence ID; preserve on retry; never reuse for a later event |
heystack.schema.version | New instrumentation | 1 |
session.id | Usage maps | Shared opaque session UUID; rotate on logout/account change |
enduser.id | User impact and cross-service pivots | Consented opaque ID from your own authentication system |
heystack.surface | Screen visits | Stable screen/route key, e.g. report-detail, not a URL with IDs |
heystack.feature | Feature adoption/outcomes | Stable feature key, e.g. reports |
heystack.attempt.id | Attempt/outcome analysis | One ID shared by a start and its terminal result |
heystack.outcome | Attempt/outcome analysis | started, then one of succeeded, failed, cancelled |
service.name, service.version, deployment.environment | Resource on every signal | Service, shipped release and environment |
| Native OTLP trace/span IDs | Technical investigation | Current trace context, propagated with W3C traceparent |
Send screen.viewed once for each actual screen transition, including the entry
screen. Repeated component renders are not screen visits. Send feature.used
for meaningful feature activity. For an operation, generate an attempt ID at
start, carry it across the request, and emit its terminal outcome at the
authoritative boundary. Record cancellation explicitly. Never label a request
sent or a button tapped as a successful business result.
The map uses adjacent recorded screen.viewed events within the same session
and user, with a maximum 30-minute gap. Equal timestamps are ambiguous and do not
create connections. Search happens after adjacency is established. Selecting a
connection finds sessions containing that exact edge. App/service filtering can
hide other surfaces; inspect the whole product for cross-service activity.
Analysis uses the latest 10,000 product events in the selected window; truncation is explicit. Events with an ID are deduplicated within this snapshot. Up to 100 connections, 50 feature groups and 100 drill-down events are returned. These are observed paths and attempt outcomes, not a complete acquisition funnel, proof of abandonment or a billing ledger. An unresolved attempt may finish later, outside the window, or have missing telemetry. Conflicting terminal outcomes are shown as ambiguous. Missing IDs are reported as coverage gaps.
Browser identity and a declared event catalogue
From JavaScript SDK 0.18.0:
import { createBrowserProductAnalytics } from "@heystack/otel/product";
const activity = createBrowserProductAnalytics({
...browserIngestConfig,
flushIntervalMs: 5000,
allowUserProfiles: true, // only with your user's consent
eventDefinitions: {
"screen.viewed": { required: ["surface", "sessionId"] },
"feature.used": { required: ["feature", "sessionId"] },
"report.export": { required: ["feature", "attemptId", "outcome", "sessionId"] },
},
});
// Configure instrumentWeb with activity.sessionId before sending screen events.
activity.screen("workspace");
// user comes from YOUR app's authenticated Clerk SDK, not Heystack's directory.
const replaySession = activity.identify(user.id, {
displayName: user.username ?? "Member", source: "clerk",
});
// Stop and restart instrumentWeb with replaySession on identity changes.
const attemptId = crypto.randomUUID();
activity.track({ name: "report.export", feature: "reports", attemptId, outcome: "started" });
// Authoritative outcome, with the same attemptId:
activity.track({ name: "report.export", feature: "reports", attemptId, outcome: "succeeded" });
// On logout, rotate both collectors; discard all old bound server/request context.
const anonymousReplaySession = activity.reset();
identify rotates the session when the user changes. reset clears the profile
and rotates the session. Both return the UUID that must also be supplied to the
restarted replay collector. Session state is in memory: persist the chosen UUID
in app-owned session storage if navigation should retain it, and clear it on
logout. On consent withdrawal, stop collection and apply your app's policy to
pending telemetry; logout alone is not a consent-withdrawal implementation.
For server events use createProductAnalytics().withContext(...) per request.
Derive user identity from verified authentication. Propagate session and attempt
IDs explicitly, but never use them as authorization. eventDefinitions rejects
undeclared event names and missing required fields; inspect track()'s boolean
return in development. Do not share the mutable browser facade on a server.
User and IP enrichment
Profile enrichment is an event-time snapshot supplied by the monitored app.
Use userProfile: { displayName, source: "clerk" | "app" } with userId and
allowUserProfiles: true. The UI retains the original ID and labels provenance;
it never assumes a monitored user belongs to Heystack's own Clerk instance.
Avoid email addresses when a username or display label is sufficient.
For network context, explicitly enable allowNetworkContext and supply
network: { ip, country, region, city, source }. These map to client.address,
geo.country.code, geo.locality.region, geo.locality.name and
heystack.geo.source. A server may use trusted metadata from the ORIGINAL client
request (for example Cloudflare request metadata). Do not attach the exporter
server's IP/geography as if it belonged to the user, or trust client-provided
identity/location as verified. Native/direct clients can emit the same fields
through their logger after applying their own collection/privacy rules.
Only signed-in people see the IP and location of an event; read keys do not. The console can look up an IP in already-recorded, scoped trace geography. This makes no third-party IP lookup and does not promise a location for every public IP. Multiple observed locations remain visible. Locations are approximate and can describe a VPN, proxy or gateway, not a person's physical location.
AI answer feedback (thumbs up / down)
Send a log record named ai.feedback, with these attributes:
| Attribute | Required | Value |
|---|---|---|
event.name | yes | ai.feedback |
heystack.feedback.rating | yes | up or down (also good / bad) |
heystack.conversation.id or gen_ai.conversation.id | if the record has no trace id | the conversation the rating is about |
heystack.feedback.reason | no | a short code, e.g. wrong_facts (≤ 64 chars) |
heystack.feedback.comment | no | the user's words (≤ 500 chars; people only, never shown to read keys) |
heystack.feedback.score | no | a number from 0 to 1 |
event.domain | no | ai or product |
Link the rating to the answer:
- Best: emit it with the answer's trace as the active context, so the record carries its trace id.
- Otherwise: give the conversation id.
A rating with neither a trace id nor a conversation id is ignored. Identity (user.id, session.id), service.version,
heystack.ai.feature and the model are read from the record or its resource.
Node / Next.js / Workers (@heystack/otel registers the OpenTelemetry logs API):
import { logs } from "@opentelemetry/api-logs";
import { context } from "@opentelemetry/api";
// Inside the request that produced the answer, or with the saved span context.
logs.getLogger("feedback").emit({
context: context.active(),
attributes: { "event.name": "ai.feedback", "heystack.feedback.rating": "down", "heystack.feedback.comment": "Wrong refund policy" },
});
From a browser or a later request, keep the answer's trace id (trace.getActiveSpan()?.spanContext().traceId) or your
conversation id. Send it to your server and emit there.
Android and React Native (raw OTLP, no SDK needed): POST https://ingest.heystack.dev/v1/logs with
Authorization: Bearer <ingest key> and content-type: application/json:
{ "resourceLogs": [{ "resource": { "attributes": [{ "key": "service.name", "value": { "stringValue": "my-app" } }] },
"scopeLogs": [{ "logRecords": [{
"timeUnixNano": "1763380800000000000",
"traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
"attributes": [
{ "key": "event.name", "value": { "stringValue": "ai.feedback" } },
{ "key": "heystack.feedback.rating", "value": { "stringValue": "up" } },
{ "key": "gen_ai.conversation.id", "value": { "stringValue": "conv_123" } },
{ "key": "user.id", "value": { "stringValue": "user_42" } }
] }] }] }] }
(traceId is optional when gen_ai.conversation.id is set.) On Android, use the same JSON with OkHttp. In React
Native, use fetch. Keep the ingest key out of public source where you can, for example behind your own endpoint.
Without an OpenTelemetry stack, POST /v1/feedback takes the same rating as plain JSON (available from SDK 0.20.0; see
the API reference). Ratings show up on AI & Safety ›
Health ("People marked bad") and on the conversation within about a minute.
Verify your instrumentation
- Exercise one successful and one failed attempt on web and iOS in a test app.
- Confirm event IDs, session/user IDs, feature/surface, environment and release.
- Inspect the same attempt's start and terminal outcome; verify no duplicate terminal emissions from both frontend and backend with different event IDs.
- Click a map connection, find the session, and follow its trace/log evidence.
- Switch accounts/logout: confirm new events use a new session and no old user or display name. Check the server receives the intended session and attempt IDs.
- Test missing IDs, offline/retry, consent and sampling. Treat missing data as a coverage gap. Do not claim complete usage maps until these checks pass.