LogoLogo
SentianceInsights-Control-TowerLegacy DocsImportant Security Notice
  • Introduction
  • Integrating the SDK
    • Getting Started
    • Android Quick Start
      • 1. Including the SDK
      • 2. Initialization
      • 3. User Creation
      • 4. Enabling Detections
      • 5. SDK Status Updates
      • 6. Permissions
      • 7. Additional Requirements
    • iOS Quick Start
      • 1. Including the SDK
        • Using CocoaPods
        • Using Carthage
        • Using Swift Package Manager
        • Manual Integration
      • 2. Project Settings
      • 3. Initialization
      • 4. User Creation
      • 5. Enabling Detections
      • 6. SDK Status Updates
      • 7. Permissions
      • 8. Additional Requirements
    • React Native Quick Start
      • 1. Including the SDK
      • 2. Configuration
      • 3. Initialization
      • 4. User Creation
      • 5. Enabling Detections
      • 6. SDK Status Updates
    • Flutter Quick Start
      • 1. Including the SDK
      • 2. Configuration
      • 3. Initialization
      • 4. User Creation
      • 5. Enabling Detections
      • 6. SDK Status Updates
    • What Comes After Integration
    • Integration (FAQ)
    • Detections (FAQ)
  • Sentiance Insights
    • Overview of Sentiance Insights
      • Driving Insights
        • Transports
        • Driving Events and Scores
        • Car Crashes
      • Mobility and Lifestyle Insights
        • Visit Essentials
        • User Segmentation
    • Engagement
      • User Adaptive Score
      • Streaks
      • Challenges
      • Reward System
      • Communication Campaign
      • Social Groups
        • Technical Details
    • Accessing Sentiance Insights
      • via On Device API
      • via Cloud API
      • via Firehose - Realtime Messages
      • via Offloads
  • FAQ
    • Security, Privacy and Terms of Service (FAQ)
  • Important topics
    • SDK
      • Appendix
        • Android
          • Android 10 Update Behavior
          • Android Battery Optimization
          • Artifacts & Dependencies
          • Manifest Permissions
          • Notification Management
          • Sample Notification
          • Supported API Levels
        • iOS
          • App Store Privacy Section
          • App Store Release
          • Apple Privacy Manifest
          • ARM Simulator Support
          • Dependencies
          • iOS 13 permission changes
          • Supported iOS Versions & Architectures
          • Swift Support
          • v5.x Framework Files
          • v6.x Framework Files
        • Controlled Detections
          • Automatic Detections
          • Automatic Detections with Forced Trips
          • Controlled Trips Only
          • Checking Trip Status
        • Control Sending Data
        • Custom User Metadata
        • Detecting Vehicle Crashes
        • Feature Production Readiness
        • Migration Guide
          • Android
          • iOS
          • React Native
          • Flutter
        • On-Device Features
        • React Native
        • SDK Initialization
        • User Access Token
        • User Creation
        • User Linking
        • Xamarin
      • API Reference
        • Android
          • AsyncInitializationError
          • AsyncInitializationResult
          • DateTime
          • DetectionStatus
          • DisableDetectionsError
          • DisableDetectionsResult
          • Driving Insights
            • CallWhileMovingEvent
            • DrivingInsight
            • DrivingInsightsApi
            • DrivingInsightsReadyListener
            • HarshDrivingEvent
              • Type
            • PhoneUsageEvent
            • SafetyScores
            • SafetyScoreRequestParameters
              • Builder
              • OccupantRoles
              • Period
              • TransportModes
            • SpeedingEvent
          • Smart Geofences
            • DetectionMode
            • SmartGeofence
            • SmartGeofenceApi
            • SmartGeofenceEvent
              • Type
            • SmartGeofenceEventListener
            • SmartGeofencesRefreshError
              • SmartGeofencesRefreshFailureReason
            • SmartGeofencesRefreshResult
          • EnableDetectionsError
            • EnableDetectionsFailureReason
          • EnableDetectionsResult
          • EventTimeline
            • EventType
            • TransportMode
            • Event
              • OffTheGridEvent
              • StationaryEvent
              • TransportEvent
              • UnknownEvent
            • EventTimelineUpdateListener
            • EventTimelineApi
            • OccupantRole
            • Venue
              • VenueType
              • VenueSignificance
          • Feedback
            • FeedbackApi
            • OccupantRoleFeedback
            • OccupantRoleFeedbackResult
          • GeoLocation
          • InitializationResult
            • InitializationFailureReason
          • InitState
          • MetaUserLinker
          • MetaUserLinkerAsync
          • MetaUserLinkerCallback
          • OnInitCallback
            • InitIssue
          • OnSdkStatusUpdateHandler
          • OnStartFinishedHandler
          • PendingOperation
            • OnSuccessListener
            • OnFailureListener
            • OnFailureListener
            • OnCompleteListener
          • ResetCallback
            • ResetCallback.ResetFailureReason
          • ResetError
            • ResetFailureReason
          • ResetResult
          • SdkConfig
            • LocationPermission
            • Builder
          • SdkException
          • SdkStatus
            • LocationSetting
            • Quota Status
            • StartStatus
          • SdkStatusUpdateListener
          • Sentiance
          • SentianceOptions
            • SentianceOptions.Builder
          • StartTripError
            • StartTripFailureReason
          • StartTripResult
          • StationaryInfo
          • StopTripError
            • StopTripFailureReason
          • StopTripResult
          • SubmitDetectionsCallback
          • SubmitDetectionsError
            • SubmitDetectionsFailureReason
          • SubmitDetectionsResult
          • Token
          • TokenResultCallback
          • TransmittableDataType
          • Transport Sessions
            • SensorDataChunk
            • TransportSession
            • TransportSessionApi
            • TransportSessionListener
          • Trip
            • StartTripCallback
            • StopTripCallback
            • TransportMode
            • TripTimeoutListener
            • TripType
          • TripInfo
          • UserAccessTokenError
            • UserAccessTokenFailureReason
          • UserActivity
          • UserActivityListener
          • UserActivityType
          • UserContext
            • Attribute
            • Segment
              • SegmentCategory
              • SegmentSubcategory
              • SegmentType
            • SemanticTime
          • UserContextApi
            • RequestUserContextFailureReason
            • RequestUserContextError
            • UserContextUpdateCriteria
            • UserContextUpdateListener
          • UserCreationError
            • UserCreationFailureReason
          • UserCreationOptions
            • UserCreationOptions.Builder
          • UserCreationResult
            • UserInfo
          • UserLinker
          • UserLinkerAsync
          • UserLinkerCallback
          • UserLinkingError
            • UserLinkingFailureReason
          • UserLinkingResult
          • VehicleCrashDetection
            • CrashDetectionApi
            • CrashDetectionState
            • VehicleCrashDiagnostic
            • VehicleCrashEvent
            • VehicleCrashDiagnosticListener
            • VehicleCrashListener
            • VehicleCrashSeverity
          • Waypoint
        • iOS
          • Detections
            • Enable Detections
            • Disable Detections
          • Driving Insights
            • SENTCallWhileMovingEvent
            • SENTDrivingInsights
            • SENTDrivingInsightsReadyDelegate
            • SENTHarshDrivingEvent
              • HarshDrivingEventType
            • SENTPhoneUsageEvent
            • SENTSpeedingEvent
            • SENTSafetyScores
            • SafetyScoreRequestParameters
              • SafetyScoreRequestOccupantRoleOption
              • SafetyScoreRequestPeriod
              • SafetyScoreRequestTransportModeOption
          • Event Timeline
            • EventTimelineDelegate
            • SENTOccupantRole
            • SENTTimelineEvent
              • SENTOffTheGridEvent
              • SENTStationaryEvent
              • SENTTransportEvent
              • SENTUnknownEvent
            • SENTTimelineEventType
            • SENTTimelineTransportMode
            • SENTVenue
            • SENTVenueSignificance
            • SENTVenueType
          • Feedback
            • SENTFeedback
            • SENTOccupantRoleFeedback
            • SENTOccupantRoleFeedbackResult
          • SENTCompletionHandlers
          • SENTConfig
          • SENTDate
          • SENTGeolocation
          • SENTAsyncInitializationCompletionHandler
          • SENTAsyncInitializationError
          • SENTAsyncInitializationResult
          • Sentiance
          • SENTInitializationResult
          • SENTOptions
            • SENTOptionsInitPurpose
          • SENTPublicDefinitions
          • SENTSDKStatus
          • SENTToken
          • SENTTransmittableDataType
          • SENTUserActivity
          • SENTVehicleCrashDetectionState
          • SENTVehicleCrashDiagnostic
          • SENTVehicleCrashEvent
            • SENTVehicleCrashSeverity
          • SENTWaypoint
          • Smart Geofences
            • SENTSmartGeofencesRefreshHandler
            • SmartGeofenceDetectionMode
            • SmartGeofencesRefreshError
              • SmartGeofencesRefreshFailureReason
            • SmartGeofencesRefreshResult
            • SmartGeofence
            • SmartGeofenceEvent
              • SmartGeofenceEventType
            • SmartGeofenceEventDelegate
          • Transport Sessions
            • SENTAccelerometerDataIterator
            • SENTLocationDataIterator
            • SENTSensorDataChunk
            • SENTTransportSession
          • User Context
            • SENTAttribute
            • SENTRequestUserContextCompletionHandler
            • SENTRequestUserContextError
            • SENTRequestUserContextFailureReason
            • SENTSegment
              • SENTSegmentCategory
              • SENTSegmentSubCategory
              • SENTSegmentType
            • SENTSemanticTime
            • SENTUserContext
            • SENTUserContextDelegate
            • SENTUserContextUpdateCriteria
          • User Creation & Linking
            • SENTUserInfo
            • User Creation
              • SENTUserCreationResult
              • SENTUserCreationFailureReason
              • SENTUserCreationError
              • SENTUserCreationCompletionHandler
              • SENTUserCreationOptions
            • User Linking
              • SENTNoOpUserLinker
              • SENTUserLinkingResult
              • SENTUserLinkingFailureReason
              • SENTUserLinkingError
              • SENTUserLinkingCompletionHandler
              • SENTUserLinker
        • React Native
          • core
            • Definitions
            • Examples
          • crash-detection
            • Definitions
            • Examples
          • driving-insights
            • Definitions
            • Examples
          • smart-geofences
            • Definitions
            • Examples
          • event-timeline
            • Definitions
            • Examples
          • legacy
            • Definitions
            • Examples
          • user-context
            • Definitions
            • Examples
        • Flutter
      • Battery Optimization on Android
      • How To
        • Check the Location Permissions
        • Utilize the Event Timeline API
        • Utilize the Driving Insights API
        • Utilize the User Context API
        • Utilize the Smart Geofences API
      • Troubleshooting
        • Android
        • iOS
      • Changelog
        • Android
        • iOS
        • React Native
        • Flutter
    • Authentication and Authorization
    • User Creation (via Authentication Code)
    • User Deletion
    • PlayStore Location Access Review
    • Privacy Report & Dashboard
    • Crash Detection
    • Important Security Notice
    • Injecting Fake Data
    • Custom Aggregation For Analytics
    • Merging Scores for Motorcycles and Cars
  • Links
    • SDK Standard License
    • Insights-by-Sentiance Application
    • Insights-by-Sentiance Privacy Policy
    • Journeys License
    • Technical & Organizational Measures
Powered by GitBook
On this page
  1. Important topics
  2. SDK
  3. API Reference
  4. React Native
  5. user-context

Definitions

Previoususer-contextNextExamples

Last updated 3 months ago

User Context

Note that some user context features are in , specifically the ones related to venue-type determination.

declare module "@sentiance-react-native/user-context" {
  import { EmitterSubscription } from "react-native";

  export type SegmentCategory = "LEISURE" | "MOBILITY" | "WORK_LIFE";
  export type SegmentSubcategory =
    | "COMMUTE"
    | "DRIVING"
    | "ENTERTAINMENT"
    | "FAMILY"
    | "HOME"
    | "SHOPPING"
    | "SOCIAL"
    | "TRANSPORT"
    | "TRAVEL"
    | "WELLBEING"
    | "WINING_AND_DINING"
    | "WORK";
  export type SegmentType =
    | "AGGRESSIVE_DRIVER"
    | "ANTICIPATIVE_DRIVER"
    | "BAR_GOER"
    | "CITY_DRIVER"
    | "CITY_HOME"
    | "CITY_WORKER"
    | "CULTURE_BUFF"
    | "DIE_HARD_DRIVER"
    | "DISTRACTED_DRIVER"
    | "DOG_WALKER"
    | "EARLY_BIRD"
    | "EASY_COMMUTER"
    | "EFFICIENT_DRIVER"
    | "FOODIE"
    | "FREQUENT_FLYER"
    | "FULLTIME_WORKER"
    | "GREEN_COMMUTER"
    | "HEALTHY_BIKER"
    | "HEALTHY_WALKER"
    | "HEAVY_COMMUTER"
    | "HOME_BOUND"
    | "HOMEBODY"
    | "HOMEWORKER"
    | "ILLEGAL_DRIVER"
    | "LATE_WORKER"
    | "LEGAL_DRIVER"
    | "LONG_COMMUTER"
    | "MOBILITY"
    | "MOBILITY__HIGH"
    | "MOBILITY__LIMITED"
    | "MOBILITY__MODERATE"
    | "MOTORWAY_DRIVER"
    | "MUSIC_LOVER"
    | "NATURE_LOVER"
    | "NIGHT_OWL"
    | "NIGHTWORKER"
    | "NORMAL_COMMUTER"
    | "PARTTIME_WORKER"
    | "PET_OWNER"
    | "PHYSICAL_ACTIVITY__HIGH"
    | "PHYSICAL_ACTIVITY__LIMITED"
    | "PHYSICAL_ACTIVITY__MODERATE"
    | "PUBLIC_TRANSPORTS_COMMUTER"
    | "PUBLIC_TRANSPORTS_USER"
    | "RECENTLY_CHANGED_JOB"
    | "RECENTLY_MOVED_HOME"
    | "RESTO_LOVER"
    | "RURAL_HOME"
    | "RURAL_WORKER"
    | "SHOPAHOLIC"
    | "SHORT_COMMUTER"
    | "SLEEP_DEPRIVED"
    | "SOCIAL_ACTIVITY"
    | "SOCIAL_ACTIVITY__HIGH"
    | "SOCIAL_ACTIVITY__LIMITED"
    | "SOCIAL_ACTIVITY__MODERATE"
    | "SPORTIVE"
    | "STUDENT"
    | "TOWN_HOME"
    | "TOWN_WORKER"
    | "UBER_PARENT"
    | "WORK_LIFE_BALANCE"
    | "WORK_TRAVELLER"
    | "WORKAHOLIC";

  export type TransportMode =
    | "UNKNOWN"
    | "BICYCLE"
    | "WALKING"
    | "RUNNING"
    | "TRAM"
    | "TRAIN"
    | "CAR"
    | "BUS"
    | "MOTORCYCLE";

  export type VenueSignificance =
    | "UNKNOWN"
    | "HOME"
    | "WORK"
    | "POINT_OF_INTEREST"

  /**
   * The list of venue types that are currently supported by the venue-type mapping model:
   *
   * <ul>
   *   <li><b>DRINK_DAY</b> - Cafes, coffee bars, tea rooms, etc</li>
   *   <li><b>DRINK_EVENING</b> - Bars, pubs and in general places where one goes for drinks in evenings.</li>
   *   <li><b>EDUCATION_INDEPENDENT</b> - Educational institutions visited by the user on his own for their own studies. High schools, universities, colleges, etc.</li>
   *   <li><b>EDUCATION_PARENTS</b> - Schools and kindergartens visited by parents.</li>
   *   <li><b>HEALTH</b> - Hospitals, clinics, emergency rooms.</li>
   *   <li><b>INDUSTRIAL</b> - Buildings tagged as “industrial” on OSM, built for some manufacturing process.</li>
   *   <li><b>LEISURE_BEACH</b> - Beaches, resorts and swimming areas.</li>
   *   <li><b>LEISURE_DAY</b> - Bowling, billiards and other entertainment places.</li>
   *   <li><b>LEISURE_EVENING</b> - Cinemas, theatres and music halls.</li>
   *   <li><b>LEISURE_MUSEUM</b> - Museums.</li>
   *   <li><b>LEISURE_NATURE</b> - Forests, lakes, national parks, etc.</li>
   *   <li><b>LEISURE_PARK</b> - City parks, gardens, zoos.</li>
   *   <li><b>OFFICE</b> - Office buildings. For example, of private lawyers, notaries or company representatives.</li>
   *   <li><b>RELIGION</b> - Churches, mosques and other religion related buildings.</li>
   *   <li><b>RESIDENTIAL</b> - Apartment blocks, houses.</li>
   *   <li><b>RESTO_MID</b> - Food courts, restaurants, snack bars.</li>
   *   <li><b>RESTO_SHORT</b> - Ice cream, fast food, donut stores.</li>
   *   <li><b>SHOP_LONG</b> - Supermarkets, malls, wholesales, shopping centres.</li>
   *   <li><b>SHOP_SHORT</b> - Small grocery stores, butchers, bakers.</li>
   *   <li><b>SPORT</b> - Gyms, sport centres. Venues visited to exercise.</li>
   *   <li><b>SPORT_ATTEND</b> - Stadiums. Venues visited to attend a sport event.</li>
   *   <li><b>TRAVEL_BUS</b> - Bus stops.</li>
   *   <li><b>TRAVEL_CONFERENCE</b> - Conference, convention, exhibition centres.</li>
   *   <li><b>TRAVEL_FILL</b> - Gas stations.</li>
   *   <li><b>TRAVEL_HOTEL</b> - Hotels, motels, guest rooms, etc.</li>
   *   <li><b>TRAVEL_LONG</b> - Airports</li>
   *   <li><b>TRAVEL_SHORT</b> - Public transport stations, railway stations.</li>
   * </ul>
   */
  export type VenueType =
    | "UNKNOWN"
    | "DRINK_DAY"
    | "DRINK_EVENING"
    | "EDUCATION_INDEPENDENT"
    | "EDUCATION_PARENTS"
    | "HEALTH"
    | "INDUSTRIAL"
    | "LEISURE_BEACH"
    | "LEISURE_DAY"
    | "LEISURE_EVENING"
    | "LEISURE_MUSEUM"
    | "LEISURE_NATURE"
    | "LEISURE_PARK"
    | "OFFICE"
    | "RELIGION"
    | "RESIDENTIAL"
    | "RESTO_MID"
    | "RESTO_SHORT"
    | "SHOP_LONG"
    | "SHOP_SHORT"
    | "SPORT"
    | "SPORT_ATTEND"
    | "TRAVEL_BUS"
    | "TRAVEL_CONFERENCE"
    | "TRAVEL_FILL"
    | "TRAVEL_HOTEL"
    | "TRAVEL_LONG"
    | "TRAVEL_SHORT"

  export type SemanticTime =
    | "UNKNOWN"
    | "MORNING"
    | "LATE_MORNING"
    | "LUNCH"
    | "AFTERNOON"
    | "EARLY_EVENING"
    | "EVENING"
    | "NIGHT";

  export type UserContextUpdateCriteria =
    | "CURRENT_EVENT"
    | "ACTIVE_SEGMENTS"
    | "VISITED_VENUES";

  export type OccupantRole =
    | "DRIVER"
    | "PASSENGER"
    | "UNAVAILABLE";

  export type TransportTags = { [key: string]: string };

  export interface Event {
    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;
    /**
     * Indicates whether the event is provisional.
     *
     * <p>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.</p>
     *
     * <p>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.</p>
     *
     * <p>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.</p>
     */
    isProvisional: boolean;
    // stationary event fields
    location: GeoLocation | null;
    venue: Venue | null;
    // transport event fields
    transportMode: TransportMode | null;
    waypoints: Waypoint[];
    distance?: number; // in meters
    transportTags: TransportTags;
    occupantRole: OccupantRole;
  }

  export interface GeoLocation {
    latitude: number;
    longitude: number;
    accuracy: number;
  }

  export interface Waypoint {
    latitude: number;
    longitude: number;
    accuracy: number;   // in meters
    timestamp: number;  // UTC epoch time in milliseconds
    speedInMps?: number;  // in meters per second
    speedLimitInMps?: number;  // in meters per second
    hasUnlimitedSpeedLimit: boolean;
    isSpeedLimitInfoSet: boolean;
    isSynthetic: boolean;
  }

  export interface Venue {
    location: GeoLocation | null;
    significance: VenueSignificance;
    type: VenueType;
  }

  export interface Segment {
    category: SegmentCategory;
    subcategory: SegmentSubcategory;
    type: SegmentType;
    id: number;
    startTime: string;
    startTimeEpoch: number; // in milliseconds
    endTime: string | null;
    endTimeEpoch: number | null; // in milliseconds
    attributes: SegmentAttribute[];
  }

  export interface SegmentAttribute {
    name: string;
    value: number;
  }

  export interface UserContext {
    events: Event[];
    activeSegments: Segment[];
    lastKnownLocation: GeoLocation | null;
    home: Venue | null;
    work: Venue | null;
    semanticTime: SemanticTime;
  }

  export interface UserContextUpdate {
    readonly criteria: UserContextUpdateCriteria[];
    readonly userContext: UserContext;
  }

  export interface SentianceUserContext {
    requestUserContext(includeProvisionalEvents?: boolean): Promise<UserContext>;

    addUserContextUpdateListener(
      onUserContextUpdated: (userContextUpdate: UserContextUpdate) => void,
      includeProvisionalEvents?: boolean
    ): Promise<EmitterSubscription>;
  }

  const SentianceUserContext: SentianceUserContext;
  export default SentianceUserContext;
}
Early Access