Skip to content

Commit 5aa6a3f

Browse files
#RI-4674 - fix recommendations list in INSIGHTS_PANEL_CLOSED telemetry event
1 parent 1a7dcad commit 5aa6a3f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

redisinsight/ui/src/components/live-time-recommendations/LiveTimeRecommendations.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ const LiveTimeRecommendations = () => {
7575
// To prevent duplication emit for FlyOut close event
7676
// https://github.com/elastic/eui/issues/3437
7777
const isCloseEventSent = useRef<boolean>(false)
78+
// Flyout onClose did not updated between rerenders
79+
const recommendationsState = useRef<IRecommendation[]>([])
7880

7981
const dispatch = useDispatch()
8082
const history = useHistory()
@@ -108,6 +110,10 @@ const LiveTimeRecommendations = () => {
108110
}
109111
}, [isContentVisible])
110112

113+
useEffect(() => {
114+
recommendationsState.current = recommendations
115+
}, [recommendations])
116+
111117
const toggleContent = () => {
112118
dispatch(setIsContentVisible(!isContentVisible))
113119
}
@@ -145,7 +151,7 @@ const LiveTimeRecommendations = () => {
145151
dispatch(setIsContentVisible(false))
146152
sendEventTelemetry({
147153
event: TelemetryEvent.INSIGHTS_PANEL_CLOSED,
148-
eventData: getTelemetryData(recommendations),
154+
eventData: getTelemetryData(recommendationsState.current),
149155
})
150156
isCloseEventSent.current = true
151157
}
@@ -311,7 +317,7 @@ const LiveTimeRecommendations = () => {
311317
className={styles.content}
312318
ownFocus
313319
size="476px"
314-
onClose={handleClose}
320+
onClose={() => handleClose(recommendations)}
315321
data-testid="insights-panel"
316322
>
317323
<EuiFlyoutHeader className={styles.header}>

0 commit comments

Comments
 (0)