Events
GlimpzeWidget.events holds the canonical event names. Subscribe with GlimpzeWidget.on(...), or listen on window; both deliver the same (sanitized) detail.
| Event | Constant | Fires when | Detail |
|---|---|---|---|
| State change | events.STATE_CHANGE (glimpze:state-change) | The widget transitions state | { state, previousState, event } |
| Availability | events.AVAILABILITY_CHANGE (glimpze:availability-change) | Live: an agent goes online/offline or a call starts/ends (pushed in real time, de-duped to genuine changes), plus once shortly after boot | { isAvailable, agents: { online, free, busy }, nextAvailableAt } |
| Ready | events.READY (glimpze:ready) | Once, the moment window.GlimpzeWidget is the live API and every call queued before boot has been replayed. A late listener misses it Use await GlimpzeWidget.ready() if you may subscribe late. | { version } |
| Internal | events.INTERNAL_EVENT (glimpze:event) | Advanced internal bus events | { type, payload } |
// Via the API (recommended):
GlimpzeWidget.on(GlimpzeWidget.events.STATE_CHANGE, ({ state, previousState }) => {
console.log('moved from', previousState.value, 'to', state.value);
});
// Or on window, without touching the API object:
window.addEventListener(GlimpzeWidget.events.AVAILABILITY_CHANGE, (evt) => {
toggleBanner(evt.detail.isAvailable);
});CTA template events
Two internal-bus event types cover embedded CTA templates, so you can send impressions and clicks to your own analytics.
| Type | Fires when | Payload |
|---|---|---|
cta_template_shown | An instance first scrolls into view, once per instance per page load | { templateId, surface: 'embed' } |
cta_template_clicked | A button inside a template is clicked | { templateId, surface: 'embed', action } |
GlimpzeWidget.on(GlimpzeWidget.events.INTERNAL_EVENT, ({ type, payload }) => {
if (type === 'cta_template_shown') analytics.track('Glimpze CTA seen', payload);
if (type === 'cta_template_clicked') analytics.track('Glimpze CTA clicked', payload);
});Capability tokens are never exposed. Conversation secrets and room URLs are stripped from every public surface, events and
getStatus(). Internal identifiers used by the runtime are not part of the public contract and may change.Widget states
getStatus().state and the STATE_CHANGE event report one of:
| State | Meaning |
|---|---|
idle | Closed / inactive. |
checkingSession | Restoring an existing session on load. |
preInteractionChoice | The home screen (call / chat choice). |
inChatOnly | A text conversation is active. |
incomingCallFromChat | An agent is calling the visitor. |
creatingCall | Setting up a call. |
connecting | Waiting for an agent to accept. |
queued | Waiting in queue for an available agent. |
joining | Joining the call room. |
inCall | Active call in progress. |
reconnecting | Attempting to reconnect a dropped call. |
reconnectFailed | Reconnection gave up. |
unavailable | No agents available (and AI not handling). |
error | An error occurred. |
States are an evolving contract: branch on the ones you need and tolerate unknown values rather than assuming the full set.