@datadog/browser-rum-core
Advanced tools
Comparing version 3.7.0 to 3.8.0
@@ -6,4 +6,4 @@ "use strict"; | ||
buildMode: 'release', | ||
sdkVersion: '3.7.0', | ||
sdkVersion: '3.8.0', | ||
}; | ||
//# sourceMappingURL=buildEnv.js.map |
@@ -38,3 +38,3 @@ "use strict"; | ||
function initRum(initConfiguration) { | ||
if (browser_core_1.isEventBridgePresent()) { | ||
if (browser_core_1.canUseEventBridge()) { | ||
initConfiguration = overrideInitConfigurationForBridge(initConfiguration); | ||
@@ -41,0 +41,0 @@ } |
@@ -25,3 +25,3 @@ "use strict"; | ||
var lifeCycle = new lifeCycle_1.LifeCycle(); | ||
var session = !browser_core_1.isEventBridgePresent() ? rumSession_1.startRumSession(configuration, lifeCycle) : rumSession_1.startRumSessionStub(); | ||
var session = !browser_core_1.canUseEventBridge() ? rumSession_1.startRumSession(configuration, lifeCycle) : rumSession_1.startRumSessionStub(); | ||
var domMutationObservable = domMutationObservable_1.createDOMMutationObservable(); | ||
@@ -60,3 +60,3 @@ var locationChangeObservable = locationChangeObservable_1.createLocationChangeObservable(location); | ||
var stopBatch; | ||
if (browser_core_1.isEventBridgePresent()) { | ||
if (browser_core_1.canUseEventBridge()) { | ||
startRumEventBridge_1.startRumEventBridge(lifeCycle); | ||
@@ -63,0 +63,0 @@ } |
@@ -12,1 +12,3 @@ import { Configuration } from '@datadog/browser-core'; | ||
export declare function startRumAssembly(applicationId: string, configuration: Configuration, lifeCycle: LifeCycle, session: RumSession, parentContexts: ParentContexts, urlContexts: UrlContexts, getCommonContext: () => CommonContext): void; | ||
export declare const SYNTHETICS_TEST_ID_COOKIE_NAME = "datadog-synthetics-public-id"; | ||
export declare const SYNTHETICS_RESULT_ID_COOKIE_NAME = "datadog-synthetics-result-id"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.startRumAssembly = void 0; | ||
exports.SYNTHETICS_RESULT_ID_COOKIE_NAME = exports.SYNTHETICS_TEST_ID_COOKIE_NAME = exports.startRumAssembly = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -37,2 +37,3 @@ var browser_core_1 = require("@datadog/browser-core"); | ||
_a); | ||
var syntheticsContext = getSyntheticsContext(); | ||
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, function (_a) { | ||
@@ -59,6 +60,5 @@ var startTime = _a.startTime, rawRumEvent = _a.rawRumEvent, domainContext = _a.domainContext, savedCommonContext = _a.savedCommonContext, customerContext = _a.customerContext; | ||
session: { | ||
// must be computed on each event because synthetics instrumentation can be done after sdk execution | ||
type: getSessionType(), | ||
type: syntheticsContext ? SessionType.SYNTHETICS : SessionType.USER, | ||
}, | ||
synthetics: getSyntheticsContext(), | ||
synthetics: syntheticsContext, | ||
}; | ||
@@ -104,10 +104,7 @@ var serverRumEvent = (needToAssembleWithAction(rawRumEvent) | ||
} | ||
function getSessionType() { | ||
return navigator.userAgent.indexOf('DatadogSynthetics') === -1 && !getSyntheticsContext() | ||
? SessionType.USER | ||
: SessionType.SYNTHETICS; | ||
} | ||
exports.SYNTHETICS_TEST_ID_COOKIE_NAME = 'datadog-synthetics-public-id'; | ||
exports.SYNTHETICS_RESULT_ID_COOKIE_NAME = 'datadog-synthetics-result-id'; | ||
function getSyntheticsContext() { | ||
var testId = window._DATADOG_SYNTHETICS_PUBLIC_ID; | ||
var resultId = window._DATADOG_SYNTHETICS_RESULT_ID; | ||
var testId = window._DATADOG_SYNTHETICS_PUBLIC_ID || browser_core_1.getCookie(exports.SYNTHETICS_TEST_ID_COOKIE_NAME); | ||
var resultId = window._DATADOG_SYNTHETICS_RESULT_ID || browser_core_1.getCookie(exports.SYNTHETICS_RESULT_ID_COOKIE_NAME); | ||
if (typeof testId === 'string' && typeof resultId === 'string') { | ||
@@ -114,0 +111,0 @@ return { |
@@ -13,3 +13,2 @@ import { Duration, EventEmitter, RelativeTime } from '@datadog/browser-core'; | ||
firstInputTime?: Duration; | ||
lcpDiscardReason?: string; | ||
} | ||
@@ -31,3 +30,3 @@ export declare function trackInitialViewTimings(lifeCycle: LifeCycle, callback: (timings: Timings) => void): { | ||
*/ | ||
export declare function trackLargestContentfulPaintTiming(lifeCycle: LifeCycle, emitter: EventEmitter, callback: (lcpTiming: RelativeTime) => void, discardCallback: (discardReason: string) => void): { | ||
export declare function trackLargestContentfulPaintTiming(lifeCycle: LifeCycle, emitter: EventEmitter, callback: (lcpTiming: RelativeTime) => void): { | ||
stop: () => void; | ||
@@ -34,0 +33,0 @@ }; |
@@ -25,6 +25,2 @@ "use strict"; | ||
}); | ||
}, function (lcpDiscardReason) { | ||
setTimings({ | ||
lcpDiscardReason: lcpDiscardReason, | ||
}); | ||
}).stop; | ||
@@ -81,3 +77,3 @@ var stopFIDTracking = trackFirstInputTimings(lifeCycle, function (_a) { | ||
*/ | ||
function trackLargestContentfulPaintTiming(lifeCycle, emitter, callback, discardCallback) { | ||
function trackLargestContentfulPaintTiming(lifeCycle, emitter, callback) { | ||
var firstHidden = trackFirstHidden_1.trackFirstHidden(); | ||
@@ -91,8 +87,5 @@ // Ignore entries that come after the first user interaction. According to the documentation, the | ||
}, { capture: true, once: true }).stop; | ||
var isFirstLCP = true; | ||
var unsubscribeLifeCycle = lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, function (entry) { | ||
if (entry.entryType !== 'largest-contentful-paint') { | ||
return; | ||
} | ||
if (entry.startTime < firstInteractionTimestamp && | ||
if (entry.entryType === 'largest-contentful-paint' && | ||
entry.startTime < firstInteractionTimestamp && | ||
entry.startTime < firstHidden.timeStamp && | ||
@@ -102,13 +95,2 @@ entry.startTime < exports.TIMING_MAXIMUM_DELAY) { | ||
} | ||
else if (isFirstLCP) { | ||
var reason = entry.startTime >= firstInteractionTimestamp | ||
? 'interaction' | ||
: entry.startTime >= firstHidden.timeStamp | ||
? 'hidden' | ||
: entry.startTime >= exports.TIMING_MAXIMUM_DELAY | ||
? 'maximum delay' | ||
: 'N/A'; | ||
discardCallback(reason); | ||
} | ||
isFirstLCP = false; | ||
}).unsubscribe; | ||
@@ -115,0 +97,0 @@ return { |
@@ -7,3 +7,2 @@ "use strict"; | ||
var lifeCycle_1 = require("../../lifeCycle"); | ||
var performanceCollection_1 = require("../../../browser/performanceCollection"); | ||
var trackViews_1 = require("./trackViews"); | ||
@@ -68,10 +67,2 @@ function startViewCollection(lifeCycle, configuration, location, domMutationObservable, locationChangeObservable, foregroundContexts, recorderApi, initialViewName) { | ||
}, | ||
customerContext: browser_core_1.isExperimentalFeatureEnabled('monitor-dropped-lcp') && view.loadingType === 'initial_load' | ||
? { | ||
lcp: { | ||
support: performanceCollection_1.supportPerformanceTimingEvent('largest-contentful-paint'), | ||
discard_reason: view.timings.lcpDiscardReason, | ||
}, | ||
} | ||
: undefined, | ||
}; | ||
@@ -78,0 +69,0 @@ } |
export var buildEnv = { | ||
buildMode: 'release', | ||
sdkVersion: '3.7.0', | ||
sdkVersion: '3.8.0', | ||
}; | ||
//# sourceMappingURL=buildEnv.js.map |
import { __assign } from "tslib"; | ||
import { BoundedBuffer, buildCookieOptions, createContextManager, deepClone, isPercentage, makePublicApi, monitor, clocksNow, timeStampNow, display, commonInit, callMonitored, createHandlingStack, isEventBridgePresent, areCookiesAuthorized, } from '@datadog/browser-core'; | ||
import { BoundedBuffer, buildCookieOptions, createContextManager, deepClone, isPercentage, makePublicApi, monitor, clocksNow, timeStampNow, display, commonInit, callMonitored, createHandlingStack, canUseEventBridge, areCookiesAuthorized, } from '@datadog/browser-core'; | ||
import { ActionType } from '../rawRumEvent.types'; | ||
@@ -35,3 +35,3 @@ import { buildEnv } from './buildEnv'; | ||
function initRum(initConfiguration) { | ||
if (isEventBridgePresent()) { | ||
if (canUseEventBridge()) { | ||
initConfiguration = overrideInitConfigurationForBridge(initConfiguration); | ||
@@ -38,0 +38,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { combine, isEventBridgePresent } from '@datadog/browser-core'; | ||
import { combine, canUseEventBridge } from '@datadog/browser-core'; | ||
import { createDOMMutationObservable } from '../browser/domMutationObservable'; | ||
@@ -22,3 +22,3 @@ import { startPerformanceCollection } from '../browser/performanceCollection'; | ||
var lifeCycle = new LifeCycle(); | ||
var session = !isEventBridgePresent() ? startRumSession(configuration, lifeCycle) : startRumSessionStub(); | ||
var session = !canUseEventBridge() ? startRumSession(configuration, lifeCycle) : startRumSessionStub(); | ||
var domMutationObservable = createDOMMutationObservable(); | ||
@@ -56,3 +56,3 @@ var locationChangeObservable = createLocationChangeObservable(location); | ||
var stopBatch; | ||
if (isEventBridgePresent()) { | ||
if (canUseEventBridge()) { | ||
startRumEventBridge(lifeCycle); | ||
@@ -59,0 +59,0 @@ } |
@@ -12,1 +12,3 @@ import { Configuration } from '@datadog/browser-core'; | ||
export declare function startRumAssembly(applicationId: string, configuration: Configuration, lifeCycle: LifeCycle, session: RumSession, parentContexts: ParentContexts, urlContexts: UrlContexts, getCommonContext: () => CommonContext): void; | ||
export declare const SYNTHETICS_TEST_ID_COOKIE_NAME = "datadog-synthetics-public-id"; | ||
export declare const SYNTHETICS_RESULT_ID_COOKIE_NAME = "datadog-synthetics-result-id"; |
import { __spreadArrays } from "tslib"; | ||
import { combine, isEmptyObject, limitModification, timeStampNow, currentDrift, display, createEventRateLimiter, } from '@datadog/browser-core'; | ||
import { combine, isEmptyObject, limitModification, timeStampNow, currentDrift, display, createEventRateLimiter, getCookie, } from '@datadog/browser-core'; | ||
import { RumEventType, } from '../rawRumEvent.types'; | ||
@@ -34,2 +34,3 @@ import { LifeCycleEventType } from './lifeCycle'; | ||
_a); | ||
var syntheticsContext = getSyntheticsContext(); | ||
lifeCycle.subscribe(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, function (_a) { | ||
@@ -56,6 +57,5 @@ var startTime = _a.startTime, rawRumEvent = _a.rawRumEvent, domainContext = _a.domainContext, savedCommonContext = _a.savedCommonContext, customerContext = _a.customerContext; | ||
session: { | ||
// must be computed on each event because synthetics instrumentation can be done after sdk execution | ||
type: getSessionType(), | ||
type: syntheticsContext ? SessionType.SYNTHETICS : SessionType.USER, | ||
}, | ||
synthetics: getSyntheticsContext(), | ||
synthetics: syntheticsContext, | ||
}; | ||
@@ -100,10 +100,7 @@ var serverRumEvent = (needToAssembleWithAction(rawRumEvent) | ||
} | ||
function getSessionType() { | ||
return navigator.userAgent.indexOf('DatadogSynthetics') === -1 && !getSyntheticsContext() | ||
? SessionType.USER | ||
: SessionType.SYNTHETICS; | ||
} | ||
export var SYNTHETICS_TEST_ID_COOKIE_NAME = 'datadog-synthetics-public-id'; | ||
export var SYNTHETICS_RESULT_ID_COOKIE_NAME = 'datadog-synthetics-result-id'; | ||
function getSyntheticsContext() { | ||
var testId = window._DATADOG_SYNTHETICS_PUBLIC_ID; | ||
var resultId = window._DATADOG_SYNTHETICS_RESULT_ID; | ||
var testId = window._DATADOG_SYNTHETICS_PUBLIC_ID || getCookie(SYNTHETICS_TEST_ID_COOKIE_NAME); | ||
var resultId = window._DATADOG_SYNTHETICS_RESULT_ID || getCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME); | ||
if (typeof testId === 'string' && typeof resultId === 'string') { | ||
@@ -110,0 +107,0 @@ return { |
@@ -13,3 +13,2 @@ import { Duration, EventEmitter, RelativeTime } from '@datadog/browser-core'; | ||
firstInputTime?: Duration; | ||
lcpDiscardReason?: string; | ||
} | ||
@@ -31,3 +30,3 @@ export declare function trackInitialViewTimings(lifeCycle: LifeCycle, callback: (timings: Timings) => void): { | ||
*/ | ||
export declare function trackLargestContentfulPaintTiming(lifeCycle: LifeCycle, emitter: EventEmitter, callback: (lcpTiming: RelativeTime) => void, discardCallback: (discardReason: string) => void): { | ||
export declare function trackLargestContentfulPaintTiming(lifeCycle: LifeCycle, emitter: EventEmitter, callback: (lcpTiming: RelativeTime) => void): { | ||
stop: () => void; | ||
@@ -34,0 +33,0 @@ }; |
@@ -22,6 +22,2 @@ import { __assign } from "tslib"; | ||
}); | ||
}, function (lcpDiscardReason) { | ||
setTimings({ | ||
lcpDiscardReason: lcpDiscardReason, | ||
}); | ||
}).stop; | ||
@@ -75,3 +71,3 @@ var stopFIDTracking = trackFirstInputTimings(lifeCycle, function (_a) { | ||
*/ | ||
export function trackLargestContentfulPaintTiming(lifeCycle, emitter, callback, discardCallback) { | ||
export function trackLargestContentfulPaintTiming(lifeCycle, emitter, callback) { | ||
var firstHidden = trackFirstHidden(); | ||
@@ -85,8 +81,5 @@ // Ignore entries that come after the first user interaction. According to the documentation, the | ||
}, { capture: true, once: true }).stop; | ||
var isFirstLCP = true; | ||
var unsubscribeLifeCycle = lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, function (entry) { | ||
if (entry.entryType !== 'largest-contentful-paint') { | ||
return; | ||
} | ||
if (entry.startTime < firstInteractionTimestamp && | ||
if (entry.entryType === 'largest-contentful-paint' && | ||
entry.startTime < firstInteractionTimestamp && | ||
entry.startTime < firstHidden.timeStamp && | ||
@@ -96,13 +89,2 @@ entry.startTime < TIMING_MAXIMUM_DELAY) { | ||
} | ||
else if (isFirstLCP) { | ||
var reason = entry.startTime >= firstInteractionTimestamp | ||
? 'interaction' | ||
: entry.startTime >= firstHidden.timeStamp | ||
? 'hidden' | ||
: entry.startTime >= TIMING_MAXIMUM_DELAY | ||
? 'maximum delay' | ||
: 'N/A'; | ||
discardCallback(reason); | ||
} | ||
isFirstLCP = false; | ||
}).unsubscribe; | ||
@@ -109,0 +91,0 @@ return { |
@@ -1,5 +0,4 @@ | ||
import { isEmptyObject, mapValues, toServerDuration, isNumber, isExperimentalFeatureEnabled, } from '@datadog/browser-core'; | ||
import { isEmptyObject, mapValues, toServerDuration, isNumber, } from '@datadog/browser-core'; | ||
import { RumEventType } from '../../../rawRumEvent.types'; | ||
import { LifeCycleEventType } from '../../lifeCycle'; | ||
import { supportPerformanceTimingEvent } from '../../../browser/performanceCollection'; | ||
import { trackViews } from './trackViews'; | ||
@@ -63,10 +62,2 @@ export function startViewCollection(lifeCycle, configuration, location, domMutationObservable, locationChangeObservable, foregroundContexts, recorderApi, initialViewName) { | ||
}, | ||
customerContext: isExperimentalFeatureEnabled('monitor-dropped-lcp') && view.loadingType === 'initial_load' | ||
? { | ||
lcp: { | ||
support: supportPerformanceTimingEvent('largest-contentful-paint'), | ||
discard_reason: view.timings.lcpDiscardReason, | ||
}, | ||
} | ||
: undefined, | ||
}; | ||
@@ -73,0 +64,0 @@ } |
{ | ||
"name": "@datadog/browser-rum-core", | ||
"version": "3.7.0", | ||
"version": "3.8.0", | ||
"license": "Apache-2.0", | ||
@@ -15,3 +15,3 @@ "main": "cjs/index.js", | ||
"dependencies": { | ||
"@datadog/browser-core": "3.7.0", | ||
"@datadog/browser-core": "3.8.0", | ||
"tslib": "^1.10.0" | ||
@@ -27,3 +27,3 @@ }, | ||
}, | ||
"gitHead": "e0138aa0a04098f2091b19057717d30a009dbdbb" | ||
"gitHead": "523c091490bd41647d4cbc52a3d01e33b1ed1c55" | ||
} |
@@ -22,3 +22,3 @@ import { | ||
RelativeTime, | ||
isEventBridgePresent, | ||
canUseEventBridge, | ||
areCookiesAuthorized, | ||
@@ -101,3 +101,3 @@ } from '@datadog/browser-core' | ||
function initRum(initConfiguration: C) { | ||
if (isEventBridgePresent()) { | ||
if (canUseEventBridge()) { | ||
initConfiguration = overrideInitConfigurationForBridge(initConfiguration) | ||
@@ -104,0 +104,0 @@ } else if (!canHandleSession(initConfiguration)) { |
@@ -1,2 +0,2 @@ | ||
import { combine, Configuration, InternalMonitoring, isEventBridgePresent, Observable } from '@datadog/browser-core' | ||
import { combine, Configuration, InternalMonitoring, canUseEventBridge, Observable } from '@datadog/browser-core' | ||
import { createDOMMutationObservable } from '../browser/domMutationObservable' | ||
@@ -32,3 +32,3 @@ import { startPerformanceCollection } from '../browser/performanceCollection' | ||
const lifeCycle = new LifeCycle() | ||
const session = !isEventBridgePresent() ? startRumSession(configuration, lifeCycle) : startRumSessionStub() | ||
const session = !canUseEventBridge() ? startRumSession(configuration, lifeCycle) : startRumSessionStub() | ||
const domMutationObservable = createDOMMutationObservable() | ||
@@ -104,3 +104,3 @@ const locationChangeObservable = createLocationChangeObservable(location) | ||
if (isEventBridgePresent()) { | ||
if (canUseEventBridge()) { | ||
startRumEventBridge(lifeCycle) | ||
@@ -107,0 +107,0 @@ } else { |
@@ -1,3 +0,3 @@ | ||
import { ErrorSource, ONE_MINUTE, RawError, RelativeTime, display } from '@datadog/browser-core' | ||
import { setUserAgent, restoreUserAgent } from '@datadog/browser-core/test/specHelper' | ||
import { ErrorSource, ONE_MINUTE, RawError, RelativeTime, display, setCookie } from '@datadog/browser-core' | ||
import { deleteCookie } from 'packages/core/src/browser/cookie' | ||
import { createRumSessionMock } from 'packages/rum-core/test/mockRumSession' | ||
@@ -9,6 +9,14 @@ import { createRawRumEvent } from '../../test/fixtures' | ||
import { RumActionEvent, RumErrorEvent, RumEvent } from '../rumEvent.types' | ||
import { BrowserWindow, startRumAssembly } from './assembly' | ||
import { | ||
BrowserWindow, | ||
startRumAssembly, | ||
SYNTHETICS_RESULT_ID_COOKIE_NAME, | ||
SYNTHETICS_TEST_ID_COOKIE_NAME, | ||
} from './assembly' | ||
import { LifeCycle, LifeCycleEventType, RawRumEventCollectedData } from './lifeCycle' | ||
import { RumSessionPlan } from './rumSession' | ||
// Duration to create a cookie lasting at least until the end of the test | ||
const COOKIE_DURATION = 1000 | ||
describe('rum assembly', () => { | ||
@@ -62,2 +70,4 @@ let setupBuilder: TestSetupBuilder | ||
cleanupSyntheticsGlobals() | ||
deleteCookie(SYNTHETICS_TEST_ID_COOKIE_NAME) | ||
deleteCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME) | ||
}) | ||
@@ -522,4 +532,4 @@ | ||
it('should detect synthetics sessions from UA', () => { | ||
setUserAgent('foo DatadogSynthetics bar') | ||
it('should detect synthetics sessions from global', () => { | ||
setSyntheticsGlobals('foo', 'bar') | ||
@@ -532,7 +542,7 @@ const { lifeCycle } = setupBuilder.build() | ||
expect(serverRumEvents[0].session.type).toEqual('synthetics') | ||
restoreUserAgent() | ||
}) | ||
it('should detect synthetics sessions from global', () => { | ||
setSyntheticsGlobals('foo', 'bar') | ||
it('should detect synthetics sessions from cookies', () => { | ||
setCookie(SYNTHETICS_TEST_ID_COOKIE_NAME, 'foo', COOKIE_DURATION) | ||
setCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME, 'bar', COOKIE_DURATION) | ||
@@ -583,2 +593,17 @@ const { lifeCycle } = setupBuilder.build() | ||
it('sets the synthetics context defined by global cookie', () => { | ||
setCookie(SYNTHETICS_TEST_ID_COOKIE_NAME, 'foo', COOKIE_DURATION) | ||
setCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME, 'bar', COOKIE_DURATION) | ||
const { lifeCycle } = setupBuilder.build() | ||
notifyRawRumEvent(lifeCycle, { | ||
rawRumEvent: createRawRumEvent(RumEventType.VIEW), | ||
}) | ||
expect(serverRumEvents[0].synthetics).toEqual({ | ||
test_id: 'foo', | ||
result_id: 'bar', | ||
}) | ||
}) | ||
it('does not set synthetics context if one global variable is undefined', () => { | ||
@@ -605,2 +630,13 @@ setSyntheticsGlobals('foo') | ||
}) | ||
it('does not set synthetics context if one cookie is undefined', () => { | ||
setCookie(SYNTHETICS_TEST_ID_COOKIE_NAME, 'foo', COOKIE_DURATION) | ||
const { lifeCycle } = setupBuilder.build() | ||
notifyRawRumEvent(lifeCycle, { | ||
rawRumEvent: createRawRumEvent(RumEventType.VIEW), | ||
}) | ||
expect(serverRumEvents[0].synthetics).toBeUndefined() | ||
}) | ||
}) | ||
@@ -607,0 +643,0 @@ |
@@ -14,2 +14,3 @@ import { | ||
EventRateLimiter, | ||
getCookie, | ||
} from '@datadog/browser-core' | ||
@@ -80,2 +81,4 @@ import { RumEventDomainContext } from '../domainContext.types' | ||
const syntheticsContext = getSyntheticsContext() | ||
lifeCycle.subscribe( | ||
@@ -103,6 +106,5 @@ LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, | ||
session: { | ||
// must be computed on each event because synthetics instrumentation can be done after sdk execution | ||
type: getSessionType(), | ||
type: syntheticsContext ? SessionType.SYNTHETICS : SessionType.USER, | ||
}, | ||
synthetics: getSyntheticsContext(), | ||
synthetics: syntheticsContext, | ||
} | ||
@@ -163,11 +165,9 @@ const serverRumEvent = (needToAssembleWithAction(rawRumEvent) | ||
function getSessionType() { | ||
return navigator.userAgent.indexOf('DatadogSynthetics') === -1 && !getSyntheticsContext() | ||
? SessionType.USER | ||
: SessionType.SYNTHETICS | ||
} | ||
export const SYNTHETICS_TEST_ID_COOKIE_NAME = 'datadog-synthetics-public-id' | ||
export const SYNTHETICS_RESULT_ID_COOKIE_NAME = 'datadog-synthetics-result-id' | ||
function getSyntheticsContext() { | ||
const testId = (window as BrowserWindow)._DATADOG_SYNTHETICS_PUBLIC_ID | ||
const resultId = (window as BrowserWindow)._DATADOG_SYNTHETICS_RESULT_ID | ||
const testId = (window as BrowserWindow)._DATADOG_SYNTHETICS_PUBLIC_ID || getCookie(SYNTHETICS_TEST_ID_COOKIE_NAME) | ||
const resultId = | ||
(window as BrowserWindow)._DATADOG_SYNTHETICS_RESULT_ID || getCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME) | ||
@@ -174,0 +174,0 @@ if (typeof testId === 'string' && typeof resultId === 'string') { |
@@ -155,3 +155,2 @@ import { DOM_EVENT, Duration, RelativeTime } from '@datadog/browser-core' | ||
let lcpCallback: jasmine.Spy<(value: RelativeTime) => void> | ||
let discardCallback: jasmine.Spy<(discardReason: string) => void> | ||
let emitter: Element | ||
@@ -161,6 +160,5 @@ | ||
lcpCallback = jasmine.createSpy() | ||
discardCallback = jasmine.createSpy() | ||
emitter = document.createElement('div') | ||
setupBuilder = setup().beforeBuild(({ lifeCycle }) => | ||
trackLargestContentfulPaintTiming(lifeCycle, emitter, lcpCallback, discardCallback) | ||
trackLargestContentfulPaintTiming(lifeCycle, emitter, lcpCallback) | ||
) | ||
@@ -191,3 +189,2 @@ resetFirstHidden() | ||
expect(lcpCallback).not.toHaveBeenCalled() | ||
expect(discardCallback).toHaveBeenCalledOnceWith('interaction') | ||
}) | ||
@@ -202,3 +199,2 @@ | ||
expect(lcpCallback).not.toHaveBeenCalled() | ||
expect(discardCallback).toHaveBeenCalledOnceWith('hidden') | ||
}) | ||
@@ -214,3 +210,2 @@ | ||
expect(lcpCallback).not.toHaveBeenCalled() | ||
expect(discardCallback).toHaveBeenCalledOnceWith('maximum delay') | ||
}) | ||
@@ -217,0 +212,0 @@ }) |
@@ -26,3 +26,2 @@ import { | ||
firstInputTime?: Duration | ||
lcpDiscardReason?: string | ||
} | ||
@@ -41,16 +40,7 @@ | ||
) | ||
const { stop: stopLCPTracking } = trackLargestContentfulPaintTiming( | ||
lifeCycle, | ||
window, | ||
(largestContentfulPaint) => { | ||
setTimings({ | ||
largestContentfulPaint, | ||
}) | ||
}, | ||
(lcpDiscardReason) => { | ||
setTimings({ | ||
lcpDiscardReason, | ||
}) | ||
} | ||
) | ||
const { stop: stopLCPTracking } = trackLargestContentfulPaintTiming(lifeCycle, window, (largestContentfulPaint) => { | ||
setTimings({ | ||
largestContentfulPaint, | ||
}) | ||
}) | ||
const { stop: stopFIDTracking } = trackFirstInputTimings(lifeCycle, ({ firstInputDelay, firstInputTime }) => { | ||
@@ -112,4 +102,3 @@ setTimings({ | ||
emitter: EventEmitter, | ||
callback: (lcpTiming: RelativeTime) => void, | ||
discardCallback: (discardReason: string) => void | ||
callback: (lcpTiming: RelativeTime) => void | ||
) { | ||
@@ -131,11 +120,7 @@ const firstHidden = trackFirstHidden() | ||
let isFirstLCP = true | ||
const { unsubscribe: unsubscribeLifeCycle } = lifeCycle.subscribe( | ||
LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, | ||
(entry) => { | ||
if (entry.entryType !== 'largest-contentful-paint') { | ||
return | ||
} | ||
if ( | ||
entry.entryType === 'largest-contentful-paint' && | ||
entry.startTime < firstInteractionTimestamp && | ||
@@ -146,15 +131,3 @@ entry.startTime < firstHidden.timeStamp && | ||
callback(entry.startTime) | ||
} else if (isFirstLCP) { | ||
const reason = | ||
entry.startTime >= firstInteractionTimestamp | ||
? 'interaction' | ||
: entry.startTime >= firstHidden.timeStamp | ||
? 'hidden' | ||
: entry.startTime >= TIMING_MAXIMUM_DELAY | ||
? 'maximum delay' | ||
: 'N/A' | ||
discardCallback(reason) | ||
} | ||
isFirstLCP = false | ||
} | ||
@@ -161,0 +134,0 @@ ) |
@@ -10,3 +10,2 @@ import { | ||
isNumber, | ||
isExperimentalFeatureEnabled, | ||
} from '@datadog/browser-core' | ||
@@ -18,3 +17,2 @@ import { RecorderApi } from '../../../boot/rumPublicApi' | ||
import { LocationChange } from '../../../browser/locationChangeObservable' | ||
import { supportPerformanceTimingEvent } from '../../../browser/performanceCollection' | ||
import { trackViews, ViewEvent } from './trackViews' | ||
@@ -107,11 +105,2 @@ | ||
}, | ||
customerContext: | ||
isExperimentalFeatureEnabled('monitor-dropped-lcp') && view.loadingType === 'initial_load' | ||
? { | ||
lcp: { | ||
support: supportPerformanceTimingEvent('largest-contentful-paint'), | ||
discard_reason: view.timings.lcpDiscardReason, | ||
}, | ||
} | ||
: undefined, | ||
} | ||
@@ -118,0 +107,0 @@ } |
@@ -6,3 +6,3 @@ import { Context, getEventBridge } from '@datadog/browser-core' | ||
export function startRumEventBridge(lifeCycle: LifeCycle) { | ||
const bridge = getEventBridge<RumEvent['type'], RumEvent>() | ||
const bridge = getEventBridge<RumEvent['type'], RumEvent>()! | ||
@@ -9,0 +9,0 @@ lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, (serverRumEvent: RumEvent & Context) => { |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
983933
20128
+ Added@datadog/browser-core@3.8.0(transitive)
- Removed@datadog/browser-core@3.7.0(transitive)
Updated@datadog/browser-core@3.8.0