rum-diary-js-client
v0.0.4
Published
rum-diary javascript client - Capture RUM: timers, events, navigation timing, resource timing.
Downloads
10
Maintainers
Readme
rum-diary-js-client
rum-diary compatible JavaScript client - Capture RUM: timers, events, navigation timing, resource timing.
Installation
Bower
The easiest way to install rum-diary-js-client is through bower.
bower install rum-diary-js-client
- Add a script to your HTML
<script src="bower_components/rum-diary-js-client/dist/rum-diary-js-client.js" defer async></script>
Minified resources can also be used:
<script src="bower_components/rum-diary-js-client/dist/rum-diary-js-client.min.js" defer async></script>
Clone the git repo
If bower isn't your thing, it is easy to do things the old fashioned way.
git clone https://github.com/shane-tomlinson/rum-diary-js-client.git
- Copy
rum-diary-js-client/dist/rum-diary-js-client.js
to a location of your choice. - Add a script tag to the copied file from step 2.
Configuration
The client is configured through data-
attributes on the script
element.
data-autoinit
If data-autoinit
is set to false
, automatic initialization will not occur and
the client must be manually initialized. See Advanced use
Defaults to true
data-tags
Comma separated list of tags to send to the server. Useful when performing experiments to tag a data set as belonging to a certain class.
Defaults to empty.
data-load_url
URL where to send "load" data. "Load" data is data that is available at the time
of window.onload
. This includes navigationTiming data, referrer, and whether
the user is a returning user.
Defaults to https://rum-diary.org/metrics
data-unload_url
URL where to send "unload" data. "Unload" data is data that is available at the time ofwindow.onunload
. This includes events, timers, and page view duration.
Defaults to https://rum-diary.org/metrics
Advanced use
Manual use
Manual use is normally only needed for access to the events and timers functionality.
First, set data-autoinit
to false
in the script tag.
<script src="/bower_components/rum-diary-js-client/dist/rum-diary-js-client.js" data-autoinit="false" defer async></script>
Get a reference to the JS client. For more on how, see below. Once a reference is obtained, instantiate a client instance.
var client = new RumDiaryJSClient();
client.init({
tags: 'experiment1266',
loadUrl: '/my_stats_collector',
unloadUrl: '/my_stats_collector'
});
Obtain a reference to the client
Use without a module loader
If used without a module loader, the client is accessible via window.RumDiaryJSClient
.
With Requirejs
Rum-diary-js-client is AMD ready and can be used like any other AMD module.
With Browserify
Rum-diary-js-client is UMD ready and can be used with Browserify.
Client API
getLoad
Get data avaialble at window.load
sendLoad
Send data available at window.load
to the loadUrl
specified in init.
getUnload
Get data avaialble at window.unload
. This includes events, timers, and duration.
sendUnload
Send data available at window.unload
to the unloadUrl
specified in init.
logEvent
Log an event.
client.logEvent('my-event');
startTimer
Start a timer.
client.startTimer('my-timer');
stopTimer
Stop a timer.
client.stopTimer('my-timer');
Get Involved:
Author:
- Shane Tomlinson
- [email protected]
- [email protected]
- [email protected]
- https://shanetomlinson.com
- https://github.com/shane-tomlinson
- @shane_tomlinson
License:
This software is available under version 2.0 of the MPL:
https://www.mozilla.org/MPL/