Hook into key moments of the alby widget’s lifecycle in order to enable custom functionality and seamless integration with your website.
This documentation provides information about the events that the alby widget publishes to the browser during its lifecycle.
Custom Events
generativeQARendered
- Description: This event is dispatched when the alby is fully loaded, and the alby widget is ready to be rendered on the screen.
- Usage: You can listen for this event to trigger any post-render actions, such as adjusting layout, displaying additional elements, or logging analytics data.
-
document.addEventListener('generativeQARendered', function() {
console.log('alby widget has been rendered!'); // Custom logic after widget renders
});
generativeQAEmpty
- Description: This event is dispatched when the widget is unable to be displayed, which can happen for various reasons. These include data not being available due to failures, a background job still processing data, or intentional conditions like the user being part of a holdout group for testing purposes. This event informs the browser that the alby widget cannot be rendered at the moment, but the underlying cause may vary.
- Usage: You can listen for this event to trigger fallback logic, such as displaying an error message, retrying the data load, or logging the failure for debugging and analytics purposes.
-
document.addEventListener('generativeQAEmpty', function() {
console.log('alby widget unable to load.'); // Custom fallback logic (e.g., hide loading animation)
});