Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@perfectum/client
Advanced tools
Library for measuring client performance metrics :rocket:
yarn add @perfectum/client
import Perfectum from '@perfectum/client';
Perfectum.init({
sendMetricsUrl: 'http://example.com/metrics',
sendMetricsData: {
app: 'example',
env: 'production'
},
sendMetricsCallback: (metrics) => {
const data = JSON.stringify(metrics);
window.navigator.sendBeacon('http://example.com/metrics', data);
},
maxPaintTime: 15000
});
By default, before the user closes the page (unload event), the Perfectum will send an object with the collected metrics to the address specified in the sendMetricsUrl property.
If you need to add data to the resulting object with collected metrics, for example, the name of the application or the type of environment, you can specify the object with additional data in the sendMetricsData property.
If you want to implement your own logic for sending the collected metrics, you can specify a callback in the sendMetricsCallback property that will be called before the user closes the page (unload event). When calling a callback, an object with collected metrics will be passed as an argument.
If you want to filter paint performance metrics such as First Paint, First Contentful Paint, Largest Contentful Paint, you can set the maxPaintTime property(in milliseconds). By default, it is set to 60 seconds.
Custom metrics are the ability to measure the performance of individual elements on a page or the operations performed in your project. These metrics are necessary to provide the most accurate picture of how users perceive the performance of your application. There are two approaches to measuring custom metrics:
Measurement at the initialization stage of the application
At this stage, we may need to measure the time of appearance of the most important page elements on the user's screen, such as a hero image, cta button, lead form etc. For this type of measurement, you need to add the elementtiming attribute to the HTML element whose performance or time of appearance on the page you would like to measure.
<h1 elementtiming="metric-name">Example App</h1>
Measurement at the stage of interaction with the application
At this stage, we may need to measure the performance of the priority task, the time spent on an important request, or the rendering of specific page components. For this type of measurement, you need to use the special interface provided in the form of two static methods, startMeasure and stopMeasure.
import Perfectum from '@perfectum/client';
Perfectum.startMeasure('metric-name');
someKindOfImportantTask();
Perfectum.stopMeasure('metric-name');
FAQs
Library for measuring client performance metrics
The npm package @perfectum/client receives a total of 16 weekly downloads. As such, @perfectum/client popularity was classified as not popular.
We found that @perfectum/client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.