Developer pages

Init reference

HumanBehaviorTracker.init(apiKey, options?) — Options from the shipped SDK types.

Signature

HumanBehaviorTracker.init(apiKey: string, options?: InitOptions): HumanBehaviorTracker
  • apiKey is required (constructor throws if missing).
  • For HumanBehaviorTracker.init, the second argument must be an options object, never a bare URL string — put the host in { ingestionUrl }.
  • CDN / UMD helper: window.humanbehavior.init(apiKey, ingestionUrl?, options?). Pass options as the third argument (init(apiKey, undefined, options)), or a bare URL string as the second argument.
  • init calls start() for you and returns a page-level singleton.

Illegal / deprecated patterns

PatternStatus
HumanBehaviorTracker.init(apiKey, "https://…") as a bare second stringInvalid — use { ingestionUrl }
window.humanbehavior.init(apiKey, options) with options as arg 2Invalid — options become the ingestion URL; use init(apiKey, undefined, options)
Provider prop named endpointInvalid — use options.ingestionUrl
Calling init in a React Server ComponentUnsupported — browser only
Top-level redactFields: string[]Deprecated — use redactionStrategy

Correct pattern

HumanBehaviorTracker.init(apiKey, {
  ingestionUrl: "https://ingest.humanbehavior.co",
  redactionStrategy: { mode: "visibility-first" },
  release: "1.4.2",
  environment: "production",
  dist: "web",
  commitSha: process.env.NEXT_PUBLIC_GIT_SHA,
});

Options table

Defaults below match packages/core/src/tracker.ts (init + constructor). Opt-out flags default to enabled unless noted.

OptionTypeDefaultPurpose
ingestionUrlstringhttps://ingest.humanbehavior.coBase URL for all /api/ingestion/* calls
logLevel'none' | 'error' | 'warn' | 'info' | 'debug'(SDK logger default)SDK console verbosity
redactionStrategy{ mode, unredactFields?, redactFields? }mode privacy-firstReplay masking strategy — see Replay privacy
redactFieldsstring[]Deprecated legacy unredact list
enableAutomaticTrackingbooleantrueInstall autocapture / forms / rage / dead click
automaticTrackingOptionsobjectsee belowFine-grained autocapture toggles
suppressConsoleErrorsbooleantrueSwallow narrow rrweb/CORS console noise (does not disable Issue capture)
recordCanvasbooleanfalseOpt-in canvas recording (throttled when on)
enableAutomaticPropertiesbooleantrueDevice / URL / UTM enrichment
propertyDenyliststring[][]Keys excluded from automatic properties
maxQueueSizenumber1000In-memory event queue cap
enableConsoleTrackingbooleantrueCapture console.warn / console.error/logs (console.log is wrapped but not ingested)
enableNetworkTrackingbooleantrueCapture failed fetch/XHR (+ long loads) → /network
enableErrorTrackingbooleantrueUncaught errors / rejections → /errors
enableWebVitalsbooleantrueCore Web Vitals as $web_vitals events
enableTracingbooleantruePage-load + resource + custom spans → /spans/batch
releasestringnullApp version stamped on error reports
environmentstringnullDeployment stage stamped on error reports
commitShastringnullGit SHA for GitHub blob links on Issues
diststringnullBuild discriminator; pairs with release for source maps
captureRequestBodiesbooleanfalseOpt-in redacted request/response bodies on error-correlated requests
minimumDurationMillisecondsnumber5000Hold outbound traffic until session age ≥ this; 0 = send immediately

automaticTrackingOptions

FieldTypeDefault in codeNotes
trackButtonsbooleantrueHistorical flag; autocapture uses a single click handler for interactive elements
trackLinksbooleanforced falseLink-only channel is disabled — clicks on <a> still emit $click via autocapture
trackFormsbooleantrueEmits $form_submitted on submit
includeTextbooleantrueInclude truncated element text on $click
includeClassesbooleanfalseInclude class / elementClass on $click

redactionStrategy

FieldTypeWhen used
mode'privacy-first' | 'visibility-first'Required when setting strategy
unredactFieldsstring[] (CSS selectors)privacy-first — fields to show
redactFieldsstring[] (CSS selectors)visibility-first — fields to hide

Password inputs are always protected (cannot be unredacted).

React provider

import { HumanBehaviorProvider } from "humanbehavior-js/react";

<HumanBehaviorProvider apiKey={apiKey} options={{ /* same InitOptions */ }}>
  {children}
</HumanBehaviorProvider>

Provider options mirror the table above (including release, environment, dist, commitSha, captureRequestBodies, vitals/tracing flags). On Next.js App Router, prefer a leaf client initializer — see Next.js.