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.5.1-rc.1 to 0.5.1-rc.2

cjs/config.js

11

CHANGES.txt
0.6.0 (XXX XX, 2024)
- Added a new event collector named `openTelemetryCollector`. This collector integrates with the OpenTelemetry SDK and Splunk RUM for Web to automatically capture OpenTelemetry spans and forward them to Split as events. Read more in our docs.
- Added '@splitsoftware/browser-rum-agent/slim' sub-package to support a smaller bundle size by excluding some event collectors, like `errors` and `navigationTimingMetrics`, from being registered by default. 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, navigationTimingMetrics } from '@splitsoftware/browser-rum-agent/slim';
SplitRumAgent.register(errors());
SplitRumAgent.register(navigationTimingMetrics());
```

@@ -4,0 +15,0 @@ 0.5.0 (March 4, 2024)

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.navigationTimingMetrics = void 0;
// import { getTTFB } from './ttfb';

@@ -11,23 +11,24 @@ var ttdi_1 = require("./ttdi");

* 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 navigationTimingMetrics() {
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.navigationTimingMetrics = navigationTimingMetrics;

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

exports.userAgent = getUserAgent();
exports.languageVersion = 'jsrum-' + '0.5.1-rc.1';
exports.languageVersion = 'jsrum-' + '0.5.1-rc.2';

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

// Sanitizes string to be compatible with EVENT_TYPE_REGEX = /^[a-zA-Z0-9][-_.:a-zA-Z0-9]{0,79}$/
// It replaces blank characters with '_' and removes invalid characters
// Examples of Amplitude event types are: "[Amplitude] Page Viewed", "$identify"
// It trims the string, replaces blank characters with '_', and removes invalid characters
function sanitizeEventTypeId(eventTypeId) {
if (!(0, isString_1.isString)(eventTypeId))
return;
// replace blank spaces with underscores
eventTypeId = eventTypeId.replace(/\s/g, '_');
// remove invalid characters
eventTypeId = eventTypeId.replace(/[^-_.:a-zA-Z0-9]/g, '');
// replace first character with 'a' if not matching the regex
eventTypeId = eventTypeId.replace(/^[^a-zA-Z0-9]/, 'a');
// limit to 80 characters. If empty, return 'a'
return eventTypeId === '' ? 'a' : eventTypeId.slice(0, 80);
return eventTypeId.trim()
// replace blank spaces with underscores
.replace(/\s/g, '_')
// remove invalid characters
.replace(/[^-_.:a-zA-Z0-9]/g, '')
// remove initial invalid characters
.replace(/^[^a-zA-Z0-9]*/, '')
// limit to 80 characters.
.slice(0, 80);
}
exports.sanitizeEventTypeId = sanitizeEventTypeId;
// 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 { openTelemetryIntegration } from './metrics/openTelemetry';

@@ -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);
};
}

@@ -8,22 +8,23 @@ // import { getTTFB } from './ttfb';

* 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 navigationTimingMetrics() {
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
};
}

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

export var userAgent = getUserAgent();
export var languageVersion = 'jsrum-' + '0.5.1-rc.1';
export var languageVersion = 'jsrum-' + '0.5.1-rc.2';
import { isString } from './isString';
// Sanitizes string to be compatible with EVENT_TYPE_REGEX = /^[a-zA-Z0-9][-_.:a-zA-Z0-9]{0,79}$/
// It replaces blank characters with '_' and removes invalid characters
// Examples of Amplitude event types are: "[Amplitude] Page Viewed", "$identify"
// It trims the string, replaces blank characters with '_', and removes invalid characters
export function sanitizeEventTypeId(eventTypeId) {
if (!isString(eventTypeId))
return;
// replace blank spaces with underscores
eventTypeId = eventTypeId.replace(/\s/g, '_');
// remove invalid characters
eventTypeId = eventTypeId.replace(/[^-_.:a-zA-Z0-9]/g, '');
// replace first character with 'a' if not matching the regex
eventTypeId = eventTypeId.replace(/^[^a-zA-Z0-9]/, 'a');
// limit to 80 characters. If empty, return 'a'
return eventTypeId === '' ? 'a' : eventTypeId.slice(0, 80);
return eventTypeId.trim()
// replace blank spaces with underscores
.replace(/\s/g, '_')
// remove invalid characters
.replace(/[^-_.:a-zA-Z0-9]/g, '')
// remove initial invalid characters
.replace(/^[^a-zA-Z0-9]*/, '')
// limit to 80 characters.
.slice(0, 80);
}
{
"name": "@splitsoftware/browser-rum-agent",
"version": "0.5.1-rc.1",
"version": "0.5.1-rc.2",
"description": "Split Software RUM Agent for Browsers.",

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

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

@@ -14,0 +15,0 @@ "cjs",

@@ -48,2 +48,3 @@ # Split Browser RUM Agent

* Angular [Github](https://github.com/splitio/angular-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/6495326064397-Angular-utilities)
* Flutter [Github](https://github.com/splitio/flutter-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/8096158017165-Flutter-plugin)
* GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)

@@ -56,2 +57,3 @@ * iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)

* PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
* PHP thin-client [Github](https://github.com/splitio/php-thin-client) [Docs](https://help.split.io/hc/en-us/articles/18305128673933-PHP-Thin-Client-SDK)
* Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)

@@ -58,0 +60,0 @@ * React [Github](https://github.com/splitio/react-client) [Docs](https://help.split.io/hc/en-us/articles/360038825091-React-SDK)

@@ -266,5 +266,5 @@ /* eslint-disable no-use-before-define */

* ```
* import { SplitRumAgent, tti } from '@splitsoftware/rum-agent';
* import { SplitRumAgent, tti } from '@splitsoftware/browser-rum-agent';
*
* SplitRumAgent.register(tti);
* SplitRumAgent.register(tti());
* ```

@@ -271,0 +271,0 @@ * - Add the following snippet of code to the head of your document (before any other scripts run):

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