Repository navigation
Navigation Metrics Refactor - #511
Conversation
| if (isArrivalEvent) { | ||
| navigationMetricListener.onArrival(location, routeProgress); | ||
| // Remove off route listeners | ||
| removeOffRouteListener(null); |
There was a problem hiding this comment.
How does this work with multiple waypoints?
There was a problem hiding this comment.
Good point - will adjust this
|
|
||
| if (isOffRoute) { | ||
| // If we are off-route, update the reroute count | ||
| navigationBuilder.rerouteCount(navigationSessionState.rerouteCount() + 1); |
There was a problem hiding this comment.
Reminder that the reroute event should hold the reroute count from before the reroute. So if this is the first reroute event the count should be 0. This will probably be addressed by moving queueRerouteEvent to onOffRouteEvent.
There was a problem hiding this comment.
This should work the way it needs to. This is only called after the route is updated after an off-route (and we are in an off-route state). At the time of an off-route event, the reroute count will not be updated (it will capture the current reroute count).
| */ | ||
| void updateSessionRoute(DirectionsRoute directionsRoute) { | ||
| SessionState.Builder navigationBuilder = navigationSessionState.toBuilder(); | ||
| navigationBuilder.currentDirectionRoute(directionsRoute); |
There was a problem hiding this comment.
Keep in mind that the reroute event should always contain the stats of the route before the new route comes in. Let's double check that this doesn't override any of that information, such as the distanceRemaining + step object. It looks like this will be addressed by moving queueRerouteEvent to onOffRouteEvent.
There was a problem hiding this comment.
Updated to add a field in RerouteEvent
| isOffRoute = false; | ||
| } else { | ||
| // Not current off-route - just update the session | ||
| navigationSessionState = navigationBuilder.build(); |
There was a problem hiding this comment.
We'll most likely need to update sessionState.routeDistanceCompleted here.
| } | ||
| } | ||
|
|
||
| private String obtainVendorId(Context context) { |
There was a problem hiding this comment.
For another PR: we might want to expose this publicly for our internal apps to be able to display this on a settings page.
|
|
||
| public abstract int rerouteCount(); | ||
|
|
||
| public abstract double routeDistanceCompleted(); |
There was a problem hiding this comment.
Nit: routeDistanceCompleted makes it hard to understand that this represents the total distance completed before the current route.
| } | ||
|
|
||
| static void arriveEvent(SessionState sessionState, RouteProgress routeProgress, Location location, | ||
| public static void arriveEvent(SessionState sessionState, RouteProgress routeProgress, Location location, |
There was a problem hiding this comment.
We probably shouldn't expose these publicly.
| } | ||
|
|
||
| static void turnstileEvent() { | ||
| public static void turnstileEvent() { |
There was a problem hiding this comment.
This shouldn't be public as someone could just call this static method and send many turnstile events.
| previousName = routeProgress.getCurrentStepName(); | ||
|
|
||
| beforeLocations = obtainLocations(sessionState.beforeRerouteLocations()); | ||
| beforeLocations = obtainLocations(sessionState.beforeEventLocations()); |
There was a problem hiding this comment.
Are these methods (including the afterEventLocations() above) still necessary with the dynamic creation of location arrays from the location buffer?
There was a problem hiding this comment.
Yeah good catch - all before / after location logic is now in NavigationTelemetry
| // Check if minimum amount of time has passed since last reroute | ||
| long secondsBeforeRerouteAllowed = TimeUnit.SECONDS.toMillis(options.secondsBeforeReroute()); | ||
| if (location.getTime() > timeSinceLastOffRoute + secondsBeforeRerouteAllowed) { | ||
| timeSinceLastOffRoute = location.getTime(); |
There was a problem hiding this comment.
Let's remove this 3 second check for now and just go with the minimumDistance check for consistency with iOS.
Thinking more about this, 25/50m isn't great for slow speed walking (that's 40s), but we can revisit this cross-platform in another PR.
cc @bsudekum
There was a problem hiding this comment.
Would it make sense to adjust the minimumDistance based on directions profile?
There was a problem hiding this comment.
Yeah, I've noted this to revisit.
Guardiola31337
left a comment
There was a problem hiding this comment.
👀 7e6b6bd (pg-511-nav-metrics)
- Hides visibility of
NavigationMetricsWrapper - Cleans up
RouteUtilsTest
…ionMetricsWrapper
…arrays that are non-primitive
- Create contract for TelemetryEvent - Rework session state
32e6100 to
49a097e
Compare
NavigationServiceSessionStatefromMapboxNavigationNavigationMetricListenerforNavigationTelemetryOffRouteDetector