Examples

Install the module

Run the following command to install the module (make sure to install the core module beforehand):

npm i @sentiance-react-native/driving-insights

Import the module

import SentianceDrivingInsights from "@sentiance-react-native/driving-insights";

You can find a reference to all the types mentioned on this page here.

Get driving insights

// returns Promise<DrivingInsights>
const drivingInsights = await SentianceDrivingInsights.getDrivingInsights(transportId);

// the transport event corresponding to driving insights.
const transportEvent = drivingInsights.transportEvent; 

// safety scores for the driving event.
const safetyScores = drivingInsights.safetyScores;

// Smooth driving score value, between 0 and 1, where 1 is the perfect score.
const smoothScore = safetyScores.smoothScore;

// Focused driving score value, between 0 and 1, where 1 is the perfect score.
const focusScore = safetyScores.focusScore;

Get Harsh Driving Events

const harshDrivingEvents = await SentianceDrivingInsights.getHarshDrivingEvents(transportId);

Listen to driving insights updates

const subscription = await SentianceDrivingInsights.addDrivingInsightsReadyListener(drivingInsights => {
  // Driving insights received
});

// Don't forget to unsubscribe, typically in componentWillUnmount
subscription.remove();

Last updated