Pārlūkot izejas kodu

feat(api): expose a way to submit feedback

Spot will need a way to submit call feedback using the iframe
api. For now expose a method on conference.js to submit that
feedback. Exposing on conference.js looks to be the existing
pattern... Also add an event to notify consumers of the iframe
api that feedback was submitted, as postMessage is async
and the notification can at least give some guarantee maybe.

I haven't updated documentation yet as I'm not confident
about this api.
master
Leonard Kim 7 gadus atpakaļ
vecāks
revīzija
762f529f1d

+ 20
- 1
conference.js Parādīt failu

@@ -91,7 +91,10 @@ import {
91 91
 import { statsEmitter } from './react/features/connection-indicator';
92 92
 import { showDesktopPicker } from './react/features/desktop-picker';
93 93
 import { appendSuffix } from './react/features/display-name';
94
-import { maybeOpenFeedbackDialog } from './react/features/feedback';
94
+import {
95
+    maybeOpenFeedbackDialog,
96
+    submitFeedback
97
+} from './react/features/feedback';
95 98
 import {
96 99
     mediaPermissionPromptVisibilityChanged,
97 100
     suspendDetected
@@ -2798,5 +2801,21 @@ export default {
2798 2801
     setAudioMuteStatus(muted) {
2799 2802
         APP.UI.setAudioMuted(this.getMyUserId(), muted);
2800 2803
         APP.API.notifyAudioMutedStatusChanged(muted);
2804
+    },
2805
+
2806
+    /**
2807
+     * Dispatches the passed in feedback for submission. The submitted score
2808
+     * should be a number inclusively between 1 through 5, or -1 for no score.
2809
+     *
2810
+     * @param {number} score - a number between 1 and 5 (inclusive) or -1 for no
2811
+     * score.
2812
+     * @param {string} message - An optional message to attach to the feedback
2813
+     * in addition to the score.
2814
+     * @returns {void}
2815
+     */
2816
+    submitFeedback(score = -1, message = '') {
2817
+        if (score === -1 || (score >= 1 && score <= 5)) {
2818
+            APP.store.dispatch(submitFeedback(score, message, room));
2819
+        }
2801 2820
     }
2802 2821
 };

+ 14
- 0
modules/API/API.js Parādīt failu

@@ -59,6 +59,10 @@ function initCommands() {
59 59
             sendAnalytics(createApiEvent('display.name.changed'));
60 60
             APP.conference.changeLocalDisplayName(displayName);
61 61
         },
62
+        'submit-feedback': feedback => {
63
+            sendAnalytics(createApiEvent('submit.feedback'));
64
+            APP.conference.submitFeedback(feedback.score, feedback.message);
65
+        },
62 66
         'toggle-audio': () => {
63 67
             sendAnalytics(createApiEvent('toggle-audio'));
64 68
             logger.log('Audio toggle: API command received');
@@ -456,6 +460,16 @@ class API {
456 460
         });
457 461
     }
458 462
 
463
+    /**
464
+     * Notify external application (if API is enabled) that conference feedback
465
+     * has been submitted. Intended to be used in conjunction with the
466
+     * submit-feedback command to get notified if feedback was submitted.
467
+     *
468
+     * @returns {void}
469
+     */
470
+    notifyFeedbackSubmitted() {
471
+        this._sendEvent({ name: 'feedback-submitted' });
472
+    }
459 473
 
460 474
     /**
461 475
      * Disposes the allocated resources.

+ 2
- 0
modules/API/external/external_api.js Parādīt failu

@@ -21,6 +21,7 @@ const commands = {
21 21
     displayName: 'display-name',
22 22
     email: 'email',
23 23
     hangup: 'video-hangup',
24
+    submitFeedback: 'submit-feedback',
24 25
     toggleAudio: 'toggle-audio',
25 26
     toggleChat: 'toggle-chat',
26 27
     toggleContactList: 'toggle-contact-list',
@@ -38,6 +39,7 @@ const events = {
38 39
     'audio-availability-changed': 'audioAvailabilityChanged',
39 40
     'audio-mute-status-changed': 'audioMuteStatusChanged',
40 41
     'display-name-change': 'displayNameChange',
42
+    'feedback-submitted': 'feedbackSubmitted',
41 43
     'incoming-message': 'incomingMessage',
42 44
     'outgoing-message': 'outgoingMessage',
43 45
     'participant-joined': 'participantJoined',

+ 1
- 0
react/features/feedback/index.js Parādīt failu

@@ -2,4 +2,5 @@ export * from './actions';
2 2
 export * from './actionTypes';
3 3
 export * from './components';
4 4
 
5
+import './middleware';
5 6
 import './reducer';

+ 26
- 0
react/features/feedback/middleware.js Parādīt failu

@@ -0,0 +1,26 @@
1
+/* @flow */
2
+
3
+import { MiddlewareRegistry } from '../base/redux';
4
+
5
+import { SUBMIT_FEEDBACK } from './actionTypes';
6
+
7
+declare var APP: Object;
8
+
9
+/**
10
+ * Implements the middleware of the feature feedback.
11
+ *
12
+ * @param {Store} store - The redux store.
13
+ * @returns {Function}
14
+ */
15
+// eslint-disable-next-line no-unused-vars
16
+MiddlewareRegistry.register(store => next => action => {
17
+    switch (action.type) {
18
+    case SUBMIT_FEEDBACK:
19
+        if (typeof APP === 'object') {
20
+            APP.API.notifyFeedbackSubmitted();
21
+        }
22
+        break;
23
+    }
24
+
25
+    return next(action);
26
+});

Notiek ielāde…
Atcelt
Saglabāt