Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mouselog

Package Overview
Dependencies
Maintainers
2
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mouselog - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

8

index.js

@@ -11,3 +11,7 @@ const uuidv4 = require('uuid/v4');

// The response data will be decoded by `decoder`
decoder: x => x
decoder: x => x,
// Use GET method to upload data? (stringified data will be embedded in URI)
enableGET: false,
// Time interval for resending the failed trace data
resendInterval: 3000
};

@@ -124,3 +128,3 @@

impressionId,
{ encoder: config.encoder, decoder: config.decoder }
config
);

@@ -127,0 +131,0 @@ }

{
"name": "mouselog",
"version": "0.0.5",
"version": "0.0.6",
"description": "The mouse tracking agent for Mouselog.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -5,4 +5,29 @@ [![NPM version](https://img.shields.io/npm/v/mouselog)](https://www.npmjs.com/package/mouselog)

# Usage
Mouselog.js
====
Mouselog.js is the client-side agent for Microsoft's [Mouselog](https://github.com/microsoft/mouselog), a user behavior monitoring platform for websites.
## Embedded JS
Embed Mouselog in your HTML files:
```html
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/mouselog@0.0.5-beta2/mouselog.js"></script>
<script>
mouselog.run("Your_Server_Url", "Your_Website_Id");
</script>
```
You can also refer mouselog dynamically in Javascript:
```Javascript
(function() {
var script = document.createElement("script");
script.src = "https://cdn.jsdelivr.net/npm/mouselog@0.0.5-beta2/mouselog.js";
script.onload = () => {
mouselog.run("Your_Server_Url", "Your_Website_Id");
}
var t = document.getElementsByTagName("script");
var s = t.length > 0 ? t[0].parentNode : document.body;
s.appendChild(script, s);
})();
```
## NPM

@@ -23,3 +48,7 @@ Install Mouselog.js via

// The response data will be decoded by `decoder`
decoder: x => x
decoder: x => x,
// Use GET method to upload data? (stringified data will be embedded in URI) default: false
enableGET: false,
// Time interval for resending the failed trace data, default: 3000
resendInterval: 3000
}

@@ -29,3 +58,3 @@ ```

```Javascript
mouselog.run("YOUR_SERVER_URL", "YOUR_WEBSITE_NAME", config);
mouselog.run("YOUR_SERVER_URL", "YOUR_WEBSITE_ID", config);
```

@@ -32,0 +61,0 @@

@@ -15,7 +15,2 @@ let StatusEnum = {

start(serverUrl, websiteId, impressionId, options) {
// options = {
// timeInterval: 3000,
// encoder: JSON.stringify,
// decoder: undefied
// }
this.serverUrl = serverUrl;

@@ -25,8 +20,9 @@ this.websiteId = websiteId;

// Resend all the failed data in this.buf every `timeInterval` ms
let timeInterval = options.timeInterval ? options.timeInterval : 3000;
// Resend all the failed data in this.buf every `resendInterval` ms
let resendInterval = options.resendInterval ? options.resendInterval : 3000;
this.resendInterval = setInterval(()=>{
this.resendFailedData.call(this);
}, timeInterval);
}, resendInterval);
this.enableGET = options.enableGET ? options.enableGET : false;
this.encoder = options.encoder ? options.encoder : JSON.stringify;

@@ -61,11 +57,26 @@ this.decoder = options.decoder ? options.decoder : x=>x;

_getUploadPromise(encodedData) {
if (this.enableGET) {
return new Promise((resolve, reject) => {
fetch(`${this.serverUrl}/api/upload-trace?websiteId=${this.websiteId}&impressionId=${this.impressionId}&data=${encodedData}`, {
method: "GET",
credentials: "include"
})
});
} else {
return new Promise((resolve, reject) => {
fetch(`${this.serverUrl}/api/upload-trace?websiteId=${this.websiteId}&impressionId=${this.impressionId}`, {
method: "POST",
credentials: "include",
body: encodedData
})
});
}
}
_uploadData(obj) {
obj.status = StatusEnum.SENDING;
let encodedData = this.encoder(obj.data);
console.log(`Here: ${this.serverUrl}`);
fetch(`${this.serverUrl}/api/upload-trace?websiteId=${this.websiteId}&impressionId=${this.impressionId}`, {
method: "POST",
credentials: "include",
body: encodedData
}).then(res => {
this._getUploadPromise(encodedData)
.then(res => {
if (res.status == 200) {

@@ -72,0 +83,0 @@ obj.status = StatusEnum.SUCCESS;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc