Skip to content

Commit

Permalink
♻️ move deflate-worker to rum-core
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-lebeau committed Nov 15, 2024
1 parent 35e9bb6 commit 5506507
Show file tree
Hide file tree
Showing 17 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion packages/rum-core/src/boot/preStartRum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
initFetchObservable,
} from '@datadog/browser-core'
import type { TrackingConsentState, DeflateWorker } from '@datadog/browser-core'
import { DeflateWorkerStatus, getDeflateWorkerStatus } from '../../../rum/src/domain/deflate'
import { DeflateWorkerStatus, getDeflateWorkerStatus } from '../domain/deflate'
import {
validateAndBuildRumConfiguration,
type RumConfiguration,
Expand Down
2 changes: 1 addition & 1 deletion packages/rum-core/src/boot/rumPublicApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
createTrackingConsentState,
timeStampToClocks,
} from '@datadog/browser-core'
import { DeflateWorkerStatus, getDeflateWorkerStatus } from '../../../rum/src/domain/deflate'
import { DeflateWorkerStatus, getDeflateWorkerStatus } from '../domain/deflate'
import type { LifeCycle } from '../domain/lifeCycle'
import type { ViewHistory } from '../domain/contexts/viewHistory'
import type { RumSessionManager } from '../domain/rumSessionManager'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type {
DeflateWorker,
EncoderResult,
} from '@datadog/browser-core'
import type { RumConfiguration } from '@datadog/browser-rum-core'
import { addEventListener, addTelemetryDebug, assign, concatBuffers } from '@datadog/browser-core'
import type { RumConfiguration } from '../configuration'

export function createDeflateEncoder(
configuration: RumConfiguration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ONE_SECOND,
DOCS_ORIGIN,
} from '@datadog/browser-core'
import type { RumConfiguration } from '@datadog/browser-rum-core'
import type { RumConfiguration } from '../configuration'

export const INITIALIZATION_TIME_OUT_DELAY = 30 * ONE_SECOND

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions packages/rum-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ export * from './domain/privacy'
export { SessionReplayState } from './domain/rumSessionManager'
export type { RumPlugin } from './domain/plugins'
export type { MouseEventOnElement } from './domain/action/listenActionEvents'
export * from './domain/deflate'
1 change: 1 addition & 0 deletions packages/rum-core/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export * from './mockPageStateHistory'
export * from './mockRumConfiguration'
export * from './locationChangeSetup'
export * from './mockContexts'
export * from './mockWorker'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { DeflateWorker, DeflateWorkerAction, DeflateWorkerResponse } from '@datadog/browser-core'
import { createNewEvent } from '@datadog/browser-core/test'
import { string2buf } from '../../worker/src/domain/deflate'
import { createNewEvent } from '../../core/test'

type DeflateWorkerListener = (event: { data: DeflateWorkerResponse }) => void

Expand Down
8 changes: 3 additions & 5 deletions packages/rum/src/boot/recorderApi.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import type { DeflateEncoder, DeflateWorker, DeflateWorkerAction } from '@datadog/browser-core'
import { BridgeCapability, PageExitReason, display, isIE } from '@datadog/browser-core'
import type { RecorderApi, RumSessionManager } from '@datadog/browser-rum-core'
import { LifeCycle, LifeCycleEventType } from '@datadog/browser-rum-core'
import type { RecorderApi, RumSessionManager, CreateDeflateWorker } from '@datadog/browser-rum-core'
import { LifeCycle, LifeCycleEventType, resetDeflateWorkerState } from '@datadog/browser-rum-core'
import { mockEventBridge, registerCleanupTask } from '@datadog/browser-core/test'
import { MockWorker } from '@datadog/browser-rum-core/test'
import type { RumSessionManagerMock } from '../../../rum-core/test'
import {
createRumSessionManagerMock,
mockDocumentReadyState,
mockRumConfiguration,
mockViewHistory,
} from '../../../rum-core/test'
import type { CreateDeflateWorker } from '../domain/deflate'
import { MockWorker } from '../../test'
import { resetDeflateWorkerState } from '../domain/deflate'
import * as replayStats from '../domain/replayStats'
import type { StartRecording } from './recorderApi'
import { makeRecorderApi } from './recorderApi'
Expand Down
11 changes: 6 additions & 5 deletions packages/rum/src/boot/recorderApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ import type {
RecorderApi,
RumConfiguration,
StartRecordingOptions,
CreateDeflateWorker,
} from '@datadog/browser-rum-core'
import { LifeCycleEventType, SessionReplayState } from '@datadog/browser-rum-core'
import { getReplayStats as getReplayStatsImpl } from '../domain/replayStats'
import { getSessionReplayLink } from '../domain/getSessionReplayLink'
import type { CreateDeflateWorker } from '../domain/deflate'
import {
LifeCycleEventType,
SessionReplayState,
createDeflateEncoder,
startDeflateWorker,
DeflateWorkerStatus,
getDeflateWorkerStatus,
} from '../domain/deflate'
} from '@datadog/browser-rum-core'
import { getReplayStats as getReplayStatsImpl } from '../domain/replayStats'
import { getSessionReplayLink } from '../domain/getSessionReplayLink'

import type { startRecording } from './startRecording'
import { isBrowserSupported } from './isBrowserSupported'
Expand Down
10 changes: 8 additions & 2 deletions packages/rum/src/boot/startRecording.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import type { TimeStamp, HttpRequest } from '@datadog/browser-core'
import { PageExitReason, DefaultPrivacyLevel, noop, isIE, DeflateEncoderStreamId } from '@datadog/browser-core'
import type { ViewCreatedEvent } from '@datadog/browser-rum-core'
import { LifeCycle, LifeCycleEventType, startViewHistory } from '@datadog/browser-rum-core'
import {
createDeflateEncoder,
LifeCycle,
LifeCycleEventType,
resetDeflateWorkerState,
startDeflateWorker,
startViewHistory,
} from '@datadog/browser-rum-core'
import { collectAsyncCalls, createNewEvent, mockEventBridge, registerCleanupTask } from '@datadog/browser-core/test'
import type { ViewEndedEvent } from 'packages/rum-core/src/domain/view/trackViews'
import type { RumSessionManagerMock } from '../../../rum-core/test'
Expand All @@ -12,7 +19,6 @@ import { setSegmentBytesLimit } from '../domain/segmentCollection'

import { RecordType } from '../types'
import { resetReplayStats } from '../domain/replayStats'
import { createDeflateEncoder, resetDeflateWorkerState, startDeflateWorker } from '../domain/deflate'
import { startRecording } from './startRecording'

const VIEW_TIMESTAMP = 1 as TimeStamp
Expand Down
5 changes: 2 additions & 3 deletions packages/rum/src/domain/segmentCollection/segment.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import type { DeflateEncoder, TimeStamp } from '@datadog/browser-core'
import { noop, setDebugMode, isIE, DeflateEncoderStreamId } from '@datadog/browser-core'
import type { RumConfiguration } from '@datadog/browser-rum-core'
import { createDeflateEncoder, type RumConfiguration } from '@datadog/browser-rum-core'
import { registerCleanupTask } from '@datadog/browser-core/test'
import { MockWorker } from '../../../test'
import { MockWorker } from '@datadog/browser-rum-core/test'
import type { CreationReason, BrowserRecord, SegmentContext, BrowserSegment, BrowserSegmentMetadata } from '../../types'
import { RecordType } from '../../types'
import { getReplayStats, resetReplayStats } from '../replayStats'
import { createDeflateEncoder } from '../deflate'
import type { AddRecordCallback, FlushCallback, Segment } from './segment'
import { createSegment } from './segment'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import type { ClocksState, HttpRequest, TimeStamp } from '@datadog/browser-core'
import { DeflateEncoderStreamId, PageExitReason, isIE } from '@datadog/browser-core'
import type { ViewHistory, ViewHistoryEntry, RumConfiguration } from '@datadog/browser-rum-core'
import { LifeCycle, LifeCycleEventType } from '@datadog/browser-rum-core'
import { createDeflateEncoder, LifeCycle, LifeCycleEventType } from '@datadog/browser-rum-core'
import type { Clock } from '@datadog/browser-core/test'
import { mockClock, registerCleanupTask, restorePageVisibility } from '@datadog/browser-core/test'
import { createRumSessionManagerMock } from '../../../../rum-core/test'
import { createRumSessionManagerMock, MockWorker } from '../../../../rum-core/test'
import type { BrowserRecord, SegmentContext } from '../../types'
import { RecordType } from '../../types'
import { MockWorker, readMetadataFromReplayPayload } from '../../../test'
import { createDeflateEncoder } from '../deflate'
import { readMetadataFromReplayPayload } from '../../../test'
import {
computeSegmentContext,
doStartSegmentCollection,
Expand Down
3 changes: 1 addition & 2 deletions packages/rum/src/entries/main.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Keep the following in sync with packages/rum-slim/src/entries/main.ts
import { defineGlobal, getGlobalObject } from '@datadog/browser-core'
import type { RumPublicApi } from '@datadog/browser-rum-core'
import { makeRumPublicApi, startRum } from '@datadog/browser-rum-core'
import { makeRumPublicApi, startRum, startDeflateWorker, createDeflateEncoder } from '@datadog/browser-rum-core'

import { startRecording } from '../boot/startRecording'
import { makeRecorderApi } from '../boot/recorderApi'
import { createDeflateEncoder, startDeflateWorker } from '../domain/deflate'

export {
CommonProperties,
Expand Down
1 change: 0 additions & 1 deletion packages/rum/test/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './mockWorker'
export * from './recordsPerFullSnapshot'
export * from './mutationPayloadValidator'
export * from './nodes'
Expand Down

0 comments on commit 5506507

Please sign in to comment.