{"id":15637758,"url":"https://github.com/megapixel99/stats-tracker","last_synced_at":"2025-08-30T16:05:13.568Z","repository":{"id":213570412,"uuid":"726708410","full_name":"Megapixel99/stats-tracker","owner":"Megapixel99","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-17T20:34:02.000Z","size":5292,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-22T20:42:29.857Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Megapixel99.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-03T06:21:34.000Z","updated_at":"2025-02-14T22:01:14.000Z","dependencies_parsed_at":"2025-03-29T20:41:48.703Z","dependency_job_id":"f13169de-6a2d-484a-854f-9f68890cbf6f","html_url":"https://github.com/Megapixel99/stats-tracker","commit_stats":null,"previous_names":["megapixel99/stats-tracker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Megapixel99/stats-tracker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Megapixel99%2Fstats-tracker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Megapixel99%2Fstats-tracker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Megapixel99%2Fstats-tracker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Megapixel99%2Fstats-tracker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Megapixel99","download_url":"https://codeload.github.com/Megapixel99/stats-tracker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Megapixel99%2Fstats-tracker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272871673,"owners_count":25007208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-30T02:00:09.474Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T11:12:45.269Z","updated_at":"2025-08-30T16:05:13.549Z","avatar_url":"https://github.com/Megapixel99.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stats Tracker\n\nThis module exposes two functions: `dashboard` and `tracker`\n\nThe `tracker` function can be used to relay information about the current NodeJS\nprocess to the dashboard (wherever the `dashboard` function is running).\n\n## tracker(config)\n\nThe tracker takes one argument, `config`. The tracker connects to the dashboard via web sockets and exposes a web socket server which the dashboard can connect to.\n\nThe `config` can be used to pass the port of the web socket server and the name of the application.\n```javascript\nconst { tracker } = require('stats-tracker');\n\nlet t = tracker({\n  name: 'test',\n  pod: 'test-1', // useful if running multiple instances of the same application, defaults to the name, in this case `test`\n  logger: console, // defaults to console if nothing is passed\n});\n```\n\nThe functions that `tracker` exposes are:\n\n`bytes.sent(data)`:\n\nThe `data` argument the function takes needs to be a number and is assumed to be the number of bytes sent.\n\n`bytes.received(data)`:\n\nThe `data` argument the function takes needs to be a number and is assumed to be the number of bytes received.\n\n`data.sent(data)`:\n\nThe `data` argument the function takes is assumed to be raw data and thus will be serialized and converted to bytes.\n\n`data.received(data)`:\n\nThe `data` argument the function takes is assumed to be raw data and thus will be serialized and converted to bytes.\n\n`database.read(data)`:\n\nThe `data` argument the function takes is assumed to be a JSON array and the length of the JSON array will be sent to the dashboard.\n\n`database.written(data)`:\n\nThe `data` argument the function takes is assumed to be a JSON array and the length of the JSON array will be sent to the dashboard.\n\n`databaseRows.sent(data)`:\n\nThe `data` argument the function takes needs to be a number and is assumed to be the number of rows sent.\n\n`databaseRows.received(data)`:\n\nThe `data` argument the function takes needs to be a number and is assumed to be the number of rows received.\n\n`job.start(jobName [, start])`:\n\nThis function will start a job, and returns a job so you can stop it later, it is up to you to end the job manually with `job.stop()`.\nThe `jobName` argument is the name of the job that you will see in the dashboard.\nThe optional `start` argument is the time when the job started in milliseconds (defaults to `Date.now()`)\n\n`job.stop()`:\n\nThis function will stop a job and data about the job will be sent to the dashboard.\n\n#### How to use job.start() and job.stop()\n\n```javascript\nconst { tracker } = require('stats-tracker');\n\nlet t = tracker({\n  name: 'test',\n  pod: 'test-1',\n  logger: console, // defaults to console if nothing is passed\n});\n\nlet job1 = t.job.start('jobName');\n\n// some other code which takes a while to run goes here\n\njob1.stop();\n```\n\n## dashboard\n\nThe `dashboard` function exposes a web-based dashboard (built using `express` and `ejs`) to see information about the various trackers that are feeding information to it (via web sockets).\n\nThe `dashboard` function takes one argument, `config`.\n\nThe `config` can be used to pass the port you want the dashboard to run on, the URL of the Mongo Database you will be using, and the url(s) or the various applications running the `tracker` function along with `usageLength` and a `logger`.\n\n```javascript\nconst { dashboard } = require('stats-tracker');\n\ndashboard({\n  port: 3000,\n  mongoUrl: 'mongodb://yourUrl',\n  usageLength: 100, // determines how much CPU usage info to save in the database (for the average CPU usage to be determined), defaults to 100 and is updated every 5 seconds\n  logger: console, // defaults to console if nothing is passed\n});\n```\n\nIf you want to spin up the dashboard as a standalone application you can run: `npm run dashboard`\n\n### For a full (running/working) demo, please see `demo.js` in the demo folder\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegapixel99%2Fstats-tracker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmegapixel99%2Fstats-tracker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegapixel99%2Fstats-tracker/lists"}