Class

Overseer

Overseer()

Business Rules Engine (former name: Overseer) is a Glia module that is responsible for observing the visitors' activity on a site 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 the Business Rules Engine detects the behaviour that is described in any of the business rules, it triggers the corresponding business rule event.

Glossary:

  • reactive component - Component on the business's 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 available operators.
  • callout - A notification that hints the visitor about the reactive component.
  • media selection - Component that lets visitor choose media (audio, video, text, phone) for the engagement. Usually shown after the visitor has selected an operator, but could also be triggered by a business rule.
  • engagement invitation - Component that displays an engagement invitation to the visitor. The visitor's answer (either agreeing or disagreeing) determines if a reactive engagement will be started.
Constructor

# new Overseer()

Example

Adding a listener for a business rule event

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

Members

object

# EVENTS

Properties:
Name Type Description
REACTIVE_ENABLE string
REACTIVE_DISABLE string
REACTIVE_SET_POSITION string
REACTIVE_EXPAND string
MEDIA_SELECTION_START string
REACTIVE_CALLOUT_START string
ENGAGEMENT_INVITATION_SHOW string

Methods

# addBufferedEventListener(type, listener)

Registers a buffered event listener 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.

Popular examples are events which occur on "navigation", which fire immediately after the visitor navigates, but before the page scripts have completely initialized.

Another popular example is when Glia scripts have finished initialization, but the page scripts have not yet been initialized and a business rule 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.

Parameters:
Name Type Description
type string

The event type for which the listener is registering. Must be one of Overseer#EVENTS.

listener function

The listener function that will be called when the event occurs.

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

# addUnbufferedEventListener(type, listener)

Registers a Business Rules Engine event listener on the API.

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 website. E.g. opened a new tab in the application.

If a listener is added while the API is processing an event, it will not be 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.

Parameters:
Name Type Description
type string The event type for which the listener is registering. Must be one of Overseer#EVENTS.
listener function The listener function that will be called when the event occurs.
Example
salemove.overseer.addUnbufferedEventListener(
    salemove.overseer.EVENTS.MEDIA_SELECTION_START,
    function(payload) {
      // Handle event here
    }
  );

# removeBufferedEventListener(type, listener)

Removes a buffered event listener 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:
Name Type Description
type string

The event type for which the listener is removed.

listener function

The event listener to be removed.

# removeUnbufferedEventListener(type, listener)

Removes a Business Rules Engine event listener 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:
Name Type Description
type string

The event type for which the listener is removed.

listener function

The event listener to be removed.

Events

# ENGAGEMENT_INVITATION_SHOW

Triggered by a ENGAGEMENT_INVITATION_SHOW business rule action. The event listener will be called with a EngagementInvitationShow 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.

# REACTIVE_DISABLE

Triggered by a REACTIVE_DISABLE business rule action.

# REACTIVE_ENABLE

Triggered by a REACTIVE_ENABLE business rule action.

# REACTIVE_EXPAND

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

# REACTIVE_SET_POSITION

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