Skip to content

Commit

Permalink
πŸ› [RUMF-1122] fix view updates while session is expired (#1228)
Browse files Browse the repository at this point in the history
* πŸ› [RUMF-1122] fix view updated while session is expired

* πŸ‘Œ add explanation + todo
  • Loading branch information
bcaudan authored Dec 21, 2021
1 parent 433202e commit a2c5674
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions packages/rum-core/src/domain/assembly.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
5 changes: 4 additions & 1 deletion packages/rum-core/src/domain/assembly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ export function startRumAssembly(
({ startTime, rawRumEvent, domainContext, savedCommonContext, customerContext }) => {
const viewContext = parentContexts.findView(startTime)
const urlContext = urlContexts.findUrl(startTime)
const session = sessionManager.findTrackedSession(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)
const commonContext = savedCommonContext || getCommonContext()
Expand Down

0 comments on commit a2c5674

Please sign in to comment.