feat(reactions) Added metrics for disable reaction sounds

Reordered reactions middleware alphabetically
This commit is contained in:
robertpin 2021-10-25 11:31:22 +03:00 committed by vp8x8
parent 1dbfbb9786
commit 0182cc0504
2 changed files with 55 additions and 22 deletions

View File

@ -821,6 +821,24 @@ export function createToolbarEvent(buttonName, attributes = {}) {
};
}
/**
* Creates an event associated with reactions.
*
* @param {string} action - Event action.
* @param {string} name - Event name.
* @param {string} source - Event source.
* @returns {Object} The event in a format suitable for sending via
* sendAnalytics.
*/
function createReactionEvent(action, name, source) {
return {
action,
actionSubject: name,
source: `reaction.${source}`,
type: TYPE_UI
};
}
/**
* Creates an event associated with a reaction button being clicked/pressed.
*
@ -830,12 +848,17 @@ export function createToolbarEvent(buttonName, attributes = {}) {
* sendAnalytics.
*/
export function createReactionMenuEvent(buttonName) {
return {
action: 'clicked',
actionSubject: buttonName,
source: 'reaction.button',
type: TYPE_UI
};
return createReactionEvent('clicked', buttonName, 'button');
}
/**
* Creates an event associated with disabling of reaction sounds.
*
* @returns {Object} The event in a format suitable for sending via
* sendAnalytics.
*/
export function createReactionSoundsDisabledEvent() {
return createReactionEvent('disabled', 'sounds', 'settings');
}
/**

View File

@ -2,10 +2,11 @@
import { batch } from 'react-redux';
import { createReactionSoundsDisabledEvent, sendAnalytics } from '../analytics';
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../base/app';
import { getParticipantCount } from '../base/participants';
import { MiddlewareRegistry } from '../base/redux';
import { updateSettings } from '../base/settings';
import { SETTINGS_UPDATED, updateSettings } from '../base/settings';
import { playSound, registerSound, unregisterSound } from '../base/sounds';
import { getDisabledSounds } from '../base/sounds/functions.any';
import { NOTIFICATION_TIMEOUT, showNotification } from '../notifications';
@ -113,21 +114,6 @@ MiddlewareRegistry.register(store => next => action => {
break;
}
case SEND_REACTIONS: {
const state = getState();
const { buffer } = state['features/reactions'];
const { conference } = state['features/base/conference'];
if (conference) {
conference.sendEndpointMessage('', {
name: ENDPOINT_REACTION_NAME,
reactions: buffer,
timestamp: Date.now()
});
}
break;
}
case PUSH_REACTIONS: {
const state = getState();
const { queue, notificationDisplayed } = state['features/reactions'];
@ -152,6 +138,30 @@ MiddlewareRegistry.register(store => next => action => {
break;
}
case SEND_REACTIONS: {
const state = getState();
const { buffer } = state['features/reactions'];
const { conference } = state['features/base/conference'];
if (conference) {
conference.sendEndpointMessage('', {
name: ENDPOINT_REACTION_NAME,
reactions: buffer,
timestamp: Date.now()
});
}
break;
}
case SETTINGS_UPDATED: {
const { soundsReactions } = getState()['features/base/settings'];
if (action.settings.soundsReactions === false && soundsReactions === true) {
sendAnalytics(createReactionSoundsDisabledEvent());
}
break;
}
case SHOW_SOUNDS_NOTIFICATION: {
dispatch(showNotification({
titleKey: 'toolbar.disableReactionSounds',