Understanding How ActivityWatch Stores Data
ActivityWatch is an open-source platform designed to monitor and record your digital activities, giving insight into how you spend your time on your devices. It tracks application usage and records event data in SQLite databases, providing a detailed look at user behavior.
Database Schema
Buckets Table
This table defines âbucketsâ that categorize different types of recorded events.
Column Name | Data Type | Description |
---|---|---|
id | INTEGER PRIMARY KEY | The unique autoincrement id of the âbucketâ. |
name | TEXT UNIQUE NOT NULL | The unique name identifying the âbucketâ. |
type | TEXT NOT NULL | The type of events the âbucketâ records. |
client | TEXT NOT NULL | The client or watcher that created the âbucketâ. |
hostname | TEXT NOT NULL | The hostname of the device where events are tracked. |
created | TEXT NOT NULL | The creation timestamp of the âbucketâ. |
data_deprecated | TEXT DEFAULT â{}â | Legacy field for additional data (unused, deprecated). |
data | TEXT NOT NULL DEFAULT â{}â | A field for additional JSON-formatted data about the âbucketâ. |
id | name | type | client | hostname | created | data_deprecated | data |
---|---|---|---|---|---|---|---|
1 | aw-watcher-afk_shasharma-c13130 | afkstatus | aw-watcher-afk | shasharma-c13130 | 2024-07-29 15:53:15.705137+00:00 | {} | {â$aw.sync.originâ:âshasharma-c13130â} |
2 | aw-watcher-window_shasharma-c13130 | currentwindow | aw-watcher-window | shasharma-c13130 | 2024-07-29 15:53:13.811889+00:00 | {} | {â$aw.sync.originâ:âshasharma-c13130â} |
Events Table
This table stores the actual time-tracked events.
Column Name | Data Type | Description |
---|---|---|
id | INTEGER PRIMARY KEY | The unique autoincrement id of the event. |
bucketrow | INTEGER NOT NULL | Foreign key to the associated âbucketâ. |
starttime | INTEGER NOT NULL | The starting timestamp of the event. |
endtime | INTEGER NOT NULL | The ending timestamp of the event. |
data | TEXT NOT NULL | The JSON-formatted data about the event. |
id | bucketrow | starttime | endtime | data |
---|---|---|---|---|
1966 | 2 | 1722344179173000000 | 1722344199921000000 | {âappâ:âArcâ,âtitleâ:âActivityWatch Web Watcher⊠|
1967 | 2 | 1722344199922000000 | 1722344200879000000 | {âappâ:âArcâ,âtitleâ:âgithub.com/activitywatch⊠|
1968 | 2 | 1722344200880000000 | 1722344208653000000 | {âappâ:âArcâ,âtitleâ:âgithub.com/ActivityWatch⊠|
Key-Value Table
A table for various settings and configuration values.
Column Name | Data Type | Description |
---|---|---|
key | TEXT PRIMARY KEY | The unique identifier for the setting. |
value | TEXT | The attached value for the setting. |
last_modified | NUMBER NOT NULL | The timestamp of the last modification. |
Indexes
ActivityWatch creates indexes to improve the performance of the database:
Query
.headers on
.mode column
SELECT *
FROM events
JOIN buckets ON events.bucketrow = buckets.id LIMIT 5;
Event ID | BucketRow | StartTime | EndTime | Event Data | Bucket ID | Bucket Name | Bucket Type | Bucket Client | Bucket Hostname | Bucket Created | Bucket Data Deprecated | Bucket Data |
---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1 | 1722248595700000000 | 1722248846293000000 | {âstatusâ:ânot-afkâ} | 1 | aw-watcher-afk_shasharma-c13130 | afkstatus | aw-watcher-afk | shasharma-c13130 | 2024-07-29 15:53:15.705137+00:00 | {} | {â$aw.sync.originâ:âshasharma-c13130â} |
2 | 1 | 1722248846293000000 | 1722249644100000000 | {âstatusâ:âafkâ} | 1 | aw-watcher-afk_shasharma-c13130 | afkstatus | aw-watcher-afk | shasharma-c13130 | 2024-07-29 15:53:15.705137+00:00 | {} | {â$aw.sync.originâ:âshasharma-c13130â} |
3 | 1 | 1722249644099000000 | 1722251767816000000 | {âstatusâ:ânot-afkâ} | 1 | aw-watcher-afk_shasharma-c13130 | afkstatus | aw-watcher-afk | shasharma-c13130 | 2024-07-29 15:53:15.705137+00:00 | {} | {â$aw.sync.originâ:âshasharma-c13130â} |
4 | 1 | 1722249644099000000 | 1722249748850000000 | {âstatusâ:ânot-afkâ} | 1 | aw-watcher-afk_shasharma-c13130 | afkstatus | aw-watcher-afk | shasharma-c13130 | 2024-07-29 15:53:15.705137+00:00 | {} | {â$aw.sync.originâ:âshasharma-c13130â} |
5 | 1 | 1722249644099000000 | 1722249718606000000 | {âstatusâ:ânot-afkâ} | 1 | aw-watcher-afk_shasharma-c13130 | afkstatus | aw-watcher-afk | shasharma-c13130 | 2024-07-29 15:53:15.705137+00:00 | {} | {â$aw.sync.originâ:âshasharma-c13130â} |
Better query will look like: