Overview
The Synheart Behavior Kotlin/Android SDK provides real-time behavioral signal inference from digital interactions for native Android applications.Installation
Add to yourbuild.gradle:
Requirements
- Android API 21+ (Android 5.0+)
- Kotlin 1.9.0+
- Gradle 8.0+
Quick Start
Basic Usage
Real-Time Event Tracking
Session Management
On-Demand Metrics Calculation
Calculate behavioral metrics for a custom time range within a session:API Reference
SynheartBehavior
Main Methods:
| Method | Description | Returns |
|---|---|---|
create(context, config) | Create SDK instance | SynheartBehavior |
initialize() | Initialize SDK | void |
attachToView(view) | Attach to view for gesture tracking | void |
startSession({sessionId}) | Start a new session | BehaviorSession |
endSession(sessionId) | End session and get summary | BehaviorSessionSummary |
calculateMetricsForTimeRange(...) | Calculate metrics for custom time range | Map<String, Any> |
getCurrentStats() | Get current statistics | BehaviorStats |
setEventHandler(callback) | Set callback for events | void |
sendEvent(event) | Manually send an event | void |
dispose() | Clean up resources | void |
calculateMetricsForTimeRange()
Calculate behavioral metrics for a custom time range within a session.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
startTimestampSeconds | Long | Yes | Start time as Unix timestamp in seconds |
endTimestampSeconds | Long | Yes | End time as Unix timestamp in seconds |
sessionId | String? | No | Session ID (uses current session if not provided) |
Map<String, Any> - Map containing all behavioral metrics for the specified time range
Throws: Exception if time range is out of session bounds or session not found
Example:
| Property | Type | Description |
|---|---|---|
isInitialized | Boolean | Whether SDK is initialized |
currentSessionId | String? | Current active session ID |
onEvent | Flow<BehaviorEvent> | Flow of behavioral events |
BehaviorConfig
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
enableInputSignals | Boolean | true | Enable scroll, tap, swipe, typing tracking |
enableAttentionSignals | Boolean | true | Enable app switching, idle gaps |
enableMotionLite | Boolean | false | Enable motion state inference |
sessionIdPrefix | String | "SESS" | Prefix for session IDs |
userId | String? | null | Optional user identifier |
deviceId | String? | null | Optional device identifier |
eventBatchSize | Int | 10 | Events per batch |
maxIdleGapSeconds | Double | 10.0 | Max idle time before task drop |
behaviorVersion | String? | null | SDK version for HSI payloads |
consentBehavior | Boolean | true | Behavior tracking consent |
BehaviorEvent
Properties:
| Property | Type | Description |
|---|---|---|
eventId | String | Unique event identifier |
sessionId | String | Associated session ID |
timestamp | String | ISO 8601 timestamp |
eventType | BehaviorEventType | Type of event |
metrics | Map<String, Any> | Event-specific metrics |
BehaviorEventType.SCROLL- Scroll interactionsBehaviorEventType.TAP- Tap interactionsBehaviorEventType.SWIPE- Swipe interactionsBehaviorEventType.TYPING- Typing session eventsBehaviorEventType.NOTIFICATION- Notification eventsBehaviorEventType.CALL- Call events
BehaviorSession
Properties:
| Property | Type | Description |
|---|---|---|
sessionId | String | Session identifier |
BehaviorSessionSummary
Properties:
| Property | Type | Description |
|---|---|---|
sessionId | String | Session identifier |
startAt | String | ISO 8601 session start time |
endAt | String | ISO 8601 session end time |
durationMs | Long | Session duration in milliseconds |
behavioralMetrics | BehavioralMetrics | Behavioral metrics |
activitySummary | ActivitySummary | Activity summary |
notificationSummary | NotificationSummary | Notification summary |
motionState | MotionState? | Motion state (if enabled) |
typingSessionSummary | TypingSessionSummary? | Typing session summary (if typing occurred) |
motionData | List<MotionDataPoint>? | Raw motion data points (if enabled) |
BehavioralMetrics
Properties:
| Property | Type | Description |
|---|---|---|
interactionIntensity | Double | Overall interaction rate (0-1) |
behavioralDistractionScore | Double | Distraction proxy (0-1) |
focusHint | Double | Focus quality proxy (0-1) |
deepFocusBlocks | List<DeepFocusBlock> | Sustained focus periods |
taskSwitchRate | Double | App switching frequency |
idleRatio | Double | Proportion of idle time |
fragmentedIdleRatio | Double | Fragmented vs continuous idle |
burstiness | Double | Temporal clustering of events |
notificationLoad | Double | Notification pressure |
scrollJitterRate | Double | Scroll pattern irregularity |
typingSpeed | Double | Average typing speed (taps per second) |
typingCadenceStability | Double | Consistency of typing rhythm (0-1) |
typingCadenceVariability | Double | Variability in timing between taps |
typingActivityRatio | Double | Fraction of session with active typing (0-1) |
typingGapRatio | Double | Proportion of intervals that are gaps (0-1) |
typingBurstiness | Double | Temporal clustering of typing events |
typingInteractionIntensity | Double | Overall typing engagement (0-1) |
Permissions
Notification Permission
Call Permission
Configuration
Update Configuration at Runtime
View Attachment
To track gestures on specific views, attach the SDK to them:Automatic Session Ending
Sessions are automatically ended after 1 minute if the app stays in the background. This prevents sessions from running indefinitely when users switch away from your app.Resources
- JitPack: synheart-behavior-kotlin
- Repository: synheart-behavior-kotlin
- Full README: View on GitHub
Author: Yoseph Gebeyehu