// // SRKeyboardMetrics.h // SensorKit // // Copyright © 2019 Apple Inc. All rights reserved. // #import #import NS_ASSUME_NONNULL_BEGIN SR_EXTERN API_AVAILABLE(ios(14.0)) API_UNAVAILABLE(watchos) API_UNAVAILABLE(tvos, macos) @interface SRKeyboardMetrics : NSObject /// The duration over which these metrics were calculated @property (readonly) NSTimeInterval duration; /// The identifier of the keyboard in the keyboard list @property (readonly, copy) NSString *keyboardIdentifier; /// The version of keyboard metrics @property (readonly, copy) NSString *version; /// The width of the keyboard in mm in the session @property (readonly) NSMeasurement *width; /// The height of the keyboard in mm in the session @property (readonly) NSMeasurement *height; /// The input modes used during a keyboard session @property (readonly, copy) NSArray *inputModes API_AVAILABLE(ios(15.0)) API_UNAVAILABLE(watchos) API_UNAVAILABLE(tvos, macos); /// The keyboard session identifiers. These are the identifiers of the keyboard sessions that contributed to keyboard metrics sample to correlate current stream with another stream using the same keyboard session indentifiers @property (readonly, copy) NSArray *sessionIdentifiers API_AVAILABLE(ios(16.4)) API_UNAVAILABLE(watchos) API_UNAVAILABLE(tvos, macos); @end SR_EXTERN API_AVAILABLE(ios(14.0)) API_UNAVAILABLE(watchos) API_UNAVAILABLE(tvos, macos) @interface SRKeyboardMetrics (ScalarMetrics) /// The total number of words typed during the session @property (readonly) NSInteger totalWords; /// The total number of altered words during the session @property (readonly) NSInteger totalAlteredWords; /// The total number of taps during the session @property (readonly) NSInteger totalTaps; /// The total number of drags during the session @property (readonly) NSInteger totalDrags; /// The total number of deletes during the session @property (readonly) NSInteger totalDeletes; /// The total number of emojis used during the session @property (readonly) NSInteger totalEmojis; /// The total number of paths used during the sesion @property (readonly) NSInteger totalPaths; /// The total time taken to complete paths in the session @property (readonly) NSTimeInterval totalPathTime; /// The total length of paths completed in the session @property (readonly) NSMeasurement *totalPathLength; /// The total number of autocorrections in the session @property (readonly) NSInteger totalAutoCorrections; /// The total number of space corrections in the session @property (readonly) NSInteger totalSpaceCorrections; /// The total number of retro corrections in the session @property (readonly) NSInteger totalRetroCorrections; /// The total number of transposition corrections in the session @property (readonly) NSInteger totalTranspositionCorrections; /// The total number of insert key corrections in the session @property (readonly) NSInteger totalInsertKeyCorrections; /// The total number of skip touch corrections in the session @property (readonly) NSInteger totalSkipTouchCorrections; /// The total number of near key corrections in the session @property (readonly) NSInteger totalNearKeyCorrections; /// The total number of substitution corrections in the session @property (readonly) NSInteger totalSubstitutionCorrections; /// The total number of hit test corrections in the session @property (readonly) NSInteger totalHitTestCorrections; /// The total amount of time typing during the session @property (readonly) NSTimeInterval totalTypingDuration; @end SR_EXTERN API_AVAILABLE(ios(14.0)) API_UNAVAILABLE(watchos) API_UNAVAILABLE(tvos, macos) @interface SRKeyboardProbabilityMetric : NSObject /// Sample values from probability distribution @property (readonly, copy) NSArray *> *distributionSampleValues; @end SR_EXTERN API_AVAILABLE(ios(14.0)) API_UNAVAILABLE(watchos) API_UNAVAILABLE(tvos, macos) @interface SRKeyboardMetrics (ProbabilityMetrics) /// The distance from the touch up to the center of any key @property (readonly, strong) SRKeyboardProbabilityMetric *upErrorDistance; /// The distance from the touch down to the center of any key @property (readonly, strong) SRKeyboardProbabilityMetric *downErrorDistance; /// The distance from the touch up to the right centroid of the space key @property (readonly, strong) SRKeyboardProbabilityMetric *spaceUpErrorDistance; /// The distance from the touch down to the right centroid of the space key @property (readonly, strong) SRKeyboardProbabilityMetric *spaceDownErrorDistance; /// The distance from the touch up to the center of the delete key @property (readonly, strong) SRKeyboardProbabilityMetric *deleteUpErrorDistance; /// The distance from the touch down to the center of the delete key @property (readonly, strong) SRKeyboardProbabilityMetric *deleteDownErrorDistance; /// The distance from the touch up to the center of the intended key of a character in a short word @property (readonly, strong) SRKeyboardProbabilityMetric *shortWordCharKeyUpErrorDistance; /// The distance from the touch down to the center of the intended key of a character in a short word @property (readonly, strong) SRKeyboardProbabilityMetric *shortWordCharKeyDownErrorDistance; /// The duration between touch down to touchup for any key @property (readonly, strong) SRKeyboardProbabilityMetric *touchDownUp; /// The duration between touch down and touchup of all space key events in the session. @property (readonly, strong) SRKeyboardProbabilityMetric *spaceTouchDownUp; /// The duration between touch down and touchup of all delete key events in the session. @property (readonly, strong) SRKeyboardProbabilityMetric *deleteTouchDownUp; /// The duration between touch down and touchup of all character keys in short words in the session. @property (readonly, strong) SRKeyboardProbabilityMetric *shortWordCharKeyTouchDownUp; /// The duration between touch down to touch down for any key @property (readonly, strong) SRKeyboardProbabilityMetric *touchDownDown; /// The duration between touch up and touch down for any key @property (readonly, strong) SRKeyboardProbabilityMetric *touchUpDown API_AVAILABLE(ios(16.4)) API_UNAVAILABLE(watchos) API_UNAVAILABLE(tvos, macos); /// The duration between touchup on a character key and touch down on a word in the prediction bar @property (readonly, strong) SRKeyboardProbabilityMetric *charKeyToPrediction; /// The duration between touchup on a character key and touch down on any sequential character key in a short word @property (readonly, strong) SRKeyboardProbabilityMetric *shortWordCharKeyToCharKey; /// The duration between touchup on a character key and touch down on the next sequential key (any key) @property (readonly, strong) SRKeyboardProbabilityMetric *charKeyToAnyTapKey; /// The duration between touchup of any key and touch down on a sequential character key @property (readonly, strong) SRKeyboardProbabilityMetric *anyTapToCharKey; /// The duration between touchup of a space key and touch down of a sequential character key @property (readonly, strong) SRKeyboardProbabilityMetric *spaceToCharKey; /// The duration between touchup of a character key and touch down of a sequential space key @property (readonly, strong) SRKeyboardProbabilityMetric *charKeyToSpaceKey; /// The duration between touchup of a space key and touch down of a sequential delete key @property (readonly, strong) SRKeyboardProbabilityMetric *spaceToDeleteKey; /// The duration between touchup of a delete key and touch down of a sequential space key @property (readonly, strong) SRKeyboardProbabilityMetric *deleteToSpaceKey; /// The duration between touchup of a space key and touch down of a sequential space key @property (readonly, strong) SRKeyboardProbabilityMetric *spaceToSpaceKey; /// The duration between touchup of a space key and touch down of a sequential Shift key @property (readonly, strong) SRKeyboardProbabilityMetric *spaceToShiftKey; /// The duration between touchup of a space key and touch down of a sequential plane change key @property (readonly, strong) SRKeyboardProbabilityMetric *spaceToPlaneChangeKey; /// The duration between touchup on the space key and touch down of a sequential selection from the prediction bar @property (readonly, strong) SRKeyboardProbabilityMetric *spaceToPredictionKey; /// The duration between touchup of a delete key and touch down of a sequential character key @property (readonly, strong) SRKeyboardProbabilityMetric *deleteToCharKey; /// The duration between touchup of a character key and touch down of a sequential delete key @property (readonly, strong) SRKeyboardProbabilityMetric *charKeyToDelete; /// The duration between touchup of a delete key and touch down of a sequential delete key @property (readonly, strong) SRKeyboardProbabilityMetric *deleteToDelete; /// The duration between touchup of a delete key and touch down of a sequential Shift key @property (readonly, strong) SRKeyboardProbabilityMetric *deleteToShiftKey; /// The duration between touchup of a delete key and touch down of a sequential plane change key @property (readonly, strong) SRKeyboardProbabilityMetric *deleteToPlaneChangeKey; /// The duration between touchup of any key and touch down on a plane change key @property (readonly, strong) SRKeyboardProbabilityMetric *anyTapToPlaneChangeKey; /// The duration between touchup on a plane change key and touch down on the next sequential key @property (readonly, strong) SRKeyboardProbabilityMetric *planeChangeToAnyTap; /// The duration between touchup of a character key and touch down of a sequential plane change key @property (readonly, strong) SRKeyboardProbabilityMetric *charKeyToPlaneChangeKey; /// The duration between touchup of a plane change key and touch down of any key @property (readonly, strong) SRKeyboardProbabilityMetric *planeChangeKeyToCharKey; /// sample values of the ratio of error distance between intended and actual path @property (readonly, strong) NSArray *pathErrorDistanceRatio; /// The duration between touchup of a delete key and touch down of a sequential path @property (readonly, strong) SRKeyboardProbabilityMetric *deleteToPath; /// The duration between touchup of a delete key and touch down of a sequential path (ie. Continuous Path) @property (readonly, strong) SRKeyboardProbabilityMetric *pathToDelete; /// The duration between touchup on the space key and touch down to begin a sequential path @property (readonly, strong) SRKeyboardProbabilityMetric *spaceToPath; /// The duration between touchup of a path and touch down of a sequential space key @property (readonly, strong) SRKeyboardProbabilityMetric *pathToSpace; /// The duration between touchup of a path and touch down of a sequential path @property (readonly, strong) SRKeyboardProbabilityMetric *pathToPath; @end /// Probability metrics for each character in a word in their respective positions (first, second, third, fourth, fifth, and the rest) SR_EXTERN API_AVAILABLE(ios(14.0)) API_UNAVAILABLE(watchos) API_UNAVAILABLE(tvos, macos) @interface SRKeyboardMetrics (PositionalMetrics) /// The distance from the touch up to the center of the intended key of the characters of a long word @property (readonly, strong) NSArray *> *longWordUpErrorDistance; /// The distance from the touch down to the center of the intended key of the characters of a long word @property (readonly, strong) NSArray *> *longWordDownErrorDistance; /// The duration between touch down and touchup of the character keys of all the long words in the session. @property (readonly, strong) NSArray *> *longWordTouchDownUp; /// The duration between touch down and touch down of the character keys of all the long words in the session. @property (readonly, strong) NSArray *> *longWordTouchDownDown; /// The duration between touch up and touch down of the character keys of all the long words in the session. @property (readonly, strong) NSArray *> *longWordTouchUpDown API_AVAILABLE(ios(16.4)) API_UNAVAILABLE(watchos) API_UNAVAILABLE(tvos, macos); /// The duration between touchup of the delete key and touch down of a sequential delete key @property (readonly, strong) NSArray *> *deleteToDeletes; @end SR_EXTERN API_AVAILABLE(ios(15.0)) API_UNAVAILABLE(watchos) API_UNAVAILABLE(tvos, macos) @interface SRKeyboardMetrics (SpeedMetrics) /// The total number of pauses during the session @property (readonly) NSInteger totalPauses; /// The total number of pauses made while entering the path for any words composed using continuous path during the session @property (readonly) NSInteger totalPathPauses; /// The words per minute typed during the session @property (readonly) double typingSpeed; /// The words per minute typed using continuous path during the session @property (readonly) double pathTypingSpeed; /// Total number of continuous typing episodes during the session @property (readonly) NSInteger totalTypingEpisodes; @end /** @abstract Categories of sentiment from words or emoji */ typedef NS_ENUM(NSInteger, SRKeyboardMetricsSentimentCategory) { SRKeyboardMetricsSentimentCategoryAbsolutist, SRKeyboardMetricsSentimentCategoryDown, SRKeyboardMetricsSentimentCategoryDeath, SRKeyboardMetricsSentimentCategoryAnxiety, SRKeyboardMetricsSentimentCategoryAnger, SRKeyboardMetricsSentimentCategoryHealth, SRKeyboardMetricsSentimentCategoryPositive, SRKeyboardMetricsSentimentCategorySad, SRKeyboardMetricsSentimentCategoryLowEnergy, SRKeyboardMetricsSentimentCategoryConfused, } API_AVAILABLE(ios(15.0)) API_UNAVAILABLE(watchos) API_UNAVAILABLE(tvos, macos); /** * These metrics describe the number of words and emoji of a particular category typed during * a keyboard session. Words and emoji may be counted in multiple categories. */ SR_EXTERN API_AVAILABLE(ios(15.0)) API_UNAVAILABLE(watchos) API_UNAVAILABLE(tvos, macos) @interface SRKeyboardMetrics (SentimentCounts) /// The count of words typed per category in the session - (NSInteger)wordCountForSentimentCategory:(SRKeyboardMetricsSentimentCategory)category; /// The count of emoji typed per category in the session - (NSInteger)emojiCountForSentimentCategory:(SRKeyboardMetricsSentimentCategory)category; @end NS_ASSUME_NONNULL_END