declare module "@sentiance-react-native/driving-insights" { import { EmitterSubscription } from "react-native"; export interface DrivingInsights { transportEvent: TransportEvent, safetyScores: SafetyScores } export interface SafetyScores { /** * Smooth driving score, between 0 and 1, where 1 is the perfect score. */ smoothScore?: number; /** * Focused driving score, between 0 and 1, where 1 is the perfect score. */ focusScore?: number; /** * Legal driving score, between 0 and 1, where 1 is the perfect score. */ legalScore?: number; /** * Call while moving driving score, between 0 and 1, where 1 is the perfect score. */ callWhileMovingScore?: number; /** * Overall driving score, between 0 and 1, where 1 is the perfect score. */ overallScore?: number; /** * Harsh braking score, between 0 and 1, where 1 is the perfect score. */ harshBrakingScore?: number; /** * Harsh turning score, between 0 and 1, where 1 is the perfect score. */ harshTurningScore?: number; /** * Harsh acceleration score, between 0 and 1, where 1 is the perfect score. */ harshAccelerationScore?: number; /** * Wrong way driving score, between 0 and 1, where 1 is the perfect score. */ wrongWayDrivingScore?: number; /** * Attention score, between 0 and 1, where 1 is the perfect score. */ attentionScore?: number; } export interface DrivingEvent { startTime: string; startTimeEpoch: number; // in milliseconds endTime: string; endTimeEpoch: number; // in milliseconds waypoints: Waypoint[]; } export type HarshDrivingEventType = | "ACCELERATION" | "BRAKING" | "TURN"; export interface HarshDrivingEvent extends DrivingEvent { magnitude: number; confidence: number; type: HarshDrivingEventType; } export interface PhoneUsageEvent extends DrivingEvent { /** * State of phone call during the phone usage event. */ callState: "NO_CALL" | "CALL_IN_PROGRESS" | "UNAVAILABLE"; } /** * @deprecated Use {@link CallEvent} instead. */ export interface CallWhileMovingEvent extends DrivingEvent { maxTravelledSpeedInMps?: number; minTravelledSpeedInMps?: number; } export type CallEvent = DrivingEvent & { /** * Maximum speed during the call in meters per second. */ maxTraveledSpeedInMps: number | null, /** * Minimum speed during the call in meters per second. */ minTraveledSpeedInMps: number | null, /** * Hands-free state during the call. */ handsFreeState: "HANDS_FREE" | "HANDHELD" | "UNAVAILABLE" }; export interface SpeedingEvent extends DrivingEvent { } export interface WrongWayDrivingEvent extends DrivingEvent { } export interface TransportEvent { id: string; startTime: string; startTimeEpoch: number; // in milliseconds lastUpdateTime: string; lastUpdateTimeEpoch: number; // in milliseconds endTime: string | null; endTimeEpoch: number | null; // in milliseconds durationInSeconds: number | null; type: string; transportMode: TransportMode | null; waypoints: Waypoint[]; distance?: number; // in meters transportTags: TransportTags; occupantRole: OccupantRole; /** * Indicates whether the event is provisional. * *

A provisional event is identified based on real-time detections, but may change in the near future * as more data is collected and processed, to filter out unwanted artifacts. * For example, a provisional car transport may get identified, followed by a provisional bus transport. * After the full trip is complete, these provisional events may get merged into a single final car event.

* *

Final events are generated independently of the provisional events, and have unique event IDs. They are * not linked to the provisional events they may resemble, replace, or overlap with.

* *

Currently, provisional events apply only to 'transport' types, as the SDK tries to determine the mode of * transport in (near) real time. When the full trip is complete (e.g. the user becomes stationary), * the collected data is reprocessed to produce a more accurate and cleaned up list of transport events.

*/ isProvisional: boolean; } export type TransportTags = { [key: string]: string }; export type TransportMode = | "UNKNOWN" | "BICYCLE" | "WALKING" | "RUNNING" | "TRAM" | "TRAIN" | "CAR" | "BUS" | "MOTORCYCLE"; export interface Waypoint { latitude: number; longitude: number; accuracy: number; // in meters timestamp: number; // UTC epoch time in milliseconds speedInMps?: number; // in meters per second /** * - If {@link isSpeedLimitInfoSet} is `false`, then this value will be `undefined`. * - If {@link hasUnlimitedSpeedLimit} is `true`, then this value will be `Number.MAX_VALUE`. */ speedLimitInMps?: number; // in meters per second hasUnlimitedSpeedLimit: boolean; isSpeedLimitInfoSet: boolean; isSynthetic: boolean; } export type OccupantRole = | "DRIVER" | "PASSENGER" | "UNAVAILABLE"; export interface SafetyScoreRequestParameters { /** * A period of the last 7, 14 or 30 days. */ period: 7 | 14 | 30; /** * Transport modes of interest. * * @defaultValue "ALL_MODES" */ transportModes: TransportMode[] | "ALL_MODES"; /** * Occupant roles of interest. * * @defaultValue "ALL_ROLES" */ occupantRoles: OccupantRole[] | "ALL_ROLES"; } export interface SentianceDrivingInsights { /** * Adds a listener that will be invoked when the driving insights for a completed, non-provisional transport becomes ready. *
* See {@link TransportEvent.isProvisional this} to learn more about what a provisional event is. * * @param onDrivingInsightsReady - listener to receive the driving insights */ addDrivingInsightsReadyListener(onDrivingInsightsReady: (drivingInsights: DrivingInsights) => void): Promise; /** * Returns the driving insights for a given non-provisional transport, or `null` if there are no driving insights, * the transport ID is invalid or the transport is a provisional one. *
* See {@link TransportEvent.isProvisional this} to learn more about what a provisional event is. * * @param transportId - the id of the desired transport */ getDrivingInsights(transportId: string): Promise; /** * Returns the harsh driving events for a completed, non-provisional transport. *
* See {@link TransportEvent.isProvisional this} to learn more about what a provisional event is. * * @param transportId - the id of the desired transport */ getHarshDrivingEvents(transportId: string): Promise; /** * Returns the phone usage events for a completed, non-provisional transport. *
* See {@link TransportEvent.isProvisional this} to learn more about what a provisional event is. * * @param transportId - the id of the desired transport */ getPhoneUsageEvents(transportId: string): Promise; /** * Returns the call while moving events for a completed, non-provisional transport. *
* See {@link TransportEvent.isProvisional this} to learn more about what a provisional event is. * * @deprecated Use {@link getCallEvents} instead. * * @param transportId - the id of the desired transport */ getCallWhileMovingEvents(transportId: string): Promise; /** * Returns the call events for a completed, non-provisional transport. *
* See {@link TransportEvent.isProvisional this} to learn more about what a provisional event is. * * @param transportId - the id of the desired transport */ getCallEvents(transportId: string): Promise; /** * Returns the speeding events for a completed, non-provisional transport. *
* See {@link TransportEvent.isProvisional this} to learn more about what a provisional event is. * * @param transportId - the id of the desired transport */ getSpeedingEvents(transportId: string): Promise; /** * Returns the wrong way driving events for a completed, non-provisional transport. *
* See {@link TransportEvent.isProvisional this} to learn more about what a provisional event is. * * @param transportId - the id of the desired transport */ getWrongWayDrivingEvents(transportId: string): Promise; /** * Returns the average overall safety score for a given set of parameters. * * @param params - the parameters for which the score will be calculated. * @returns the average overall safety score, or `null` if a score is not available. * @throws {@link Error} if any of the inputs provided is invalid. * @example * ``` * import drivingInsights from "@sentiance-react-native/driving-insights"; * const params = { * period: 7, * transportModes: ["CAR", "BUS"], * occupantRoles: "ALL_ROLES" * } * const avgOverallScore = await drivingInsights.getAverageOverallSafetyScore(params); * ``` */ getAverageOverallSafetyScore(params: SafetyScoreRequestParameters): Promise; } const SentianceDrivingInsights: SentianceDrivingInsights; export default SentianceDrivingInsights; }