You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: architecture.rst
+5-3
Original file line number
Diff line number
Diff line change
@@ -12,18 +12,20 @@ Server
12
12
13
13
Known as aw-server, it handles storage and retrieval of all activities/entries in buckets. Usually there exists one bucket per watcher.
14
14
15
+
The server also hosts the Web UI (aw-webui) which does all communication with the server using the REST API.
16
+
15
17
Clients
16
18
-------
17
19
18
-
The server doesn't do anything interesting on its own, for that we need clients such as watchers and user interfaces.
19
-
Writing these clients is something we've tried to make as easy as possible by creating client libraries with a clear API.
20
+
The server doesn't do anything very interesting on its own, for that we need clients. Most specifically a certain type of client known as watchers.
21
+
Writing these clients is something we've tried to make as easy as possible by creating client libraries with a clear API.
20
22
21
23
Currently the primary client library is written in Python (known simply as aw-client) but a client library written in JavaScript is on the way and is expected to have the same level of support in the future.
Copy file name to clipboardexpand all lines: faq.rst
+22-12
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ FAQ
8
8
How do I programmatically use ActivityWatch?
9
9
--------------------------------------------
10
10
11
-
See the documentation for :doc:`extending` or checkout the `aw-client` repository.
11
+
See the documentation for :doc:`extending` or checkout the aw-client repository.
12
12
13
13
How do I understand the data that is stored?
14
14
--------------------------------------------
@@ -26,22 +26,28 @@ Get some events with
26
26
bucket_id =next(buckets.keys())
27
27
events = ac.get_events(bucket_id)
28
28
29
-
Events from the aw-watcher-afk bucket have the fields `['timestamp']`, `['duration']`, and `['data']['status']`. The status can be one of `afk`, `not-afk`, or `hibernating`. If `e0` and `e1` are consecutive events, you should expect
30
-
`e0['timestamp'] + e0['duration'] == e1['timestamp']` (within some milliseconds) and report issues when it is not the case. Actually this is only true for aw-watcher-afk, because aw-watcher-window doesn't record anything when afk or asleep.
29
+
For a description of the `event-model`.
31
30
32
-
In principle, `afk` and `not-afk` events alternate, but there are currently many edge cases where it doesn't happen.
31
+
Events from the aw-watcher-afk bucket have the fields :code:`timestamp`, :code:`duration`, and :code:`data`.
33
32
34
-
No two events in a bucket should cover the same moment, but right now in some cases `hibernating` events overlap entirely with some `afk` events.
33
+
As an example for AFK events: The data field contains a JSON object (in Python a dict) which has one key :code:`status` which can be one of: :code:`afk`, :code:`not-afk`, :code:`hibernating`.
35
34
36
-
How to determine bucket name?
37
-
-----------------------------
35
+
..
36
+
If :code:`e0` and :code:`e1` are consecutive events, you should expect :code:`e0.timestamp + e0.duration == e1.timestamp` (within some milliseconds) and report issues when it is not the case.
37
+
Actually this is only true for aw-watcher-afk, because aw-watcher-window doesn't record anything when afk or asleep.
38
+
In principle, `afk` and `not-afk` events alternate, but there are currently many edge cases where it doesn't happen.
39
+
40
+
No two events in a bucket should cover the same moment, if that happens there is an issue with the watcher that should be resolved.
38
41
39
-
`<name of watcher>` (one of `aw-watcher-afk` or `aw-watcher-window`) + `_` + `<name of your machine>` (how to determine? look in "Raw Data" tab of web UI)
42
+
What happens if it is down or crashes?
43
+
--------------------------------------
40
44
41
-
What happens when AW is down or crashes?
42
-
----------------------------------------
45
+
Since ActivityWatch consists of several modules running independently, one thing crashing will have limited impact on the rest of the system.
43
46
44
-
Stored data up to the crash is not corrupted (up to few seconds before). When AW is restarted, it will first register a `not-afk` event. Several `not-afk` can come one after the other if AW is interrupted in between. No data will be stored when AW is off.
47
+
If the server crashes, all watchers which use the heartbeat queue should simply queue heartbeats until the server becomes available again.
48
+
Since heartbeats are currently sent immediately to the server for storage, all data before the crash should be untouched.
49
+
50
+
If a watcher crashes, its bucket will simply remain untouched until it is restarted.
45
51
46
52
What happens when my computer is off or asleep?
47
53
-----------------------------------------------
@@ -51,4 +57,8 @@ When asleep, aw-watcher-afk will record a "hibernating" event (this might change
51
57
Some events have 0 duration. What does this mean?
52
58
-------------------------------------------------
53
59
54
-
It's a glitch (caused by 3 consecutive heartbeats having different data?).
60
+
Watchers most commonly use a polling method called heartbeats in order to store information on the server.
61
+
Heartbeats are received regularly with some data, and when two consecutive heartbeats have identical data they get merged and the duration of the new one becomes the time difference between the previous two.
62
+
Sometimes, a single heartbeat doesn't get a following event with identical data. It is then impossible to know the duration of that event.
63
+
64
+
The assumption could be made to consider all zero-duration events actually have a duration equal to the time of the next event, but all such assumptions are left to the analysis stage.
0 commit comments