{"id":18368169,"url":"https://github.com/thinkjs/lightkeeper","last_synced_at":"2025-04-06T17:31:38.487Z","repository":{"id":73609517,"uuid":"108803681","full_name":"thinkjs/lightkeeper","owner":"thinkjs","description":"pharos data send script for web.","archived":false,"fork":false,"pushed_at":"2019-06-28T14:09:15.000Z","size":31,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-22T03:51:20.255Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://pharos.baomitu.com","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/thinkjs.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":"2017-10-30T04:59:51.000Z","updated_at":"2019-03-06T10:40:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"65b16d95-566b-4def-a2c8-d114eda301f0","html_url":"https://github.com/thinkjs/lightkeeper","commit_stats":{"total_commits":50,"total_committers":4,"mean_commits":12.5,"dds":0.14,"last_synced_commit":"169b7da34a0f9e5dd67267cc3bb305fd40d22630"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Flightkeeper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Flightkeeper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Flightkeeper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Flightkeeper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thinkjs","download_url":"https://codeload.github.com/thinkjs/lightkeeper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247522326,"owners_count":20952522,"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","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-11-05T23:24:54.943Z","updated_at":"2025-04-06T17:31:38.481Z","avatar_url":"https://github.com/thinkjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lightkeeper\n\n[![npm](https://img.shields.io/npm/v/lightkeeper.svg?style=flat-square)]()\n[![Travis](https://img.shields.io/travis/thinkjs/lightkeeper.svg?style=flat-square)]()\n[![Coveralls](https://img.shields.io/coveralls/thinkjs/lightkeeper/master.svg?style=flat-square)]()\n[![David](https://img.shields.io/david/thinkjs/lightkeeper.svg?style=flat-square)]()\n\npharos data send script for web. Support UMD, AMD, CommonJS in Browser.\n\n## Installation\n\n```sh\nnpm install lightkeeper --save-dev\n```\n\n## How To Use\n\n### UMD\n\nYou can use with `script` tag easily like:\n\n```html\n\u003cscript \n  src=\"https://unpkg.com/lightkeeper/dist/pharos.min.js\"\n  data-siteid=\"1\"\n  data-host=\"//pharos.eming.li\"  \n\u003e\u003c/script\u003e\n\u003cscript type=\"text/javascript\"\u003e\nwindow.addEventListener('load', function() {\n  pharos.monitor();\n});\n\u003c/script\u003e\n```\n\n### Webpack\n\nWe also support commonjs require in webpack or rollup like:\n\n```js\nconst Pharos = require('lightkeeper');\nconst site_id = 1;\nconst host = 'https://pharos.eming.li';\n\nconst pharos = new Pharos(site_id, host);\npharos.monitor();\n```\n\n## API\n\n### pharos.monitor()\n\nSend performance to server, return Promise.\n\n### pharos.add(key, val)\n\nAllow develops add customized performance data. And the **val** must be a **Number**, otherwise, it will failed. And return **true** if added successfully. \n\n```js\npharos.add('render', 300);\n\npharos.add({\n  render: 300,\n  footer: 58\n});\n```\n### pharos.delete(infoKeys)\n\nRemove one or more keys from the performance data. And return **true** if deleted successfully.\n\n```js\npharos.delete('render');\n\npharos.delete('loadPage', 'ttfb', 'lookupDomain');\n```\n\n### pharos.clear()\n\nRemote all keys from the performance data. And return old data if clear successfully.\n\n```js\nconst old = pharos.clear();\n\nconsole.log(old);\n//{loadPage: 0, ttfb: 0, lookupDomain: 0}\n```\n### pharos.search(key)\n\nReturn the value of the specified parameter from the performance data.\n\n```js\npharos.add('footer', 100);\n\npharos.search('footer');\n//100\n```\n\n### pharos.time(name)\n\nWork with pharos.timeEnd. To get a duration in milliseconds. pharos.time starts the time.\n\n```js\npharos.time('fib_time');\nfib(20);\npharos.timeEnd('fib_time');\n//fib_time: 0.007080078125ms\npharos.search('fib_time');\n//0.007080078125\n```\n### pharos.timeEnd(name)\n\npharos.timeEnd stops the timer and return the duration.\n\n```js\npharos.time('fib_time');\nfib(20);\npharos.timeEnd('fib_time');\n//fib_time: 0.007080078125ms\npharos.search('fib_time');\n//0.007080078125\n```\n\n## Contributing\n\nContributions welecome!\n\n## License\n\n[MIT](https://github.com/thinkjs/lightkeeper/blob/master/LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkjs%2Flightkeeper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthinkjs%2Flightkeeper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkjs%2Flightkeeper/lists"}