You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526
  1. import { createRejoinedEvent, sendAnalytics } from '../analytics';
  2. import { StateListenerRegistry } from '../base/redux';
  3. StateListenerRegistry.register(
  4. /* selector */ state => {
  5. const recentList = state['features/recent-list'];
  6. // Return the most recent conference entry
  7. return recentList && recentList.length && recentList[recentList.length - 1];
  8. },
  9. // eslint-disable-next-line no-empty-pattern
  10. /* listener */ (newMostRecent, { }, prevMostRecent) => {
  11. if (prevMostRecent && newMostRecent) {
  12. // Send the rejoined event just before the duration is reset on the most recent entry
  13. if (prevMostRecent.conference === newMostRecent.conference && newMostRecent.duration === 0) {
  14. sendAnalytics(
  15. createRejoinedEvent({
  16. lastConferenceDuration: prevMostRecent.duration / 1000,
  17. timeSinceLeft: (Date.now() - (prevMostRecent.date + prevMostRecent.duration)) / 1000,
  18. url: prevMostRecent.conference
  19. })
  20. );
  21. }
  22. }
  23. });