use of com.mapbox.services.android.navigation.v5.navigation.metrics.SessionState in project mapbox-navigation-android by mapbox.
the class NavigationMetricsWrapper method arriveEvent.
static void arriveEvent(SessionState sessionState, RouteProgress routeProgress, Location location) {
Hashtable<String, Object> arriveEvent = MapboxNavigationEvent.buildArriveEvent(sdkIdentifier, BuildConfig.MAPBOX_NAVIGATION_VERSION_NAME, sessionState.sessionIdentifier(), location.getLatitude(), location.getLongitude(), sessionState.currentGeometry(), routeProgress.directionsRoute().routeOptions().profile(), routeProgress.directionsRoute().distance().intValue(), routeProgress.directionsRoute().duration().intValue(), sessionState.rerouteCount(), sessionState.startTimestamp(), (int) (sessionState.eventRouteDistanceCompleted() + routeProgress.distanceTraveled()), (int) routeProgress.distanceRemaining(), (int) routeProgress.durationRemaining(), sessionState.mockLocation(), sessionState.originalRequestIdentifier(), sessionState.requestIdentifier(), sessionState.originalGeometry(), sessionState.originalDistance(), sessionState.originalDuration(), null, sessionState.currentStepCount(), sessionState.originalStepCount());
MetricsRouteProgress metricsRouteProgress = new MetricsRouteProgress(routeProgress);
int absoluteDistance = DistanceUtils.calculateAbsoluteDistance(location, metricsRouteProgress);
MapboxTelemetry.getInstance().addPercentTimeInForeground(sessionState.percentInForeground(), arriveEvent);
MapboxTelemetry.getInstance().addPercentTimeInPortrait(sessionState.percentInPortrait(), arriveEvent);
MapboxTelemetry.getInstance().addAbsoluteDistanceToDestination(absoluteDistance, arriveEvent);
MapboxTelemetry.getInstance().addLocationEngineName(sessionState.locationEngineName(), arriveEvent);
MapboxTelemetry.getInstance().pushEvent(arriveEvent);
MapboxTelemetry.getInstance().flushEventsQueueImmediately(false);
}
use of com.mapbox.services.android.navigation.v5.navigation.metrics.SessionState in project mapbox-navigation-android by mapbox.
the class NavigationTelemetry method queueFeedbackEvent.
@NonNull
private FeedbackEvent queueFeedbackEvent(@FeedbackEvent.FeedbackType String feedbackType, String description, @FeedbackEvent.FeedbackSource String feedbackSource) {
updateLifecyclePercentages();
// Distance completed = previous distance completed + current RouteProgress distance traveled
double distanceCompleted = navigationSessionState.eventRouteDistanceCompleted() + metricProgress.getDistanceTraveled();
// Create a new session state given the current navigation session
SessionState feedbackEventSessionState = navigationSessionState.toBuilder().eventDate(new Date()).eventRouteProgress(metricProgress).eventRouteDistanceCompleted(distanceCompleted).eventLocation(metricLocation.getLocation()).mockLocation(metricLocation.getLocation().getProvider().equals(MOCK_PROVIDER)).build();
FeedbackEvent feedbackEvent = new FeedbackEvent(feedbackEventSessionState, feedbackSource);
feedbackEvent.setDescription(description);
feedbackEvent.setFeedbackType(feedbackType);
queuedFeedbackEvents.add(feedbackEvent);
return feedbackEvent;
}
use of com.mapbox.services.android.navigation.v5.navigation.metrics.SessionState in project mapbox-navigation-android by mapbox.
the class NavigationTelemetry method queueRerouteEvent.
private void queueRerouteEvent() {
updateLifecyclePercentages();
// Create a new session state given the current navigation session
Date eventDate = new Date();
SessionState rerouteEventSessionState = navigationSessionState.toBuilder().eventDate(eventDate).eventRouteProgress(metricProgress).eventLocation(metricLocation.getLocation()).secondsSinceLastReroute(getSecondsSinceLastReroute(eventDate)).mockLocation(metricLocation.getLocation().getProvider().equals(MOCK_PROVIDER)).build();
RerouteEvent rerouteEvent = new RerouteEvent(rerouteEventSessionState);
queuedRerouteEvents.add(rerouteEvent);
}
use of com.mapbox.services.android.navigation.v5.navigation.metrics.SessionState in project mapbox-navigation-android by mapbox.
the class NavigationTelemetry method sendFeedbackEvent.
private void sendFeedbackEvent(FeedbackEvent feedbackEvent) {
if (feedbackEvent.getSessionState().startTimestamp() == null) {
return;
}
// Create arrays with locations from before / after the reroute occurred
List<Location> beforeLocations = createLocationListBeforeEvent(feedbackEvent.getSessionState().eventDate());
List<Location> afterLocations = createLocationListAfterEvent(feedbackEvent.getSessionState().eventDate());
// Update session state with locations after feedback
SessionState feedbackSessionState = feedbackEvent.getSessionState().toBuilder().beforeEventLocations(beforeLocations).afterEventLocations(afterLocations).build();
NavigationMetricsWrapper.feedbackEvent(feedbackSessionState, metricProgress, feedbackEvent.getSessionState().eventLocation(), feedbackEvent.getDescription(), feedbackEvent.getFeedbackType(), feedbackEvent.getScreenshot(), feedbackEvent.getEventId(), vendorId);
}
use of com.mapbox.services.android.navigation.v5.navigation.metrics.SessionState in project mapbox-navigation-android by mapbox.
the class NavigationTelemetry method sendRerouteEvent.
private void sendRerouteEvent(RerouteEvent rerouteEvent) {
// If there isn't an updated geometry, don't send
if (rerouteEvent.getNewRouteGeometry() == null || rerouteEvent.getSessionState().startTimestamp() == null) {
return;
}
// Create arrays with locations from before / after the reroute occurred
List<Location> beforeLocations = createLocationListBeforeEvent(rerouteEvent.getSessionState().eventDate());
List<Location> afterLocations = createLocationListAfterEvent(rerouteEvent.getSessionState().eventDate());
// Update session state with locations after feedback
SessionState rerouteSessionState = rerouteEvent.getSessionState().toBuilder().beforeEventLocations(beforeLocations).afterEventLocations(afterLocations).build();
// Set the updated session state
rerouteEvent.setRerouteSessionState(rerouteSessionState);
NavigationMetricsWrapper.rerouteEvent(rerouteEvent, metricProgress, rerouteEvent.getSessionState().eventLocation());
}
Aggregations