@splitsoftware/browser-rum-agent
Advanced tools
Comparing version 0.3.2-rc.0 to 0.3.2-rc.1
@@ -1,2 +0,3 @@ | ||
0.3.2 (October XX, 2023) | ||
0.4.0 (October 12, 2023) | ||
- BREAKING CHANGE: Updated the shape of the options object for the `webVitals` event collector. It no longer allows overwriting the default report options per metric. | ||
- Added user consent feature to allow delaying or disabling the event tracking until user consent is explicitly granted or declined. Read more in our docs. | ||
@@ -3,0 +4,0 @@ - Bugfixing - Fixed an issue with parsing error events, which caused the agent to not track errors occurring in scripts from different origins. |
@@ -25,5 +25,4 @@ "use strict"; | ||
var WebVitals = __importStar(require("web-vitals")); | ||
var isObject_1 = require("../../utils/isObject"); | ||
function convertWebVitalsMetricToSplitEvent(_a) { | ||
var name = _a.name, value = _a.value, rating = _a.rating, delta = _a.delta, navigationType = _a.navigationType; | ||
var name = _a.name, value = _a.value, rating = _a.rating, navigationType = _a.navigationType; | ||
return { | ||
@@ -34,3 +33,2 @@ eventTypeId: "webvitals." + name.toLowerCase(), | ||
rating: rating, | ||
delta: delta, | ||
navigationType: navigationType | ||
@@ -45,4 +43,3 @@ } | ||
function webVitals(options) { | ||
if (options === void 0) { options = {}; } | ||
var _a = options.reportOptions, reportOptions = _a === void 0 ? { | ||
if (options === void 0) { options = { | ||
onCLS: true, | ||
@@ -54,9 +51,9 @@ onFCP: true, | ||
onTTFB: true, | ||
} : _a; | ||
}; } | ||
return function onWebVitals(ctx) { | ||
Object.keys(reportOptions).forEach(function (key) { | ||
if (reportOptions[key] && WebVitals[key]) { | ||
Object.keys(options).forEach(function (key) { | ||
if (options[key] && WebVitals[key]) { | ||
WebVitals[key](function (metric) { | ||
ctx.track(convertWebVitalsMetricToSplitEvent(metric)); | ||
}, (0, isObject_1.isObject)(reportOptions[key]) ? reportOptions[key] : undefined); | ||
}); | ||
} | ||
@@ -63,0 +60,0 @@ }); |
@@ -38,2 +38,2 @@ "use strict"; | ||
exports.userAgent = getUserAgent(); | ||
exports.languageVersion = 'jsrum-' + '0.3.2-rc.0'; | ||
exports.languageVersion = 'jsrum-' + '0.3.2-rc.1'; |
@@ -25,6 +25,2 @@ "use strict"; | ||
var conf = window.SplitRumAgent.__getConfig(); | ||
// If user consent is DECLINED, drop events. | ||
if (conf.userConsent === constants_1.CONSENT_DECLINED) { | ||
exports.queue.length = 0; | ||
} | ||
// Only send events if we do have the config. | ||
@@ -50,3 +46,4 @@ if (conf.a && conf.i.length && conf.userConsent === constants_1.CONSENT_GRANTED) { | ||
}, conf.log); | ||
if (!eventData) | ||
// If the event is invalid or the user consent is DECLINED, drop the event. | ||
if (!eventData || conf.userConsent === constants_1.CONSENT_DECLINED) | ||
return; | ||
@@ -53,0 +50,0 @@ // If people configures the agent at a really late time, prevent having a giant queue and attempt to send them or drop. First events will be the most important ones anyways. |
// webVitals plugin uses the web-vital standard build. | ||
import * as WebVitals from 'web-vitals'; | ||
import { isObject } from '../../utils/isObject'; | ||
export function convertWebVitalsMetricToSplitEvent(_a) { | ||
var name = _a.name, value = _a.value, rating = _a.rating, delta = _a.delta, navigationType = _a.navigationType; | ||
var name = _a.name, value = _a.value, rating = _a.rating, navigationType = _a.navigationType; | ||
return { | ||
@@ -11,3 +10,2 @@ eventTypeId: "webvitals." + name.toLowerCase(), | ||
rating: rating, | ||
delta: delta, | ||
navigationType: navigationType | ||
@@ -21,4 +19,3 @@ } | ||
export function webVitals(options) { | ||
if (options === void 0) { options = {}; } | ||
var _a = options.reportOptions, reportOptions = _a === void 0 ? { | ||
if (options === void 0) { options = { | ||
onCLS: true, | ||
@@ -30,9 +27,9 @@ onFCP: true, | ||
onTTFB: true, | ||
} : _a; | ||
}; } | ||
return function onWebVitals(ctx) { | ||
Object.keys(reportOptions).forEach(function (key) { | ||
if (reportOptions[key] && WebVitals[key]) { | ||
Object.keys(options).forEach(function (key) { | ||
if (options[key] && WebVitals[key]) { | ||
WebVitals[key](function (metric) { | ||
ctx.track(convertWebVitalsMetricToSplitEvent(metric)); | ||
}, isObject(reportOptions[key]) ? reportOptions[key] : undefined); | ||
}); | ||
} | ||
@@ -39,0 +36,0 @@ }); |
@@ -31,2 +31,2 @@ /* eslint-disable compat/compat */ | ||
export var userAgent = getUserAgent(); | ||
export var languageVersion = 'jsrum-' + '0.3.2-rc.0'; | ||
export var languageVersion = 'jsrum-' + '0.3.2-rc.1'; |
@@ -22,6 +22,2 @@ import { getConnectionType, getUrl, userAgent } from './context'; | ||
var conf = window.SplitRumAgent.__getConfig(); | ||
// If user consent is DECLINED, drop events. | ||
if (conf.userConsent === CONSENT_DECLINED) { | ||
queue.length = 0; | ||
} | ||
// Only send events if we do have the config. | ||
@@ -45,3 +41,4 @@ if (conf.a && conf.i.length && conf.userConsent === CONSENT_GRANTED) { | ||
}, conf.log); | ||
if (!eventData) | ||
// If the event is invalid or the user consent is DECLINED, drop the event. | ||
if (!eventData || conf.userConsent === CONSENT_DECLINED) | ||
return; | ||
@@ -48,0 +45,0 @@ // If people configures the agent at a really late time, prevent having a giant queue and attempt to send them or drop. First events will be the most important ones anyways. |
{ | ||
"name": "@splitsoftware/browser-rum-agent", | ||
"version": "0.3.2-rc.0", | ||
"version": "0.3.2-rc.1", | ||
"description": "Split Software RUM Agent for Browsers.", | ||
@@ -40,3 +40,3 @@ "main": "cjs/index.js", | ||
"dependencies": { | ||
"web-vitals": "^3.1.0" | ||
"web-vitals": "^3.5.0" | ||
}, | ||
@@ -43,0 +43,0 @@ "devDependencies": { |
@@ -330,10 +330,8 @@ import type { ReportOpts } from 'web-vitals' | ||
export interface IWebVitalsOptions { | ||
reportOptions?: { | ||
onCLS?: boolean | ReportOpts, | ||
onFCP?: boolean | ReportOpts, | ||
onFID?: boolean | ReportOpts, | ||
onINP?: boolean | ReportOpts, | ||
onLCP?: boolean | ReportOpts, | ||
onTTFB?: boolean | ReportOpts, | ||
} | ||
onCLS?: boolean, | ||
onFCP?: boolean, | ||
onFID?: boolean, | ||
onINP?: boolean, | ||
onLCP?: boolean, | ||
onTTFB?: boolean, | ||
} | ||
@@ -344,3 +342,3 @@ | ||
* | ||
* By default it collects all web-vitals metrics, but you can specify which ones to collect by passing a `reportOptions` object. | ||
* By default it collects all Web-Vitals metrics, but you can specify which ones to collect by passing the corresponding options. | ||
* | ||
@@ -350,7 +348,5 @@ * For example: | ||
* SplitRumAgent.register(webVitals({ | ||
* reportOptions: { | ||
* onCLS: true, // collects Cumulative Layout Shift | ||
* onFCP: { reportAllChanges: true }, // collects First Contentful Paint and overwrites its default options | ||
* // other web-vital metrics are not collected | ||
* } | ||
* // collects only Cumulative Layout Shift | ||
* onCLS: true | ||
* // other web-vital metrics are not collected | ||
* })); | ||
@@ -366,3 +362,2 @@ * ``` | ||
* rating: 'good' | 'needsImprovement' | 'poor', | ||
* delta: number, | ||
* navigationType: 'navigate' | 'reload' | 'back_forward' | 'back-forward-cache' | 'prerender' | 'restore' | ||
@@ -372,3 +367,9 @@ * } | ||
* ``` | ||
* | ||
* @param {IWebVitalsOptions} options | ||
* @default | ||
* ``` | ||
* { onCLS: true, onFCP: true, onFID: true, onINP: true, onLCP: true, onTTFB: true } | ||
* ``` | ||
*/ | ||
export declare function webVitals(options?: IWebVitalsOptions): EventCollector; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123802
2662
Updatedweb-vitals@^3.5.0