{"id":28398398,"url":"https://github.com/primus/primus-analytics","last_synced_at":"2025-08-12T05:15:54.991Z","repository":{"id":57330437,"uuid":"41422459","full_name":"primus/primus-analytics","owner":"primus","description":"Deep integration of Google Analytics in to Primus using event tracking","archived":false,"fork":false,"pushed_at":"2022-12-31T20:20:48.000Z","size":27,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-08-09T13:38:39.273Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/primus.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}},"created_at":"2015-08-26T11:42:02.000Z","updated_at":"2023-02-28T15:49:08.000Z","dependencies_parsed_at":"2023-01-31T19:45:50.093Z","dependency_job_id":null,"html_url":"https://github.com/primus/primus-analytics","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/primus/primus-analytics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primus%2Fprimus-analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primus%2Fprimus-analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primus%2Fprimus-analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primus%2Fprimus-analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/primus","download_url":"https://codeload.github.com/primus/primus-analytics/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primus%2Fprimus-analytics/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269772277,"owners_count":24473374,"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-10T02:00:08.965Z","response_time":71,"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":"2025-06-01T04:38:38.881Z","updated_at":"2025-08-12T05:15:54.981Z","avatar_url":"https://github.com/primus.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# primus-analytics\n\n[![Version npm][npm-primus-analytics-badge]][npm-primus-analytics][![CI][ci-primus-analytics-badge]][ci-primus-analytics]\n\nIntegrates Google Analytics deeply in the Primus client by using its event\ntracking functionality. This allows you to get an insight on how things are\nrunning on the client.\n\n## Installation\n\nThe module is released in the public npm registry and can be installed by\nrunning:\n\n```\nnpm install --save primus-analytics\n```\n\n## Integration\n\nWe assume that you've already setup your Primus server. If not we assume the\nfollowing base initialization in our example code:\n\n```js\n'use strict';\n\nvar Primus = require('primus')\n  , http = require('http')\n  , server = http.createServer();\n\nvar primus = new Primus(server);\n```\n\nTo add this plugin to your created Primus server instance you need to use the\n`.plugin` method which accepts a name and the required plugin as argument. The name\ncan be anything you want. It's there for lookup and debugging purposes.\n\n```js\nprimus.plugin('google analytics', require('primus-analaytics'));\n```\n\nPlease note that after adding this plugin, you should re-generate the client\nlibrary if you are not using the primus library that is served from\n`/primus/primus.js`.\n\n```js\nprimus.save(__dirname +'/your-completed-library.js');\n```\n\n## API\n\nNow that the server is completely set up with the correct plugins and all files\nhave been re-compiled we can start configuring the client side. In most if not\nall cases you don't really need to do anything here. When you create a new\nPrimus client it will automatically start tracking:\n\n- The custom events and their names when using `primus-emit` or `primus-emitter`\n- Close, reconnected, reconnect-failed, open events.\n- Reconnect-start event.\n- Exception tracking for `error` events.\n\nBut everything here is configurable by supplying an `analytics` object in the\noptions object of the `Primus` constructor. The following options are\nsupported:\n\n- *category*  The event category we should log the events under. It defaults to\n  `primus`.\n- *events* Should be an object where the key is the name of the event we tracked\n  and the value is the event action that should be logged. If value is set to\n  `false` we assume that you want to prevent this event from being tracked so it\n  will not be sent to Google Analytics. This is also useful to block highly\n  frequent events so you don't reach your event limit in Google Analytics.\n- *app* With the exception reporting that we trigger on the `error` event, we\n  also send the name of the application, the app property allows you to\n  configure this name. If defaults to `primus`.\n\n```js\nvar primus = new Primus('http://your-website.here', {\n  analytics: {\n    category: 'chat server',\n    events: {\n      'load more': 'load-more-messages',\n      'mousemove': false\n    }\n  }\n});\n```\n\n[npm-primus-analytics-badge]: https://img.shields.io/npm/v/primus-analytics.svg?style=flat-square\n[npm-primus-analytics]: https://www.npmjs.com/package/primus-analytics\n[ci-primus-analytics-badge]: https://img.shields.io/github/actions/workflow/status/primus/primus-analytics/ci.yml?branch=master\u0026label=CI\u0026style=flat-square\n[ci-primus-analytics]: https://github.com/primus/primus-analytics/actions?query=workflow%3ACI+branch%3Amaster\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprimus%2Fprimus-analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprimus%2Fprimus-analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprimus%2Fprimus-analytics/lists"}