{"id":15677067,"url":"https://github.com/daniel31x13/open-analytics-core","last_synced_at":"2025-10-14T08:31:16.201Z","repository":{"id":104426798,"uuid":"437312492","full_name":"daniel31x13/open-analytics-core","owner":"daniel31x13","description":"Open source alternative to Google Analytics (server side.)","archived":true,"fork":false,"pushed_at":"2022-01-24T08:45:30.000Z","size":183,"stargazers_count":13,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-04T09:48:53.261Z","etag":null,"topics":["javascript","mongodb","nodejs","socket-io"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/daniel31x13.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}},"created_at":"2021-12-11T15:03:02.000Z","updated_at":"2024-10-26T18:50:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"a639dbaf-b3a7-4b25-b989-660c593d72d3","html_url":"https://github.com/daniel31x13/open-analytics-core","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/daniel31x13/open-analytics-core","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel31x13%2Fopen-analytics-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel31x13%2Fopen-analytics-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel31x13%2Fopen-analytics-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel31x13%2Fopen-analytics-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daniel31x13","download_url":"https://codeload.github.com/daniel31x13/open-analytics-core/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel31x13%2Fopen-analytics-core/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018313,"owners_count":26086342,"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-10-14T02:00:06.444Z","response_time":60,"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":["javascript","mongodb","nodejs","socket-io"],"created_at":"2024-10-03T16:08:20.558Z","updated_at":"2025-10-14T08:31:16.194Z","avatar_url":"https://github.com/daniel31x13.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Open Analytics Core\n### Get real-time online users and save the data to MongoDB database.\n\nBasically what it does is aside from showing real-time total active clients in the node console it also logs the following information to a MongoDB database:\n- #### Device Ip\n- #### User-agent\n- #### IsMobile\n- #### Date\n- #### Active Time (Seconds)\n- #### Visited url\n- #### Location\n- #### Referrer\n\n### Demo\n\n![alt demo](https://i.imgur.com/0kLzHWj.png)\n\n------------\n### Requirements\nThese are the versions that I had so it **may** work on your PC if you had an older version installed:\n- #### NodeJS (version 16 or later)\n- #### MongoDB (version 5 or later)\n- #### Any other webserver that you want to serve your clients with (even NodeJS)\n- #### OpenSSL (Optional: For HTTPS setup.)\n\n------------\n### Setup\n\n#### First Step\nAdd this code to your client HTML page ([Example](clientExample.html \"Example\")):\n\n```javascript\n\u003cscript src=\"https://cdn.socket.io/4.4.0/socket.io.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    const socket = io(\"ADDRESS\"); // Enter URL with port\n    socket.on('socketClientID', function (socketClientID) {\n        socket.emit('clientMessage', {url: window.location.href, referrer: document.referrer}); // Send url and referrer as an object\n    });\n\u003c/script\u003e\n```\n\n#### Second Step\nRun `npm install` in the main folder.\n#### Third Step\nAnd finally run `node index` also in the main folder.\n\n------------\n\n### HTTPS Setup\nIf your website is using HTTPS instead of HTTP you'll need to do the steps which are shown below:\n#### First Step\nTo set up HTTPS support you'll need an [SSL certificate](https://nodejs.org/en/knowledge/HTTP/servers/how-to-create-a-HTTPS-server/ \"SSL certificate\").\nTo generate a self-signed certificate, run the following in your shell:\n\n    openssl genrsa -out key.pem\n    openssl req -new -key key.pem -out csr.pem\n    openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem\n    rm csr.pem\n    \n#### Second Step\nAfter getting your `.pem` files just change line [7](https://github.com/Daniel31x13/Open-Analytics-Core-HTTP/blob/065d420066aa10d0787165f56f7d05d3b4ccc7d9/index.js#L7) to [12](https://github.com/Daniel31x13/Open-Analytics-Core-HTTP/blob/065d420066aa10d0787165f56f7d05d3b4ccc7d9/index.js#L12) (index.js file) with this: \n\n```javascript\nconst options = {\n    key: fs.readFileSync('key.pem'), // Edit key.pem file path if needed (Default: Main folder)\n    cert: fs.readFileSync('cert.pem'), // Edit key.pem file path if needed (Default: Main folder)\n    cors: {\n        origin: '*',\n      }\n}\n\nconst https = require('https').createServer(options, app);\nconst io = require('socket.io')(https, {\n    cors: {\n      origin: '*',\n    }\n});\n```\n#### Third Step\nYou'll need to add the `fs` module so add `const fs = require('fs');` at top of the index.js file.\n\n#### Fourth Step\nChange line [64](https://github.com/Daniel31x13/Open-Analytics-Core-HTTP/blob/065d420066aa10d0787165f56f7d05d3b4ccc7d9/index.js#L64) to [66](https://github.com/Daniel31x13/Open-Analytics-Core-HTTP/blob/065d420066aa10d0787165f56f7d05d3b4ccc7d9/index.js#L66) (bottom of the index.js file) with this:\n\n```javascript\nhttps.listen(PORT, () =\u003e {\n    console.log(\"ALL SET!\");\n});\n```\n\n#### Fifth Step\nLastly change `const socket = io(\"ADDRESS\");` to `const socket = io(\"ADDRESS\", {secure: true});` where ever your using the [client script](clientExample.html \"client script\").\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaniel31x13%2Fopen-analytics-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaniel31x13%2Fopen-analytics-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaniel31x13%2Fopen-analytics-core/lists"}