{"id":42272096,"url":"https://github.com/genert/metis","last_synced_at":"2026-01-27T07:27:15.659Z","repository":{"id":57295962,"uuid":"165413073","full_name":"genert/metis","owner":"genert","description":"Asynchronous data sender library","archived":false,"fork":false,"pushed_at":"2023-12-15T02:34:40.000Z","size":105,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-10T19:07:35.297Z","etag":null,"topics":["analytics","asynchronous","data","dependency-free","typescript"],"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/genert.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":"2019-01-12T17:01:56.000Z","updated_at":"2019-01-14T05:43:27.000Z","dependencies_parsed_at":"2022-08-26T16:20:12.138Z","dependency_job_id":null,"html_url":"https://github.com/genert/metis","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/genert/metis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genert%2Fmetis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genert%2Fmetis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genert%2Fmetis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genert%2Fmetis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/genert","download_url":"https://codeload.github.com/genert/metis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genert%2Fmetis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28808006,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T07:14:39.408Z","status":"ssl_error","status_checked_at":"2026-01-27T07:14:39.098Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["analytics","asynchronous","data","dependency-free","typescript"],"created_at":"2026-01-27T07:27:13.533Z","updated_at":"2026-01-27T07:27:15.647Z","avatar_url":"https://github.com/genert.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Metis\n\n[![NPM Version](https://badge.fury.io/js/metis-data.svg)](https://badge.fury.io/js/metis-data)\n\n\u003e Asynchronous data sender library\n\n- Asynchronous-first :zap:\n- Uses [navigator.sendBeacon](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon) to send data over HTTP to configured host without waiting for a response. Falls back to XHR when not supported.\n- Sends event collection at configured interval or when maximum event collection size is reached.\n- Sends all accepted events when the document or a child resource is being unloaded.\n- Does not block the process of unloading the document.\n- 2.08 kB kB gzipped of minified version.\n- Dependency-free :tada:\n\n## Getting Started\n\n#### Step 1: Install\n\n[Download the latest release](https://raw.githubusercontent.com/Genert/metis-data/master/dist/main.js) or install with npm.\n\n```sh\nnpm install metis-data --save\n```\n\n#### Step 2: Reference\nIf you linked `metis-data` directly in your HTML, you can use `window.MetisData`. If you're using a module bundler, you'll need to import it.\n\n```javascript\n// CommonJS\nconst MetisData = require('metis-data');\n\n// ES2015\nimport MetisData from 'metis-data';\n```\n\n### Step 3: Usage\n\nMinimal example. See configuration options below.\n\n```javascript\nconst analytics = new MetisData({\n  api: {\n    host: 'https://yourapi.com/path'\n  }\n}));\n\nanalytics.addEvent({\n  name: 'your-event-name',\n  data: {\n    // Data payload\n    something: 'mock-data'\n  }\n});\n```\n\nWith default settings, following event will be sent to configured host as POST request within default buffer time (2s).\n\nThe payload will be array of event objects converted to a JSON string as following:\n\n```\n[\n  {\n    \"id\":\"b9e601f6-462a-413b-af98-3f5e28fe2f12\",\n    \"name\":\"your-event-name\",\n    \"timestamp\":1547411367556,\n    \"data\":{\n      \"something\":\"mock-data\"\n    }\n  }\n]\n```\n\nEach event has unique RFC4122 version 4 compliant UUID by default, which can be overridden with your preferred id.\n\nAlso, timestamp is added when the event was added to the event collection. This can be also overriden as following example shows:\n\n```javascript\nanalytics.addEvent({\n  id: 'your-id', // Must be string\n  name: 'your-event-name',\n  timestamp: Date.now(),\n  data: {\n    // Data payload\n  }\n});\n```\n\n## Options\nYou can set options on `metis-data` during initialization.\n\n```javascript\n// During initialize\nnew MetisData({\n  api: {\n    host: 'https://yourapi.com/path',\n    method: 'POST',\n    query: {\n      param: 123\n    }\n  },\n  bufferTime: 10000,\n  batchSize: 32768\n});\n```\n\n### `options.api.host` (required)\n\n\u003e Describes configured host, where payload is sent.\n\n### `options.api.method`\n\n\u003e Describes HTTP request method to the configured host.\n\u003e\n\u003e **Default:** *(string)* `POST`.\n\n### `options.api.query`\n\n\u003e Describes list of query params that will be appended to the host url.\n\u003e\n\u003e **Default:** *(object)* `{}`.\n\n### `options.bufferTime`\n\n\u003e Describes timespan in what event collection is gathered and sent to configured host.\n\u003e\n\u003e **Default:** *(integer)* `2000` (2s).\n\n### `options.batchSize`\n\n\u003e Defines maximum batch size for both event collection and event itself.\n\u003e\n\u003e **Default:** *(integer)* `32768` (32 kB)\n\n## Polyfill\n\nThe library uses [navigator.sendBeacon](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon) and [Object.keys](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys) that you might need polyfill for. You can for instance use *babel-polyfill* in this case.\n\n## Contributions \u0026 Issues\n\nContributions are welcome. Please clearly explain the purpose of the PR and follow the current style.\n\nIssues can be resolved quickest if they are descriptive and include both a reduced test case and a set of steps to reproduce.\n\n## Licence\n\nLicensed under the [MIT License](LICENSE) © 2019 Genert Org","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenert%2Fmetis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenert%2Fmetis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenert%2Fmetis/lists"}