Class: Overseer

Overview

Overseer is part of the SaleMove platform that is responsible for observing Visitors and triggering events based on their behaviour.

A specified behaviour (e.g. spending a specified amount of time on page) and an action (e.g. showing a list of operators to the Visitor) make up a business rule. When Overseer detects behaviour that is described in any of business rules, it triggers the corresponding business rule event.

Glossary:

  • reactive component component on the Visitor page that can be used by the Visitor to start an engagement
  • expanded reactive the expanded reactive displays further options for starting an engagement, e.g. a list of Operators available
  • callout notification that hints the Visitor about the reactive component
  • media selection component that lets Visitor choose media (audio, video, text, phone etc) for the engagement. Usually shown after the Visitor has selected an Operator, but could also be triggered e.g. by a business rule.

Examples:

Adding a listener for an Overseer event

var expandReactiveTab = function(options) {
  var duration = options.duration;
  // Your code
};

salemove.overseer.addBufferedEventListener(
  salemove.overseer.REACTIVE_EXPAND,
  expandReactiveTab
);

Events:

REACTIVE_ENABLE

Triggered by a REACTIVE_ENABLE business rule action

REACTIVE_DISABLE

Triggered by a REACTIVE_DISABLE business rule action

REACTIVE_SET_POSITION

Triggered by a REACTIVE_SET_POSITION business rule action The event listener will be called with a ReactivePosition instance.

REACTIVE_EXPAND

Triggered by a REACTIVE_EXPAND business rule action. The event listener will be called with a ReactiveExpand instance.

MEDIA_SELECTION_START

Triggered by a MEDIA_SELECTION_START business rule action The event listener will be called with a MediaSelectionStart instance.

REACTIVE_CALLOUT_START

Triggered by a REACTIVE_CALLOUT_START business rule action The event listener will be called with a ReactiveCalloutStart instance.

Variables Summary

EVENTS =
{
  REACTIVE_ENABLE: 'overseer:reactive_enable',
  REACTIVE_DISABLE: 'overseer:reactive_disable',
  REACTIVE_SET_POSITION: 'overseer:reactive_set_position',
  REACTIVE_EXPAND: 'overseer:reactive_expand',
  MEDIA_SELECTION_START: 'overseer:media_selection_start',
  REACTIVE_CALLOUT_START: 'overseer:reactive_callout_start'
}

Instance Method Summary

Instance Method Details

# (void) addUnbufferedEventListener(type, listener)

This method allows registration of Overseer event listeners on the API.

This means that listeners added via this method will miss events triggered before the listener was added. E.g. events that occur before the page and its scripts are fully loaded. If you want to make sure that all events are handled in page lifecycle, consider using Overseer#addBufferedEventListener.

This listener is useful, for example, in Single Page Applications, where you want to add listeners after the Visitor has done some action on the web-page. E.g. opened a new tab in the application.

If a listener is added while the API 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 removeUnbufferedEventListener method.

Examples:

salemove.overseer.addUnbufferedEventListener(
  salemove.overseer.EVENTS.MEDIA_SELECTION_START,
  function(payload) {
    // Handle event here
  }
);

Parameters:

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

# (void) removeUnbufferedEventListener(type, listener)

This method allows the removal of Overseer 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 removeUnbufferedEventListener 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 Overseer buffered event listeners on the API.

If you want to add listeners when starting the application, then this should be the default choice over Overseer#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 events which occur on "navigation", which fires immediately after the Visitor navigates, but before the page scripts have completely initialized.

Another popular example is when SaleMove scripts have finished initialization, but the page scripts have not yet been initialized and an Overseer event fires. Using buffered listener can ensure that these events can be handled properly.

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:

salemove.overseer.addBufferedEventListener(
  salemove.overseer.EVENTS.MEDIA_SELECTION_START,
  function(payload) {
    // Handle event here
  }
);

Parameters:

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

# (void) removeBufferedEventListener(type, listener)

This method allows the removal of Overseer 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: