Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing js-sdk logging #7736

Merged
merged 1 commit into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions src/vector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ require('gfm.css/gfm.css');
require('highlight.js/styles/github.css');
require('draft-js/dist/Draft.css');

import './rageshakesetup';

import React from 'react';
// add React and ReactPerf to the global namespace, to make them easier to
// access via the console
Expand Down Expand Up @@ -56,8 +58,6 @@ import SdkConfig from "matrix-react-sdk/lib/SdkConfig";

import Olm from 'olm';

import rageshake from "matrix-react-sdk/lib/rageshake/rageshake";

import CallHandler from 'matrix-react-sdk/lib/CallHandler';

import {getVectorConfig} from './getconfig';
Expand All @@ -68,22 +68,6 @@ let lastLocationHashSet = null;
// and need to migrate, but they spam the console with warnings.
Promise.config({warnings: false});

function initRageshake() {
rageshake.init().then(() => {
console.log("Initialised rageshake: See https://bugs.chromium.org/p/chromium/issues/detail?id=583193 to fix line numbers on Chrome.");

window.addEventListener('beforeunload', (e) => {
console.log('riot-web closing');
// try to flush the logs to indexeddb
rageshake.flush();
});

rageshake.cleanup();
}, (err) => {
console.error("Failed to initialise rageshake: " + err);
});
}

function checkBrowserFeatures(featureList) {
if (!window.Modernizr) {
console.error("Cannot check features - Modernizr global is missing.");
Expand Down Expand Up @@ -225,7 +209,6 @@ function onTokenLoginCompleted() {
}

async function loadApp() {
initRageshake();
MatrixClientPeg.setIndexedDbWorkerScript(window.vector_indexeddb_worker_script);
CallHandler.setConferenceHandler(VectorConferenceHandler);

Expand Down
46 changes: 46 additions & 0 deletions src/vector/rageshakesetup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
Copyright 2018 New Vector Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/*
* Separate file that sets up rageshake logging when imported.
* This is necessary so that rageshake logging is set up before
* anything else. Webpack puts all import statements at the top
* of the file before any code, so imports will always be
* evaluated first. Other imports can cause other code to be
* evaluated (eg. the loglevel library in js-sdk, which if set
* up before rageshake causes some js-sdk logging to be missing
* from the rageshake.)
*/

import rageshake from "matrix-react-sdk/lib/rageshake/rageshake";

function initRageshake() {
rageshake.init().then(() => {
console.log("Initialised rageshake: See https://bugs.chromium.org/p/chromium/issues/detail?id=583193 to fix line numbers on Chrome.");

window.addEventListener('beforeunload', (e) => {
console.log('riot-web closing');
// try to flush the logs to indexeddb
rageshake.flush();
});

rageshake.cleanup();
}, (err) => {
console.error("Failed to initialise rageshake: " + err);
});
}

initRageshake();