-
Notifications
You must be signed in to change notification settings - Fork 3
Log Analysis API
The loaders.py and containers.py libraries will help you read the log files downloaded from the extension, and provide simple API access to the data. There are three data objects you need to know: Snapshot, Tab, and Focus. A Snapshot represent the state your browser at a given time period, which includes every Tabs and any Focus changes during that time. Every time the state of your browser changes, a Snapshot is automatically taken by the extension. For example, when a new tab is created or closed, when a tab finished loading, when tabs are reordered, ..., etc. To load all the Snapshots, run the following in the analysis/ directory and with your logs under the data/ directory:
In [1]: import loaders
In [2]: snapshots, focuses, navs = loaders.loadEverything('data/tabLogs.csv', 'data/focusLogs.csv', 'data/navLogs.csv')The snapshots variable is a list of Snapshot objects sorted by time.
Attributes of Snapshot objects:
-
time: timestamp of when the snapshot is taken -
endTime: timestamp of when the browser state changed (when the next snapshot is taken) -
duration: endTime - time -
tabs: list ofTabobjects that were opened -
snapshotAction: the change of browser state that trigger this snapshot -
focuses: a list ofFocusobjects that indicate focus change during this snapshot -
lastFocus: theFocusbefore the snapshot was taken
In [10]: print snapshots[3]
[Snapshot:updated:complete for 0:00:00.893000 @ 2015-04-07 02:43:14.340000 - d0d91def-a22a-4719-bde7-964177b7b96e
<Tab 371:374 complete: https://www.facebook.com/>
<Tab 371:621 complete: http://mashable.com/2015/04/05/homeless-coder-still-homeless/?df
from: <Tab 371:374 complete: https://www.facebook.com/>
>
<Tab 371:512 complete: chrome-extension://gladehdlabngfbhpefnpjccjadnjlgmi/dist/html/interface.html>
(last) <Focus tabChange 371:374 @ 2015-04-07 02:41:41.041000>
<Focus tabChange 371:623 @ 2015-04-07 02:43:15.015000>
]The Tab object is a snapshot of one tab, the attributes are:
-
id: the id of this tab, may be reused over time. See https://developer.chrome.com/extensions/tabs#type-Tab -
windowId: the id of the browser window that hosts this tab, may be reused over time. -
url: the url of the tab -
domain: the domain part of the url -
index: the index of this tab in its host window (e.g., the second tab of the window) -
status: the status of the tab ('loading' or 'complete') -
source: aTabobject that branched out this tab (open in a new tab)
In [12]: print snapshots[3].tabs[1]
<Tab 371:621 complete: http://mashable.com/2015/04/05/homeless-coder-still-homeless/?df
from: <Tab 371:374 complete: https://www.facebook.com/>
>The Focus object is an event of focus change, the attributes are:
-
time: timestamp of when the event happened -
windowId: the window id of the focused window, -1 indicates switching to other applications -
id: the tab id of the focused tab -
action: type of action that triggered the focus change, wither 'windowChange' or 'tabChange'