Class: Framework

Framework

The Analytics Framework's goal is to abstract capturing all the events in code for the purpose of analytics reporting (from any source). When a plugin is registered with the framework, it will be validated, registered and automatically receive all messages that are published to the framework. The list of events that are currently supported are located in AnalyticsConstants.js. That file also contains all the methods that need to be implemented by a plugin for it to be considered valid.

Framework()

Initialize an instance of the current class using the new keyword along with this constructor.

Methods

RegisterPluginFactory(factory)

Registers a plugin factory in a global list of factories and then registers the factory with any existing framework instances.
Parameters:
Name Type Description
factory object The factory creation function

RegisterFrameworkInstance(framework)

Registers a framework instance in a global list of frameworks and then register any plugin factory that are in the global plugin factory list.
Parameters:
Name Type Description
framework object Instance of the framework to register

UnregisterFrameworkInstance(framework)

Remove a framework instance from the global list of instance. You must have a reference to the FrameworkRegistrationObject from that framework to remove it. This is meant for framework instances to remove themselves from the list only.
Parameters:
Name Type Description
framework object Instance of the FrameworkRegistrationObject created when framework instance was registered

setPluginMetadata(pluginMetadata) → {boolean}

Set the metadata for all plugins. Each plugin will only receive the data pluginMetadata["myPluginName"]. This can only be set once per framework instance.
Parameters:
Name Type Description
pluginMetadata object Object containing metadata for all plugins
Returns:
Return true if metadata is valid and has not been set before.
Type
boolean

destroy()

Destructor/cleanup for OO.Analytics.Framework.

getRecordedEvents() → {Array}

Returns a shallow copy array of the currently stored recordedEvents in chronological order.
Returns:
Shallow copy of recordedEvents in chronological order.
Type
Array

registerPlugin(pluginFactory) → {string}

Register plugin as a factory. It will be validated and an instance of it will be maintained internally. The plugin will then be able to receive events from the framework. Multiple of the same plugin factory can be registered. Each one will have its own unique plugin id.
Parameters:
Name Type Description
pluginFactory function Plugin factory function
Returns:
Returns a unique plugin id for this plugin factory.
Type
string

unregisterPlugin(pluginIDToRemove) → {boolean}

Remove plugin from the framework. All instances will stop receiving messages from the framework.
Parameters:
Name Type Description
pluginIDToRemove string Plugin id to be removed
Returns:
Return true if plugin was found and removed.
Type
boolean

validatePlugin(plugin) → {boolean}

Validates that a plugin instance has all the correct functions.
Parameters:
Name Type Description
plugin object Plugin instance to be validated
Returns:
Return true if plugin contains all the correct functions.
Type
boolean

getPluginIDList() → {Array}

Get a list of plugin ids for the currently registered plugins.
Returns:
An array of plugin IDs.
Type
Array

isPluginActive(pluginID) → {boolean}

Return whether or not a plugin is active and able to receive events.
Parameters:
Name Type Description
pluginID string Plugin id to check
Returns:
Returns true if plugin is active. If plugin isn't registered, it will return false.
Type
boolean

makePluginActive(pluginID) → {boolean}

Set a plugin to be active and receive messages.
Parameters:
Name Type Description
pluginID string Plugin id to set to active
Returns:
Returns true if plugin found and was able to be activated.
Type
boolean

makePluginInactive(pluginID) → {boolean}

Set a plugin to be inactive.
Parameters:
Name Type Description
pluginID string Plugin id to set to inactive
Returns:
Returns true if plugin found and was able to be deactivated.
Type
boolean

flattenEvents(eventObject) → {Array.<string>}

Helper function to flatten an object with a nested objects into a single array of values.
Parameters:
Name Type Description
eventObject object The event key-value pair to flatten
Returns:
An array of strings representing the flattened values of the object.
Type
Array.<string>

createEventDictionary() → {object|null}

Helper function to create the events lookup dictionary.
Returns:
The created events dictionary. Returns null if there are any errors.
Type
object | null

publishEvent(eventName, params) → {boolean}

Publish an event to all registered and active plugins.
Parameters:
Name Type Description
eventName string Name of event to publish
params Array Parameters to pass along with the event.
Returns:
Return true if message is in OO.Analytics.EVENTS and was successfully published.
Type
boolean