Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [RUMF-1267] remove last circular dependencies #1577

Merged
merged 6 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/transport/eventBridge.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getGlobalObject } from '..'
import { getGlobalObject } from '../tools/utils'

export interface BrowserWindowWithEventBridge extends Window {
DatadogEventBridge?: DatadogEventBridge
Expand Down
5 changes: 3 additions & 2 deletions packages/rum/src/domain/record/mutationObserver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import {
PRIVACY_ATTR_VALUE_MASK,
PRIVACY_ATTR_VALUE_MASK_USER_INPUT,
} from '../../constants'
import type { AttributeMutation, Attributes } from '../../types'
import { NodeType } from '../../types'
import { serializeDocument } from './serialize'
import { sortAddedAndMovedNodes, startMutationObserver, MutationController } from './mutationObserver'
import type { AttributeMutation, Attributes, MutationCallBack } from './types'
import { NodeType } from './types'
import type { MutationCallBack } from './types'

describe('startMutationCollection', () => {
let sandbox: HTMLElement
Expand Down
5 changes: 1 addition & 4 deletions packages/rum/src/domain/record/mutationObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { DefaultPrivacyLevel } from '@datadog/browser-core'
import { monitor, noop } from '@datadog/browser-core'
import { getMutationObserverConstructor } from '@datadog/browser-rum-core'
import { NodePrivacyLevel } from '../../constants'
import type { AddedNodeMutation, AttributeMutation, RemovedNodeMutation, TextMutation } from '../../types'
import { getNodePrivacyLevel, getTextContent } from './privacy'
import type { NodeWithSerializedNode } from './serializationUtils'
import {
Expand All @@ -12,15 +13,11 @@ import {
} from './serializationUtils'
import { serializeNodeWithId, serializeAttribute } from './serialize'
import type {
AddedNodeMutation,
AttributeMutation,
RumAttributesMutationRecord,
RumCharacterDataMutationRecord,
RumChildListMutationRecord,
MutationCallBack,
RumMutationRecord,
RemovedNodeMutation,
TextMutation,
} from './types'
import { forEach } from './utils'
import { createMutationBatch } from './mutationBatch'
Expand Down
28 changes: 13 additions & 15 deletions packages/rum/src/domain/record/observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import {
noop,
} from '@datadog/browser-core'
import { NodePrivacyLevel } from '../../constants'
import type { InputState, MousePosition, MouseInteraction } from '../../types'
import { IncrementalSource, MediaInteractionType, MouseInteractionType } from '../../types'
import { getNodePrivacyLevel, shouldMaskNode } from './privacy'
import { getElementInputValue, getSerializedNodeId, hasSerializedNode } from './serializationUtils'
import type {
FocusCallback,
InputCallback,
InputState,
ListenerHandler,
MediaInteractionCallback,
MouseInteractionCallBack,
Expand All @@ -27,10 +28,7 @@ import type {
StyleSheetRuleCallback,
ViewportResizeCallback,
VisualViewportResizeCallback,
MousePosition,
MouseInteractionParam,
} from './types'
import { IncrementalSource, MediaInteractions, MouseInteractions } from './types'
import { forEach, isTouchEvent } from './utils'
import type { MutationController } from './mutationObserver'
import { startMutationObserver } from './mutationObserver'
Expand Down Expand Up @@ -115,15 +113,15 @@ function initMoveObserver(cb: MousemoveCallBack): ListenerHandler {
}

const eventTypeToMouseInteraction = {
[DOM_EVENT.MOUSE_UP]: MouseInteractions.MouseUp,
[DOM_EVENT.MOUSE_DOWN]: MouseInteractions.MouseDown,
[DOM_EVENT.CLICK]: MouseInteractions.Click,
[DOM_EVENT.CONTEXT_MENU]: MouseInteractions.ContextMenu,
[DOM_EVENT.DBL_CLICK]: MouseInteractions.DblClick,
[DOM_EVENT.FOCUS]: MouseInteractions.Focus,
[DOM_EVENT.BLUR]: MouseInteractions.Blur,
[DOM_EVENT.TOUCH_START]: MouseInteractions.TouchStart,
[DOM_EVENT.TOUCH_END]: MouseInteractions.TouchEnd,
[DOM_EVENT.MOUSE_UP]: MouseInteractionType.MouseUp,
[DOM_EVENT.MOUSE_DOWN]: MouseInteractionType.MouseDown,
[DOM_EVENT.CLICK]: MouseInteractionType.Click,
[DOM_EVENT.CONTEXT_MENU]: MouseInteractionType.ContextMenu,
[DOM_EVENT.DBL_CLICK]: MouseInteractionType.DblClick,
[DOM_EVENT.FOCUS]: MouseInteractionType.Focus,
[DOM_EVENT.BLUR]: MouseInteractionType.Blur,
[DOM_EVENT.TOUCH_START]: MouseInteractionType.TouchStart,
[DOM_EVENT.TOUCH_END]: MouseInteractionType.TouchEnd,
}
function initMouseInteractionObserver(
cb: MouseInteractionCallBack,
Expand All @@ -135,7 +133,7 @@ function initMouseInteractionObserver(
return
}
const { clientX, clientY } = isTouchEvent(event) ? event.changedTouches[0] : event
const position: MouseInteractionParam = {
const position: MouseInteraction = {
id: getSerializedNodeId(target),
type: eventTypeToMouseInteraction[event.type as keyof typeof eventTypeToMouseInteraction],
x: clientX,
Expand Down Expand Up @@ -341,7 +339,7 @@ function initMediaInteractionObserver(
}
mediaInteractionCb({
id: getSerializedNodeId(target),
type: event.type === DOM_EVENT.PLAY ? MediaInteractions.Play : MediaInteractions.Pause,
type: event.type === DOM_EVENT.PLAY ? MediaInteractionType.Play : MediaInteractionType.Pause,
})
}
return addEventListeners(document, [DOM_EVENT.PLAY, DOM_EVENT.PAUSE], handler, { capture: true, passive: true }).stop
Expand Down
14 changes: 6 additions & 8 deletions packages/rum/src/domain/record/record.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import { assign, timeStampNow } from '@datadog/browser-core'
import type { IncrementalSnapshotRecord } from '../../types'
import { RecordType } from '../../types'
import { serializeDocument } from './serialize'
import { initObservers } from './observer'
import { IncrementalSource } from './types'
import type {
IncrementalSnapshotRecord,
IncrementalData,
InputData,
RecordAPI,
RecordOptions,
MediaInteractionData,
MouseInteractionData,
MousemoveData,
MutationData,
ScrollData,
StyleSheetRuleData,
ViewportResizeData,
} from './types'
} from '../../types'
import { RecordType, IncrementalSource } from '../../types'
import { serializeDocument } from './serialize'
import { initObservers } from './observer'
import type { RecordAPI, RecordOptions } from './types'

import { MutationController } from './mutationObserver'
import { getVisualViewport, getScrollX, getScrollY, getWindowHeight, getWindowWidth } from './viewports'
Expand Down
4 changes: 2 additions & 2 deletions packages/rum/src/domain/record/serialize.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
AST_MASK_USER_INPUT,
generateLeanSerializedDoc,
} from '../../../test/htmlAst'
import type { ElementNode, SerializedNodeWithId, TextNode } from '../../types'
import { NodeType } from '../../types'
import { hasSerializedNode } from './serializationUtils'
import type { SerializeOptions } from './serialize'
import {
Expand All @@ -24,8 +26,6 @@ import {
serializeAttribute,
} from './serialize'
import { MAX_ATTRIBUTE_VALUE_CHAR_LENGTH } from './privacy'
import type { ElementNode, SerializedNodeWithId, TextNode } from './types'
import { NodeType } from './types'

const DEFAULT_OPTIONS: SerializeOptions = {
document,
Expand Down
18 changes: 9 additions & 9 deletions packages/rum/src/domain/record/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ import {
CENSORED_STRING_MARK,
CENSORED_IMG_MARK,
} from '../../constants'
import {
getTextContent,
shouldMaskNode,
reducePrivacyLevel,
getNodeSelfPrivacyLevel,
MAX_ATTRIBUTE_VALUE_CHAR_LENGTH,
} from './privacy'
import type {
SerializedNode,
SerializedNodeWithId,
Expand All @@ -21,8 +14,15 @@ import type {
ElementNode,
TextNode,
CDataNode,
} from './types'
import { NodeType } from './types'
} from '../../types'
import { NodeType } from '../../types'
import {
getTextContent,
shouldMaskNode,
reducePrivacyLevel,
getNodeSelfPrivacyLevel,
MAX_ATTRIBUTE_VALUE_CHAR_LENGTH,
} from './privacy'
import { getSerializedNodeId, setSerializedNodeId, getElementInputValue } from './serializationUtils'
import { forEach } from './utils'

Expand Down
Loading