An implementation based on browser storage
event to persist items in local storage and session storage against clear action.
1 ✔ | 45 ✔ | ? | 15 ✔ | (min version support?) ✔ |
For more details, visit mdn.
npm i permanent-storage
import PermanentStorage from "permanent-storage";
// default is localStorage
const trackerStorage = new PermanentStorage();
/* can be overridden by passing storage object
const trackerStorage = new PermanentStorage(window.sessionStorage);
*/
trackerStorage.setItem("a", "7823634e-0b8d-4b5d-ac59-d1bd298d6116");
trackerStorage.setItem("tracking-id", "UA298d61");
trackerStorage.getItem("tracking-id");
trackerStorage.removeItem("tracking-id");
trackerStorage.clear();
For anonymous users, if you want to curbstone to prevent spam, this could be a neat and more reliable solution than using browser fingerprint. Fingerprinting is prune to data change that generate different hashes over time. Even if fingerprinting is using canvas images; chances of collision and gradual inconsistency are high.
Copyright (c) 2020 - present by Rehan Umar and individual contributors. Licensed under MIT license.