Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

JitsiMeetLogStorage.ts 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { IStore } from '../../app/types';
  2. import RTCStats from '../../rtcstats/RTCStats';
  3. import { isRTCStatsEnabled } from '../../rtcstats/functions';
  4. /**
  5. * Implements log storage interface from the @jitsi/logger lib.
  6. */
  7. export default class JitsiMeetLogStorage {
  8. counter: number;
  9. getState: IStore['getState'];
  10. /**
  11. * Creates new <tt>JitsiMeetLogStorage</tt>.
  12. *
  13. * @param {Function} getState - The Redux store's {@code getState} method.
  14. */
  15. constructor(getState: IStore['getState']) {
  16. /**
  17. * Counts each log entry, increases on every batch log entry stored.
  18. *
  19. * @type {number}
  20. */
  21. this.counter = 1;
  22. /**
  23. * The Redux store's {@code getState} method.
  24. *
  25. * @type {Function}
  26. */
  27. this.getState = getState;
  28. }
  29. /**
  30. * The JitsiMeetLogStorage is ready when the conference has been joined.
  31. * A conference is considered joined when the 'conference' field is defined
  32. * in the base/conference state.
  33. *
  34. * @returns {boolean} <tt>true</tt> when this storage is ready or
  35. * <tt>false</tt> otherwise.
  36. */
  37. isReady() {
  38. const { conference } = this.getState()['features/base/conference'];
  39. return Boolean(conference);
  40. }
  41. /**
  42. * Checks whether rtcstats logs storage is enabled.
  43. *
  44. * @returns {boolean} <tt>true</tt> when this storage can store logs to
  45. * rtcstats, <tt>false</tt> otherwise.
  46. */
  47. canStoreLogsRtcstats() {
  48. const config = this.getState()['features/base/config'];
  49. // Saving the logs in RTCStats is a new feature and so there is no prior behavior that needs to be maintained.
  50. // That said, this is still experimental and needs to be rolled out gradually so we want this to be off by
  51. // default.
  52. return config?.analytics?.rtcstatsStoreLogs && isRTCStatsEnabled(this.getState());
  53. }
  54. /**
  55. * Called by the <tt>LogCollector</tt> to store a series of log lines into
  56. * batch.
  57. *
  58. * @param {Array<string|Object>} logEntries - An array containing strings
  59. * representing log lines or aggregated lines objects.
  60. * @returns {void}
  61. */
  62. storeLogs(logEntries: Array<string | any>) {
  63. if (this.canStoreLogsRtcstats()) {
  64. RTCStats.sendLogs(logEntries);
  65. }
  66. }
  67. }