osmandapp / OsmAnd

OsmAnd
https://osmand.net
Other
4.67k stars 1.02k forks source link

Trip recording / online tracking: add unique session ID (e.g. UUID4) to URL variables #19704

Open bastimeyer opened 6 months ago

bastimeyer commented 6 months ago

Describe the idea (required)

With #16044 being fixed via 8541e0d86521 (thank you) and the online tracking feature now being usable, there's one tiny thing which is missing IMO, namely a unique session ID which gets generated every time a new recording is started. That session ID could be a simple UUID4 string for example.

Tell us about the expected behaviour (required)

My use-case is basically described here: https://github.com/osmandapp/OsmAnd/issues/16044#issuecomment-2081514195

I've built a server backend for collecting my live cycling data with a small web frontend which displays the live data (and past sessions). A session system is currently difficult to implement, because it's limited to reading the timestamps of the individual requests made by OsmAnd, where my backend has to set a specific timestamp diff threshold to figure out whether a new session was started. Having a URL variable for a unique session ID would be a great addition.

Tell us about alternatives you've considered (required)

A unique session ID parameter could be set manually in the URL via the app's settings menu, but that's really tedious and annoying, because it'd have to be changed every time.

An implementation for this simple feature should however be really trivial: https://github.com/osmandapp/OsmAnd/blob/cfe4c24d862e4748e22138bd57f0153e0ad3274b/OsmAnd/src/net/osmand/plus/plugins/monitoring/LiveMonitoringHelper.java#L246-L283

Simply generate a UUID4 string when starting a new recording, keep it stored on the LiveMonitoringHelper instance and make it available in LiveMonitoringHelper.getLiveUrl(). Alternatively, add the unique session ID to each LiveMonitoringData object.

I could probably hack something together myself and submit a PR with the changes, but since I don't have any experience with Java and Andoid development and also don't want to spend hours setting everything up, I'm opening this feature request instead and kindly ask for one of the devs to have a look at this. Thank you!

Context (optional)

No response

vshcherb commented 6 months ago

I didn't understand why you can't hard code UUID in url template like 'https://.... /uuid=123123&lat={1}&lon={2}...'

bastimeyer commented 6 months ago

I didn't understand why you can't hard code UUID in url template like 'https://.... /uuid=123123&lat={1}&lon={2}...'

As explained, the URL in the plugin settings would have to be changed manually every time the user starts a new recording. Adding a URL variable for unique recording/session IDs eleminates the need to update the URL manually, which is tedious and annoying.

vshcherb commented 6 months ago

Session id could be detected on server side if you have unique device id

bastimeyer commented 6 months ago

A device ID is not unique between sessions/recordings.

Maybe there's still a bit of confusion here because I probably didn't describe my feature request properly yet:

It's currently impossible on the receiving end of the individual HTTP requests made by OsmAnd's online tracking feature to distinguish between multiple sessions/recordings. This is because only the timestamp could in theory be used to figure out when a session/recording has stopped and when a new one has started, for example because enough time has passed between two HTTP requests. "Enough time" however is an arbitrary value, which makes this a non-ideal solution.

Since OsmAnd now only sends HTTP requests once the user starts recording and not while idling (changed via 8541e0d86521c734871acbb625823db495b42b6b), it's trivial to add a unique "session ID" or "recording ID" to the available URL variables (the next available one is {11}), so that the user doesn't have to set a custom session/recording ID to their configured URL and also doesn't have to update it every time manually before starting a new recording in the plugin settings menu. This ID must be unique and must update every time a new recording is started. The most simple solution would be generating a new UUID4 string when the recording is started. An implementation for that is super trivial. Making the ID available as a new URL variable also doesn't introduce any breaking changes for existing users, so there's no concern here either.

I hope this fully clarifies any confusion. Thanks for considering adding this.

vshcherb commented 6 months ago

Though OsmAnd uses arbitrary solution inside when Auto-saving track 20min pause - new segment, 2 h pause new track