Overview
The Synheart Behavior Dart/Flutter SDK provides real-time behavioral signal inference from digital interactions for cross-platform mobile applications.Installation
Add topubspec.yaml:
Requirements
- Flutter >= 3.10.0
- Dart >= 3.0.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 |
|---|---|---|
initialize({config}) | Initialize SDK | Future<SynheartBehavior> |
wrapWithGestureDetector(widget) | Wrap app to enable gesture tracking | Widget |
startSession({sessionId}) | Start a new session | Future<BehaviorSession> |
calculateMetricsForTimeRange(...) | Calculate metrics for custom time range | Future<Map<String, dynamic>> |
getCurrentStats() | Get current statistics | Future<BehaviorStats> |
onEvent | Stream of behavioral events | Stream<BehaviorEvent> |
dispose() | Clean up resources | void |
calculateMetricsForTimeRange()
Calculate behavioral metrics for a custom time range within a session.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
startTimestampSeconds | int | Yes | Start time as Unix timestamp in seconds |
endTimestampSeconds | int | Yes | End time as Unix timestamp in seconds |
sessionId | String? | No | Session ID (uses current session if not provided) |
Future<Map<String, dynamic>> - 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 | bool | Whether SDK is initialized |
currentSessionId | String? | Current active session ID |
BehaviorConfig
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
enableInputSignals | bool | true | Enable scroll, tap, swipe, typing tracking |
enableAttentionSignals | bool | true | Enable app switching, idle gaps |
enableMotionLite | bool | 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 |
BehaviorEvent
Properties:
| Property | Type | Description |
|---|---|---|
eventId | String | Unique event identifier |
sessionId | String | Associated session ID |
timestamp | DateTime | Event timestamp |
eventType | BehaviorEventType | Type of event |
metrics | Map<String, dynamic> | Event-specific metrics |
BehaviorEventType.scroll- Scroll interactionsBehaviorEventType.tap- Tap interactionsBehaviorEventType.swipe- Swipe interactionsBehaviorEventType.typing- Typing session eventsBehaviorEventType.notification- Notification eventsBehaviorEventType.call- Call events
BehaviorSession
Methods:
| Method | Description | Returns |
|---|---|---|
end() | End session and get summary | Future<BehaviorSessionSummary> |
| Property | Type | Description |
|---|---|---|
sessionId | String | Session identifier |
BehaviorSessionSummary
Properties:
| Property | Type | Description |
|---|---|---|
sessionId | String | Session identifier |
startAt | DateTime | Session start time |
endAt | DateTime | Session end time |
durationMs | int | Session duration in milliseconds |
behavioralMetrics | BehavioralMetrics | Behavioral metrics |
activitySummary | ActivitySummary | Activity summary |
notificationSummary | NotificationSummary | Notification summary |
motionState | MotionState? | Motion state (if enabled) |
BehavioralMetrics
Properties:
| Property | Type | Description |
|---|---|---|
interactionIntensity | double | Overall interaction rate (0-1) |
distractionScore | 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
Resources
- pub.dev: synheart_behavior
- Repository: synheart-behavior-dart
- Full README: View on GitHub
Author: Yoseph Gebeyehu