Skip to content

Commit

Permalink
[RUMF-998] adjust some comments and typos
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitZugmeyer committed Aug 20, 2021
1 parent a541c0a commit 279e300
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
6 changes: 3 additions & 3 deletions packages/rum/src/domain/record/privacy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ describe('serializeDocumentNode handles', function testAllowDomTree() {
})

describe('for privacy tag `mask`, a DOM tree', function testMaskDomTree() {
it("doesn't have innerText alpha numberics", () => {
it("doesn't have innerText alpha numeric", () => {
const serializedDoc = generateLeanSerializedDoc(HTML, 'mask')
expect({ text: getTextNodesFromSerialized(serializedDoc) }).not.toBe({
text: jasmine.stringMatching(/^[*᙮\s]+\.example {content: "anything";}[*᙮\s]+$/),
Expand All @@ -321,7 +321,7 @@ describe('serializeDocumentNode handles', function testAllowDomTree() {
})

describe('for privacy tag `mask-forms-only`, a DOM tree', function testMaskFormsOnlyDomTree() {
it('doesnt mask text content', () => {
it("doesn't mask text content", () => {
const serializedDoc = generateLeanSerializedDoc(HTML, 'mask-forms-only')
expect(JSON.stringify(serializedDoc)).not.toContain('xx')
})
Expand All @@ -332,7 +332,7 @@ describe('serializeDocumentNode handles', function testAllowDomTree() {
})

describe('for privacy tag `allow`, a DOM tree', function testAllowDomTree() {
it("doesn't have innerText alpha numberics", () => {
it("doesn't have innerText alpha numeric", () => {
const serializedDoc = generateLeanSerializedDoc(HTML, 'allow')
const innerText = getTextNodesFromSerialized(serializedDoc)
const privateWordMatchCount = innerText.match(/private/g)?.length
Expand Down
17 changes: 7 additions & 10 deletions packages/rum/src/domain/record/privacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import { shouldIgnoreElement } from './serialize'
const TEXT_MASKING_CHAR = '᙮'

/**
* INTERNAL FUNC: Get privacy level without remapping (or setting cache)
* This function may be explicitly used when passing internal privacy levels to
* child nodes for performance reasons, otherwise you should use `getNodePrivacyLevel`
* Get node privacy level by iterating over its ancestors. When the direct parent privacy level is
* know, it is best to use something like:
*
* derivePrivacyLevelGivenParent(getNodeSelfPrivacyLevel(node), parentNodePrivacyLevel)
*/
export function getNodePrivacyLevel(node: Node, initialPrivacyLevel: NodePrivacyLevel): NodePrivacyLevel {
const parentNodePrivacyLevel = node.parentNode
Expand All @@ -46,7 +47,7 @@ export function derivePrivacyLevelGivenParent(
parentNodePrivacyLevel: NodePrivacyLevel
): NodePrivacyLevel {
switch (parentNodePrivacyLevel) {
// These values cannot be overrided
// These values cannot be overridden
case NodePrivacyLevel.HIDDEN:
case NodePrivacyLevel.IGNORE:
return parentNodePrivacyLevel
Expand All @@ -65,8 +66,6 @@ export function derivePrivacyLevelGivenParent(

/**
* Determines the node's own privacy level without checking for ancestors.
* This function is purposely not exposed because we do care about the ancestor level.
* As per our privacy spreadsheet, we will `overrule` privacy tags to protect user passwords and autocomplete fields.
*/
export function getNodeSelfPrivacyLevel(node: Node): NodePrivacyLevel | undefined {
// Only Element types can be have a privacy level set
Expand Down Expand Up @@ -220,10 +219,8 @@ function isFormElement(node: Node | null): boolean {
}

/**
* Text censoring non-destructively maintains whitespace characters in order to preserve text shape during replay.
* For short text, simply replace all non-whitespace characters
* For long text, we assume sufficient text entropy to support scrambling the non-whitespace characters in order to
* preserve the charset, allowing for near pixel perfect text shape.
* Text censoring non-destructively maintains whitespace characters in order to preserve text shape
* during replay.
*/
export const censorText = (text: string) => text.replace(/\S/g, TEXT_MASKING_CHAR)

Expand Down

0 comments on commit 279e300

Please sign in to comment.