Complete API reference for HumanBehaviorTracker
Example screenshot – your actual API key will be different.
HumanBehaviorTracker.init(apiKey, options?)
apiKey
(string): Your HumanBehavior API keyoptions
(object, optional): Configuration options
ingestionUrl
(string, optional): Custom ingestion URLlogLevel
(string, optional): Logging levelredactFields
(string[], optional): CSS selectors for fields to redactenableAutomaticTracking
(boolean, optional): Enable automatic tracking (default: true)automaticTrackingOptions
(object, optional): Automatic tracking configurationHumanBehaviorTracker
instance
Example:
start()
stop()
customEvent(eventName, properties?)
eventName
(string): Name of the custom eventproperties
(object, optional): Additional event propertiesaddEvent(event)
event
(any): Raw event object to recordidentifyUser({ userProperties })
endUserId
and merges user properties.
userProperties
(object): User properties including email, name, image, provider, etc.Promise<string>
- The current endUserId
Example:
getUserAttributes()
logout()
trackPageView(url?)
url
(string, optional): URL to track (defaults to current URL)trackNavigationEvent(type, fromUrl, toUrl)
type
(string): Navigation type (e.g., ‘push’, ‘pop’, ‘replace’)fromUrl
(string): Previous URLtoUrl
(string): New URLsetRedactedFields(fields)
fields
(string[]): Array of CSS selectors for fields to redactisRedactionActive()
boolean
- Whether redaction is active
Example:
getRedactedFields()
string[]
- Array of current redacted field selectors
Example:
unredactFields(fields)
fields
(string[]): Array of CSS selectors for fields to unredactclearRedactedFields()
redact(options?)
options
(object, optional): Redaction optionsgetSessionId()
string
- Current session ID
Example:
getCurrentUrl()
string
- Current URL
Example:
getUserInfo()
isPreexistingUser()
boolean
- Whether user is preexisting
Example:
testConnection()
getConnectionStatus()
viewLogs()
configureLogging(config)
config
(object): Logging configuration
level
(string, optional): Log levelenableConsole
(boolean, optional): Enable console loggingenableStorage
(boolean, optional): Enable storage logginggetSnapshotFrequencyInfo()