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.30.0 to 4.30.1

cjs/domain/record/browser.types.d.ts

4

cjs/domain/record/privacy.js

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

return (
// Scripts
(relAttribute === 'preload' && getLowerCaseAttribute('as') === 'script') ||
// Link as script - Ignore only when rel=preload, modulepreload or prefetch
(/preload|prefetch/i.test(relAttribute) && getLowerCaseAttribute('as') === 'script') ||
// Favicons

@@ -195,0 +195,0 @@ relAttribute === 'shortcut icon' ||

import type { NodePrivacyLevel } from '../../constants';
import type { StyleSheet } from '../../types';
export declare type NodeWithSerializedNode = Node & {

@@ -21,1 +22,2 @@ s: 'Node with serialized node';

export declare function makeUrlAbsolute(url: string, baseUrl: string): string;
export declare function serializeStyleSheets(cssStyleSheets: CSSStyleSheet[] | undefined): StyleSheet[] | undefined;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeUrlAbsolute = exports.switchToAbsoluteUrl = exports.DATA_URI = exports.ABSOLUTE_URL = exports.URL_IN_CSS_REF = exports.getElementInputValue = exports.setSerializedNodeId = exports.getSerializedNodeId = exports.nodeAndAncestorsHaveSerializedNode = exports.hasSerializedNode = void 0;
exports.serializeStyleSheets = exports.makeUrlAbsolute = exports.switchToAbsoluteUrl = exports.DATA_URI = exports.ABSOLUTE_URL = exports.URL_IN_CSS_REF = exports.getElementInputValue = exports.setSerializedNodeId = exports.getSerializedNodeId = exports.nodeAndAncestorsHaveSerializedNode = exports.hasSerializedNode = void 0;
var browser_core_1 = require("@datadog/browser-core");

@@ -91,2 +91,18 @@ var browser_rum_core_1 = require("@datadog/browser-rum-core");

exports.makeUrlAbsolute = makeUrlAbsolute;
function serializeStyleSheets(cssStyleSheets) {
if (cssStyleSheets === undefined || cssStyleSheets.length === 0) {
return undefined;
}
return cssStyleSheets.map(function (cssStyleSheet) {
var rules = cssStyleSheet.cssRules || cssStyleSheet.rules;
var cssRules = Array.from(rules, function (cssRule) { return cssRule.cssText; });
var styleSheet = {
cssRules: cssRules,
disabled: cssStyleSheet.disabled || undefined,
media: cssStyleSheet.media.length > 0 ? Array.from(cssStyleSheet.media) : undefined,
};
return styleSheet;
});
}
exports.serializeStyleSheets = serializeStyleSheets;
//# sourceMappingURL=serializationUtils.js.map

@@ -56,2 +56,3 @@ "use strict";

childNodes: serializeChildNodes(document, options),
adoptedStyleSheets: (0, serializationUtils_1.serializeStyleSheets)(document.adoptedStyleSheets),
};

@@ -81,2 +82,5 @@ }

isShadowRoot: isShadowRoot,
adoptedStyleSheets: isShadowRoot
? (0, serializationUtils_1.serializeStyleSheets)(element.adoptedStyleSheets)
: undefined,
};

@@ -83,0 +87,0 @@ }

@@ -182,4 +182,4 @@ import { isElementNode, getParentNode, isTextNode } from '@datadog/browser-rum-core';

return (
// Scripts
(relAttribute === 'preload' && getLowerCaseAttribute('as') === 'script') ||
// Link as script - Ignore only when rel=preload, modulepreload or prefetch
(/preload|prefetch/i.test(relAttribute) && getLowerCaseAttribute('as') === 'script') ||
// Favicons

@@ -186,0 +186,0 @@ relAttribute === 'shortcut icon' ||

import type { NodePrivacyLevel } from '../../constants';
import type { StyleSheet } from '../../types';
export declare type NodeWithSerializedNode = Node & {

@@ -21,1 +22,2 @@ s: 'Node with serialized node';

export declare function makeUrlAbsolute(url: string, baseUrl: string): string;
export declare function serializeStyleSheets(cssStyleSheets: CSSStyleSheet[] | undefined): StyleSheet[] | undefined;

@@ -81,2 +81,17 @@ import { buildUrl } from '@datadog/browser-core';

}
export function serializeStyleSheets(cssStyleSheets) {
if (cssStyleSheets === undefined || cssStyleSheets.length === 0) {
return undefined;
}
return cssStyleSheets.map(function (cssStyleSheet) {
var rules = cssStyleSheet.cssRules || cssStyleSheet.rules;
var cssRules = Array.from(rules, function (cssRule) { return cssRule.cssText; });
var styleSheet = {
cssRules: cssRules,
disabled: cssStyleSheet.disabled || undefined,
media: cssStyleSheet.media.length > 0 ? Array.from(cssStyleSheet.media) : undefined,
};
return styleSheet;
});
}
//# sourceMappingURL=serializationUtils.js.map

@@ -6,3 +6,3 @@ import { assign, isExperimentalFeatureEnabled, startsWith } from '@datadog/browser-core';

import { getTextContent, shouldMaskNode, reducePrivacyLevel, getNodeSelfPrivacyLevel, MAX_ATTRIBUTE_VALUE_CHAR_LENGTH, } from './privacy';
import { getSerializedNodeId, setSerializedNodeId, getElementInputValue, switchToAbsoluteUrl, } from './serializationUtils';
import { getSerializedNodeId, setSerializedNodeId, getElementInputValue, switchToAbsoluteUrl, serializeStyleSheets, } from './serializationUtils';
import { forEach } from './utils';

@@ -52,2 +52,3 @@ export function serializeDocument(document, configuration, serializationContext) {

childNodes: serializeChildNodes(document, options),
adoptedStyleSheets: serializeStyleSheets(document.adoptedStyleSheets),
};

@@ -76,2 +77,5 @@ }

isShadowRoot: isShadowRoot,
adoptedStyleSheets: isShadowRoot
? serializeStyleSheets(element.adoptedStyleSheets)
: undefined,
};

@@ -78,0 +82,0 @@ }

{
"name": "@datadog/browser-rum",
"version": "4.30.0",
"version": "4.30.1",
"license": "Apache-2.0",

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

"dependencies": {
"@datadog/browser-core": "4.30.0",
"@datadog/browser-rum-core": "4.30.0"
"@datadog/browser-core": "4.30.1",
"@datadog/browser-rum-core": "4.30.1"
},
"peerDependencies": {
"@datadog/browser-logs": "4.30.0"
"@datadog/browser-logs": "4.30.1"
},

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

},
"gitHead": "fada5c570ec088b6df967f1eee32c887bd138ec8"
"gitHead": "2427f67053ca6041dd81eb565ea0d49483811f81"
}

@@ -206,2 +206,22 @@ import { isIE } from '@datadog/browser-core'

},
{
msg: 'is a link with rel=preload and as=script',
html: '<link rel="preload" crossorigins as="script">',
expected: NodePrivacyLevel.IGNORE,
},
{
msg: 'is a link with rel=modulepreload and as=script',
html: '<link rel="modulepreload" as="script">',
expected: NodePrivacyLevel.IGNORE,
},
{
msg: 'is a link with rel=prefetch and as=script',
html: '<link rel="prefetch" as="script">',
expected: NodePrivacyLevel.IGNORE,
},
{
msg: 'is a link with rel=stylesheet and a not expected as=script',
html: '<link rel="stylesheet" as="script">',
expected: undefined,
},

@@ -208,0 +228,0 @@ // Precedence

@@ -223,4 +223,4 @@ import { isElementNode, getParentNode, isTextNode } from '@datadog/browser-rum-core'

return (
// Scripts
(relAttribute === 'preload' && getLowerCaseAttribute('as') === 'script') ||
// Link as script - Ignore only when rel=preload, modulepreload or prefetch
(/preload|prefetch/i.test(relAttribute) && getLowerCaseAttribute('as') === 'script') ||
// Favicons

@@ -227,0 +227,0 @@ relAttribute === 'shortcut icon' ||

import { isIE } from '@datadog/browser-core'
import { isAdoptedStyleSheetsSupported } from '../../../../core/test/specHelper'
import { NodePrivacyLevel } from '../../constants'

@@ -9,2 +10,3 @@ import {

switchToAbsoluteUrl,
serializeStyleSheets,
} from './serializationUtils'

@@ -187,1 +189,25 @@

})
describe('serializeStyleSheets', () => {
beforeEach(() => {
if (!isAdoptedStyleSheetsSupported()) {
pending('no adoptedStyleSheets support')
}
})
it('should return undefined if no stylesheets', () => {
expect(serializeStyleSheets(undefined)).toBe(undefined)
expect(serializeStyleSheets([])).toBe(undefined)
})
it('should return serialized stylesheet', () => {
const disabledStylesheet = new CSSStyleSheet({ disabled: true })
disabledStylesheet.insertRule('div { width: 100%; }')
const printStylesheet = new CSSStyleSheet({ disabled: false, media: 'print' })
printStylesheet.insertRule('a { color: red; }')
expect(serializeStyleSheets([disabledStylesheet, printStylesheet])).toEqual([
{ cssRules: ['div { width: 100%; }'], disabled: true, media: undefined },
{ cssRules: ['a { color: red; }'], disabled: undefined, media: ['print'] },
])
})
})

@@ -5,2 +5,3 @@ import { buildUrl } from '@datadog/browser-core'

import { CENSORED_STRING_MARK } from '../../constants'
import type { StyleSheet } from '../../types'
import { shouldMaskNode } from './privacy'

@@ -110,1 +111,18 @@

}
export function serializeStyleSheets(cssStyleSheets: CSSStyleSheet[] | undefined): StyleSheet[] | undefined {
if (cssStyleSheets === undefined || cssStyleSheets.length === 0) {
return undefined
}
return cssStyleSheets.map((cssStyleSheet) => {
const rules = cssStyleSheet.cssRules || cssStyleSheet.rules
const cssRules = Array.from(rules, (cssRule) => cssRule.cssText)
const styleSheet: StyleSheet = {
cssRules,
disabled: cssStyleSheet.disabled || undefined,
media: cssStyleSheet.media.length > 0 ? Array.from(cssStyleSheet.media) : undefined,
}
return styleSheet
})
}
import { isIE, noop, resetExperimentalFeatures, updateExperimentalFeatures } from '@datadog/browser-core'
import type { RumConfiguration } from '@datadog/browser-rum-core'

@@ -12,2 +13,3 @@ import { STABLE_ATTRIBUTES, DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE } from '@datadog/browser-rum-core'

} from '../../constants'
import { isAdoptedStyleSheetsSupported } from '../../../../core/test/specHelper'
import {

@@ -23,2 +25,4 @@ HTML,

import { NodeType } from '../../types'
import type { IsolatedDom } from '../../../../rum-core/test/createIsolatedDom'
import { createIsolatedDom } from '../../../../rum-core/test/createIsolatedDom'
import { hasSerializedNode } from './serializationUtils'

@@ -38,2 +42,3 @@ import type { SerializationContext, SerializeOptions } from './serialize'

import type { ShadowRootCallBack, ShadowRootsController } from './shadowRootsController'
import type { WithAdoptedStyleSheets } from './browser.types'

@@ -92,2 +97,3 @@ const DEFAULT_CONFIGURATION = {} as RumConfiguration

],
adoptedStyleSheets: undefined,
id: jasmine.any(Number) as unknown as number,

@@ -444,2 +450,3 @@ })

id: jasmine.any(Number) as unknown as number,
adoptedStyleSheets: undefined,
},

@@ -476,2 +483,3 @@ ],

isShadowRoot: true,
adoptedStyleSheets: undefined,
childNodes: [

@@ -693,2 +701,35 @@ {

describe('with dynamic stylesheet', () => {
let isolatedDom: IsolatedDom
beforeEach(() => {
isolatedDom = createIsolatedDom()
})
afterEach(() => {
isolatedDom.clear()
})
it('serializes a document with adoptedStyleSheets', () => {
if (!isAdoptedStyleSheetsSupported()) {
pending('no adoptedStyleSheets support')
}
const styleSheet = new isolatedDom.window.CSSStyleSheet()
styleSheet.insertRule('div { width: 100%; }')
;(isolatedDom.document as WithAdoptedStyleSheets).adoptedStyleSheets = [styleSheet]
expect(serializeDocument(isolatedDom.document, DEFAULT_CONFIGURATION, DEFAULT_SERIALIZATION_CONTEXT)).toEqual({
type: NodeType.Document,
childNodes: [jasmine.objectContaining({ type: NodeType.Element, tagName: 'html' })],
adoptedStyleSheets: [
{
cssRules: ['div { width: 100%; }'],
disabled: undefined,
media: undefined,
},
],
id: jasmine.any(Number) as unknown as number,
})
})
})
it('a masked DOM Document itself is still serialized ', () => {

@@ -702,2 +743,3 @@ const serializeOptionsMask: SerializeOptions = {

childNodes: serializeChildNodes(document, serializeOptionsMask),
adoptedStyleSheets: undefined,
})

@@ -704,0 +746,0 @@ })

@@ -34,2 +34,3 @@ import { assign, isExperimentalFeatureEnabled, startsWith } from '@datadog/browser-core'

switchToAbsoluteUrl,
serializeStyleSheets,
} from './serializationUtils'

@@ -39,2 +40,3 @@ import { forEach } from './utils'

import type { ShadowRootsController } from './shadowRootsController'
import type { WithAdoptedStyleSheets } from './browser.types'

@@ -130,2 +132,3 @@ // Those values are the only one that can be used when inheriting privacy levels from parent to

childNodes: serializeChildNodes(document, options),
adoptedStyleSheets: serializeStyleSheets((document as WithAdoptedStyleSheets).adoptedStyleSheets),
}

@@ -161,2 +164,5 @@ }

isShadowRoot,
adoptedStyleSheets: isShadowRoot
? serializeStyleSheets((element as WithAdoptedStyleSheets).adoptedStyleSheets)
: undefined,
}

@@ -163,0 +169,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

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