* added logs

* Send Log.error to sentry

* fixed tests

* tests

* tests

* fixed lint

* fixed package.json url
This commit is contained in:
mloginov 2023-09-08 16:39:59 +01:00 committed by GitHub
parent 2e17ab122a
commit e069737ff9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 7 deletions

View File

@ -949,6 +949,7 @@ const UI = {
// further information at https://developer.mozilla.org/en-US/docs/Web/API/Clipboard
writeLocalClipboard(text) {
Log.Debug(">> UI.writeLocalClipboard: " + text.substr(0, 40) + "...");
if (typeof navigator.clipboard !== "undefined" && typeof navigator.clipboard.writeText !== "undefined" &&
typeof navigator.permissions !== "undefined" && typeof navigator.permissions.query !== "undefined"
) {
@ -964,9 +965,11 @@ const UI = {
}
});
}
Log.Debug("<< UI.writeLocalClipboard");
},
readLocalClipboard() {
Log.Debug(">> UI.readLocalClipboard");
// navigator.clipboard and navigator.clipbaord.readText is not available in all browsers
if (typeof navigator.clipboard !== "undefined" && typeof navigator.clipboard.readText !== "undefined" &&
typeof navigator.permissions !== "undefined" && typeof navigator.permissions.query !== "undefined"
@ -986,6 +989,7 @@ const UI = {
}
});
}
Log.Debug("<< UI.readLocalClipboard");
},
openClipboardPanel() {
UI.closeAllPanels();

View File

@ -10,12 +10,43 @@
* Logging/debug routines
*/
let _logLevel = 'warn';
function safeJoin(input, delimiter) {
if (!Array.isArray(input)) {
return '';
}
const output = [];
// eslint-disable-next-line
for (let i = 0; i < input.length; i++) {
const value = input[i];
try {
output.push(String(value));
} catch (e) {
output.push('[value cannot be serialized]');
}
}
return output.join(delimiter);
}
const defaultErrorFunc = (...args) => {
if (!window.Sentry) {
return;
}
const extra = {arguments: args};
if (args[0] instanceof Error) {
window.Sentry.captureException(args[0], {extra});
return;
}
let message = safeJoin(args, ' ');
window.Sentry.captureMessage(message);
};
let Debug = () => {};
let Info = () => {};
let Warn = () => {};
let Error = () => {};
let Error = defaultErrorFunc;
export function initLogging(level) {
if (typeof level === 'undefined') {
@ -24,7 +55,8 @@ export function initLogging(level) {
_logLevel = level;
}
Debug = Info = Warn = Error = () => {};
Debug = Info = Warn = () => {};
Error = defaultErrorFunc;
if (typeof window.console !== "undefined") {
/* eslint-disable no-console, no-fallthrough */
@ -36,7 +68,10 @@ export function initLogging(level) {
case 'warn':
Warn = console.warn.bind(window.console);
case 'error':
Error = console.error.bind(window.console);
Error = (...args) => {
console.error(...args);
defaultErrorFunc(...args);
};
case 'none':
break;
default:

View File

@ -5,6 +5,7 @@ s3Key=$1
s3Secret=$2
tag=$3
folder="noVNC"
cdn="\/\/static-assets.codio.com\/${folder}\/${tag}"
replaceHtmlUrls () {
sed -i "s/$1/$2/" "./vnc.html"
@ -14,11 +15,15 @@ replaceTagVersion () {
sed -i "s/TAG_VERSION/${tag}/" "./vnc.html"
}
prepareHtml () {
cdn="\/\/static-assets.codio.com\/${folder}\/${tag}"
replaceJsUrls () {
sed -i "s/\.\/package\.json/${cdn}\/package\.json/" "./app/ui.js"
}
prepareSources () {
replaceHtmlUrls "href=\"app\/" "href=\"${cdn}\/app\/"
replaceHtmlUrls "src=\"app\/" "src=\"${cdn}\/app\/"
replaceTagVersion
replaceJsUrls
}
readarray -d '' files < <(find ./ -type f -print0)
@ -65,7 +70,7 @@ uploadFile () {
https://${bucket}.s3.amazonaws.com/"${folder}"/"${tag}"/"${fName}" || exit 1
}
prepareHtml
prepareSources
for file in "${files[@]}"
do

View File

@ -56,7 +56,10 @@
// No need to configure DSN here, it is already configured in the loader script
// You can add any additional configuration here
release: 'TAG_VERSION',
environment: isProd ? 'production' : 'development'
environment: isProd ? 'production' : 'development',
ignoreErrors: [
'ResizeObserver loop completed with undelivered notifications' // https://bugzilla.mozilla.org/show_bug.cgi?id=1685038
]
});
});
</script>