Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat: use LogCollector to capture JS console logs
paweldomas36bcc6831b5e
diff --git a/app.js b/app.jsindex 7996f208e8..7b48bddce6 100644--- a/app.js+++ b/app.js@@ -20,6 +20,7 @@ import 'aui-experimental-css';window.toastr = require("toastr");const Logger = require("jitsi-meet-logger");+const LogCollector = Logger.LogCollector;import URLProcessor from "./modules/config/URLProcessor";import RoomnameGenerator from './modules/util/RoomnameGenerator';@@ -34,6 +35,7 @@ import UIEvents from './service/UI/UIEvents';import getTokenData from "./modules/tokendata/TokenData";import translation from "./modules/translation/translation";+const ConferenceEvents = JitsiMeetJS.events.conference;/*** Tries to push history state with the following parameters:@@ -131,6 +133,16 @@ const APP = {settings,conference,translation,+ /**+ * The log collector which captures JS console logs for this app.+ * @type {LogCollector}+ */+ logCollector: null,+ /**+ * Indicates if the log collector has been started (it will not be started+ * if the welcome page is displayed).+ */+ logCollectorStarted : false,/*** After the APP has been initialized provides utility methods for dealing* with the conference room URL(address).@@ -140,11 +152,40 @@ const APP = {connection: null,API,init () {- configureLoggingLevels();+ this.initLogging();this.keyboardshortcut =require("./modules/keyboardshortcut/keyboardshortcut");this.configFetch = require("./modules/config/HttpConfigFetch");this.tokenData = getTokenData();+ },+ initLogging () {+ // Adjust logging level+ configureLoggingLevels();+ // Start the LogCollector and register it as the global log transport+ if (!this.logCollector) {+ this.logCollector = new LogCollector({+ storeLogs: (logJSON) => {+ // Try catch was used, because there are many variables+ // on the way that could be uninitialized if the storeLogs+ // attempt would be made very early (which is unlikely)+ try {+ // Currently it makes sense to store the log only+ // if CallStats is enabled+ if (APP.logCollectorStarted+ && APP.conference+ && APP.conference.isCallstatsEnabled()) {+ APP.conference.logJSON(logJSON);+ }+ } catch (error) {+ // NOTE console is intentional here+ console.error(+ "Failed to store the logs: ", logJSON, error);+ }+ }+ });+ Logger.addGlobalTransport(this.logCollector);+ JitsiMeetJS.addGlobalLogTransport(this.logCollector);+ }}};@@ -168,7 +209,25 @@ function init() {replaceHistoryState(APP.ConferenceUrl.getInviteUrl());var isUIReady = APP.UI.start();if (isUIReady) {+ // Start the LogCollector's periodic "store logs" task only if we're in+ // the conference and not on the welcome page.+ APP.logCollector.start();+ APP.logCollectorStarted = true;+APP.conference.init({roomName: buildRoomName()}).then(function () {++ // Will flush the logs, before the stats are disposed+ if (APP.logCollector) {+ APP.conference.addConferenceListener(+ ConferenceEvents.BEFORE_STATISTICS_DISPOSED,+ () => {+ if (APP.logCollector) {+ APP.logCollector.flush();+ }+ }+ );+ }+APP.UI.initConference();APP.UI.addListener(UIEvents.LANG_CHANGED, function (language) {@@ -237,6 +296,11 @@ $(document).ready(function () {});$(window).bind('beforeunload', function () {+ // Stop the LogCollector+ if (APP.logCollectorStarted) {+ APP.logCollector.stop();+ APP.logCollectorStarted = false;+ }APP.API.dispose();});diff --git a/conference.js b/conference.jsindex 992d0ef35d..648bcb9ec8 100644--- a/conference.js+++ b/conference.js@@ -1743,6 +1743,15 @@ export default {room.sendApplicationLog(JSON.stringify({name, value}));}},+ /**+ * Methods logs an application event given in the JSON format.+ * @param {string} logJSON an event to be logged in JSON format+ */+ logJSON(logJSON) {+ if (room) {+ room.sendApplicationLog(logJSON);+ }+ },/*** Disconnect from the conference and optionally request user feedback.* @param {boolean} [requestFeedback=false] if user feedback should be