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.3.1-rc.1 to 0.3.1

2

CHANGES.txt

@@ -1,2 +0,2 @@

0.4.0 (September XX, 2023)
0.3.1 (September 27, 2023)
- Updated internal implementation to push events on 'visibilitychange' and 'pagehide' DOM events, instead of 'unload', which is not reliable in modern mobile and desktop Web browsers.

@@ -3,0 +3,0 @@ - Bugfixing - Fixed a runtime error when the agent is loaded asynchronously and errors were tracked in the `window.__error` object.

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

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 () {
w.removeEventListener('error', g.l1);
w.removeEventListener('unhandledrejection', g.l2);
g.e1.forEach(handleUncaughtErrors);

@@ -52,0 +52,0 @@ g.e2.forEach(handleRejectionsErrors); // @ts-expect-error object might be polluted

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

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

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

// `unload` is not reliable, so we use `pagehide` if available: https://developer.chrome.com/articles/page-lifecycle-api/#the-unload-event
var PAGEHIDE_EVENT = typeof window.onpagehide !== 'undefined' ? 'pagehide' : 'unload';
var PAGE_TERMINATION_EVENT = typeof window.onpagehide !== 'undefined' ? 'pagehide' : 'unload';
function onPageHideOrVisibilityChange(callback) {

@@ -35,6 +35,7 @@ // Flush data whenever the page is hidden or unloaded

}
// Some browsers like Safari does not fire the `visibilitychange` event when the page is being unloaded. Therefore, we also flush data in the `pagehide` event (or `unload` if `pagehide` is not available).
// Some browsers, like Safari, does not fire the `visibilitychange` event when the page is being unloaded.
// Therefore, we also flush data in the `pagehide` event (or `unload` if `pagehide` is not available).
// If both events are triggered, the latter will find the events queue empty, so no duplicate data will be submitted.
window.addEventListener(PAGEHIDE_EVENT, callback);
window.addEventListener(PAGE_TERMINATION_EVENT, callback);
}
exports.onPageHideOrVisibilityChange = onPageHideOrVisibilityChange;

@@ -42,6 +42,6 @@ import { getErrorData } from '../utils/getErrorData';

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 () {
w.removeEventListener('error', g.l1);
w.removeEventListener('unhandledrejection', g.l2);
g.e1.forEach(handleUncaughtErrors);

@@ -48,0 +48,0 @@ g.e2.forEach(handleRejectionsErrors); // @ts-expect-error object might be polluted

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

export var userAgent = getUserAgent();
export var languageVersion = 'jsrum-' + '0.3.1-rc.1';
export var languageVersion = 'jsrum-' + '0.3.1';

@@ -21,3 +21,3 @@ var callbacks = [];

// `unload` is not reliable, so we use `pagehide` if available: https://developer.chrome.com/articles/page-lifecycle-api/#the-unload-event
var PAGEHIDE_EVENT = typeof window.onpagehide !== 'undefined' ? 'pagehide' : 'unload';
var PAGE_TERMINATION_EVENT = typeof window.onpagehide !== 'undefined' ? 'pagehide' : 'unload';
export function onPageHideOrVisibilityChange(callback) {

@@ -31,5 +31,6 @@ // Flush data whenever the page is hidden or unloaded

}
// Some browsers like Safari does not fire the `visibilitychange` event when the page is being unloaded. Therefore, we also flush data in the `pagehide` event (or `unload` if `pagehide` is not available).
// Some browsers, like Safari, does not fire the `visibilitychange` event when the page is being unloaded.
// Therefore, we also flush data in the `pagehide` event (or `unload` if `pagehide` is not available).
// If both events are triggered, the latter will find the events queue empty, so no duplicate data will be submitted.
window.addEventListener(PAGEHIDE_EVENT, callback);
window.addEventListener(PAGE_TERMINATION_EVENT, callback);
}
{
"name": "@splitsoftware/browser-rum-agent",
"version": "0.3.1-rc.1",
"version": "0.3.1",
"description": "Split Software RUM Agent for Browsers.",

@@ -5,0 +5,0 @@ "main": "cjs/index.js",

@@ -22,2 +22,26 @@ import type { ReportOpts } from 'web-vitals'

/**
* A function that receives the RUM Agent's `track` method to send events to Split.
*
* It can optionally return an object with a `flush` method, which will be called by the RUM Agent when to page is hidden or terminated (See https://developer.chrome.com/articles/page-lifecycle-api/#states).
* This is useful to `track` any pending events before the page is closed, but consider that it might be called multiple times.
*
* @typedef {function} EventCollector
* @param {Object} ctx - An object with the RUM Agent's `track` method.
* @returns {void | { flush: function(): void }} Optionally, an object with a `flush` method.
* @example
* ```js
* function myEventCollector({ track }) {
* track({ eventTypeId: 'my.event' });
*
* return {
* flush() {
* track({ eventTypeId: 'my.event' });
* }
* }
* };
*
* SplitRumAgent.register(myEventCollector);
* ```
*/
export type EventCollector = (ctx: {

@@ -24,0 +48,0 @@ track(event: EventData): void

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