{"id":20832108,"url":"https://github.com/ihtml5/dtracker","last_synced_at":"2025-10-25T12:14:00.090Z","repository":{"id":83258240,"uuid":"517057828","full_name":"ihtml5/dtracker","owner":"ihtml5","description":"支持Ajax，Fetch，Image，navigator.sendBeacon等请求。常用于接口异常监控，数据上报，数据旁路等场景。Support Ajax, Fetch and other images, navigator.sendBeacon is often used in interface monitoring, data reporting, data bypass and other scenarios","archived":false,"fork":false,"pushed_at":"2022-07-23T14:07:56.000Z","size":116,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T16:01:15.010Z","etag":null,"topics":["ajax","fetch","lit-element","mdebug","monitor","navigator","react","sendbeacon","vconsole","vuejs"],"latest_commit_sha":null,"homepage":"https://ihtml5.github.io/dtracker","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/ihtml5.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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":"2022-07-23T12:56:11.000Z","updated_at":"2024-10-15T06:10:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"ea5e6f42-0a5c-4fdc-aaec-3b0066d7a6a0","html_url":"https://github.com/ihtml5/dtracker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ihtml5%2Fdtracker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ihtml5%2Fdtracker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ihtml5%2Fdtracker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ihtml5%2Fdtracker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ihtml5","download_url":"https://codeload.github.com/ihtml5/dtracker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252978686,"owners_count":21834913,"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":["ajax","fetch","lit-element","mdebug","monitor","navigator","react","sendbeacon","vconsole","vuejs"],"created_at":"2024-11-18T00:10:15.252Z","updated_at":"2025-10-25T12:14:00.019Z","avatar_url":"https://github.com/ihtml5.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dtracker\n\u003ch1 align=\"center\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/6822604/179356367-c781af73-e8ae-4959-9871-75e0476fcea5.png\"/\u003e\u003c/h1\u003e\n\u003ch4 align=\"center\"\u003e通用前端网络请求拦截库\u003c/h4\u003e\n\u003cp align=\"center\"\u003e\n支持Ajax，Fetch，Image，navigator.sendBeacon等请求。常用于接口异常监控，数据上报，数据旁路等场景\n\u003c/p\u003e\n\u003cdiv align=\"center\"\u003e\n\u003ca href=\"https://npmjs.org/package/dtracker\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/dtracker.svg\" alt=\"NPM Version\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/ihtml5/dtracker/pulls\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/PRs-welcome-brightgreen.svg\" alt=\"PRs\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://nodejs.org\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/node-%3E%3D%208.0.0-brightgreen.svg\" alt=\"Node Version\" /\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n## 一、安装\n\n#### Install using npm \n``` \nnpm install dtracker --save\n\n```\n## 二、如何使用\n### 1.自动基于已经上报的数据做上报\n ```javascript\n  dtracker.create({\n    onProxy: function(data) {\n    /*\n    data.data object 获取到的上报数据\n    data.type object 请求类型 ajax|fetch|image|beacon,\n    data.extra object 包含请求地址等其他信息\n    1. 传给onProxy函数的data代表通过sdk捕获到的网络请求\n    2. 根据上报的网络请求地址,拿到上报的信息\n    3. 将上报的信息经过标准化后通过调用doReport回传\n    dtracker.doReport({\n        baseUrl: 'https://reporteurl.com', 填入数据上报目标地址\n        data: transformdata,\n        method: 'GET' // 默认get, 也支持post发送\n    });\n    */\n    },\n})\n ```\n### 2.使用dtracker.doReport在代码中进行手动上报\n```javascript\n  dtracker.doReport({\n    baseUrl: 'https://reporteurl.com', // 填入数据上报目标地址\n    data: {\n        sOp: 'pageView',\n        osType: 'iphone',\n    },\n    method: 'GET' // 默认get, 也支持post发送\n  });\n```\n## 三、相关文章\n\n1. [揭开JS无埋点技术的神秘面纱](http://unclechen.github.io/2018/06/24/%E6%8F%AD%E5%BC%80JS%E6%97%A0%E5%9F%8B%E7%82%B9%E6%8A%80%E6%9C%AF%E7%9A%84%E7%A5%9E%E7%A7%98%E9%9D%A2%E7%BA%B1/)\n2. [前端热力图系统实现](https://nodefe.com/heatmap-system/)\n3. [基于IntersectionObserver的曝光统计测试](https://xgfe.github.io/2017/10/18/lulutia/IntersectionObserver/)\n4. [Building and testing at Facebook](https://www.facebook.com/notes/facebook-engineering/building-and-testing-at-facebook/10151004157328920/)\n\n## 四、相关项目\n1. [optimal-select](https://github.com/Autarc/optimal-select)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fihtml5%2Fdtracker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fihtml5%2Fdtracker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fihtml5%2Fdtracker/lists"}