Skip to content

Commit 26e2c93

Browse files
committed
👷 conflicts
1 parent 9acd9dc commit 26e2c93

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

‎packages/core/src/tools/globalObject.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export function getGlobalObject<T = typeof globalThis>(): T {
4848
// eslint-disable-next-line local-rules/disallow-side-effects
4949
export const globalObject = getGlobalObject<GlobalObject>()
5050

51+
export const isBrowserEnvironment = 'document' in globalObject
5152
export const isWorkerEnvironment = 'WorkerGlobalScope' in globalObject
5253
export const isNodeEnvironment =
5354
// @ts-expect-error for Node.js-specific globals that are not present in browser environments

‎packages/logs/src/boot/preStartLogs.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { TrackingConsentState } from '@datadog/browser-core'
22
import {
3+
isNodeEnvironment,
34
createBoundedBuffer,
45
canUseEventBridge,
56
display,
@@ -55,6 +56,10 @@ export function createPreStartStrategy(
5556

5657
return {
5758
init(initConfiguration, errorStack) {
59+
if (isNodeEnvironment) {
60+
return
61+
}
62+
5863
if (!initConfiguration) {
5964
display.error('Missing configuration')
6065
return

‎packages/logs/src/boot/startLogs.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { TrackingConsentState, BufferedObservable, BufferedData, PageMayExitEvent } from '@datadog/browser-core'
22
import {
3+
isBrowserEnvironment,
34
Observable,
45
sendToExtension,
56
createPageMayExitObservable,
@@ -11,7 +12,6 @@ import {
1112
TelemetryService,
1213
createIdentityEncoder,
1314
startUserContext,
14-
isWorkerEnvironment,
1515
} from '@datadog/browser-core'
1616
import { startLogsSessionManager, startLogsSessionManagerStub } from '../domain/logsSessionManager'
1717
import type { LogsConfiguration } from '../domain/configuration'
@@ -55,7 +55,7 @@ export function startLogs(
5555

5656
const reportError = startReportError(lifeCycle)
5757
// Page exit is not observable in worker environments (no window/document events)
58-
const pageMayExitObservable = isWorkerEnvironment
58+
const pageMayExitObservable = !isBrowserEnvironment
5959
? new Observable<PageMayExitEvent>()
6060
: createPageMayExitObservable(configuration)
6161

‎packages/logs/src/domain/networkError/networkErrorCollection.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { FetchResolveContext, XhrCompleteContext } from '@datadog/browser-core'
22
import {
3-
isWorkerEnvironment,
3+
isBrowserEnvironment,
44
Observable,
55
ErrorSource,
66
initXhrObservable,
@@ -28,7 +28,7 @@ export function startNetworkErrorCollection(configuration: LogsConfiguration, li
2828

2929
// XHR is not available in web workers, so we use an empty observable that never emits
3030
const xhrSubscription = (
31-
isWorkerEnvironment ? new Observable<XhrCompleteContext>() : initXhrObservable(configuration)
31+
!isBrowserEnvironment ? new Observable<XhrCompleteContext>() : initXhrObservable(configuration)
3232
).subscribe((context) => {
3333
if (context.state === 'complete') {
3434
handleResponse(RequestType.XHR, context)

‎packages/rum-core/src/boot/preStartRum.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { TrackingConsentState, DeflateWorker, Context, ContextManager, BoundedBuffer } from '@datadog/browser-core'
22
import {
3+
isNodeEnvironment,
34
createBoundedBuffer,
45
display,
56
canUseEventBridge,
@@ -100,6 +101,10 @@ export function createPreStartStrategy(
100101
}
101102

102103
function doInit(initConfiguration: RumInitConfiguration, errorStack?: string) {
104+
if (isNodeEnvironment) {
105+
return
106+
}
107+
103108
const eventBridgeAvailable = canUseEventBridge()
104109
if (eventBridgeAvailable) {
105110
initConfiguration = overrideInitConfigurationForBridge(initConfiguration)

0 commit comments

Comments
 (0)