Skip to content

Commit

Permalink
👌 rename visibility_change to visibility_reason
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitZugmeyer committed Jan 19, 2021
1 parent 557358b commit 28be2f4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/rum-recorder/src/domain/segmentCollection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ describe('startSegmentCollection', () => {
setPageVisibility('hidden')
const { eventEmitter, sendCurrentSegment } = startSegmentCollection(CONTEXT)
eventEmitter.dispatchEvent(createNewEvent(DOM_EVENT.VISIBILITY_CHANGE))
expect(sendCurrentSegment().creation_reason).toBe('visibility_change')
expect(sendCurrentSegment().creation_reason).toBe('visibility_hidden')
})

it('does not flush segment when the page become visible', () => {
setPageVisibility('visible')
const { eventEmitter, segmentFlushSpy, sendCurrentSegment } = startSegmentCollection(CONTEXT)
eventEmitter.dispatchEvent(createNewEvent(DOM_EVENT.VISIBILITY_CHANGE))
expect(segmentFlushSpy).not.toHaveBeenCalled()
expect(sendCurrentSegment().creation_reason).not.toBe('visibility_change')
expect(sendCurrentSegment().creation_reason).not.toBe('visibility_hidden')
})

it('flushes segment when the current segment deflate size reaches SEND_BEACON_BYTE_LENGTH_LIMIT', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/rum-recorder/src/domain/segmentCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function doStartSegmentCollection(
DOM_EVENT.VISIBILITY_CHANGE,
() => {
if (document.visibilityState === 'hidden') {
flushSegment('visibility_change')
flushSegment('visibility_hidden')
}
},
{ capture: true }
Expand Down
2 changes: 1 addition & 1 deletion packages/rum-recorder/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ export type CreationReason =
| 'view_change'
| 'session_renewed'
| 'before_unload'
| 'visibility_change'
| 'visibility_hidden'

0 comments on commit 28be2f4

Please sign in to comment.