Fix stateStorageStrategy localStorage not increasing session counters
See original GitHub issueWe are looking into changing the stateStorageStrategy
from cookie
to localstorage
. The current mechanism to detect a new session is the absence of the _sp_ses cookie which expires after the configured sessionCookieTimeout
. The problem is, that localstorage does not have an expiry mechanism, so the the _sp_ses.xxxx key in local storage stays forever.
The timestamps are properly written to the _sp_id.xxxx key in local storage. And the timestamps are actually enough to detect a beginning of a new session. If current timestamp and last visit time stamp are longer apart from each other than the session duration, the counter could be incremented.
And then we could get rid of _sp_ses cookie/localstorage key.
What do you think?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Session not tracked correctly - Discourse – Snowplow
We had a similar problem when using “localStorage” for the storage strategy. By setting it to “cookie” we managed to get the session...
Read more >localStorage is not working on google chrome - Stack Overflow
LocalStorage supports only string values, not boolean or others. Method to store and retrieve values: Put the value into storage
Read more >How to Fix "localStorage is not defined" in Next.js
This is because localStorage is not defined on the window object, and Next.js performs a server render before the client render. Therefore, you'll...
Read more >How to Make localStorage Reactive in Vue - CSS-Tricks
While the counter property inside the Vue instance is reactive, it won't change just because we changed its origin in localStorage . There...
Read more >Build a COUNTER with LOCAL STORAGE in JAVASCRIPT
Learn how to build a javascript counter that saves its result to the browsers local storage ! A beginner friendly javascript tutorial!
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The issue has been addressed at Snowplow forums (https://discourse.snowplowanalytics.com/t/session-not-tracked-correctly/3026). Can it be prioritized @alexanderdean ? Especially as it seems to be slight workaround for ITP2.2.
I owe everyone on this thread an update! Sincere apologies for the radio silence.
One thing that has held things up on this is that we ideally don’t want to ship a change before we’ve completed a new suite of integration tests for the tracker. We’ve had to roll patches to a few tracker releases recently following up on regression bugs, and even a few is a few too many! With histories and configurations as long as our trackers, they’re hard to manually test. So we’re investing time in automated tests that build confidence that the release is going to work, end to end, as intended and in perpetuity. We’d like to get at least the beginnings of these tests and cover off some critical paths before rolling out any change to the storage strategy.
We’re in a position to prioritise both the tests and this change now, so we’ll hopefully not keep you waiting too long. I’ve made a note to keep this thread updated with progress. Thank you for your patience!