Events
attachEvent(element, evt, fn, useCapture)
Pendo agent’s version of attaching event listeners.
Param | Type | Description |
---|---|---|
element | HTMLElement | DOM element to attach listener |
evt | string | type of DOM event |
fn | function | callback function |
useCapture | Boolean | use capture phase instead of bubble |
Example
pendo.attachEvent(pendo.dom("h1")[0], 'click', helloWorld = () => { console.log(Hello World") });"
detachEvent(element, evt, fn, useCapture)
Pendo agent’s version of detaching event listeners. Callback must be a named function, cannot remove anonymous functions.
Param | Type | Description |
---|---|---|
element | HTMLElement | DOM element to attach listener |
evt | string | type of DOM event |
fn | function | callback function |
useCapture | Boolean | use capture phase instead of bubble |
Example
pendo.detachEvent(pendo.dom("h1")[0], 'click', helloWorld);
doNotProcess : string
If a visitor has been marked as "Do Not Process" then this value will be set to true.
Example
pendo.doNotProcess => true
flushNow(force) ⇒ void
This will force a flush of cached event objects.
Param | Type | Description |
---|---|---|
force | boolean | a "full" flush, i.e. ALL pendo.buffers.silos |
Example
pendo.flushNow()
isSendingEvents() ⇒ Boolean
Returns true if event collection is currently enabled.
Example
pendo.stopSendingEvents()
pendo.isSendingEvents() => false
pendo.startSendingEvents()
pendo.isSendingEvents() => true
startSendingEvents()
Starts event collection and transmission.
Example
$ pendo.startSendingEvents()
> Pendo Agent unlocked. Events will be written.
stopSendingEvents()
Stops event collection and transmission.
Example
$ pendo.stopSendingEvents()
> Pendo Agent locked. No more events will be written.
track(name, [props])
Method to manually track events. Requires a non-empty name string to collect event.
Param | Type | Description |
---|---|---|
name | string | name of the collected event |
[props] | Object | optional properties object to collect with to the event |
Example
pendo.track('scroll')
trackAgent(type, props)
Method to manually track agentic events. Uses agent functions for IDs and context.
Param | Type | Description |
---|---|---|
type | string | type of the collected agentic event ['prompt', 'system_response', 'user_reaction'] |
props | Object | event-specific properties object |
Example
pendo.trackAgent('type_of_event', {
agentId: 'weather_assistant',
conversationId: 'conv_abc123',
messageId: 'msg_xyz789',
content: 'thumbs_up',
modelUsed: 'gpt-4',
suggestedPrompt: false,
toolsUsed: [],
fileUploaded: false
})