You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbstractHandler.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * Abstract implementation of analytics handler
  3. */
  4. export default class AbstractHandler {
  5. /**
  6. * Creates new instance.
  7. */
  8. constructor() {
  9. this._enabled = false;
  10. }
  11. /**
  12. * Extracts a name for the event from the event properties.
  13. *
  14. * @param {Object} event - The analytics event.
  15. * @returns {string} - The extracted name.
  16. */
  17. _extractName(event) {
  18. // Page events have a single 'name' field.
  19. if (event.type === 'page') {
  20. return event.name;
  21. }
  22. const {
  23. action,
  24. actionSubject,
  25. source
  26. } = event;
  27. // All events have action, actionSubject, and source fields. All
  28. // three fields are required, and often jitsi-meet and
  29. // lib-jitsi-meet use the same value when separate values are not
  30. // necessary (i.e. event.action == event.actionSubject).
  31. // Here we concatenate these three fields, but avoid adding the same
  32. // value twice, because it would only make the event's name harder
  33. // to read.
  34. let name = action;
  35. if (actionSubject && actionSubject !== action) {
  36. name = `${actionSubject}.${action}`;
  37. }
  38. if (source && source !== action) {
  39. name = `${source}.${name}`;
  40. }
  41. return name;
  42. }
  43. /**
  44. * Checks if an event should be ignored or not.
  45. *
  46. * @param {Object} event - The event.
  47. * @returns {boolean}
  48. */
  49. _shouldIgnore(event) {
  50. if (!event || !this._enabled) {
  51. return true;
  52. }
  53. const ignoredEvents
  54. = [ 'e2e_rtt', 'rtp.stats', 'rtt.by.region', 'available.device',
  55. 'stream.switch.delay', 'ice.state.changed', 'ice.duration' ];
  56. // Temporary removing some of the events that are too noisy.
  57. return ignoredEvents.indexOf(event.action) !== -1;
  58. }
  59. }