The History plugin allows you to automatically monitor Single Page
App (SPA) navigations that change their routes via the
window.history
object.
The History plugin can be used for any SPA (eg. Angular, Backbone, Ember, React, Vue, etc.) and replaces the deprecated Angular, Backbone and Ember plugins.
Note: This plugin requires the BOOMR.plugins.AutoXHR and
BOOMR.plugins.SPA plugins to be loaded first (in that order).
For details on how Boomerang Single Page App instrumentation works, see the
BOOMR.plugins.SPA documentation.
For information on how to include this plugin, see the Building tutorial.
Compatibility
This plugin should work with any Single Page App, by instrumenting the
window.history
object to monitor for route changes.
The SPA app needs to change the history state or hash before doing the work required to
change the route (eg. XHRs, DOM node changes). With frameworks where the history events
happen after the route change has completed (e.g. Ember.js 1.x), we can configure the
plugin with monitorHistory: false and call BOOMR.plugins.SPA.route_change() manually
when the route change begins.
Beacon Parameters
This plugin does not add any additional beacon parameters beyond the
BOOMR.plugins.SPA plugin.
Usage
Include the BOOMR.plugins.AutoXHR, BOOMR.plugins.SPA
and BOOMR.plugins.History plugins. See Building for details.
Methods
-
disable()
-
Disables the History plugin
Returns:
BOOMR.plugins.HistoryThe History plugin for chaining -
enable()
-
Enables the History plugin
Returns:
BOOMR.plugins.HistoryThe History plugin for chaining -
hook(history [, hadRouteChange] [, options])
-
Hooks Boomerang into the History events.
Parameters:
Name Type Argument Description historyobject Deprecated
hadRouteChangeboolean <optional>
Deprecated event prior to this
hook()calloptionsobject <optional>
Optional options. Can contain
routeFilterand/orrouteChangeWaitFilterReturns:
BOOMR.plugins.HistoryThe History plugin for chaining -
init(config)
-
Initializes the plugin.
Parameters:
Name Type Description configobject Configuration
Properties
Name Type Argument Description History.autoboolean <optional>
Whether or not to automatically instrument the
window.historyobject. If set tofalse, the React snippet should be used.History.disableHardNavboolean <optional>
Whether or not to disable SPA hard beacons
History.routeFilterfunction <optional>
Route change filter callback function
History.routeChangeWaitFilterfunction <optional>
Route change wait filter callback function
History.routeChangeWaitFilterHardNavsboolean <optional>
Whether to apply wait filter on hard navs
History.monitorReplaceStateboolean <optional>
Whether or not to hook History.replaceState
Returns:
BOOMR.plugins.HistoryThe History plugin for chainingExample
BOOMR.init({ History: { enabled: true }); }); -
is_complete()
-
This plugin is always complete (ready to send a beacon)
Returns:
Type: boolean
true