frontend performance resource collector
npm install performance-resource-collector
This script is a tool for collecting frontend metrics.
You should check browser compatibility about PerformanceObserver or use a polyfill before use this.
sh
yarn add performance-resource-collector
`Usage
`js
import { initCollector } from 'performance-resource-collector';initCollector({
callback: (entries) => {
navigator.sendBeacon("http://metric-collect-service/resources", JSON.stringify(entries))
},
onUnsupported: () => {
console.log('unsupport!');
},
onSetUp: () => {
console.log('collecting performance entries...');
},
throttle: 2000,
});
``or see example