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