
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
statful-client-javascript
Advanced tools
Statful client for Javascript applications.
bower install --save statful-client-javascript
or
npm install --save statful-client-javascript
All methods that provider timing mechanism are based in the user-timing specification.
statful.registerTimer('your.timer.metric.name', 100, {
tags: {tagKey: 'foo'}
});
// Register counters
// Increment 1 (default)
statful.registerCounter('your.counter.metric.name');
// Increment 5
statful.registerCounter('your.counter.metric.name', {metricValue: 5});
// Increment 5 with custom tag and aggregation
statful.registerCounter('your.counter.metric.name', {
metricValue: 5,
tags: {tagKey: 'foo'},
aggregations: ['avg']
});
// Register a gauge with custom tag, aggregations and aggregation frequency
statful.registerGauge('your.gauge.metric.name', 345, {
tags: {tagKey: 'foo'},
aggregations: ['avg', 'last'],
aggregationFrequency: 30
});
Support for the user-timing specification is available.
statful.registerMark('mark_start');
statful.registerMark('mark_end');
// Measure and Timer between two marks
statful.registerMark('mark_start');
statful.registerMark('mark_end');
var options = {
startMark: 'mark_start',
endMark: 'mark_end'
tags: {mark: my_tag}
}
statful.registerMeasure('measure_name', 'metric_name' options);
// Measure and Timer from the navigationStart eent until the current time
var options = {
tags: {mark: my_tag}
}
statful.registerMeasure('measure_name', 'metric_name' options);
You can omit both start and end mark names:
Support for the resource-timing specification is available and controlled as:
statful.initialize({
registerResourceLoading: true,
resourceLoadingTrackingInterval: 5000,
resourceLoadingTrackingExclusions: [],
resourceLoadingNameTracking: {}
...
});
Please note that not all browsers support the resource timing specification and therefore don't support resource tracking.
You can enable or disable resource loading tracking by setting the registerResourceLoading
attribute accordingly.
A blacklist of resource types can be defined to limit the type of resources tracked by setting the resourceLoadingTypeBlacklist
attribute.
This array should contain define types according to the resource timing specification which at the time are: link, css, script, img, object, subdocument, preflight, xmlhttprequest, svg, other.
You can apply a global resource filtering function based on the resource name by setting the resourceLoadingPathFilter
attribute. This should be a callback function that receives the resource name and should return true or false to either include or exclude it.
If you want to capture the name of the resources being tracked as a tag you should use the resourceLoadingNameTracking
attribute.
The way this works is that yu create an attribute in that object matching the initiatorType you want to track the name of and assign it a callback function which returns the parsed.
Example: Let's say you wanted to:
// original resource name is foo.1234asdf.js
// parsed resource name is foo.js
var scriptCaptureFunc = function (name) {
var captured = /(\w+.)(\w+.)(\w+)$/.exec(name);
return captured[1] + captured[3];
};
// filter everything that's not jquery
var srcFilterFunc = function (name) {
return name !== 'https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js';
};
statful.initialize({
registerResourceLoading: true,
resourceLoadingTrackingInterval: 5000,
resourceLoadingTypeBlacklist: ['img'],
resourceLoadingPathFilter: srcFilterFunc,
resourceLoadingNameTracking: {
script: scriptCaptureFunc
}
...
});
To being able to fully track asset loaded using cross origin requests please follow the specification.
Support for the resource loading error specification is available and controlled as:
statful.initialize({
registerResourceErrors: false,
resourceErrorsNameTracking: {},
resourceErrorsTypeBlacklist: []
...
});
IMPORTANT: If you want to track errors in every added resource you have to include and configure client, before all other things, in your header.
That is controlled by a metric with name: ''.counter.resource.error.
You can enable or disable resources loading errors tracking by setting the registerResourceErrors
attribute accordingly.
A blacklist of resource types can be defined to limit the type of resources tracked by setting the resourceErrorsTypeBlacklist
attribute.
This array should use the following available resource types: img, script, link.
If you want to capture a custom name of the resources being tracked as a tag, instead of default behaviour that captures all resource path as a tag (including http://), you should use the resourceErrorsNameTracking
attribute. The way this works is that you create an attribute in that object matching the resource type you want to track the name of and assign it a callback function which returns the parsed.
Example: Let's say you wanted to:
// original resource name is foo.1234asdf.js
// parsed resource name is foo.js
var scriptCaptureFunc = function (name) {
var captured = /(\w+.)(\w+.)(\w+)$/.exec(name);
return captured[1] + captured[3];
};
statful.initialize({
registerResourceErrors: true,
resourceErrorsNameTracking: {
script: scriptCaptureFunc
},
resourceErrorsTypeBlacklist: ['img']
...
});
// install deps
$ npm install && bower install
// run watch
$ grunt dev
// build dist
$ grunt
FAQs
Statful client for Javascript applications
The npm package statful-client-javascript receives a total of 5 weekly downloads. As such, statful-client-javascript popularity was classified as not popular.
We found that statful-client-javascript demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.