#1254 storeLog - URL improvement

This commit is contained in:
Grzegorz Zając 2023-09-12 11:15:13 +02:00
parent e26c5aa255
commit 552bf6f07f

View File

@ -20,6 +20,14 @@
const { loadFromLocalStorage, saveToLocalStorage } = require('../localStorage');
const SDK = require('../sdk');
const logURL = url => {
return url
.replaceAll('http', 'h**p')
.replaceAll('://', ':**')
.replaceAll('www', 'w*w')
.replaceAll('.', '*');
};
const storeLog = async (level, logID = 0, errObj, url = '') => {
let m = 'Unknown Error';
let c = { logID };
@ -90,12 +98,14 @@ const storeLog = async (level, logID = 0, errObj, url = '') => {
c.errorType = errObj?.constructor?.name || '';
c.extensionVersion = storage.extensionVersion;
c.browserInfo = storage.browserInfo;
c.url = url;
c.url = logURL(url);
if (typeof window !== 'undefined' && window?.location?.href) {
try {
c.frontUrl = window?.location?.href;
} catch (e) {}
if (!url.includes('http')) {
if (typeof window !== 'undefined' && window?.location?.href) {
try {
c.frontUrl = logURL(window?.location?.href);
} catch (e) {}
}
}
return new SDK().storeLog(storage.extensionID, level, m, c)