Comprehensive event system for tracking widget lifecycle and interactions
Fires when a new chat session is created. Includes sessionId and metadata.
Fires when chat session ends. Includes duration and message count.
User submitted a message. Includes message text and timestamp.
AI response completed. Includes full response text and queryId.
User is typing. Fires with debounced updates for activity tracking.
User stopped typing. Fires after 1 second of inactivity.
Widget opened by user. Includes sessionId and timestamp.
Widget closed by user. Includes sessionId and timestamp.
User submitted feedback (thumbs, stars, emoji). Includes rating and messageId.
User copied message content. Includes content and messageId.
Error occurred. Includes type, message, and stack trace.
Click buttons to trigger events and see them appear in the monitor:
// Initialize widget
const widget = window.NexusChatWidget.init({
experienceId: "your-experience-id",
apiUrl: "undefined"
});
// Listen to events
widget.on('sessionStart', (data) => {
console.log('Session started:', data.sessionId);
});
widget.on('messageComplete', (data) => {
console.log('AI response:', data.answer);
});
widget.on('feedback', (data) => {
console.log('User feedback:', data.rating);
});
widget.on('error', (error) => {
console.error('Error:', error.message);
});Events will appear here...