While safari running on private mode window.localStorage will be available (not null/undefined ) but setItem will throw exception . It will make data loss while user this library to tracking .
Currently my solution is create custom in-memory storage to replace default storage while below condition is fulfilled :
testStorageAvailable=()->
storage = window.localStorage
if storage?
try
storage.setItem("Storage Available", "true")
return true
catch e
return false
else
return false
While safari running on private mode window.localStorage will be available (not null/undefined ) but setItem will throw exception . It will make data loss while user this library to tracking .
Currently my solution is create custom in-memory storage to replace default storage while below condition is fulfilled :
testStorageAvailable=()-> storage = window.localStorage if storage? try storage.setItem("Storage Available", "true") return true catch e return false else return false