Currently localStorage keeps a bunch of info about domains and nudges but it's not enough to do proper analysis and tell people e.g. you used FB for 3 hours this week (data clears itself every day). Additionally if we stored this all in localStorage or Chrome.storage we would quickly run out of space so this 'proper all-time history' needs to be sent to our server, which is set up already.
History should include the following:
Visits to nudge domains
visitId
domain
visitStart date and time
visitEnd date and time
(you can use the visit unit that already exists in the app)
Nudges (most of this already exists in nudges in localStorage)
nudge date and time
nudge amount (e.g. 50 visits, 20 minutes)
nudge domain
nudge modal or drawer
postNudgeAction
any event of close tab within 10mins after receive nudge or navigate away from tab within 10mins after receive nudge
(this is an optional extra at this stage)
Figure out sensible schedule for sending this data to server, and way to ensure information is never duplicated on server side (and that no information is skipped).
I will send an email now detailing the server API info for sending data over. You can see there is a function in background.js which enables sending stuff to server - you can find a user ID hash there. Server API was made by Kristo.
use chrome identity API in place of getRandomToken (background.js line 114) - https://developer.chrome.com/apps/identity. this is so that each user always has the same ID, even if Nudge is deleted and reinstalled. currently every time i reinstall Nudge, it's creating a new user in the DB
log Visits, Nudges (as defined above - ignore postNudgeActions for now) in localStorage. requires creating a new localStorage object localStorage.visits where visits get put in once that particular visit has ended - which occurs line 432 background.js when 'domainTimeUpdater' runs
send all 3 over to DB using post function at background.js line 147 every [week] and clear localStorage once data successfully transferred
some safeguard to prevent duplication of data onto database
@biggest-dave could you add @danieljvdm to the nudge-api repo in case that's helpful?
Currently localStorage keeps a bunch of info about domains and nudges but it's not enough to do proper analysis and tell people e.g. you used FB for 3 hours this week (data clears itself every day). Additionally if we stored this all in localStorage or Chrome.storage we would quickly run out of space so this 'proper all-time history' needs to be sent to our server, which is set up already.
History should include the following:
Visits to nudge domains
Nudges (most of this already exists in nudges in localStorage)
postNudgeAction
Figure out sensible schedule for sending this data to server, and way to ensure information is never duplicated on server side (and that no information is skipped).
I will send an email now detailing the server API info for sending data over. You can see there is a function in background.js which enables sending stuff to server - you can find a user ID hash there. Server API was made by Kristo.