Search in sources :

Example 1 with SessionState

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);
}
Also used : MetricsRouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.MetricsRouteProgress)

Example 2 with SessionState

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;
}
Also used : SessionState(com.mapbox.services.android.navigation.v5.navigation.metrics.SessionState) FeedbackEvent(com.mapbox.services.android.navigation.v5.navigation.metrics.FeedbackEvent) Date(java.util.Date) NonNull(android.support.annotation.NonNull)

Example 3 with SessionState

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);
}
Also used : SessionState(com.mapbox.services.android.navigation.v5.navigation.metrics.SessionState) Date(java.util.Date) RerouteEvent(com.mapbox.services.android.navigation.v5.navigation.metrics.RerouteEvent)

Example 4 with SessionState

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);
}
Also used : SessionState(com.mapbox.services.android.navigation.v5.navigation.metrics.SessionState) MetricsLocation(com.mapbox.services.android.navigation.v5.location.MetricsLocation) Location(android.location.Location)

Example 5 with SessionState

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());
}
Also used : SessionState(com.mapbox.services.android.navigation.v5.navigation.metrics.SessionState) MetricsLocation(com.mapbox.services.android.navigation.v5.location.MetricsLocation) Location(android.location.Location)

Aggregations

SessionState (com.mapbox.services.android.navigation.v5.navigation.metrics.SessionState)6 Date (java.util.Date)3 Location (android.location.Location)2 MetricsLocation (com.mapbox.services.android.navigation.v5.location.MetricsLocation)2 NonNull (android.support.annotation.NonNull)1 FeedbackEvent (com.mapbox.services.android.navigation.v5.navigation.metrics.FeedbackEvent)1 RerouteEvent (com.mapbox.services.android.navigation.v5.navigation.metrics.RerouteEvent)1 MetricsRouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.MetricsRouteProgress)1