Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@splitsoftware/browser-rum-agent

Package Overview
Dependencies
Maintainers
8
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@splitsoftware/browser-rum-agent - npm Package Compare versions

Comparing version 0.6.1 to 0.6.2-rc.0

cjs/config.js

13

CHANGES.txt

@@ -0,1 +1,14 @@

0.7.0 (May 15, 2024)
- Added '@splitsoftware/browser-rum-agent/slim' sub-package for ES Modules and CommonJS builds, to support a smaller bundle size by excluding the event collectors that are registered by default in the main package, like `errors` and `navigationTiming`. This package is recommended for users who want to manually register only the event collectors they need.
In other words, importing:
```js
import { SplitRumAgent } from '@splitsoftware/browser-rum-agent';
```
is equivalent to:
```js
import { SplitRumAgent, errors, navigationTiming } from '@splitsoftware/browser-rum-agent/slim';
SplitRumAgent.register(errors());
SplitRumAgent.register(navigationTiming());
```
0.6.1 (April 11, 2024)

@@ -2,0 +15,0 @@ - Bugfixing - Fixed an issue in the `SplitRumAgent.setup` method where undefined configuration options were incorrectly overwriting the default values with `undefined`.

2

cjs/index.js

@@ -6,3 +6,3 @@ "use strict";

// Must use a named import to create the SplitRumAgent namespace (side effects)
var config_1 = require("./utils/config");
var config_1 = require("./config");
Object.defineProperty(exports, "SplitRumAgent", { enumerable: true, get: function () { return config_1.SplitRumAgent; } });

@@ -9,0 +9,0 @@ // Pluggable event collectors

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.onError = exports.handleCustomErrors = void 0;
exports.errors = exports.handleCustomErrors = void 0;
var getErrorData_1 = require("../utils/getErrorData");

@@ -33,27 +33,29 @@ var constants_1 = require("../utils/constants");

*/
function onError(ctx) {
function handleUncaughtErrors(event) {
trackError(event ? event.error || event.message || constants_1.UNAVAILABLE : constants_1.UNAVAILABLE, ctx);
}
function handleRejectionsErrors(e) {
trackError(e ? e.reason : constants_1.UNAVAILABLE, ctx);
}
// In case customer placed the snippet in the head, remove listeners and process errors
var w = window; // @ts-expect-error object might be polluted
var g = w.__error;
if (g) {
w.removeEventListener('error', g.l1);
w.removeEventListener('unhandledrejection', g.l2);
// @TODO remove `setTimeout` eventually. ATM we have to run next code asynchronously, because `track` calls require global SplitRumAgent available
setTimeout(function () {
g.e1.forEach(handleUncaughtErrors);
g.e2.forEach(handleRejectionsErrors); // @ts-expect-error object might be polluted
delete w.__error;
}, 0);
}
// Capture browser uncaught errors.
w.addEventListener('error', handleUncaughtErrors);
// Capture browser promise rejection errors.
w.addEventListener('unhandledrejection', handleRejectionsErrors);
function errors() {
return function onError(ctx) {
function handleUncaughtErrors(event) {
trackError(event ? event.error || event.message || constants_1.UNAVAILABLE : constants_1.UNAVAILABLE, ctx);
}
function handleRejectionsErrors(e) {
trackError(e ? e.reason : constants_1.UNAVAILABLE, ctx);
}
// If the user has placed the snippet in the <head>, remove listeners and process errors
var w = window; // @ts-expect-error object might be polluted
var g = w.__error;
if (g) {
w.removeEventListener('error', g.l1);
w.removeEventListener('unhandledrejection', g.l2);
// @TODO remove `setTimeout` eventually. ATM we have to run next code asynchronously, because `track` calls require global SplitRumAgent available
setTimeout(function () {
g.e1.forEach(handleUncaughtErrors);
g.e2.forEach(handleRejectionsErrors); // @ts-expect-error object might be polluted
delete w.__error;
}, 0);
}
// Capture browser uncaught errors.
w.addEventListener('error', handleUncaughtErrors);
// Capture browser promise rejection errors.
w.addEventListener('unhandledrejection', handleRejectionsErrors);
};
}
exports.onError = onError;
exports.errors = errors;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.onNavigationTimingMetrics = void 0;
exports.navigationTiming = void 0;
// import { getTTFB } from './ttfb';

@@ -9,25 +9,26 @@ var ttdi_1 = require("./ttdi");

/**
* Calculates navigation performance metrics using the Navigation Timing API.
* Calculates navigation timing metrics using the Navigation Timing API.
* Metrics:
* - time.to.first.byte
* - time.to.dom.interactive
* - page.load.time
*/
function onNavigationTimingMetrics(ctx) {
var getMetrics = function () {
var ttdi = (0, ttdi_1.getTTDI)(),
// ttfb = getTTFB(),
plt = (0, plt_1.getPLT)();
if (ttdi)
ctx.track(ttdi);
// @TODO regarding `time.to.first.byte`, either rename to `server.time.to.first.byte`, update its definition (https://web.dev/ttfb/), or remove it. For now, the metric is also provided by webVitals collector.
// if (ttfb) ctx.track(ttfb);
if (plt)
ctx.track(plt);
function navigationTiming() {
return function onNavigationTimingMetrics(ctx) {
var getMetrics = function () {
var ttdi = (0, ttdi_1.getTTDI)(),
// ttfb = getTTFB(),
plt = (0, plt_1.getPLT)();
if (ttdi)
ctx.track(ttdi);
// @TODO regarding `time.to.first.byte`, either rename to `server.time.to.first.byte`, update its definition (https://web.dev/ttfb/), or remove it. For now, the metric is also provided by webVitals collector.
// if (ttfb) ctx.track(ttfb);
if (plt)
ctx.track(plt);
};
(0, whenLoaded_1.whenLoaded)(getMetrics);
return {
flush: getMetrics
};
};
(0, whenLoaded_1.whenLoaded)(getMetrics);
return {
flush: getMetrics
};
}
exports.onNavigationTimingMetrics = onNavigationTimingMetrics;
exports.navigationTiming = navigationTiming;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -29,3 +33,3 @@ if (k2 === undefined) k2 = k;

return {
eventTypeId: "webvitals." + name.toLowerCase(),
eventTypeId: "webvitals.".concat(name.toLowerCase()),
value: value,

@@ -32,0 +36,0 @@ properties: {

@@ -38,2 +38,2 @@ "use strict";

exports.userAgent = getUserAgent();
exports.languageVersion = 'jsrum-' + '0.6.1';
exports.languageVersion = 'jsrum-' + '0.6.2-rc.0';

@@ -59,3 +59,3 @@ "use strict";

if (conf.prefix)
eventData.eventTypeId = conf.prefix + "." + eventData.eventTypeId;
eventData.eventTypeId = "".concat(conf.prefix, ".").concat(eventData.eventTypeId);
// include extra properties

@@ -62,0 +62,0 @@ var commonProperties = {

@@ -23,3 +23,3 @@ "use strict";

return;
log.warn("Property " + key + " is of invalid type. Setting value to null.");
log.warn("Property ".concat(key, " is of invalid type. Setting value to null."));
propertiesClone[key] = null;

@@ -35,3 +35,3 @@ });

return true;
log.error("Event type " + item + " must be a string that adheres to the regular expression " + EVENT_TYPE_REGEX.toString() + ". You passed \"" + eventTypeId + "\"");
log.error("Event type ".concat(item, " must be a string that adheres to the regular expression ").concat(EVENT_TYPE_REGEX.toString(), ". You passed \"").concat(eventTypeId, "\""));
return false;

@@ -38,0 +38,0 @@ }

// Create SplitRumAgent namespace and export it for ESM/CJS imports
// Must use a named import to create the SplitRumAgent namespace (side effects)
export { SplitRumAgent } from './utils/config';
export { SplitRumAgent } from './config';
// Pluggable event collectors

@@ -5,0 +5,0 @@ export { tti } from './metrics/tti';

@@ -29,26 +29,28 @@ import { getErrorData } from '../utils/getErrorData';

*/
export function onError(ctx) {
function handleUncaughtErrors(event) {
trackError(event ? event.error || event.message || UNAVAILABLE : UNAVAILABLE, ctx);
}
function handleRejectionsErrors(e) {
trackError(e ? e.reason : UNAVAILABLE, ctx);
}
// In case customer placed the snippet in the head, remove listeners and process errors
var w = window; // @ts-expect-error object might be polluted
var g = w.__error;
if (g) {
w.removeEventListener('error', g.l1);
w.removeEventListener('unhandledrejection', g.l2);
// @TODO remove `setTimeout` eventually. ATM we have to run next code asynchronously, because `track` calls require global SplitRumAgent available
setTimeout(function () {
g.e1.forEach(handleUncaughtErrors);
g.e2.forEach(handleRejectionsErrors); // @ts-expect-error object might be polluted
delete w.__error;
}, 0);
}
// Capture browser uncaught errors.
w.addEventListener('error', handleUncaughtErrors);
// Capture browser promise rejection errors.
w.addEventListener('unhandledrejection', handleRejectionsErrors);
export function errors() {
return function onError(ctx) {
function handleUncaughtErrors(event) {
trackError(event ? event.error || event.message || UNAVAILABLE : UNAVAILABLE, ctx);
}
function handleRejectionsErrors(e) {
trackError(e ? e.reason : UNAVAILABLE, ctx);
}
// If the user has placed the snippet in the <head>, remove listeners and process errors
var w = window; // @ts-expect-error object might be polluted
var g = w.__error;
if (g) {
w.removeEventListener('error', g.l1);
w.removeEventListener('unhandledrejection', g.l2);
// @TODO remove `setTimeout` eventually. ATM we have to run next code asynchronously, because `track` calls require global SplitRumAgent available
setTimeout(function () {
g.e1.forEach(handleUncaughtErrors);
g.e2.forEach(handleRejectionsErrors); // @ts-expect-error object might be polluted
delete w.__error;
}, 0);
}
// Capture browser uncaught errors.
w.addEventListener('error', handleUncaughtErrors);
// Capture browser promise rejection errors.
w.addEventListener('unhandledrejection', handleRejectionsErrors);
};
}

@@ -6,24 +6,25 @@ // import { getTTFB } from './ttfb';

/**
* Calculates navigation performance metrics using the Navigation Timing API.
* Calculates navigation timing metrics using the Navigation Timing API.
* Metrics:
* - time.to.first.byte
* - time.to.dom.interactive
* - page.load.time
*/
export function onNavigationTimingMetrics(ctx) {
var getMetrics = function () {
var ttdi = getTTDI(),
// ttfb = getTTFB(),
plt = getPLT();
if (ttdi)
ctx.track(ttdi);
// @TODO regarding `time.to.first.byte`, either rename to `server.time.to.first.byte`, update its definition (https://web.dev/ttfb/), or remove it. For now, the metric is also provided by webVitals collector.
// if (ttfb) ctx.track(ttfb);
if (plt)
ctx.track(plt);
export function navigationTiming() {
return function onNavigationTimingMetrics(ctx) {
var getMetrics = function () {
var ttdi = getTTDI(),
// ttfb = getTTFB(),
plt = getPLT();
if (ttdi)
ctx.track(ttdi);
// @TODO regarding `time.to.first.byte`, either rename to `server.time.to.first.byte`, update its definition (https://web.dev/ttfb/), or remove it. For now, the metric is also provided by webVitals collector.
// if (ttfb) ctx.track(ttfb);
if (plt)
ctx.track(plt);
};
whenLoaded(getMetrics);
return {
flush: getMetrics
};
};
whenLoaded(getMetrics);
return {
flush: getMetrics
};
}

@@ -7,3 +7,3 @@ // webVitals plugin uses the web-vital standard build.

return {
eventTypeId: "webvitals." + name.toLowerCase(),
eventTypeId: "webvitals.".concat(name.toLowerCase()),
value: value,

@@ -10,0 +10,0 @@ properties: {

@@ -31,2 +31,2 @@ /* eslint-disable compat/compat */

export var userAgent = getUserAgent();
export var languageVersion = 'jsrum-' + '0.6.1';
export var languageVersion = 'jsrum-' + '0.6.2-rc.0';

@@ -54,3 +54,3 @@ import { getConnectionType, getUrl, userAgent } from './context';

if (conf.prefix)
eventData.eventTypeId = conf.prefix + "." + eventData.eventTypeId;
eventData.eventTypeId = "".concat(conf.prefix, ".").concat(eventData.eventTypeId);
// include extra properties

@@ -57,0 +57,0 @@ var commonProperties = {

@@ -20,3 +20,3 @@ import { isBoolean } from './isBoolean';

return;
log.warn("Property " + key + " is of invalid type. Setting value to null.");
log.warn("Property ".concat(key, " is of invalid type. Setting value to null."));
propertiesClone[key] = null;

@@ -31,3 +31,3 @@ });

return true;
log.error("Event type " + item + " must be a string that adheres to the regular expression " + EVENT_TYPE_REGEX.toString() + ". You passed \"" + eventTypeId + "\"");
log.error("Event type ".concat(item, " must be a string that adheres to the regular expression ").concat(EVENT_TYPE_REGEX.toString(), ". You passed \"").concat(eventTypeId, "\""));
return false;

@@ -34,0 +34,0 @@ }

{
"name": "@splitsoftware/browser-rum-agent",
"version": "0.6.1",
"version": "0.6.2-rc.0",
"description": "Split Software RUM Agent for Browsers.",

@@ -12,2 +12,3 @@ "main": "cjs/index.js",

"CHANGES.txt",
"slim",
"types",

@@ -49,2 +50,4 @@ "cjs",

"@rollup/plugin-terser": "^0.2.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.7",
"@typescript-eslint/eslint-plugin": "^5.48.1",

@@ -56,4 +59,4 @@ "@typescript-eslint/parser": "^5.48.1",

"eslint-plugin-tsdoc": "^0.2.17",
"jest": "^27.5.1",
"jest-environment-jsdom": "^27.5.1",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"karma": "^6.4.1",

@@ -69,5 +72,5 @@ "karma-chrome-launcher": "^3.1.1",

"tape": "^5.6.1",
"ts-jest": "^27.1.5",
"ts-jest": "^29.1.2",
"ts-loader": "9.4.1",
"typescript": "4.4.4",
"typescript": "4.9.5",
"webpack": "^5.75.0"

@@ -74,0 +77,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc