Comparing version 0.0.4-beta1 to 0.0.4-beta2
25
index.js
@@ -7,4 +7,9 @@ const uuidv1 = require('uuid/v1'); | ||
url: "/data", | ||
// Upload data once capture `frequency` events. | ||
frequency: 50, | ||
} | ||
// If config.upload.encoder is defined, data object will be encoded by `encoder` before uploading. | ||
encoder: JSON.stringify, | ||
// If config.upload.decoder is defined, data will be decoded by `decoder` after receiving the response from the server | ||
decoder: undefined | ||
}, | ||
}; | ||
@@ -56,3 +61,4 @@ | ||
id: uuid, | ||
url: window.location.pathname, | ||
url: window.location.hostname ? window.location.hostname : "localhost", | ||
path: window.location.pathname, | ||
width: document.body.scrollWidth, | ||
@@ -72,4 +78,9 @@ height: document.body.scrollHeight, | ||
trace.events = eventsList.slice(start, end) | ||
let buffer; | ||
let traceStr = JSON.stringify(trace); | ||
if (config.upload.encoder) { | ||
buffer = config.upload.encoder(trace); | ||
} else { | ||
buffer = trace; | ||
} | ||
@@ -79,4 +90,8 @@ return fetch(config.upload.url, { | ||
credentials: 'include', | ||
body: traceStr, | ||
}).then(res => res.json()); | ||
body: buffer, | ||
}).then(res => { | ||
if (config.upload.decoder) | ||
res = config.upload.decoder(res); | ||
//TODO | ||
}); | ||
} | ||
@@ -83,0 +98,0 @@ |
{ | ||
"name": "mouselog", | ||
"version": "0.0.4-beta1", | ||
"version": "0.0.4-beta2", | ||
"description": "The mouse tracking agent for Mouselog.", | ||
@@ -12,8 +12,3 @@ "main": "index.js", | ||
"author": "Microsoft", | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/microsoft/mouselog.js/blob/master/LICENSE" | ||
} | ||
], | ||
"license": "MIT", | ||
"dependencies": { | ||
@@ -20,0 +15,0 @@ "uuid": "^3.3.3" |
@@ -0,1 +1,3 @@ | ||
[![NPM version](https://img.shields.io/npm/v/mouselog)](https://www.npmjs.com/package/mouselog) | ||
# Configuration | ||
@@ -2,0 +4,0 @@ |
9663
132
21