feat(polls): Add analytics for polls

This commit is contained in:
Vlad Piersec
2021-10-13 10:47:55 +03:00
committed by vp8x8
parent 04194ae8a1
commit ebb0a206f1
4 changed files with 34 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import type { AbstractComponent } from 'react';
import { useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'react-redux';
import { sendAnalytics, createPollEvent } from '../../analytics';
import { getLocalParticipant, getParticipantById } from '../../base/participants';
import { registerVote } from '../actions';
import { COMMAND_ANSWER_POLL } from '../constants';
@@ -60,6 +61,7 @@ const AbstractPollAnswer = (Component: AbstractComponent<AbstractProps>) => (pro
newCheckBoxStates[index] = state;
setCheckBoxState(newCheckBoxStates);
sendAnalytics(createPollEvent('vote.checked'));
}, [ checkBoxStates ]);
const dispatch = useDispatch();
@@ -76,6 +78,7 @@ const AbstractPollAnswer = (Component: AbstractComponent<AbstractProps>) => (pro
answers: checkBoxStates
});
sendAnalytics(createPollEvent('vote.sent'));
dispatch(registerVote(pollId, checkBoxStates));
return false;
@@ -83,6 +86,7 @@ const AbstractPollAnswer = (Component: AbstractComponent<AbstractProps>) => (pro
const skipAnswer = useCallback(() => {
dispatch(registerVote(pollId, null));
sendAnalytics(createPollEvent('vote.skipped'));
}, [ pollId ]);