2022-10-28 08:53:24 +00:00
|
|
|
import { createRejoinedEvent } from '../analytics/AnalyticsEvents';
|
|
|
|
import { sendAnalytics } from '../analytics/functions';
|
|
|
|
import StateListenerRegistry from '../base/redux/StateListenerRegistry';
|
2019-07-25 11:23:48 +00:00
|
|
|
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => {
|
|
|
|
const recentList = state['features/recent-list'];
|
|
|
|
|
|
|
|
// Return the most recent conference entry
|
2022-10-28 08:53:24 +00:00
|
|
|
return recentList?.length && recentList[recentList.length - 1];
|
2019-07-25 11:23:48 +00:00
|
|
|
},
|
|
|
|
// eslint-disable-next-line no-empty-pattern
|
|
|
|
/* listener */ (newMostRecent, { }, prevMostRecent) => {
|
|
|
|
if (prevMostRecent && newMostRecent) {
|
|
|
|
|
|
|
|
// Send the rejoined event just before the duration is reset on the most recent entry
|
|
|
|
if (prevMostRecent.conference === newMostRecent.conference && newMostRecent.duration === 0) {
|
|
|
|
sendAnalytics(
|
|
|
|
createRejoinedEvent({
|
|
|
|
lastConferenceDuration: prevMostRecent.duration / 1000,
|
|
|
|
timeSinceLeft: (Date.now() - (prevMostRecent.date + prevMostRecent.duration)) / 1000,
|
|
|
|
url: prevMostRecent.conference
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|