@videsk/uhistory
v1.0.4
Published
A Javascript library for browsing history for persistent or temporary record
Downloads
8
Readme
uHistory
uHistory is a Javascript library for tracking all browsing history. That means, save all page the user visit, with time in page, datetime and url.
Ex. This works for apps that need get history of user before offer support in realtime.
uHistory is totally compatible with SPA (single-page application).
This is not a replacement to Google Analytics or similars.
Is a complement for track users and get history in realtime during active session.
Ex. User request a new chat -> Get history -> Send to agent
This library can be complemented with a xDebugger!
This library was designed for Videsk™ :)
Features
- Save all visited page
- Track time in page
- Get datetime when page was visited
- Persistent history in localstorage (optional)
- Compatible with SPA or AJAX load
- LZ UTF-16 compression to history
- Protected access directly from session or local storage
Installation
Via NPM
npm i @videsk/uhistory
or in body
<script src="../uhistory.min.js"></script>
Use minified version in production located in dist/
folder.
How works
Not persistent history (only during session)
const history = new uHistory({});
history.init();
Persistent history (localStorage)
const history = new uHistory({ persistent: true });
history.init();
Get history
For get all history only need execute:
history.get();
// Output
// { history: Array, ua: String, lang: String }
The output it's composed of the follow keys:
history
: Array with all visited pagesua
: String with User-Agentlang
: String with the main language of browser
Schema of history
{
history: [
{
url: 'https://example.com/post/12345', // Page visited
time: 12345, // Time in page in milliseconds
date: 1568777632096 // Timestamp when page is loaded
}
]
}
Stop to tracking
For stop to tracking only need execute history.stop();
. This clean all data in store and stop all intervals.
Custom key for store
If you want save data with other key in local or session storage only need set before to initialize.
const history = new uHistory({ key: 'my-custom-key' });
history.init();
Copyrights
This library is totally open source with Apache 2.0 license, but was designed for Videsk™ products.