Class: Cobrowser

Overview

Examples:

Accept a CoBrowsing request


engagement.cobrowser.addUnbufferedEventListener(
  engagement.cobrowser.EVENTS.COBROWSING_REQUEST,
  function(cobrowsingRequest) {
    cobrowsingRequest.allow();
  }
);

Listen to mode changes and stop a CoBrowsing session on user event


engagement.cobrowser.addBufferedEventListener(
  engagement.cobrowser.EVENTS.MODE_CHANGE,
  function(cobrowsingState) {
    if (cobrowsingState.mode === engagement.cobrowser.MODES.ENGAGEMENT) {
      var stopButton = document.createElement("div");
      stopButton.innerHTML = 'Stop CoBrowsing';
      stopButton.addEventListener('click', function() {
        cobrowsingState.session.stop();
      });
      document.body.appendChild(stopButton);
    }
  }
);

Events:

COBROWSING_REQUEST

Triggered when an Operator requests to CoBrowse with the Visitor. Accepting this request means that the Operator can fill inputs, click links etc in the Visitor's stead. This event might be triggered multiple times. Declining one request does not prevent further requests from being sent by the Operator. The event listener will be called with a CobrowsingRequest instance.

MODE_CHANGE

Triggered when CoBrowsing mode is changed. For instance, when Operator accepts Visitor's CoBrowsing request, mode is changed from 'OBSERVATION' to 'ENGAGEMENT' and MODE_CHANGE event is triggered right after. The event is also triggered when Engagement is being re-established, e.g. when loading the page after Visitor has navigated. The event listener will be called with a CobrowsingState instance.

Variables Summary

EVENTS =
{
  COBROWSING_REQUEST: 'cobrowsing_request',
  MODE_CHANGE: 'cobrowser_mode_change'
}
MODES =
{
  OBSERVATION: 'OBSERVATION',
  ENGAGEMENT: 'ENGAGEMENT',
  POINTER: 'POINTER'
}

Instance Method Summary

Instance Method Details

# (void) addUnbufferedEventListener(type, listener)

This method allows registration of event listeners on the Cobrowser.

If a listener is added while the Cobrowser is processing an event, it will be not triggered with the current event.

If multiple identical listeners are registered on the same event type the duplicate instances are discarded. They do not cause the listener to be called twice and do not need to be removed with the removeEventListener method.

Parameters:

  • type ( string ) The event type for which the user is registering. Must be one of Cobrowser.EVENTS.
  • listener ( function ) The listener function that will be called when the event occurs.

# (void) removeUnbufferedEventListener(type, listener)

This method allows the removal of event listeners from the Cobrowser.

If an event listener is removed while the Cobrowser is processing an event, it will not be triggered with the current event.

An event listener is never invoked after being removed.

Calling removeEventListener with arguments which do not identify any currently registered listener has no effect.

Parameters:

  • type ( string ) The event type for the listener being removed.
  • listener ( function ) The event listener to be removed.

# (void) addBufferedEventListener(type, listener)

This method allows registration of Cobrowser buffered event listeners on the API.

If you want to add listeners when starting the application, then this should be the default choice over Cobrowser#addUnbufferedEventListener.

This listener has a buffer for events that occurred before the listener was added. It will buffer the last event that was fired before any listeners were added. In another word, if a listener is added during or after an event has occurred, the listener will trigger immediately.

This can be useful, for example, if a listener should fire for events that occurred during page loading and all the scripts were not yet initialized.

A popular example is MODE_CHANGE event which, in addition to regular CoBrowsing mode changes, is also triggered when Engagement is being re-established after Visitor navigation.

If multiple identical listeners are registered on the same event type the duplicate instances are discarded. They do not cause the listener to be called twice and do not need to be removed with the removeBufferedEventListener method.

Examples:

engagement.cobrowser.addBufferedEventListener(
  engagement.cobrowser.EVENTS.MODE_CHANGE,
  function(payload) {
    // Handle event here
  }
);

Parameters:

  • type ( string ) The event type for which the Visitor is registering. Must be one of Cobrowser.EVENTS.
  • listener ( function ) The listener function that will be called when the event occurs.

# (void) removeBufferedEventListener(type, listener)

This method allows the removal of Cobrowser buffered event listeners from the API.

If an event listener is removed while the API is processing an event, it will not be triggered with the current event.

An event listener is never invoked after being removed.

Calling removeBufferedEventListener with arguments which do not identify any currently registered listener has no effect.

Parameters:

  • type ( string ) The event type for the listener being removed.
  • listener ( function ) The event listener to be removed.

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: