
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
metricsfn is a lightweight JavaScript library designed to facilitate the collection of metrics and performance data in an application.
Install the library via npm:
npm install metricsfn
// Create an instance of Metrics
const metrics = new Metrics();
// Initialize Metrics
metrics.Init();
// Add an ID
metrics.ID(123);
// Add data
metrics.UserID('user123')
.TimeSamp()
.ParseErrors();
// Retrieve data
const data = metrics.env();
console.log(data);
const axios = require('axios')
const Metrics = require('metricsfn')
const metrics = new Metrics();
async function makeRequest(url, method = 'GET', data = null) {
metrics.Init();
const id = 123
metrics.ID(id);
metrics.ID(id).TimeSamp()
const datas = {};
const metricsDatas = {};
try {
metrics.TimerStart(id);
const response = await axios({
method,
url,
data,
});
metrics.ID(id).FetchTimeExec(metrics.TimerStop(id)).Success()
datas = response.data
metricsDatas = metrics.ID(id).env()
return {datas, metricsDatas};
} catch (error) {
metrics.ID(id).FetchTimeExec(metrics.TimerStop(id)).FetchError().Aborted()
metricsDatas = metrics.ID(id).env()
return {datas, metricsDatas};
}
}
const apiUrl = 'https://jsonplaceholder.typicode.com/posts/1';
makeRequest(apiUrl, 'GET');
Init()Initializes the Metrics library.
ID(id: string)Adds a new ID to the data table.
id: Unique identifier.UserID(data: string)Adds the user ID to the data.
data: User ID.TimeSamp()Adds a timestamp to the data.
ParseErrors()Increments the parse errors count in the data.
SyntaxErrors()Increments the syntax errors count in the data.
FilterTimeExec(timesamp: string)Adds filter execution time to the data.
timesamp: Timestamp of filter execution time.GenerateTimeExec(timesamp: string)Adds generation execution time to the data.
timesamp: Timestamp of generation execution time.FetchTimeExec(timesamp: string)Adds fetch execution time to the data.
timesamp: Timestamp of fetch execution time.Aborted()Indicates in the data that the operation was aborted.
Exited()Indicates in the data that the operation was exited.
Success()Indicates in the data that the operation was successful.
TimerStart(key: string)Starts a timer with the specified key.
key: Timer key.TimerStop(key: string)Stops the timer and returns the elapsed time.
key: Timer key.TimerClear(key: string)Stops and clears the timer associated with the specified key.
key: Timer key.env()Gets the complete data array.
FAQs
Get metric data on your scripts
We found that metricsfn demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.