Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@ringcentral/mfe-logger

Package Overview
Dependencies
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ringcentral/mfe-logger - npm Package Compare versions

Comparing version
0.4.16
to
0.4.17
+27
-36
dist/index.js

@@ -196,3 +196,14 @@ 'use strict';

this._onUnload();
this._pruneLogs();
if (mfeShared.global.localStorage) {
const key = `${this._tempKey}-prune-time`;
const PrunedTime = mfeShared.global.localStorage.getItem(key);
if (PrunedTime !== new Date().toLocaleDateString()) {
setTimeout(() => {
this._pruneLogs();
mfeShared.global.localStorage.setItem(key, new Date().toLocaleDateString());
// Avoid running during peak startup load.
// 5 seconds later
}, 5 * 1000);
}
}
setInterval(() => {

@@ -243,3 +254,3 @@ this._pruneLogs();

var _a;
return `${(_a = this._options.prefix) !== null && _a !== void 0 ? _a : 'rc-mfe'}-log`;
return `${(_a = this._options.prefix) !== null && _a !== void 0 ? _a : 'rc-mfe'}:log`;
}

@@ -251,3 +262,3 @@ _initDB() {

db.version((_a = this._options.version) !== null && _a !== void 0 ? _a : 1).stores({
logs: '&time',
logs: '&time, size',
});

@@ -315,18 +326,7 @@ this._table = db.table('logs');

return __awaiter(this, void 0, void 0, function* () {
// Ensure time is a valid number - Dexie requires proper number type
const validTime = Number(time);
if (Number.isNaN(validTime)) {
return Date.now(); // Fallback to current timestamp if invalid
const count = yield ((_a = this._table) === null || _a === void 0 ? void 0 : _a.where('time').equals(time).count());
if (count) {
return this._checkTimeKey(time + 1);
}
try {
const count = yield ((_a = this._table) === null || _a === void 0 ? void 0 : _a.where('time').equals(validTime).count());
if (count) {
return this._checkTimeKey(validTime + 1);
}
return validTime;
}
catch (error) {
console.error('Error in _checkTimeKey:', error);
return validTime + 1; // Move to next time value in case of error
}
return time;
});

@@ -387,7 +387,6 @@ }

return __awaiter(this, void 0, void 0, function* () {
const logs = (_b = (yield ((_a = this._table) === null || _a === void 0 ? void 0 : _a.toArray()))) !== null && _b !== void 0 ? _b : [];
const totalLogSize = logs.reduce((acc, log) => {
return acc + (log.size || 0);
const sizes = (_b = (yield ((_a = this._table) === null || _a === void 0 ? void 0 : _a.orderBy('size').keys()))) !== null && _b !== void 0 ? _b : [];
return sizes.reduce((acc, size) => {
return acc + size;
}, 0);
return totalLogSize;
});

@@ -429,14 +428,6 @@ }

const allLogs = (_a = (yield this._getLogs())) !== null && _a !== void 0 ? _a : [];
const allSessions = new Set();
// Collect all valid sessions
allLogs.forEach((log) => {
if (log.session) {
allSessions.add(log.session);
}
});
// Get recent logs by time
const data = (_c = (yield ((_b = this._table) === null || _b === void 0 ? void 0 : _b.where('time').above(Date.now() - recentTime).toArray()))) !== null && _c !== void 0 ? _c : [];
const allSessions = new Set(allLogs.map((log) => log.session));
const data = (_c = (yield ((_b = this._table) === null || _b === void 0 ? void 0 : _b.where('time').above(Date.now() - recentTime).sortBy('time')))) !== null && _c !== void 0 ? _c : [];
if (!data.length)
return;
data.sort((a, b) => a.time - b.time);
const endTime = new Date(data[data.length - 1].time).toISOString();

@@ -450,10 +441,8 @@ const startTime = new Date(data[0].time).toISOString();

const historyFolder = logFolder.folder('history');
// Process each session
for (const session of allSessions) {
const sessionLogs = allLogs
const _logs = allLogs
.filter((log) => log.session === session)
.sort((a, b) => a.time - b.time)
.map((item) => item.messages.join('\n'))
.join('\n');
historyFolder.file(`${session}.log`, `${sessionLogs}\n`);
historyFolder.file(`${session}.log`, `${_logs}\n`);
}

@@ -481,2 +470,4 @@ for (const extraLog of extraLogs) {

return __awaiter(this, void 0, void 0, function* () {
// before query logs, prune logs
yield this._pruneLogs();
const data = yield this.queryLogs({

@@ -483,0 +474,0 @@ name: _name,

@@ -1,1 +0,1 @@

{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}

@@ -194,3 +194,14 @@ import { global } from '@ringcentral/mfe-shared';

this._onUnload();
this._pruneLogs();
if (global.localStorage) {
const key = `${this._tempKey}-prune-time`;
const PrunedTime = global.localStorage.getItem(key);
if (PrunedTime !== new Date().toLocaleDateString()) {
setTimeout(() => {
this._pruneLogs();
global.localStorage.setItem(key, new Date().toLocaleDateString());
// Avoid running during peak startup load.
// 5 seconds later
}, 5 * 1000);
}
}
setInterval(() => {

@@ -241,3 +252,3 @@ this._pruneLogs();

var _a;
return `${(_a = this._options.prefix) !== null && _a !== void 0 ? _a : 'rc-mfe'}-log`;
return `${(_a = this._options.prefix) !== null && _a !== void 0 ? _a : 'rc-mfe'}:log`;
}

@@ -249,3 +260,3 @@ _initDB() {

db.version((_a = this._options.version) !== null && _a !== void 0 ? _a : 1).stores({
logs: '&time',
logs: '&time, size',
});

@@ -313,18 +324,7 @@ this._table = db.table('logs');

return __awaiter(this, void 0, void 0, function* () {
// Ensure time is a valid number - Dexie requires proper number type
const validTime = Number(time);
if (Number.isNaN(validTime)) {
return Date.now(); // Fallback to current timestamp if invalid
const count = yield ((_a = this._table) === null || _a === void 0 ? void 0 : _a.where('time').equals(time).count());
if (count) {
return this._checkTimeKey(time + 1);
}
try {
const count = yield ((_a = this._table) === null || _a === void 0 ? void 0 : _a.where('time').equals(validTime).count());
if (count) {
return this._checkTimeKey(validTime + 1);
}
return validTime;
}
catch (error) {
console.error('Error in _checkTimeKey:', error);
return validTime + 1; // Move to next time value in case of error
}
return time;
});

@@ -385,7 +385,6 @@ }

return __awaiter(this, void 0, void 0, function* () {
const logs = (_b = (yield ((_a = this._table) === null || _a === void 0 ? void 0 : _a.toArray()))) !== null && _b !== void 0 ? _b : [];
const totalLogSize = logs.reduce((acc, log) => {
return acc + (log.size || 0);
const sizes = (_b = (yield ((_a = this._table) === null || _a === void 0 ? void 0 : _a.orderBy('size').keys()))) !== null && _b !== void 0 ? _b : [];
return sizes.reduce((acc, size) => {
return acc + size;
}, 0);
return totalLogSize;
});

@@ -427,14 +426,6 @@ }

const allLogs = (_a = (yield this._getLogs())) !== null && _a !== void 0 ? _a : [];
const allSessions = new Set();
// Collect all valid sessions
allLogs.forEach((log) => {
if (log.session) {
allSessions.add(log.session);
}
});
// Get recent logs by time
const data = (_c = (yield ((_b = this._table) === null || _b === void 0 ? void 0 : _b.where('time').above(Date.now() - recentTime).toArray()))) !== null && _c !== void 0 ? _c : [];
const allSessions = new Set(allLogs.map((log) => log.session));
const data = (_c = (yield ((_b = this._table) === null || _b === void 0 ? void 0 : _b.where('time').above(Date.now() - recentTime).sortBy('time')))) !== null && _c !== void 0 ? _c : [];
if (!data.length)
return;
data.sort((a, b) => a.time - b.time);
const endTime = new Date(data[data.length - 1].time).toISOString();

@@ -448,10 +439,8 @@ const startTime = new Date(data[0].time).toISOString();

const historyFolder = logFolder.folder('history');
// Process each session
for (const session of allSessions) {
const sessionLogs = allLogs
const _logs = allLogs
.filter((log) => log.session === session)
.sort((a, b) => a.time - b.time)
.map((item) => item.messages.join('\n'))
.join('\n');
historyFolder.file(`${session}.log`, `${sessionLogs}\n`);
historyFolder.file(`${session}.log`, `${_logs}\n`);
}

@@ -479,2 +468,4 @@ for (const extraLog of extraLogs) {

return __awaiter(this, void 0, void 0, function* () {
// before query logs, prune logs
yield this._pruneLogs();
const data = yield this.queryLogs({

@@ -481,0 +472,0 @@ name: _name,

@@ -1,1 +0,1 @@

{"version":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E,OAAO,CAAC,IAAI,CAAC,CAAC;IAElC,SAAS,CAAC,WAAW,YAAmB;cAExB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;cAmB5C,SAAS,CAAC,IAAI,EAAE,IAAI;IA0BpC,IAAI,WAAW,WAEd;IAED,SAAS,CAAC,kBAAkB;IAI5B,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM;cAIlB,QAAQ;IAIxB,IAAI,WAAW,WAEd;cAGe,aAAa;cAQb,UAAU;IA2B1B,IAAI,UAAU,WAEb;IAED;;OAEG;IACG,SAAS,CAAC,EACd,IAAI,EAAE,KAAiB,EACvB,UAA4B,EAC5B,SAAc,GACf,GAAE;QACD;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd;;WAEG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB;;WAEG;QACH,SAAS,CAAC,EAAE,SAAS,CAAC;KAClB;;;;IAwDN;;OAEG;IACG,OAAO,CAAC,EACZ,IAAI,EAAE,KAAiB,EACvB,UAA4B,EAC5B,SAAc,GACf,GAAE;QACD;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd;;WAEG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB;;WAEG;QACH,SAAS,CAAC,EAAE,SAAS,CAAC;KAClB;;;;IAeN;;OAEG;IACG,OAAO,CAAC,GAAG,EAAE,KAAK;IAWxB;;OAEG;IACG,YAAY,CAAC,EACjB,IAAgB,EAChB,UAA4B,EAC5B,SAAc,GACf,GAAE;QACD;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd;;WAEG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB;;WAEG;QACH,SAAS,CAAC,EAAE,SAAS,CAAC;KAClB;CAaP"}
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../../../src/transports/storage.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,MAAM,OAA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AAS,CAAC;KAClB;;;;IAuCN;;OAEG;IACG,OAAO,CAAC,EACZ,IAAI,EAAE,KAAiB,EACvB,UAA4B,EAC5B,SAAc,GACf,GAAE;QACD;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd;;WAEG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB;;WAEG;QACH,SAAS,CAAC,EAAE,SAAS,CAAC;KAClB;;;;IAiBN;;OAEG;IACG,OAAO,CAAC,GAAG,EAAE,KAAK;IAWxB;;OAEG;IACG,YAAY,CAAC,EACjB,IAAgB,EAChB,UAA4B,EAC5B,SAAc,GACf,GAAE;QACD;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd;;WAEG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB;;WAEG;QACH,SAAS,CAAC,EAAE,SAAS,CAAC;KAClB;CAaP"}
{
"name": "@ringcentral/mfe-logger",
"version": "0.4.16",
"version": "0.4.17",
"description": "A micro frontends framework for building Web applications",

@@ -45,3 +45,3 @@ "main": "dist/index.js",

"dependencies": {
"@ringcentral/mfe-shared": "^0.4.16",
"@ringcentral/mfe-shared": "^0.4.17",
"@roarr/browser-log-writer": "1.3.0",

@@ -48,0 +48,0 @@ "dexie": "3.2.4",

@@ -111,3 +111,14 @@ /* eslint-disable no-param-reassign */

this._onUnload();
this._pruneLogs();
if (global.localStorage) {
const key = `${this._tempKey}-prune-time`;
const PrunedTime = global.localStorage.getItem(key);
if (PrunedTime !== new Date().toLocaleDateString()) {
setTimeout(() => {
this._pruneLogs();
global.localStorage.setItem(key, new Date().toLocaleDateString());
// Avoid running during peak startup load.
// 5 seconds later
}, 5 * 1000);
}
}
setInterval(() => {

@@ -161,3 +172,3 @@ this._pruneLogs();

get name() {
return `${this._options.prefix ?? 'rc-mfe'}-log`;
return `${this._options.prefix ?? 'rc-mfe'}:log`;
}

@@ -168,3 +179,3 @@

db.version(this._options.version ?? 1).stores({
logs: '&time',
logs: '&time, size',
});

@@ -249,18 +260,7 @@ this._table = db.table('logs');

protected async _checkTimeKey(time: number): Promise<number> {
// Ensure time is a valid number - Dexie requires proper number type
const validTime = Number(time);
if (Number.isNaN(validTime)) {
return Date.now(); // Fallback to current timestamp if invalid
const count = await this._table?.where('time').equals(time).count();
if (count) {
return this._checkTimeKey(time + 1);
}
try {
const count = await this._table?.where('time').equals(validTime).count();
if (count) {
return this._checkTimeKey(validTime + 1);
}
return validTime;
} catch (error) {
console.error('Error in _checkTimeKey:', error);
return validTime + 1; // Move to next time value in case of error
}
return time;
}

@@ -316,7 +316,7 @@

protected async _getTotalSize() {
const logs = (await this._table?.toArray()) ?? [];
const totalLogSize = logs.reduce((acc, log) => {
return acc + (log.size || 0);
const sizes =
((await this._table?.orderBy('size').keys()) as number[]) ?? [];
return sizes.reduce((acc, size) => {
return acc + size;
}, 0);
return totalLogSize;
}

@@ -377,12 +377,3 @@

const allLogs = (await this._getLogs()) ?? [];
const allSessions = new Set<string>();
// Collect all valid sessions
allLogs.forEach((log) => {
if (log.session) {
allSessions.add(log.session);
}
});
// Get recent logs by time
const allSessions = new Set(allLogs.map((log) => log.session));
const data =

@@ -392,8 +383,4 @@ (await this._table

.above(Date.now() - recentTime)
.toArray()) ?? [];
.sortBy('time')) ?? [];
if (!data.length) return;
data.sort((a, b) => a.time - b.time);
const endTime = new Date(data[data.length - 1].time).toISOString();

@@ -407,13 +394,9 @@ const startTime = new Date(data[0].time).toISOString();

const historyFolder = logFolder.folder('history')!;
// Process each session
for (const session of allSessions) {
const sessionLogs = allLogs
const _logs = allLogs
.filter((log) => log.session === session)
.sort((a, b) => a.time - b.time)
.map((item) => item.messages.join('\n'))
.join('\n');
historyFolder.file(`${session}.log`, `${sessionLogs}\n`);
historyFolder.file(`${session}.log`, `${_logs}\n`);
}
for (const extraLog of extraLogs) {

@@ -455,2 +438,4 @@ // Append a newline for string logs to ensure proper text formatting.

} = {}) {
// before query logs, prune logs
await this._pruneLogs();
const data = await this.queryLogs({

@@ -457,0 +442,0 @@ name: _name,