From 4d6df5253fcfc08ea4d700ff5df25c9101bb83e3 Mon Sep 17 00:00:00 2001 From: Bastien Caudan Date: Mon, 20 Dec 2021 13:39:30 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20[RUMF-1122]=20fix=20view=20u?= =?UTF-8?q?pdated=20while=20session=20is=20expired?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/rum-core/src/domain/assembly.spec.ts | 13 +++++++++++++ packages/rum-core/src/domain/assembly.ts | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/rum-core/src/domain/assembly.spec.ts b/packages/rum-core/src/domain/assembly.spec.ts index 44e2d2f9c5..2879b1d5be 100644 --- a/packages/rum-core/src/domain/assembly.spec.ts +++ b/packages/rum-core/src/domain/assembly.spec.ts @@ -492,6 +492,19 @@ describe('rum assembly', () => { expect(rumSessionManager.findTrackedSession).toHaveBeenCalledWith(123 as RelativeTime) }) + + it('should get current session state for view event', () => { + const rumSessionManager = createRumSessionManagerMock() + spyOn(rumSessionManager, 'findTrackedSession').and.callThrough() + + const { lifeCycle } = setupBuilder.withSessionManager(rumSessionManager).build() + notifyRawRumEvent(lifeCycle, { + rawRumEvent: createRawRumEvent(RumEventType.VIEW), + startTime: 123 as RelativeTime, + }) + + expect(rumSessionManager.findTrackedSession).toHaveBeenCalledWith(undefined) + }) }) describe('session context', () => { diff --git a/packages/rum-core/src/domain/assembly.ts b/packages/rum-core/src/domain/assembly.ts index 9edb2dc800..43bb4083f9 100644 --- a/packages/rum-core/src/domain/assembly.ts +++ b/packages/rum-core/src/domain/assembly.ts @@ -81,7 +81,7 @@ export function startRumAssembly( ({ startTime, rawRumEvent, domainContext, savedCommonContext, customerContext }) => { const viewContext = parentContexts.findView(startTime) const urlContext = urlContexts.findUrl(startTime) - const session = sessionManager.findTrackedSession(startTime) + const session = sessionManager.findTrackedSession(rawRumEvent.type !== RumEventType.VIEW ? startTime : undefined) if (session && viewContext && urlContext) { const actionContext = parentContexts.findAction(startTime) const commonContext = savedCommonContext || getCommonContext() From 4d1b7843639e9b95c06172ac15d321fd3961265b Mon Sep 17 00:00:00 2001 From: Bastien Caudan Date: Mon, 20 Dec 2021 15:19:11 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=91=8C=20add=20explanation=20+=20todo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/rum-core/src/domain/assembly.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/rum-core/src/domain/assembly.ts b/packages/rum-core/src/domain/assembly.ts index 43bb4083f9..0e516a948e 100644 --- a/packages/rum-core/src/domain/assembly.ts +++ b/packages/rum-core/src/domain/assembly.ts @@ -81,6 +81,9 @@ export function startRumAssembly( ({ startTime, rawRumEvent, domainContext, savedCommonContext, customerContext }) => { const viewContext = parentContexts.findView(startTime) const urlContext = urlContexts.findUrl(startTime) + // allow to send events if the session was tracked when they start + // except for views which are continuously updated + // TODO: stop sending view updates when session is expired const session = sessionManager.findTrackedSession(rawRumEvent.type !== RumEventType.VIEW ? startTime : undefined) if (session && viewContext && urlContext) { const actionContext = parentContexts.findAction(startTime)