analytics icon indicating copy to clipboard operation
analytics copied to clipboard

Analytics Util Session - utilSessions.extendSession().isNew (Always False)

Open zgjimgjonbalaj opened this issue 4 years ago • 1 comments

Thanks for the awesome tools in this area, much needed. Also, not a huge issue here but thought I'd share.

I'm hoping to use this plugin to track sessions to a custom backend, followed the documentation here: https://github.com/DavidWells/analytics/blob/master/packages/analytics-util-session/example/index.html

Including the libs in the browser directly as such:

<!-- Include from CDN -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/analytics.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@analytics/[email protected]/dist/browser/session-utils.umd.js"></script>

I am essentially hoping to avoid calling getSession() and instead just fire the extendSession() whenever activity has been detected (page view, clicks etc) or whenever I call Analytics.track() for example but whenever I call extendSession() after clearing out cookies to "reset" the session, it successfully creates the new session but the parameter isNew always returns false. Should this be true sine all cookies were removed? Thinking that the isNew should return true whenever it is a new session despite what method is called?

Only when I run getSession() and it is in fact a new session (cookies cleared) do I get a isNew: true. Attaching a screengrab below.

image

zgjimgjonbalaj avatar Aug 09 '21 20:08 zgjimgjonbalaj

I see what you mean. I'll try to come up with something around this when I get a chance

DavidWells avatar Aug 27 '21 05:08 DavidWells