@@ -2,7 +2,7 @@ import { Observable } from '../../tools/observable'
22import type { Context } from '../../tools/serialisation/context'
33import { createValueHistory } from '../../tools/valueHistory'
44import type { RelativeTime } from '../../tools/utils/timeUtils'
5- import { clocksOrigin , dateNow , ONE_MINUTE , relativeNow } from '../../tools/utils/timeUtils'
5+ import { clocksOrigin , ONE_MINUTE , relativeNow } from '../../tools/utils/timeUtils'
66import { addEventListener , addEventListeners , DOM_EVENT } from '../../browser/addEventListener'
77import { clearInterval , setInterval } from '../../tools/timer'
88import type { Configuration } from '../configuration'
@@ -11,13 +11,9 @@ import { addTelemetryDebug } from '../telemetry'
1111import { isSyntheticsTest } from '../synthetics/syntheticsWorkerValues'
1212import type { CookieStore } from '../../browser/browser.types'
1313import { getCurrentSite } from '../../browser/cookie'
14- import { ExperimentalFeature , isExperimentalFeatureEnabled } from '../../tools/experimentalFeatures'
15- import { findLast } from '../../tools/utils/polyfills'
16- import { monitorError } from '../../tools/monitor'
1714import { SESSION_NOT_TRACKED , SESSION_TIME_OUT_DELAY , SessionPersistence } from './sessionConstants'
1815import { startSessionStore } from './sessionStore'
1916import type { SessionState } from './sessionState'
20- import { toSessionState } from './sessionState'
2117import { retrieveSessionCookie } from './storeStrategies/sessionInCookie'
2218import { SESSION_STORE_KEY } from './storeStrategies/sessionStoreStrategy'
2319import { retrieveSessionFromLocalStorage } from './storeStrategies/sessionInLocalStorage'
@@ -81,12 +77,6 @@ export function startSessionManager<TrackingType extends string>(
8177 // manager is started.
8278 sessionStore . expandOrRenewSession ( )
8379 sessionContextHistory . add ( buildSessionContext ( ) , clocksOrigin ( ) . relative )
84- if ( isExperimentalFeatureEnabled ( ExperimentalFeature . SHORT_SESSION_INVESTIGATION ) ) {
85- const session = sessionStore . getSession ( )
86- if ( session ) {
87- detectSessionIdChange ( configuration , session )
88- }
89- }
9080
9181 trackingConsentState . observable . subscribe ( ( ) => {
9282 if ( trackingConsentState . isGranted ( ) ) {
@@ -203,49 +193,6 @@ async function reportUnexpectedSessionState(configuration: Configuration) {
203193 } )
204194}
205195
206- function detectSessionIdChange ( configuration : Configuration , initialSessionState : SessionState ) {
207- if ( ! window . cookieStore || ! initialSessionState . created ) {
208- return
209- }
210-
211- const sessionCreatedTime = Number ( initialSessionState . created )
212- const sdkInitTime = dateNow ( )
213-
214- const { stop } = addEventListener ( configuration , cookieStore as CookieStore , DOM_EVENT . CHANGE , listener )
215- stopCallbacks . push ( stop )
216-
217- function listener ( event : CookieChangeEvent ) {
218- const changed = findLast ( event . changed , ( change ) : change is CookieListItem => change . name === SESSION_STORE_KEY )
219- if ( ! changed ) {
220- return
221- }
222-
223- const sessionAge = dateNow ( ) - sessionCreatedTime
224- if ( sessionAge > 14 * ONE_MINUTE ) {
225- // The session might have expired just because it's too old or lack activity
226- stop ( )
227- } else {
228- const newSessionState = toSessionState ( changed . value )
229- if ( newSessionState . id && newSessionState . id !== initialSessionState . id ) {
230- stop ( )
231- const time = dateNow ( ) - sdkInitTime
232- getSessionCookies ( )
233- . then ( ( cookie ) => {
234- // monitor-until: 2026-04-01, after RUM-10845 investigation done
235- addTelemetryDebug ( 'Session cookie changed' , {
236- time,
237- session_age : sessionAge ,
238- old : initialSessionState ,
239- new : newSessionState ,
240- cookie,
241- } )
242- } )
243- . catch ( monitorError )
244- }
245- }
246- }
247- }
248-
249196async function getSessionCookies ( ) : Promise < { count : number ; domain : string } > {
250197 let sessionCookies : string [ ] | Awaited < ReturnType < CookieStore [ 'getAll' ] > >
251198 if ( 'cookieStore' in window ) {
0 commit comments