Events
Subscribe to widget lifecycle events with on(event, cb). It returns an unsubscribe function.
js
const off = window.laneChat.on('open', () => {
console.log('Support panel opened')
})
// later
off() // stop listeningAvailable events
| Event | Fired when |
|---|---|
open | The chat panel opens (open() / openChat() / toggle()). |
close | The chat panel closes (close() / toggle()). |
Semantics
on(event, cb)returns an unsubscribe function — call it to remove the listener.- Callbacks currently receive no payload.
- Listener exceptions are caught and logged; a throwing callback never breaks the widget.
Example: analytics
js
window.laneChat.on('open', () => {
window.analytics?.track('Support Widget Opened')
})
window.laneChat.on('close', () => {
window.analytics?.track('Support Widget Closed')
})Deeper real-time events
on() covers the widget's own UI lifecycle. For message-level and call events (new messages, typing, button clicks, calls), subscribe to Webhooks on your backend.