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

@datadog/browser-rum-core

Package Overview
Dependencies
Maintainers
1
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datadog/browser-rum-core - npm Package Compare versions

Comparing version 4.0.1 to 4.1.0

2

cjs/boot/buildEnv.js

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

buildMode: 'release',
sdkVersion: '4.0.1',
sdkVersion: '4.1.0',
};
//# sourceMappingURL=buildEnv.js.map

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

var eventRateLimiters = (_a = {},
_a[rawRumEvent_types_1.RumEventType.ERROR] = browser_core_1.createEventRateLimiter(rawRumEvent_types_1.RumEventType.ERROR, configuration.maxErrorsPerMinute, reportError),
_a[rawRumEvent_types_1.RumEventType.ACTION] = browser_core_1.createEventRateLimiter(rawRumEvent_types_1.RumEventType.ACTION, configuration.maxActionsPerMinute, reportError),
_a[rawRumEvent_types_1.RumEventType.ERROR] = browser_core_1.createEventRateLimiter(rawRumEvent_types_1.RumEventType.ERROR, configuration.eventRateLimiterThreshold, reportError),
_a[rawRumEvent_types_1.RumEventType.ACTION] = browser_core_1.createEventRateLimiter(rawRumEvent_types_1.RumEventType.ACTION, configuration.eventRateLimiterThreshold, reportError),
_a);

@@ -42,0 +42,0 @@ var syntheticsContext = syntheticsContext_1.getSyntheticsContext();

@@ -23,4 +23,3 @@ import { Configuration, DefaultPrivacyLevel, InitConfiguration } from '@datadog/browser-core';

trackViewsManually: boolean;
maxActionsPerMinute: number;
}
export declare function validateAndBuildRumConfiguration(initConfiguration: RumInitConfiguration): RumConfiguration | undefined;

@@ -33,5 +33,5 @@ "use strict";

? initConfiguration.defaultPrivacyLevel
: browser_core_1.DefaultPrivacyLevel.MASK_USER_INPUT, maxActionsPerMinute: 3000 });
: browser_core_1.DefaultPrivacyLevel.MASK_USER_INPUT });
}
exports.validateAndBuildRumConfiguration = validateAndBuildRumConfiguration;
//# sourceMappingURL=configuration.js.map

@@ -11,3 +11,5 @@ "use strict";

if (document.visibilityState === 'hidden') {
trackFirstHiddenSingleton = { timeStamp: 0 };
trackFirstHiddenSingleton = {
timeStamp: 0,
};
}

@@ -18,6 +20,8 @@ else {

};
(stopListeners = browser_core_1.addEventListener(emitter, "pagehide" /* PAGE_HIDE */, function (_a) {
var timeStamp = _a.timeStamp;
trackFirstHiddenSingleton.timeStamp = timeStamp;
}, { capture: true, once: true }).stop);
(stopListeners = browser_core_1.addEventListeners(emitter, ["pagehide" /* PAGE_HIDE */, "visibilitychange" /* VISIBILITY_CHANGE */], function (event) {
if (event.type === 'pagehide' || document.visibilityState === 'hidden') {
trackFirstHiddenSingleton.timeStamp = event.timeStamp;
stopListeners();
}
}, { capture: true }).stop);
}

@@ -24,0 +28,0 @@ }

export var buildEnv = {
buildMode: 'release',
sdkVersion: '4.0.1',
sdkVersion: '4.1.0',
};
//# sourceMappingURL=buildEnv.js.map

@@ -35,4 +35,4 @@ import { __spreadArrays } from "tslib";

var eventRateLimiters = (_a = {},
_a[RumEventType.ERROR] = createEventRateLimiter(RumEventType.ERROR, configuration.maxErrorsPerMinute, reportError),
_a[RumEventType.ACTION] = createEventRateLimiter(RumEventType.ACTION, configuration.maxActionsPerMinute, reportError),
_a[RumEventType.ERROR] = createEventRateLimiter(RumEventType.ERROR, configuration.eventRateLimiterThreshold, reportError),
_a[RumEventType.ACTION] = createEventRateLimiter(RumEventType.ACTION, configuration.eventRateLimiterThreshold, reportError),
_a);

@@ -39,0 +39,0 @@ var syntheticsContext = getSyntheticsContext();

@@ -23,4 +23,3 @@ import { Configuration, DefaultPrivacyLevel, InitConfiguration } from '@datadog/browser-core';

trackViewsManually: boolean;
maxActionsPerMinute: number;
}
export declare function validateAndBuildRumConfiguration(initConfiguration: RumInitConfiguration): RumConfiguration | undefined;

@@ -30,4 +30,4 @@ import { __assign } from "tslib";

? initConfiguration.defaultPrivacyLevel
: DefaultPrivacyLevel.MASK_USER_INPUT, maxActionsPerMinute: 3000 });
: DefaultPrivacyLevel.MASK_USER_INPUT });
}
//# sourceMappingURL=configuration.js.map

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

import { addEventListener } from '@datadog/browser-core';
import { addEventListeners } from '@datadog/browser-core';
var trackFirstHiddenSingleton;

@@ -8,3 +8,5 @@ var stopListeners;

if (document.visibilityState === 'hidden') {
trackFirstHiddenSingleton = { timeStamp: 0 };
trackFirstHiddenSingleton = {
timeStamp: 0,
};
}

@@ -15,6 +17,8 @@ else {

};
(stopListeners = addEventListener(emitter, "pagehide" /* PAGE_HIDE */, function (_a) {
var timeStamp = _a.timeStamp;
trackFirstHiddenSingleton.timeStamp = timeStamp;
}, { capture: true, once: true }).stop);
(stopListeners = addEventListeners(emitter, ["pagehide" /* PAGE_HIDE */, "visibilitychange" /* VISIBILITY_CHANGE */], function (event) {
if (event.type === 'pagehide' || document.visibilityState === 'hidden') {
trackFirstHiddenSingleton.timeStamp = event.timeStamp;
stopListeners();
}
}, { capture: true }).stop);
}

@@ -21,0 +25,0 @@ }

{
"name": "@datadog/browser-rum-core",
"version": "4.0.1",
"version": "4.1.0",
"license": "Apache-2.0",

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

"dependencies": {
"@datadog/browser-core": "4.0.1",
"@datadog/browser-core": "4.1.0",
"tslib": "^1.10.0"

@@ -27,3 +27,3 @@ },

},
"gitHead": "a24681d36c129ec6ae0a71f0758fe5833f7f7474"
"gitHead": "27c7b4c01354dd77116f5bfb6eef370d4e2585bd"
}

@@ -616,3 +616,3 @@ import {

it('stops sending error events when reaching the limit', () => {
const { lifeCycle } = setupBuilder.withConfiguration({ maxErrorsPerMinute: 1 }).build()
const { lifeCycle } = setupBuilder.withConfiguration({ eventRateLimiterThreshold: 1 }).build()
notifyRawRumErrorEvent(lifeCycle, 'foo')

@@ -635,3 +635,3 @@ notifyRawRumErrorEvent(lifeCycle, 'bar')

.withConfiguration({
maxErrorsPerMinute: 1,
eventRateLimiterThreshold: 1,
beforeSend: (event) => {

@@ -654,3 +654,6 @@ if (event.type === RumEventType.ERROR && (event as RumErrorEvent).error.message === 'discard me') {

it('allows to send new errors after a minute', () => {
const { lifeCycle, clock } = setupBuilder.withFakeClock().withConfiguration({ maxErrorsPerMinute: 1 }).build()
const { lifeCycle, clock } = setupBuilder
.withFakeClock()
.withConfiguration({ eventRateLimiterThreshold: 1 })
.build()
notifyRawRumErrorEvent(lifeCycle, 'foo')

@@ -686,3 +689,3 @@ notifyRawRumErrorEvent(lifeCycle, 'bar')

it('stops sending action events when reaching the limit', () => {
const { lifeCycle } = setupBuilder.withConfiguration({ maxActionsPerMinute: 1 }).build()
const { lifeCycle } = setupBuilder.withConfiguration({ eventRateLimiterThreshold: 1 }).build()

@@ -706,3 +709,3 @@ notifyRumActionEvent(lifeCycle, 'foo')

.withConfiguration({
maxErrorsPerMinute: 1,
eventRateLimiterThreshold: 1,
beforeSend: (event) => {

@@ -725,3 +728,6 @@ if (event.type === RumEventType.ACTION && (event as RumActionEvent).action.target?.name === 'discard me') {

it('allows to send new actions after a minute', () => {
const { lifeCycle, clock } = setupBuilder.withFakeClock().withConfiguration({ maxActionsPerMinute: 1 }).build()
const { lifeCycle, clock } = setupBuilder
.withFakeClock()
.withConfiguration({ eventRateLimiterThreshold: 1 })
.build()
notifyRumActionEvent(lifeCycle, 'foo')

@@ -728,0 +734,0 @@ notifyRumActionEvent(lifeCycle, 'bar')

@@ -73,4 +73,12 @@ import {

const eventRateLimiters = {
[RumEventType.ERROR]: createEventRateLimiter(RumEventType.ERROR, configuration.maxErrorsPerMinute, reportError),
[RumEventType.ACTION]: createEventRateLimiter(RumEventType.ACTION, configuration.maxActionsPerMinute, reportError),
[RumEventType.ERROR]: createEventRateLimiter(
RumEventType.ERROR,
configuration.eventRateLimiterThreshold,
reportError
),
[RumEventType.ACTION]: createEventRateLimiter(
RumEventType.ACTION,
configuration.eventRateLimiterThreshold,
reportError
),
}

@@ -77,0 +85,0 @@

@@ -45,5 +45,2 @@ import {

trackViewsManually: boolean
// Event limits
maxActionsPerMinute: number
}

@@ -92,5 +89,3 @@

: DefaultPrivacyLevel.MASK_USER_INPUT,
maxActionsPerMinute: 3000,
}
}

@@ -11,39 +11,67 @@ import { DOM_EVENT, RelativeTime } from '@datadog/browser-core'

it('should return Infinity if the page was not hidden yet', () => {
expect(trackFirstHidden().timeStamp).toBe(Infinity as RelativeTime)
})
describe('the page is initially hidden', () => {
it('should return 0', () => {
setPageVisibility('hidden')
expect(trackFirstHidden().timeStamp).toBe(0 as RelativeTime)
})
it('should return 0 if the page was hidden when executing trackFirstHidden', () => {
setPageVisibility('hidden')
expect(trackFirstHidden().timeStamp).toBe(0 as RelativeTime)
it('should ignore events', () => {
setPageVisibility('hidden')
const emitter = document.createElement('div')
const firstHidden = trackFirstHidden(emitter)
emitter.dispatchEvent(createNewEvent(DOM_EVENT.PAGE_HIDE, { timeStamp: 100 }))
emitter.dispatchEvent(createNewEvent(DOM_EVENT.VISIBILITY_CHANGE, { timeStamp: 100 }))
expect(firstHidden.timeStamp).toBe(0 as RelativeTime)
})
})
it('should stay to 0 if the page was hidden when executing trackFirstHidden and a pagehide occurs', () => {
setPageVisibility('hidden')
const emitter = document.createElement('div')
const firstHidden = trackFirstHidden(emitter)
describe('the page is initially visible', () => {
it('should return Infinity if the page was not hidden yet', () => {
expect(trackFirstHidden().timeStamp).toBe(Infinity as RelativeTime)
})
emitter.dispatchEvent(createNewEvent(DOM_EVENT.PAGE_HIDE, { timeStamp: 100 }))
it('should return the timestamp of the first pagehide event', () => {
const emitter = document.createElement('div')
const firstHidden = trackFirstHidden(emitter)
expect(firstHidden.timeStamp).toBe(0 as RelativeTime)
})
emitter.dispatchEvent(createNewEvent(DOM_EVENT.PAGE_HIDE, { timeStamp: 100 }))
it('should return the timestamp of the first pagehide event', () => {
const emitter = document.createElement('div')
const firstHidden = trackFirstHidden(emitter)
expect(firstHidden.timeStamp).toBe(100 as RelativeTime)
})
emitter.dispatchEvent(createNewEvent(DOM_EVENT.PAGE_HIDE, { timeStamp: 100 }))
it('should return the timestamp of the first visibilitychange event if the page is hidden', () => {
const emitter = document.createElement('div')
const firstHidden = trackFirstHidden(emitter)
expect(firstHidden.timeStamp).toBe(100 as RelativeTime)
})
setPageVisibility('hidden')
emitter.dispatchEvent(createNewEvent(DOM_EVENT.VISIBILITY_CHANGE, { timeStamp: 100 }))
it('should stay to the first value if multiple pagehide event occurs', () => {
const emitter = document.createElement('div')
const firstHidden = trackFirstHidden(emitter)
expect(firstHidden.timeStamp).toBe(100 as RelativeTime)
})
emitter.dispatchEvent(createNewEvent(DOM_EVENT.PAGE_HIDE, { timeStamp: 100 }))
emitter.dispatchEvent(createNewEvent(DOM_EVENT.PAGE_HIDE, { timeStamp: 200 }))
it('should ignore visibilitychange event if the page is visible', () => {
const emitter = document.createElement('div')
const firstHidden = trackFirstHidden(emitter)
expect(firstHidden.timeStamp).toBe(100 as RelativeTime)
emitter.dispatchEvent(createNewEvent(DOM_EVENT.VISIBILITY_CHANGE, { timeStamp: 100 }))
expect(firstHidden.timeStamp).toBe(Infinity as RelativeTime)
})
it('should ignore subsequent events', () => {
const emitter = document.createElement('div')
const firstHidden = trackFirstHidden(emitter)
emitter.dispatchEvent(createNewEvent(DOM_EVENT.PAGE_HIDE, { timeStamp: 100 }))
// Subsequent events:
emitter.dispatchEvent(createNewEvent(DOM_EVENT.PAGE_HIDE, { timeStamp: 200 }))
setPageVisibility('hidden')
emitter.dispatchEvent(createNewEvent(DOM_EVENT.VISIBILITY_CHANGE, { timeStamp: 200 }))
expect(firstHidden.timeStamp).toBe(100 as RelativeTime)
})
})
})

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

import { addEventListener, DOM_EVENT, EventEmitter, RelativeTime } from '@datadog/browser-core'
import { addEventListeners, DOM_EVENT, EventEmitter, RelativeTime } from '@datadog/browser-core'

@@ -9,3 +9,5 @@ let trackFirstHiddenSingleton: { timeStamp: RelativeTime } | undefined

if (document.visibilityState === 'hidden') {
trackFirstHiddenSingleton = { timeStamp: 0 as RelativeTime }
trackFirstHiddenSingleton = {
timeStamp: 0 as RelativeTime,
}
} else {

@@ -15,9 +17,12 @@ trackFirstHiddenSingleton = {

}
;({ stop: stopListeners } = addEventListener(
;({ stop: stopListeners } = addEventListeners(
emitter,
DOM_EVENT.PAGE_HIDE,
({ timeStamp }) => {
trackFirstHiddenSingleton!.timeStamp = timeStamp as RelativeTime
[DOM_EVENT.PAGE_HIDE, DOM_EVENT.VISIBILITY_CHANGE],
(event) => {
if (event.type === 'pagehide' || document.visibilityState === 'hidden') {
trackFirstHiddenSingleton!.timeStamp = event.timeStamp as RelativeTime
stopListeners!()
}
},
{ capture: true, once: true }
{ capture: true }
))

@@ -24,0 +29,0 @@ }

@@ -17,13 +17,5 @@ import {

function setupDraws({ tracked, trackedWithReplay }: { tracked?: boolean; trackedWithReplay?: boolean }) {
spyOn(Math, 'random').and.returnValues(tracked ? 0 : 1, trackedWithReplay ? 0 : 1)
}
describe('rum session manager', () => {
const DURATION = 123456
const configuration: RumConfiguration = {
...validateAndBuildRumConfiguration({ clientToken: 'xxx', applicationId: 'xxx' })!,
sampleRate: 50,
replaySampleRate: 50,
}
let configuration: RumConfiguration
let lifeCycle: LifeCycle

@@ -34,2 +26,7 @@ let expireSessionSpy: jasmine.Spy

function setupDraws({ tracked, trackedWithReplay }: { tracked?: boolean; trackedWithReplay?: boolean }) {
configuration.sampleRate = tracked ? 100 : 0
configuration.replaySampleRate = trackedWithReplay ? 100 : 0
}
beforeEach(() => {

@@ -39,2 +36,7 @@ if (isIE()) {

}
configuration = {
...validateAndBuildRumConfiguration({ clientToken: 'xxx', applicationId: 'xxx' })!,
sampleRate: 50,
replaySampleRate: 50,
}
clock = mockClock()

@@ -41,0 +43,0 @@ expireSessionSpy = jasmine.createSpy('expireSessionSpy')

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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