Custom Dimension - Session Id, how to identify session start/end
I have a single page web application with some Custom Dimensions that are session-level.
To my understanding, a session-level custom dimension will take the last value they were set to during that session, then apply them to all events during that session.
This is useful, but only if you can identify which session you are in by an ID.
Two use cases:
The issue with implementing these is when my single page application is refreshed, I have no method of determining if I am in a new session or not (or what the last values of those dimensions were - I can use localStorage but I still need to know the GA session ID).
How can I determine which session I am in with JS? Is there an API?