WebMemex / webmemex-extension

📇 Your digital memory extension, as a browser extension
https://webmemex.org
Other
208 stars 45 forks source link

Log time spent in each visit #45

Closed Treora closed 6 years ago

Treora commented 7 years ago

We currently only log the start time of each visit, not the end. This would be an obvious first thing to add. Much better still, we should log when a tab becomes active or inactive, because that is what actually matters, and possibly what we should really call a visit.

Let's start with logging the end time of the visit (= when the tab closed), and counting the total time spent viewing the page (≈ tab being active) and adding this number as a separate field to the visit.

This may require keeping some state in the background script about which tabs correspond to which visits.

If you have an idea or existing code for approaching this, feel free to share.

Treora commented 7 years ago

Bonus points for adding this idea from #11: use mouse or keyboard activity to estimate whether the user is looking at the page or is away from keyboard, as to not log the latter as active viewing time.

anona-R commented 7 years ago

Can we use ifvisible to check whether a user is looking at a page or not and then track the time by a timer

Treora commented 7 years ago

Can we use ifvisible

Yes, brilliant, exactly the piece we need for the bonus points. What remains is just counting and summing up active times in the activity-logger content script, then somehow report it to the background script (not sure yet which way is best for that, but that can come later).

vaibsharma commented 7 years ago

I made a chrome extension two months back, in which I required the total time spend in the current tab or website in that tab. We can use that approach for letting the end time come into the picture . By using port.postmessage({}) API of chrome we can send data whenever the condition satisfy . And then listen to this message in background . ^but I am not sure because in that I knew the websites that were allowed by the content script and each one of them had their indices , but since here we are using content script for all then perhaps we have to think of using different idea for using that code

NimmiW commented 7 years ago

@Treora @vaibsharma yes we have think of some different idea. Let me and @uchithaR look into this :) We like to contribute to this project.

NimmiW commented 7 years ago

@Treora https://github.com/NimmiW/activity-log-time/blob/master/background.js

Here we @uchithaR have done getting the active time log of all the tabs when navigating through tabs. This uses that active status of the tab to get the active time. Now we have work on detecting the real active time by using mouse over events and keyboard pressed events.

We went only through the Chrome API documentation since this is out first time developing a browser extension even though we are familiar with JavaScript.

Sample Output from background.js

image

Treora commented 7 years ago

@NimmiW @uchithaR: nice start, looking forward to see more.

blackforestboi commented 7 years ago

@NimmiW @uchithaR Is there any progress for this?

NimmiW commented 7 years ago

@oliversauter yes now we are using https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Browser_support_for_JavaScript_APIs. :) We have a issue in storing in the browser, so that data will remain even after closing the browser.

blackforestboi commented 7 years ago

@NimmiW Where do you aim to store it in the browser? Local storage?

If I am not mistaken then this data should be stored in the DB, associated to the correct URL. The question is only where to store it? In the visit object? @Treora

NimmiW commented 7 years ago

@oliversauter @Treora We need some guidance for that. We hope to store in Local Storge

Treora commented 7 years ago

We have a issue in storing in the browser, so that data will remain even after closing the browser.

The activity-logger's background code could update the visit object to add the end-time and spent-time of each visit. I have to think still about how to organise this process, e.g. which side (background/content-script) initiates the updates. It is fine if you just find a good solution that counts the time spent, and perhaps triggers an event upon activation and deactivation, but leave how to report and store this for later.

NimmiW commented 7 years ago

ok @Treora We will try to modify that first according to our logic

Treora commented 6 years ago

Closing this issue; features like this one have been fading off the roadmap for a while. Maybe some day..