Daily event report of all of a user's node packages
jgresham opened this issue · comments
Johns Gresham commented
Feature details
This is useful to know what nodes people are running, which versions they're using, the clients they have selected, etc. This is extremely helpful for the contributors to both know what users use and better allocate time, and it is vital data for use for applying for grants.
Technicals
- Create cron job when app opens using https://www.npmjs.com/package/cron to run every day at midnight and run the function on create as well.
- The function will do the following:
- From
store
insrc/main
, retrieve the value forlastDailyReportTimestamp
to see if a daily report has been sent within the previous day (can use 23 hours & 59 minutes to account to make sure we don't miss a day). If it hasn't been a day, do nothing. - If it has been more than a day, call the function below:
- create a new function in
src/main/state/nodePackages.ts
calledgetUserNodePackagesWithNodes()
- It should call
getUserNodePackages
andgetUserNodes
and for each nodePackage, loop over the services and find the corresponding node. Effectively we are just merge parents with their children. It is already done on the front-end but should be done on the backend. The function will look similar to :
userNodePackages.forEach(nodePackage =>
const nodes = []
nodePackage.services.map((service) => {
const nodeId = service.node.id;
const node = userNodes?.nodes[nodeId];
nodes.push(node)
});
nodePackage.nodes = nodes;
});
- Then call `src/events.reportEvent('DailyUserReport', userNodePackages);
The data sent to mix panel will look something like:
nodes : array
status:
version:
network:
services:
nodes: array
status:
name:
version:
otherConfig:
....
I think the cron job should be "deleted" when the app closes, but double-check so that we don't increase the number of cron jobs everytime the user opens the app.