|
@@ -20,6 +20,7 @@ import 'aui-experimental-css';
|
20
|
20
|
window.toastr = require("toastr");
|
21
|
21
|
|
22
|
22
|
const Logger = require("jitsi-meet-logger");
|
|
23
|
+const LogCollector = Logger.LogCollector;
|
23
|
24
|
|
24
|
25
|
import URLProcessor from "./modules/config/URLProcessor";
|
25
|
26
|
import RoomnameGenerator from './modules/util/RoomnameGenerator';
|
|
@@ -34,6 +35,7 @@ import UIEvents from './service/UI/UIEvents';
|
34
|
35
|
import getTokenData from "./modules/tokendata/TokenData";
|
35
|
36
|
import translation from "./modules/translation/translation";
|
36
|
37
|
|
|
38
|
+const ConferenceEvents = JitsiMeetJS.events.conference;
|
37
|
39
|
|
38
|
40
|
/**
|
39
|
41
|
* Tries to push history state with the following parameters:
|
|
@@ -131,6 +133,16 @@ const APP = {
|
131
|
133
|
settings,
|
132
|
134
|
conference,
|
133
|
135
|
translation,
|
|
136
|
+ /**
|
|
137
|
+ * The log collector which captures JS console logs for this app.
|
|
138
|
+ * @type {LogCollector}
|
|
139
|
+ */
|
|
140
|
+ logCollector: null,
|
|
141
|
+ /**
|
|
142
|
+ * Indicates if the log collector has been started (it will not be started
|
|
143
|
+ * if the welcome page is displayed).
|
|
144
|
+ */
|
|
145
|
+ logCollectorStarted : false,
|
134
|
146
|
/**
|
135
|
147
|
* After the APP has been initialized provides utility methods for dealing
|
136
|
148
|
* with the conference room URL(address).
|
|
@@ -140,11 +152,40 @@ const APP = {
|
140
|
152
|
connection: null,
|
141
|
153
|
API,
|
142
|
154
|
init () {
|
143
|
|
- configureLoggingLevels();
|
|
155
|
+ this.initLogging();
|
144
|
156
|
this.keyboardshortcut =
|
145
|
157
|
require("./modules/keyboardshortcut/keyboardshortcut");
|
146
|
158
|
this.configFetch = require("./modules/config/HttpConfigFetch");
|
147
|
159
|
this.tokenData = getTokenData();
|
|
160
|
+ },
|
|
161
|
+ initLogging () {
|
|
162
|
+ // Adjust logging level
|
|
163
|
+ configureLoggingLevels();
|
|
164
|
+ // Start the LogCollector and register it as the global log transport
|
|
165
|
+ if (!this.logCollector) {
|
|
166
|
+ this.logCollector = new LogCollector({
|
|
167
|
+ storeLogs: (logJSON) => {
|
|
168
|
+ // Try catch was used, because there are many variables
|
|
169
|
+ // on the way that could be uninitialized if the storeLogs
|
|
170
|
+ // attempt would be made very early (which is unlikely)
|
|
171
|
+ try {
|
|
172
|
+ // Currently it makes sense to store the log only
|
|
173
|
+ // if CallStats is enabled
|
|
174
|
+ if (APP.logCollectorStarted
|
|
175
|
+ && APP.conference
|
|
176
|
+ && APP.conference.isCallstatsEnabled()) {
|
|
177
|
+ APP.conference.logJSON(logJSON);
|
|
178
|
+ }
|
|
179
|
+ } catch (error) {
|
|
180
|
+ // NOTE console is intentional here
|
|
181
|
+ console.error(
|
|
182
|
+ "Failed to store the logs: ", logJSON, error);
|
|
183
|
+ }
|
|
184
|
+ }
|
|
185
|
+ });
|
|
186
|
+ Logger.addGlobalTransport(this.logCollector);
|
|
187
|
+ JitsiMeetJS.addGlobalLogTransport(this.logCollector);
|
|
188
|
+ }
|
148
|
189
|
}
|
149
|
190
|
};
|
150
|
191
|
|
|
@@ -168,7 +209,25 @@ function init() {
|
168
|
209
|
replaceHistoryState(APP.ConferenceUrl.getInviteUrl());
|
169
|
210
|
var isUIReady = APP.UI.start();
|
170
|
211
|
if (isUIReady) {
|
|
212
|
+ // Start the LogCollector's periodic "store logs" task only if we're in
|
|
213
|
+ // the conference and not on the welcome page.
|
|
214
|
+ APP.logCollector.start();
|
|
215
|
+ APP.logCollectorStarted = true;
|
|
216
|
+
|
171
|
217
|
APP.conference.init({roomName: buildRoomName()}).then(function () {
|
|
218
|
+
|
|
219
|
+ // Will flush the logs, before the stats are disposed
|
|
220
|
+ if (APP.logCollector) {
|
|
221
|
+ APP.conference.addConferenceListener(
|
|
222
|
+ ConferenceEvents.BEFORE_STATISTICS_DISPOSED,
|
|
223
|
+ () => {
|
|
224
|
+ if (APP.logCollector) {
|
|
225
|
+ APP.logCollector.flush();
|
|
226
|
+ }
|
|
227
|
+ }
|
|
228
|
+ );
|
|
229
|
+ }
|
|
230
|
+
|
172
|
231
|
APP.UI.initConference();
|
173
|
232
|
|
174
|
233
|
APP.UI.addListener(UIEvents.LANG_CHANGED, function (language) {
|
|
@@ -237,6 +296,11 @@ $(document).ready(function () {
|
237
|
296
|
});
|
238
|
297
|
|
239
|
298
|
$(window).bind('beforeunload', function () {
|
|
299
|
+ // Stop the LogCollector
|
|
300
|
+ if (APP.logCollectorStarted) {
|
|
301
|
+ APP.logCollector.stop();
|
|
302
|
+ APP.logCollectorStarted = false;
|
|
303
|
+ }
|
240
|
304
|
APP.API.dispose();
|
241
|
305
|
});
|
242
|
306
|
|