Browse Source

Merge pull request #2023 from jitsi/remote_menu_analytics

feat(remote_menu): Add analytics
j8
virtuacoplenny 7 years ago
parent
commit
1996ac4e02

+ 8
- 0
react/features/remote-video-menu/components/KickButton.js View File

3
 import { connect } from 'react-redux';
3
 import { connect } from 'react-redux';
4
 
4
 
5
 import { translate } from '../../base/i18n';
5
 import { translate } from '../../base/i18n';
6
+import JitsiMeetJS from '../../base/lib-jitsi-meet';
6
 import { kickParticipant } from '../../base/participants';
7
 import { kickParticipant } from '../../base/participants';
7
 
8
 
8
 import RemoteVideoMenuButton from './RemoteVideoMenuButton';
9
 import RemoteVideoMenuButton from './RemoteVideoMenuButton';
82
     _onClick() {
83
     _onClick() {
83
         const { dispatch, onClick, participantID } = this.props;
84
         const { dispatch, onClick, participantID } = this.props;
84
 
85
 
86
+        JitsiMeetJS.analytics.sendEvent(
87
+            'remotevideomenu.kick',
88
+            {
89
+                value: 1,
90
+                label: participantID
91
+            }
92
+        );
85
         dispatch(kickParticipant(participantID));
93
         dispatch(kickParticipant(participantID));
86
 
94
 
87
         if (onClick) {
95
         if (onClick) {

+ 9
- 0
react/features/remote-video-menu/components/MuteButton.js View File

3
 import { connect } from 'react-redux';
3
 import { connect } from 'react-redux';
4
 
4
 
5
 import { translate } from '../../base/i18n';
5
 import { translate } from '../../base/i18n';
6
+import JitsiMeetJS from '../../base/lib-jitsi-meet';
6
 import { muteRemoteParticipant } from '../../base/participants';
7
 import { muteRemoteParticipant } from '../../base/participants';
7
 
8
 
8
 import RemoteVideoMenuButton from './RemoteVideoMenuButton';
9
 import RemoteVideoMenuButton from './RemoteVideoMenuButton';
96
     _onClick() {
97
     _onClick() {
97
         const { dispatch, onClick, participantID } = this.props;
98
         const { dispatch, onClick, participantID } = this.props;
98
 
99
 
100
+        JitsiMeetJS.analytics.sendEvent(
101
+            'remotevideomenu.mute',
102
+            {
103
+                value: 1,
104
+                label: participantID
105
+            }
106
+        );
107
+
99
         dispatch(muteRemoteParticipant(participantID));
108
         dispatch(muteRemoteParticipant(participantID));
100
 
109
 
101
         if (onClick) {
110
         if (onClick) {

+ 50
- 2
react/features/remote-video-menu/components/RemoteControlButton.js View File

1
 import PropTypes from 'prop-types';
1
 import PropTypes from 'prop-types';
2
 import React, { Component } from 'react';
2
 import React, { Component } from 'react';
3
 
3
 
4
+import JitsiMeetJS from '../../base/lib-jitsi-meet';
4
 import { translate } from '../../base/i18n';
5
 import { translate } from '../../base/i18n';
5
 
6
 
6
 import RemoteVideoMenuButton from './RemoteVideoMenuButton';
7
 import RemoteVideoMenuButton from './RemoteVideoMenuButton';
50
         t: PropTypes.func
51
         t: PropTypes.func
51
     };
52
     };
52
 
53
 
54
+    /**
55
+     * Initializes a new {@code RemoteControlButton} instance.
56
+     *
57
+     * @param {Object} props - The read-only React Component props with which
58
+     * the new instance is to be initialized.
59
+     */
60
+    constructor(props) {
61
+        super(props);
62
+
63
+        // Bind event handlers so they are only bound once for every instance.
64
+        this._onClick = this._onClick.bind(this);
65
+    }
66
+
53
     /**
67
     /**
54
      * Implements React's {@link Component#render()}.
68
      * Implements React's {@link Component#render()}.
55
      *
69
      *
58
      */
72
      */
59
     render() {
73
     render() {
60
         const {
74
         const {
61
-            onClick,
62
             participantID,
75
             participantID,
63
             remoteControlState,
76
             remoteControlState,
64
             t
77
             t
92
                 displayClass = { className }
105
                 displayClass = { className }
93
                 iconClass = { icon }
106
                 iconClass = { icon }
94
                 id = { `remoteControl_${participantID}` }
107
                 id = { `remoteControl_${participantID}` }
95
-                onClick = { onClick } />
108
+                onClick = { this._onClick } />
96
         );
109
         );
97
     }
110
     }
111
+
112
+    /**
113
+     * Sends analytics event for pressing the button and executes the passed
114
+     * onClick handler.
115
+     *
116
+     * @private
117
+     * @returns {void}
118
+     */
119
+    _onClick() {
120
+        const { onClick, participantID, remoteControlState } = this.props;
121
+
122
+        let eventName;
123
+
124
+        if (remoteControlState === REMOTE_CONTROL_MENU_STATES.STARTED) {
125
+            eventName = 'stop';
126
+        }
127
+
128
+        if (remoteControlState === REMOTE_CONTROL_MENU_STATES.NOT_STARTED) {
129
+            eventName = 'start';
130
+        }
131
+
132
+        if (eventName) {
133
+            JitsiMeetJS.analytics.sendEvent(
134
+                `remotevideomenu.remotecontrol.${eventName}`,
135
+                {
136
+                    value: 1,
137
+                    label: participantID
138
+                }
139
+            );
140
+        }
141
+
142
+        if (onClick) {
143
+            onClick();
144
+        }
145
+    }
98
 }
146
 }
99
 
147
 
100
 export default translate(RemoteControlButton);
148
 export default translate(RemoteControlButton);

Loading…
Cancel
Save