NiceNode / nice-node

Run a node — just press start

Home Page:https://www.nicenode.xyz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Daily event report of all of a user's node packages

jgresham opened this issue · comments

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

  1. 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.
  2. The function will do the following:
  3. From store in src/main, retrieve the value for lastDailyReportTimestamp 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.
  4. If it has been more than a day, call the function below:
  5. create a new function in src/main/state/nodePackages.ts called getUserNodePackagesWithNodes()
  6. It should call getUserNodePackages and getUserNodes 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;
 });

  1. 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.