1.0.2 • Published 1 year ago
@guillaumebonnaire/sleep-tracker-js v1.0.2
sleeper-tracker-js
Sleep tracker JS is a component for tracking user inactivity on a web application. This component manages several pages opened
Get started
const sleepTrackerInstance = sleepTracker({
timeout: 60, // in minutes, By default is 30 minutes
delayCallAwake: 10
});
sleepTrackerInstance.on("beforeasleep", function() {
// Open modal to ask if user is awake ! If ok call sleepTrackerInstance.awake();
});
sleepTrackerInstance.on("awakened", function() {
// User indicate on other page he awake. If modal is open, you can close it
});
sleepTrackerInstance.on("awake", function() {
// Execute code to indicate to the server user is awake
});
sleepTrackerInstance.on("asleep", function() {
// Execute code because user is asleep. example logout, black screen, ...
});
CDN
You can use this CDN link
<script src="https://cdn.jsdelivr.net/gh/GBonnaire/sleep-tracker-js@latest/dist/sleeptracker.min.js"></script>
NPM
npm install @guillaumebonnaire/sleep-tracker-js
import sleepTracker from '@guillaumebonnaire/sleep-tracker-js';