Skip to content

Navigation Metrics Refactor - #511

Merged
danesfeder merged 11 commits into
masterfrom
dan-telem-refactor
Nov 21, 2017
Merged

danesfeder merged 11 commits into
masterfrom
dan-telem-refactor

Conversation

@danesfeder

@danesfeder danesfeder commented Nov 16, 2017 •

Copy link
Copy Markdown
Contributor
  • Removes all telemetry from NavigationService
  • Removes SessionState from MapboxNavigation
  • Creates NavigationMetricListener for NavigationTelemetry
  • Moves offRoute checks for time / distance since last reroute to the OffRouteDetector

if (isArrivalEvent) {
navigationMetricListener.onArrival(location, routeProgress);
// Remove off route listeners
removeOffRouteListener(null);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work with multiple waypoints?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point - will adjust this


if (isOffRoute) {
// If we are off-route, update the reroute count
navigationBuilder.rerouteCount(navigationSessionState.rerouteCount() + 1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to add a field in RerouteEvent

isOffRoute = false;
} else {
// Not current off-route - just update the session
navigationSessionState = navigationBuilder.build();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll most likely need to update sessionState.routeDistanceCompleted here.

}
}

private String obtainVendorId(Context context) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For another PR: we might want to expose this publicly for our internal apps to be able to display this on a settings page.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ticketed #516


public abstract int rerouteCount();

public abstract double routeDistanceCompleted();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably shouldn't expose these publicly.

}

static void turnstileEvent() {
public static void turnstileEvent() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these methods (including the afterEventLocations() above) still necessary with the dynamic creation of location arrays from the location buffer?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to adjust the minimumDistance based on directions profile?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I've noted this to revisit.

@Guardiola31337 Guardiola31337 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 7e6b6bd (pg-511-nav-metrics)

  • Hides visibility of NavigationMetricsWrapper
  • Cleans up RouteUtilsTest

@danesfeder danesfeder added ✓ ready for review and removed ⚠️ DO NOT MERGE PR should not be merged! labels Nov 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants