Socket
Socket
Sign inDemoInstall

@datadog/browser-rum

Package Overview
Dependencies
Maintainers
1
Versions
256
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datadog/browser-rum - npm Package Compare versions

Comparing version 4.45.0 to 4.46.0

7

cjs/boot/recorderApi.js

@@ -8,5 +8,7 @@ "use strict";

var segmentCollection_1 = require("../domain/segmentCollection");
var record_1 = require("../domain/record");
var isBrowserSupported_1 = require("./isBrowserSupported");
function makeRecorderApi(startRecordingImpl, startDeflateWorkerImpl) {
if (startDeflateWorkerImpl === void 0) { startDeflateWorkerImpl = segmentCollection_1.startDeflateWorker; }
var recorderStartObservable = new browser_core_1.Observable();
if ((0, browser_core_1.canUseEventBridge)() || !(0, isBrowserSupported_1.isBrowserSupported)()) {

@@ -20,2 +22,4 @@ return {

getSessionReplayLink: function () { return undefined; },
getSerializedNodeId: function () { return undefined; },
recorderStartObservable: recorderStartObservable,
};

@@ -39,2 +43,4 @@ }

},
recorderStartObservable: recorderStartObservable,
getSerializedNodeId: record_1.getSerializedNodeId,
onRumStart: function (lifeCycle, configuration, sessionManager, viewContexts) {

@@ -77,2 +83,3 @@ lifeCycle.subscribe(7 /* LifeCycleEventType.SESSION_EXPIRED */, function () {

var stopRecording = startRecordingImpl(lifeCycle, configuration, sessionManager, viewContexts, worker).stop;
recorderStartObservable.notify((0, browser_core_1.relativeNow)());
state = {

@@ -79,0 +86,0 @@ status: 3 /* RecorderStatus.Started */,

1

cjs/domain/record/index.d.ts

@@ -5,1 +5,2 @@ export { record } from './record';

export { ShadowRootsController } from './shadowRootsController';
export { getSerializedNodeId } from './serialization';

4

cjs/domain/record/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createElementsScrollPositions = exports.serializeDocument = exports.serializeNodeWithId = exports.record = void 0;
exports.getSerializedNodeId = exports.createElementsScrollPositions = exports.serializeDocument = exports.serializeNodeWithId = exports.record = void 0;
var record_1 = require("./record");

@@ -11,2 +11,4 @@ Object.defineProperty(exports, "record", { enumerable: true, get: function () { return record_1.record; } });

Object.defineProperty(exports, "createElementsScrollPositions", { enumerable: true, get: function () { return elementsScrollPositions_1.createElementsScrollPositions; } });
var serialization_2 = require("./serialization");
Object.defineProperty(exports, "getSerializedNodeId", { enumerable: true, get: function () { return serialization_2.getSerializedNodeId; } });
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeAttributes = void 0;
var browser_core_1 = require("@datadog/browser-core");
var constants_1 = require("../../../constants");

@@ -45,3 +46,3 @@ var privacy_1 = require("../privacy");

var cssText = getCssRulesString(stylesheet);
if (cssText && stylesheet) {
if (cssText && stylesheet && !(0, browser_core_1.isExperimentalFeatureEnabled)(browser_core_1.ExperimentalFeature.DISABLE_REPLAY_INLINE_CSS)) {
safeAttrs._cssText = cssText;

@@ -48,0 +49,0 @@ }

@@ -9,5 +9,7 @@ import type { BrowserRecord, BrowserSegmentMetadata, CreationReason, SegmentContext } from '../../types';

private id;
private pendingWriteCount;
constructor(worker: DeflateWorker, context: SegmentContext, creationReason: CreationReason, initialRecord: BrowserRecord, onWrote: (compressedBytesCount: number) => void, onFlushed: (data: Uint8Array, rawBytesCount: number) => void);
addRecord(record: BrowserRecord): void;
flush(reason: FlushReason): void;
private write;
}

@@ -30,2 +30,4 @@ "use strict";

var replayStats = __importStar(require("../replayStats"));
// Arbitrary id, will be replaced when we have multiple parallel streams.
var STREAM_ID = 1;
var nextId = 0;

@@ -37,2 +39,3 @@ var Segment = /** @class */ (function () {

this.id = nextId++;
this.pendingWriteCount = 0;
var viewId = context.view.id;

@@ -50,15 +53,23 @@ this.metadata = (0, browser_core_1.assign)({

replayStats.addRecord(viewId);
var rawBytesCount = 0;
var compressedBytesCount = 0;
var compressedData = [];
var removeMessageListener = (0, browser_core_1.addEventListener)(worker, 'message', function (_a) {
var data = _a.data;
if (data.type === 'errored' || data.type === 'initialized') {
if (data.type !== 'wrote') {
return;
}
if (data.id === _this.id) {
_this.pendingWriteCount -= 1;
replayStats.addWroteData(viewId, data.additionalBytesCount);
if (data.type === 'flushed') {
onFlushed(data.result, data.rawBytesCount);
rawBytesCount += data.additionalBytesCount;
compressedBytesCount += data.result.length;
compressedData.push(data.result);
if (_this.flushReason && _this.pendingWriteCount === 0) {
compressedData.push(data.trailer);
onFlushed((0, browser_core_1.concatBuffers)(compressedData), rawBytesCount);
removeMessageListener();
}
else {
onWrote(data.compressedBytesCount);
onWrote(compressedBytesCount);
}

@@ -80,3 +91,3 @@ }

(0, browser_core_1.sendToExtension)('record', { record: initialRecord, segment: this.metadata });
this.worker.postMessage({ data: "{\"records\":[".concat(JSON.stringify(initialRecord)), id: this.id, action: 'write' });
this.write("{\"records\":[".concat(JSON.stringify(initialRecord)));
}

@@ -91,12 +102,21 @@ Segment.prototype.addRecord = function (record) {

(0, browser_core_1.sendToExtension)('record', { record: record, segment: this.metadata });
this.worker.postMessage({ data: ",".concat(JSON.stringify(record)), id: this.id, action: 'write' });
this.write(",".concat(JSON.stringify(record)));
};
Segment.prototype.flush = function (reason) {
this.write("],".concat(JSON.stringify(this.metadata).slice(1), "\n"));
this.worker.postMessage({
data: "],".concat(JSON.stringify(this.metadata).slice(1), "\n"),
id: this.id,
action: 'flush',
action: 'reset',
streamId: STREAM_ID,
});
this.flushReason = reason;
};
Segment.prototype.write = function (data) {
this.pendingWriteCount += 1;
this.worker.postMessage({
data: data,
id: this.id,
streamId: STREAM_ID,
action: 'write',
});
};
return Segment;

@@ -103,0 +123,0 @@ }());

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

if (data.type === 'errored') {
onError(data.error);
onError(data.error, data.streamId);
}
else if (data.type === 'initialized') {
onInitialized(worker_1);
onInitialized(worker_1, data.version);
}

@@ -71,9 +71,9 @@ });

exports.doStartDeflateWorker = doStartDeflateWorker;
function onInitialized(worker) {
function onInitialized(worker, version) {
if (state.status === 1 /* DeflateWorkerStatus.Loading */) {
state.callbacks.forEach(function (callback) { return callback(worker); });
state = { status: 3 /* DeflateWorkerStatus.Initialized */, worker: worker };
state = { status: 3 /* DeflateWorkerStatus.Initialized */, worker: worker, version: version };
}
}
function onError(error) {
function onError(error, streamId) {
if (state.status === 1 /* DeflateWorkerStatus.Loading */) {

@@ -92,3 +92,6 @@ browser_core_1.display.error('Session Replay recording failed to start: an error occurred while creating the Worker:', error);

else {
(0, browser_core_1.addTelemetryError)(error);
(0, browser_core_1.addTelemetryError)(error, {
worker_version: state.status === 3 /* DeflateWorkerStatus.Initialized */ && state.version,
stream_id: streamId,
});
}

@@ -95,0 +98,0 @@ }

@@ -1,8 +0,10 @@

import { canUseEventBridge, noop, runOnReadyState } from '@datadog/browser-core';
import { Observable, canUseEventBridge, noop, runOnReadyState, relativeNow } from '@datadog/browser-core';
import { getReplayStats } from '../domain/replayStats';
import { getSessionReplayLink } from '../domain/getSessionReplayLink';
import { startDeflateWorker } from '../domain/segmentCollection';
import { getSerializedNodeId } from '../domain/record';
import { isBrowserSupported } from './isBrowserSupported';
export function makeRecorderApi(startRecordingImpl, startDeflateWorkerImpl) {
if (startDeflateWorkerImpl === void 0) { startDeflateWorkerImpl = startDeflateWorker; }
var recorderStartObservable = new Observable();
if (canUseEventBridge() || !isBrowserSupported()) {

@@ -16,2 +18,4 @@ return {

getSessionReplayLink: function () { return undefined; },
getSerializedNodeId: function () { return undefined; },
recorderStartObservable: recorderStartObservable,
};

@@ -35,2 +39,4 @@ }

},
recorderStartObservable: recorderStartObservable,
getSerializedNodeId: getSerializedNodeId,
onRumStart: function (lifeCycle, configuration, sessionManager, viewContexts) {

@@ -73,2 +79,3 @@ lifeCycle.subscribe(7 /* LifeCycleEventType.SESSION_EXPIRED */, function () {

var stopRecording = startRecordingImpl(lifeCycle, configuration, sessionManager, viewContexts, worker).stop;
recorderStartObservable.notify(relativeNow());
state = {

@@ -75,0 +82,0 @@ status: 3 /* RecorderStatus.Started */,

@@ -5,1 +5,2 @@ export { record } from './record';

export { ShadowRootsController } from './shadowRootsController';
export { getSerializedNodeId } from './serialization';
export { record } from './record';
export { serializeNodeWithId, serializeDocument } from './serialization';
export { createElementsScrollPositions } from './elementsScrollPositions';
export { getSerializedNodeId } from './serialization';
//# sourceMappingURL=index.js.map

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

import { ExperimentalFeature, isExperimentalFeatureEnabled } from '@datadog/browser-core';
import { NodePrivacyLevel } from '../../../constants';

@@ -42,3 +43,3 @@ import { shouldMaskNode } from '../privacy';

var cssText = getCssRulesString(stylesheet);
if (cssText && stylesheet) {
if (cssText && stylesheet && !isExperimentalFeatureEnabled(ExperimentalFeature.DISABLE_REPLAY_INLINE_CSS)) {
safeAttrs._cssText = cssText;

@@ -45,0 +46,0 @@ }

@@ -9,5 +9,7 @@ import type { BrowserRecord, BrowserSegmentMetadata, CreationReason, SegmentContext } from '../../types';

private id;
private pendingWriteCount;
constructor(worker: DeflateWorker, context: SegmentContext, creationReason: CreationReason, initialRecord: BrowserRecord, onWrote: (compressedBytesCount: number) => void, onFlushed: (data: Uint8Array, rawBytesCount: number) => void);
addRecord(record: BrowserRecord): void;
flush(reason: FlushReason): void;
private write;
}

@@ -1,4 +0,6 @@

import { addTelemetryDebug, assign, sendToExtension, addEventListener } from '@datadog/browser-core';
import { addTelemetryDebug, assign, sendToExtension, addEventListener, concatBuffers } from '@datadog/browser-core';
import { RecordType } from '../../types';
import * as replayStats from '../replayStats';
// Arbitrary id, will be replaced when we have multiple parallel streams.
var STREAM_ID = 1;
var nextId = 0;

@@ -10,2 +12,3 @@ var Segment = /** @class */ (function () {

this.id = nextId++;
this.pendingWriteCount = 0;
var viewId = context.view.id;

@@ -23,15 +26,23 @@ this.metadata = assign({

replayStats.addRecord(viewId);
var rawBytesCount = 0;
var compressedBytesCount = 0;
var compressedData = [];
var removeMessageListener = addEventListener(worker, 'message', function (_a) {
var data = _a.data;
if (data.type === 'errored' || data.type === 'initialized') {
if (data.type !== 'wrote') {
return;
}
if (data.id === _this.id) {
_this.pendingWriteCount -= 1;
replayStats.addWroteData(viewId, data.additionalBytesCount);
if (data.type === 'flushed') {
onFlushed(data.result, data.rawBytesCount);
rawBytesCount += data.additionalBytesCount;
compressedBytesCount += data.result.length;
compressedData.push(data.result);
if (_this.flushReason && _this.pendingWriteCount === 0) {
compressedData.push(data.trailer);
onFlushed(concatBuffers(compressedData), rawBytesCount);
removeMessageListener();
}
else {
onWrote(data.compressedBytesCount);
onWrote(compressedBytesCount);
}

@@ -53,3 +64,3 @@ }

sendToExtension('record', { record: initialRecord, segment: this.metadata });
this.worker.postMessage({ data: "{\"records\":[".concat(JSON.stringify(initialRecord)), id: this.id, action: 'write' });
this.write("{\"records\":[".concat(JSON.stringify(initialRecord)));
}

@@ -64,12 +75,21 @@ Segment.prototype.addRecord = function (record) {

sendToExtension('record', { record: record, segment: this.metadata });
this.worker.postMessage({ data: ",".concat(JSON.stringify(record)), id: this.id, action: 'write' });
this.write(",".concat(JSON.stringify(record)));
};
Segment.prototype.flush = function (reason) {
this.write("],".concat(JSON.stringify(this.metadata).slice(1), "\n"));
this.worker.postMessage({
data: "],".concat(JSON.stringify(this.metadata).slice(1), "\n"),
id: this.id,
action: 'flush',
action: 'reset',
streamId: STREAM_ID,
});
this.flushReason = reason;
};
Segment.prototype.write = function (data) {
this.pendingWriteCount += 1;
this.worker.postMessage({
data: data,
id: this.id,
streamId: STREAM_ID,
action: 'write',
});
};
return Segment;

@@ -76,0 +96,0 @@ }());

@@ -50,6 +50,6 @@ import { addTelemetryError, display, includes, addEventListener } from '@datadog/browser-core';

if (data.type === 'errored') {
onError(data.error);
onError(data.error, data.streamId);
}
else if (data.type === 'initialized') {
onInitialized(worker_1);
onInitialized(worker_1, data.version);
}

@@ -64,9 +64,9 @@ });

}
function onInitialized(worker) {
function onInitialized(worker, version) {
if (state.status === 1 /* DeflateWorkerStatus.Loading */) {
state.callbacks.forEach(function (callback) { return callback(worker); });
state = { status: 3 /* DeflateWorkerStatus.Initialized */, worker: worker };
state = { status: 3 /* DeflateWorkerStatus.Initialized */, worker: worker, version: version };
}
}
function onError(error) {
function onError(error, streamId) {
if (state.status === 1 /* DeflateWorkerStatus.Loading */) {

@@ -85,3 +85,6 @@ display.error('Session Replay recording failed to start: an error occurred while creating the Worker:', error);

else {
addTelemetryError(error);
addTelemetryError(error, {
worker_version: state.status === 3 /* DeflateWorkerStatus.Initialized */ && state.version,
stream_id: streamId,
});
}

@@ -88,0 +91,0 @@ }

{
"name": "@datadog/browser-rum",
"version": "4.45.0",
"version": "4.46.0",
"license": "Apache-2.0",

@@ -15,8 +15,8 @@ "main": "cjs/entries/main.js",

"dependencies": {
"@datadog/browser-core": "4.45.0",
"@datadog/browser-rum-core": "4.45.0",
"@datadog/browser-worker": "4.45.0"
"@datadog/browser-core": "4.46.0",
"@datadog/browser-rum-core": "4.46.0",
"@datadog/browser-worker": "4.46.0"
},
"peerDependencies": {
"@datadog/browser-logs": "4.45.0"
"@datadog/browser-logs": "4.46.0"
},

@@ -43,3 +43,3 @@ "peerDependenciesMeta": {

},
"gitHead": "4b06c56c78f438cb4d11e9075b107839196e60dd"
"gitHead": "fdd9a6034d8e1460cbb3dfdac188f102de10347f"
}

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

import { canUseEventBridge, noop, runOnReadyState } from '@datadog/browser-core'
import type { RelativeTime } from '@datadog/browser-core'
import { Observable, canUseEventBridge, noop, runOnReadyState, relativeNow } from '@datadog/browser-core'
import type {

@@ -14,2 +15,3 @@ LifeCycle,

import { getSerializedNodeId } from '../domain/record'
import type { startRecording } from './startRecording'

@@ -50,2 +52,4 @@ import { isBrowserSupported } from './isBrowserSupported'

): RecorderApi {
const recorderStartObservable = new Observable<RelativeTime>()
if (canUseEventBridge() || !isBrowserSupported()) {

@@ -59,2 +63,4 @@ return {

getSessionReplayLink: () => undefined,
getSerializedNodeId: () => undefined,
recorderStartObservable,
}

@@ -79,2 +85,4 @@ }

getSessionReplayLink(configuration, sessionManager, viewContexts, state.status !== RecorderStatus.Stopped),
recorderStartObservable,
getSerializedNodeId,
onRumStart: (

@@ -136,2 +144,3 @@ lifeCycle: LifeCycle,

)
recorderStartObservable.notify(relativeNow())
state = {

@@ -138,0 +147,0 @@ status: RecorderStatus.Started,

@@ -5,1 +5,2 @@ export { record } from './record'

export { ShadowRootsController } from './shadowRootsController'
export { getSerializedNodeId } from './serialization'

@@ -0,1 +1,3 @@

import { ExperimentalFeature, isExperimentalFeatureEnabled } from '@datadog/browser-core'
import { NodePrivacyLevel } from '../../../constants'

@@ -54,3 +56,3 @@ import { shouldMaskNode } from '../privacy'

const cssText = getCssRulesString(stylesheet)
if (cssText && stylesheet) {
if (cssText && stylesheet && !isExperimentalFeatureEnabled(ExperimentalFeature.DISABLE_REPLAY_INLINE_CSS)) {
safeAttrs._cssText = cssText

@@ -57,0 +59,0 @@ }

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

import { addTelemetryDebug, assign, sendToExtension, addEventListener } from '@datadog/browser-core'
import { addTelemetryDebug, assign, sendToExtension, addEventListener, concatBuffers } from '@datadog/browser-core'
import type { DeflateWorkerResponse } from '@datadog/browser-worker'

@@ -8,2 +8,4 @@ import type { BrowserRecord, BrowserSegmentMetadata, CreationReason, SegmentContext } from '../../types'

// Arbitrary id, will be replaced when we have multiple parallel streams.
const STREAM_ID = 1
let nextId = 0

@@ -19,2 +21,3 @@

private id = nextId++
private pendingWriteCount = 0

@@ -46,2 +49,5 @@ constructor(

replayStats.addRecord(viewId)
let rawBytesCount = 0
let compressedBytesCount = 0
const compressedData: Uint8Array[] = []

@@ -52,3 +58,3 @@ const { stop: removeMessageListener } = addEventListener(

({ data }: MessageEvent<DeflateWorkerResponse>) => {
if (data.type === 'errored' || data.type === 'initialized') {
if (data.type !== 'wrote') {
return

@@ -58,8 +64,13 @@ }

if (data.id === this.id) {
this.pendingWriteCount -= 1
replayStats.addWroteData(viewId, data.additionalBytesCount)
if (data.type === 'flushed') {
onFlushed(data.result, data.rawBytesCount)
rawBytesCount += data.additionalBytesCount
compressedBytesCount += data.result.length
compressedData.push(data.result)
if (this.flushReason && this.pendingWriteCount === 0) {
compressedData.push(data.trailer)
onFlushed(concatBuffers(compressedData), rawBytesCount)
removeMessageListener()
} else {
onWrote(data.compressedBytesCount)
onWrote(compressedBytesCount)
}

@@ -81,3 +92,3 @@ } else if (data.id > this.id) {

sendToExtension('record', { record: initialRecord, segment: this.metadata })
this.worker.postMessage({ data: `{"records":[${JSON.stringify(initialRecord)}`, id: this.id, action: 'write' })
this.write(`{"records":[${JSON.stringify(initialRecord)}`)
}

@@ -92,13 +103,23 @@

sendToExtension('record', { record, segment: this.metadata })
this.worker.postMessage({ data: `,${JSON.stringify(record)}`, id: this.id, action: 'write' })
this.write(`,${JSON.stringify(record)}`)
}
flush(reason: FlushReason) {
this.write(`],${JSON.stringify(this.metadata).slice(1)}\n`)
this.worker.postMessage({
data: `],${JSON.stringify(this.metadata).slice(1)}\n`,
id: this.id,
action: 'flush',
action: 'reset',
streamId: STREAM_ID,
})
this.flushReason = reason
}
private write(data: string) {
this.pendingWriteCount += 1
this.worker.postMessage({
data,
id: this.id,
streamId: STREAM_ID,
action: 'write',
})
}
}

@@ -31,2 +31,3 @@ import { addTelemetryError, display, includes, addEventListener } from '@datadog/browser-core'

worker: DeflateWorker
version: string
}

@@ -90,5 +91,5 @@

if (data.type === 'errored') {
onError(data.error)
onError(data.error, data.streamId)
} else if (data.type === 'initialized') {
onInitialized(worker)
onInitialized(worker, data.version)
}

@@ -103,10 +104,10 @@ })

function onInitialized(worker: DeflateWorker) {
function onInitialized(worker: DeflateWorker, version: string) {
if (state.status === DeflateWorkerStatus.Loading) {
state.callbacks.forEach((callback) => callback(worker))
state = { status: DeflateWorkerStatus.Initialized, worker }
state = { status: DeflateWorkerStatus.Initialized, worker, version }
}
}
function onError(error: unknown) {
function onError(error: unknown, streamId?: number) {
if (state.status === DeflateWorkerStatus.Loading) {

@@ -125,3 +126,6 @@ display.error('Session Replay recording failed to start: an error occurred while creating the Worker:', error)

} else {
addTelemetryError(error)
addTelemetryError(error, {
worker_version: state.status === DeflateWorkerStatus.Initialized && state.version,
stream_id: streamId,
})
}

@@ -128,0 +132,0 @@ }

Sorry, the diff of this file is too big to display

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

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