Session Events
Certain actions that happen within the session will trigger an event which can be tied to a certain Webhook defined by you.
But this can be extended further by yourself by leveraging our Virtual Web Extension API, allowing you to listen to certain Session events, such as when a session is started or the participant navigates to a new page. Next to that, each Session spins up its own Session API, such as: End the Session, Navigate to a Location, Load a Piece of Code, Send an API Message to Space Session
Use Cases
Section titled âUse CasesâGetting Started
Section titled âGetting StartedâSee the Session API reference for more information.
You can listen to and attach custom handler functions to events using webfuseSession.on(). Callback functions are provided with arguments, depending on the event type.
Session event handlers can be set with the webfuseSession.on() method, or with the global webfuse.on() method available from the Widget API. The latter will affect all existing and future sessions.
Callback functions should accept two arguments:
- A
Sessioninstance that Triggers the event - A JSON object with event attributes
// This will be Triggers for all sessions, including the restored oneswebfuse .on('session_ended', session => { console.log(session, 'has ended'); });
webfuse .initSpace('your_widget_key', 'your_space_id').then(async space => { const session = space.session();
// Add event listeners session.on('session_started', session => { console.log('Session has started'); });
session.on('participant_joined', (session, event) => { console.log('A participant joined with client index:', event.clientIndex); });
session.on('session_ended', session => { console.log('Session has ended'); });
// Start the session await session.start(); });session_created
Section titled âsession_createdâTriggers when a session is created (usually after space.session() call).
session_started
Section titled âsession_startedâTriggers when a session window has been loaded (usually after a call to session.start();). Has no additional parameters.
session_ended
Section titled âsession_endedâTriggers when the session has been properly finished (normally after clicking the close button, or as a result of session.end() call).
Parameters
Section titled âParametersâfinal_location
- On the leader side, URL of the last browsed page.
metadata_updated
Section titled âmetadata_updatedâTriggers when the session metadata is updated.
Parameters
Section titled âParametersâmetadata
- Object with the updated metadata values.
message
Section titled âmessageâTriggers when the message is received.
Parameters
Section titled âParametersâdata
- Message object sent from the other side.
origin
- The origin of the sender window.
host_rights_requested
Section titled âhost_rights_requestedâTriggers when host rights for the session had been requested.
Parameters
Section titled âParametersâclientIndex
- Index of the user who requested control.
host_rights_refused
Section titled âhost_rights_refusedâTriggers when host rights for the session had been refused.
Parameters
Section titled âParametersâclientIndex
- Index of the user whose request was refused.
host_changed
Section titled âhost_changedâTriggers when host of the session has been changed.
Parameters
Section titled âParametersâto
- Index of the client that now is the host. Always 0 for the leader, 1 or more for a viewer.
gained
- Set to true if host rights were given to the current user.
myIndex
- Contains the user index of the current user_activity.
file_downloaded
Section titled âfile_downloadedâTriggers when a file download occurs inside the session. Note that this event is only fired when the user is controlling the session. This JS event is fired regardless of the download_trigger_enabled session option.
Parameters
Section titled âParametersâurl
- Direct link to the downloaded file. File will be available until the end of the session.
filename - Name of the downloaded file.
chat_message
Section titled âchat_messageâTriggers when a message is received from the chat.
Parameters
Section titled âParametersâmessage
- Message received from the chat.
clientIndex
- Index of the user who sent the message
screen_resized
Section titled âscreen_resizedâTriggers every time the screen size of the session is changed.
Parameters
Section titled âParametersâwidth
- The width of the screen.
height
- The height of the screen.
Participant Events
Section titled âParticipant Eventsâparticipant_joined
Section titled âparticipant_joinedâTriggers when a participant joins the session.
Parameters
Section titled âParametersâclientIndex
- Index of the user. Can be used in subsequent
session.makeHost()calls.
userData
- Data provided in
userDataargument ofsession.start*()call.
participant_left
Section titled âparticipant_leftâTriggers when a participant leaves the session.
Parameters
Section titled âParametersâclientIndex
- Index of the user.
userData
- Data provided in
userDataargument ofsession.start*()call
user_activity
Section titled âuser_activityâTriggers when master clicks, moves mouse, or presses any key. Triggers once per second if activity is present.
Tab Events
Section titled âTab Eventsâtab_opened
Section titled âtab_openedâTriggers when a new tab with url is opened via session.openTab() api call.
Parameters
Section titled âParametersâurl
- Absolute URL of the new tab.
ssid
- SSID of the opened tab.
page_info
Section titled âpage_infoâTriggers when the page info is received from the cobrowsing session frame.
Parameters
Section titled âParametersâtitle
- The title of the page.
tabId
- SSID of the tab.
new_tab_opened
Section titled ânew_tab_openedâTriggers when a new tab page is opened.
tab_closed
Section titled âtab_closedâTriggers when a tab is closed.
Parameters
Section titled âParametersâssid
- SSID of the closed tab.
tab_relocate_start
Section titled âtab_relocate_startâ(not available inside a session)
Triggers when the current tab inside a virtual session starts loading a new page. In conjunction with the tab_relocated event, it allows you to track page loading inside a cobrowsing session. For example, use it to show a custom loading indicator.
Parameters
Section titled âParametersâurl
- Absolute URL loading webpage
ssid
- SSID of the tab that is starting to load a new page.
tab_relocated
Section titled âtab_relocatedâ(not available inside a session)
Triggers when a tab is relocated to a new url. Not available for media sharing tabs (screen sharing, video camera sharing).
Parameters
Section titled âParametersâurl
- Absolute URL of the new location.
ssid
- SSID of the relocated tab.
tab_reloaded
Section titled âtab_reloadedâTriggers when a tab reload is triggered. Not available for media sharing tabs (screen sharing, video camera sharing).
Parameters
Section titled âParametersâurl
- Absolute URL of the new location.
ssid
- SSID of the reloaded tab.
tab_paused
Section titled âtab_pausedâTriggers when a tab is paused by the tab owner. See also tab_resumed event.
Parameters
Section titled âParametersâleaderIndex
- Index of the participant who owns the tab.
ssid
- SSID of the paused tab.
tab_resumed
Section titled âtab_resumedâTriggers when a session is resumed after a pause. See also tab_paused event.
Parameters
Section titled âParametersâleaderIndex
- Index of the participant who owns the tab.
ssid
- SSID of the resumed tab.
tab_activated
Section titled âtab_activatedâTriggers when a tab is activated by any means, such as a session tab click or a session.activateTab() API call â including a click on the already-active tab, so the event may fire even when the active tab does not change.
Parameters
Section titled âParametersâssid
- SSID of the activated tab.
tab_control_requested
Section titled âtab_control_requestedâTriggers when control over the tab has been requested.
Parameters
Section titled âParametersâclientIndex
- Index of the user who requested control.
ssid
- SSID of the tab that control has been requested for.
tab_control
Section titled âtab_controlâTriggers when control over the tab has been transferred.
Parameters
Section titled âParametersâleaderIndex
- Index of the participant who owns the tab.
controlIndex
- Index of the participant who controls the tab at the moment.
ssid
- SSID of the tab that control has been transferred for.
huddle_mode
Section titled âhuddle_modeâTriggers when huddle mode is toggled.
Parameters
Section titled âParametersâenabled
- Status of huddle mode (
boolean).
huddle_follow
Section titled âhuddle_followâTriggers when a when a participant follows another participant. This event is only trigged when huddle mode is enabled.
Parameters
Section titled âParametersâclient_index
- Index of the follower.
following_index
- Index of the parcipant the
client_indexis following.
(not available inside a session)
Triggers on common errors.
Parameters
Section titled âParametersâreason
- Error description. Currently may be one of the following:
"other_connection"the leader_link was opened elsewhere. The new window/browser becomes the leader and the old leader is kicked out. It also happens if follower_link was open twice in the same browser."connect_failed"The WebSocket connection to Surfly cannot be established."create_failed"Surfly session could not be created. Check thedetailsattribute of the event object for more information about the error."start_failed"Surfly session could not be started. Check thedetailsattribute of the event object for more information about the error.
popup_enabled
Section titled âpopup_enabledâTriggers when the extension popup is enabled.
Parameters
Section titled âParametersâextensionId
- ID of the extension that enabled the popup.
tabId
- ID of the tab that the popup is enabled for.
nullif the popup is enabled for all tabs.
popup_disabled
Section titled âpopup_disabledâTriggers when the extension popup is disabled.
Parameters
Section titled âParametersâextensionId
- ID of the extension that disabled the popup.
tabId
- ID of the tab that the popup is disabled for.
nullif the popup is disabled for all tabs.
popup_badge_text_set
Section titled âpopup_badge_text_setâTriggers when the badge text of the extension popup is set.
Parameters
Section titled âParametersâextensionId
- ID of the extension that set the badge text.
text
- The text to set as the badge text.
tabId
- ID of the tab that the badge text is set for.
nullif the badge text is set for all tabs.
popup_badge_background_color_set
Section titled âpopup_badge_background_color_setâTriggers when the background color of the extension popup badge is set.
Parameters
Section titled âParametersâextensionId
- ID of the extension that set the background color.
color
- The background color to set as the badge color.
tabId
- ID of the tab that the background color is set for.
nullif the background color is set for all tabs.
popup_title_set
Section titled âpopup_title_setâTriggers when the title of the extension popup is set.
Parameters
Section titled âParametersâextensionId
- ID of the extension that set the title.
title
- The title to set as the popup title.
tabId
- ID of the tab that the title is set for.
nullif the title is set for all tabs.
popup_icon_set
Section titled âpopup_icon_setâTriggers when the icon of the extension in the top bar is set.
Parameters
Section titled âParametersâextensionId
- ID of the extension that set the icon.
icon
- The url of the icon that is set as the extension icon.
tabId
- ID of the tab that the icon is set for.
nullif the icon is set for all tabs.
popup_set
Section titled âpopup_setâTriggers when the popup of the extension is set.
Parameters
Section titled âParametersâextensionId
- ID of the extension that set the popup.
popup
- The url of the popup that is set as the extension popup.
tabId
- ID of the tab that the popup is set for.
nullif the popup is set for all tabs.
extension_side_panel_opened
Section titled âextension_side_panel_openedâTriggers when the extension side panel is opened.
Parameters
Section titled âParametersâextensionId
- ID of the extension that opened the side panel.
tabId
- ID of the tab that the side panel is opened for.
nullif the side panel is opened for all tabs.
extension_side_panel_closed
Section titled âextension_side_panel_closedâTriggers when the extension side panel is closed.
Parameters
Section titled âParametersâextensionId
- ID of the extension that closed the side panel.
tabId
- ID of the tab that the side panel is closed for.
nullif the side panel is closed for all tabs.
extension_side_panel_options_set
Section titled âextension_side_panel_options_setâTriggers when the options of the extension side panel are set.
Parameters
Section titled âParametersâextensionId
- ID of the extension that set the side panel options.
options
- The options that were set.
optionsobject contains the following properties:path: The path to the side panel template file relative to the root folder of the extension directory.enabled: Whether the side panel is enabled.tabId: ID of the tab that the side panel options are set for.nullif the side panel options are set for all tabs.
tabId
- ID of the tab that the side panel options are set for.
nullif the side panel options are set for all tabs.
extension_side_panel_layout_set
Section titled âextension_side_panel_layout_setâTriggers when the layout of the extension side panel is set.
Parameters
Section titled âParametersâextensionId
- ID of the extension that set the side panel layout.
side
- The side of the extension side panel that was set. It must be either
leftorright, default isright.
tabId
- ID of the tab that the side panel layout is set for.
nullif the side panel layout is set for all tabs.
extension_side_panel_behavior_set
Section titled âextension_side_panel_behavior_setâTriggers when the behavior of the extension side panel is set.
Parameters
Section titled âParametersâextensionId
- ID of the extension that set the side panel behavior.
openPanelOnActionClick
- Whether the side panel should be opened on action click. Default value is
false.
extension_refreshed
Section titled âextension_refreshedâTriggers when an Extension is refreshed in the Session.
Parameters
Section titled âParametersâextension_id
- ID of the Extension that was refreshed.
extension_removed
Section titled âextension_removedâTriggers when an Extension is removed from the Session.
Parameters
Section titled âParametersâextension_id
- ID of the Extension that was removed.
Session UI Events
Section titled âSession UI EventsâThese events fire when a built-in session UI panel or dialog is opened or closed, whether triggered through the Session API ui namespace or by the user.
chat_sidebar_opened / chat_sidebar_closed
Section titled âchat_sidebar_opened / chat_sidebar_closedâTriggers when the chat sidebar is opened or closed.
videochat_sidebar_opened / videochat_sidebar_closed
Section titled âvideochat_sidebar_opened / videochat_sidebar_closedâTriggers when the video chat sidebar is opened or closed.
participants_sidebar_opened / participants_sidebar_closed
Section titled âparticipants_sidebar_opened / participants_sidebar_closedâTriggers when the participants sidebar is opened or closed.
viewport_control_opened / viewport_control_closed
Section titled âviewport_control_opened / viewport_control_closedâTriggers when the viewport control drawer is opened or closed.
automation_inspector_opened / automation_inspector_closed
Section titled âautomation_inspector_opened / automation_inspector_closedâTriggers when the Automation Inspector panel is opened or closed.
space_editor_opened
Section titled âspace_editor_openedâTriggers when the space editor is opened.
Parameters
Section titled âParametersâmenu
- The active editor menu (
settings,extensions,apps, oraccess), ornull.
tab
- The active settings tab, or
null.
space_editor_closed
Section titled âspace_editor_closedâTriggers when the space editor is closed.
invite_dialog_opened / invite_dialog_closed
Section titled âinvite_dialog_opened / invite_dialog_closedâTriggers when the invite dialog is opened or closed.
video_settings_opened / video_settings_closed
Section titled âvideo_settings_opened / video_settings_closedâTriggers when the video settings dialog is opened or closed.
end_dialog_opened / end_dialog_closed
Section titled âend_dialog_opened / end_dialog_closedâTriggers when the end-session confirmation dialog is opened or closed.
videosharing_settings_opened / videosharing_settings_closed
Section titled âvideosharing_settings_opened / videosharing_settings_closedâTriggers when the video sharing settings dialog is opened or closed.
Videochat Events
Section titled âVideochat EventsâThese events fire when the videochat state changes, whether triggered through the Session API or by the user.
videochat_started
Section titled âvideochat_startedâTriggers when the videochat is started.
videochat_camera_toggled
Section titled âvideochat_camera_toggledâTriggers when the camera is turned on or off.
Parameters
Section titled âParametersâcamera
- The new camera state (
trueif on).
videochat_microphone_toggled
Section titled âvideochat_microphone_toggledâTriggers when the microphone is muted or unmuted.
Parameters
Section titled âParametersâmicrophone
- The new microphone state (
trueif on).
videochat_fullscreen_toggled
Section titled âvideochat_fullscreen_toggledâTriggers when videochat fullscreen mode is toggled.
Parameters
Section titled âParametersâfullscreen
- The new fullscreen state (
trueif fullscreen).
videochat_mode_changed
Section titled âvideochat_mode_changedâTriggers when the videochat mode changes.
Parameters
Section titled âParametersâmode
- The new mode (
sidebarorfloating).
videochat_floating_position_changed
Section titled âvideochat_floating_position_changedâTriggers when the floating videochat window is moved.
Parameters
Section titled âParametersâx / y
- The new top-left position of the floating videochat window, in viewport pixels.
screensharing_started / screensharing_stopped
Section titled âscreensharing_started / screensharing_stoppedâTriggers when screensharing starts or stops.