Skip to content

Commit acd25f4

Browse files
committed
simplify
1 parent cde4571 commit acd25f4

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

packages/rum-core/src/domain/view/viewMetrics/trackCommonViewMetrics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ export function trackCommonViewMetrics(
3636
configuration,
3737
loadingType,
3838
viewStart,
39-
(newLoadingTime, wasHiddenDuringLoading) => {
40-
commonViewMetrics.wasHiddenDuringLoading = wasHiddenDuringLoading
39+
(newLoadingTime) => {
40+
commonViewMetrics.wasHiddenDuringLoading = !newLoadingTime
4141
commonViewMetrics.loadingTime = newLoadingTime
4242
scheduleViewUpdate()
4343
}

packages/rum-core/src/domain/view/viewMetrics/trackLoadingTime.spec.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('trackLoadingTime', () => {
2222
let clock: Clock
2323
let domMutationObservable: Observable<void>
2424
let windowOpenObservable: Observable<void>
25-
let loadingTimeCallback: jasmine.Spy<(loadingTime: Duration | undefined, wasHiddenDuringLoading: boolean) => void>
25+
let loadingTimeCallback: jasmine.Spy<(loadingTime?: Duration) => void>
2626
let setLoadEvent: (loadEvent: Duration) => void
2727
let stopLoadingTimeTracking: () => void
2828

@@ -65,7 +65,7 @@ describe('trackLoadingTime', () => {
6565
domMutationObservable.notify()
6666
clock.tick(AFTER_PAGE_ACTIVITY_END_DELAY)
6767

68-
expect(loadingTimeCallback).toHaveBeenCalledOnceWith(clock.relative(BEFORE_PAGE_ACTIVITY_VALIDATION_DELAY), false)
68+
expect(loadingTimeCallback).toHaveBeenCalledOnceWith(clock.relative(BEFORE_PAGE_ACTIVITY_VALIDATION_DELAY))
6969
})
7070

7171
it('should use loadEventEnd for initial view when having no activity', () => {
@@ -77,7 +77,7 @@ describe('trackLoadingTime', () => {
7777
setLoadEvent(entry.loadEventEnd)
7878
clock.tick(PAGE_ACTIVITY_END_DELAY)
7979

80-
expect(loadingTimeCallback).toHaveBeenCalledOnceWith(entry.loadEventEnd, false)
80+
expect(loadingTimeCallback).toHaveBeenCalledOnceWith(entry.loadEventEnd)
8181
})
8282

8383
it('should use loadEventEnd for initial view when load event is bigger than computed loading time', () => {
@@ -90,7 +90,7 @@ describe('trackLoadingTime', () => {
9090
domMutationObservable.notify()
9191
clock.tick(AFTER_PAGE_ACTIVITY_END_DELAY)
9292

93-
expect(loadingTimeCallback).toHaveBeenCalledOnceWith(clock.relative(LOAD_EVENT_AFTER_ACTIVITY_TIMING), false)
93+
expect(loadingTimeCallback).toHaveBeenCalledOnceWith(clock.relative(LOAD_EVENT_AFTER_ACTIVITY_TIMING))
9494
})
9595

9696
it('should use computed loading time for initial view when load event is smaller than computed loading time', () => {
@@ -104,7 +104,7 @@ describe('trackLoadingTime', () => {
104104
domMutationObservable.notify()
105105
clock.tick(AFTER_PAGE_ACTIVITY_END_DELAY)
106106

107-
expect(loadingTimeCallback).toHaveBeenCalledOnceWith(clock.relative(BEFORE_PAGE_ACTIVITY_VALIDATION_DELAY), false)
107+
expect(loadingTimeCallback).toHaveBeenCalledOnceWith(clock.relative(BEFORE_PAGE_ACTIVITY_VALIDATION_DELAY))
108108
})
109109

110110
it('should use computed loading time from time origin for initial view', () => {
@@ -127,8 +127,7 @@ describe('trackLoadingTime', () => {
127127
clock.tick(AFTER_PAGE_ACTIVITY_END_DELAY)
128128

129129
expect(loadingTimeCallback).toHaveBeenCalledOnceWith(
130-
clock.relative(BEFORE_PAGE_ACTIVITY_VALIDATION_DELAY + CLOCK_GAP),
131-
false
130+
clock.relative(BEFORE_PAGE_ACTIVITY_VALIDATION_DELAY + CLOCK_GAP)
132131
)
133132
})
134133

@@ -140,6 +139,6 @@ describe('trackLoadingTime', () => {
140139
domMutationObservable.notify()
141140
clock.tick(AFTER_PAGE_ACTIVITY_END_DELAY)
142141

143-
expect(loadingTimeCallback).toHaveBeenCalledOnceWith(undefined, true)
142+
expect(loadingTimeCallback).toHaveBeenCalledOnceWith(undefined)
144143
})
145144
})

packages/rum-core/src/domain/view/viewMetrics/trackLoadingTime.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function trackLoadingTime(
1313
configuration: RumConfiguration,
1414
loadType: ViewLoadingType,
1515
viewStart: ClocksState,
16-
callback: (loadingTime: Duration | undefined, wasHiddenDuringLoading: boolean) => void
16+
callback: (loadingTime?: Duration) => void
1717
) {
1818
let isWaitingForLoadEvent = loadType === ViewLoadingType.INITIAL_LOAD
1919
let isWaitingForActivityLoadingTime = true
@@ -24,9 +24,9 @@ export function trackLoadingTime(
2424
if (!isWaitingForActivityLoadingTime && !isWaitingForLoadEvent && loadingTimeCandidates.length > 0) {
2525
const loadingTime = Math.max(...loadingTimeCandidates)
2626
if (loadingTime < firstHidden.timeStamp) {
27-
callback(loadingTime as Duration, false)
27+
callback(loadingTime as Duration)
2828
} else {
29-
callback(undefined, true)
29+
callback()
3030
}
3131
}
3232
}

0 commit comments

Comments
 (0)