@mrporter/frontend-monitoring
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -32,9 +32,13 @@ 'use strict'; | ||
value: function trackEvent(event) { | ||
if (!this.client) { | ||
console.log('Keen Event (Dev Mode): ', event); | ||
} else if (event) { | ||
var collection = event.collection; | ||
var event_data = event.event_data; | ||
var sampleRate = arguments.length <= 1 || arguments[1] === undefined ? 1 : arguments[1]; | ||
this.client.addEvent(collection, { event_data: event_data }); | ||
if (Math.random() < sampleRate) { | ||
if (!this.client) { | ||
console.log('Keen Event (Dev Mode): ', event); | ||
} else if (event) { | ||
var collection = event.collection; | ||
var event_data = event.event_data; | ||
this.client.addEvent(collection, { event_data: event_data }); | ||
} | ||
} | ||
@@ -47,7 +51,9 @@ } | ||
this.trackEvent((0, _events.pagePerformance)()); | ||
var sampleRate = arguments.length <= 0 || arguments[0] === undefined ? 1 : arguments[0]; | ||
this.trackEvent((0, _events.pagePerformance)(), sampleRate); | ||
document.onreadystatechange = function () { | ||
if (document.readyState === 'complete') { | ||
_this.trackEvent((0, _events.domPerformance)()); | ||
_this.trackEvent((0, _events.domPerformance)(), sampleRate); | ||
} | ||
@@ -54,0 +60,0 @@ }; |
{ | ||
"name": "@mrporter/frontend-monitoring", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Utils and Events for MRP front end monitoring", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -19,3 +19,3 @@ # MRP Front End Monitoring | ||
``` | ||
monitoring.trackEvent(event); | ||
monitoring.trackEvent(event, sampleRate); | ||
@@ -28,2 +28,4 @@ // event should be of the form: | ||
``` | ||
The sampleRate is a float between 0 and 1, representing the proportion of events you want to track (e.g, 0 tracks nothing, 0.5 tracks half the events, 1 tracks all.) | ||
The following global properties are sent with every event: | ||
@@ -30,0 +32,0 @@ (see https://keen.io/docs/api/#data-enrichment) |
8318
136
54