您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

middleware.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { sendAnalytics, createVpaasConferenceJoinedEvent } from '../analytics';
  2. import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
  3. import { PARTICIPANT_JOINED } from '../base/participants/actionTypes';
  4. import { MiddlewareRegistry } from '../base/redux';
  5. import { countEndpoint } from './actions';
  6. import { isVpaasMeeting, extractVpaasTenantFromPath } from './functions';
  7. /**
  8. * The redux middleware for billing counter.
  9. *
  10. * @param {Store} store - The redux store.
  11. * @returns {Function}
  12. */
  13. MiddlewareRegistry.register(store => next => async action => {
  14. switch (action.type) {
  15. case CONFERENCE_JOINED: {
  16. _maybeTrackVpaasConferenceJoin(store.getState());
  17. break;
  18. }
  19. case PARTICIPANT_JOINED: {
  20. const shouldCount = !store.getState()['features/billing-counter'].endpointCounted
  21. && !action.participant.local;
  22. if (shouldCount) {
  23. store.dispatch(countEndpoint());
  24. }
  25. break;
  26. }
  27. }
  28. return next(action);
  29. });
  30. /**
  31. * Tracks the conference join event if the meeting is a vpaas one.
  32. *
  33. * @param {Store} state - The app state.
  34. * @returns {Function}
  35. */
  36. function _maybeTrackVpaasConferenceJoin(state) {
  37. if (isVpaasMeeting(state)) {
  38. sendAnalytics(createVpaasConferenceJoinedEvent(
  39. extractVpaasTenantFromPath(
  40. state['features/base/connection'].locationURL.pathname)));
  41. }
  42. }