@aient/otel-browser
@aient/otel-browser sends browser traces and logs to Aient using public OTLP HTTP endpoints. Use a publishable key and release metadata from your build environment.
For React or Next.js (client mount, identify/clearUser, and cleanup), see the browser quickstart.
Configuration
The SDK sends OTLP HTTP JSON payloads.
http/protobuf is not bundled; legacy protobuf config falls back to JSON.
Avoid high-cardinality span names and avoid attaching sensitive user input to attributes.
Release metadata
Pass the full build commit SHA explicitly inrelease.commit, using the same value when uploading source maps. Your build must expose that value to browser code.
For Next.js on Vercel, pass process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA as shown in the browser quickstart. For Vite, set VITE_COMMIT_SHA when building and pass it explicitly:
Dynamic context
Callsdk.setContextAttributes() after a business, account, or workspace switch. The call synchronously replaces the whole snapshot; null or an empty object clears it. sdk.getContextAttributes() returns a clone.
enduser.* keys and app.installation.id are omitted from generic context.
Browser context and baggage are untrusted telemetry correlation data. Never use them for authorization; downstream services must derive identity and access from trusted server-side sessions or credentials.
User context and baggage
Callsdk.identify({ userId, pseudoId, email, role }) after sign-in to replace the complete user snapshot and tag future browser spans/logs. Call sdk.clearUser() on sign-out. sdk.getIdentity() returns a clone containing the installation plus current user fields. The legacy user-context methods remain aliases.
app.installation.id, enduser.id, and enduser.pseudo.id may propagate as W3C baggage. They are correlation hints, not authentication. Email and role do not propagate. Aient backends derive authenticated enduser.id from the verified server session and overwrite the browser value before downstream work.
Use a stable, non-reversible hash (for example, an HMAC of the user id with a server-side secret) for pseudoId so you can correlate sessions without exposing PII.