Skip to content

Commit 7a9abc2

Browse files
add deps logging
1 parent b1bf533 commit 7a9abc2

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/hooks/useSidebarOrderedReports.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,21 @@ function getChangedKeys<T extends Record<string, unknown>>(deps: T, prevDeps: T)
284284
function logChangedDeps<T extends Record<string, unknown>>(msg: string, deps: T, prevDeps: T) {
285285
const startTime = performance.now();
286286
const changedDeps = getChangedKeys(deps, prevDeps);
287+
const parsedDeps = parseDepsForLogging(deps);
287288
const processingDuration = performance.now() - startTime;
288289
Log.info(msg, false, {
290+
deps: parsedDeps,
289291
changedDeps,
290292
processingDuration,
291293
});
292294
}
295+
296+
/**
297+
* @param deps - The dependencies to parse.
298+
* @returns A simplified object with light-weight values.
299+
*/
300+
function parseDepsForLogging<T extends Record<string, unknown>>(deps: T) {
301+
// If object or array, return the keys' length
302+
// If primitive, return the value
303+
return Object.fromEntries(Object.entries(deps).map(([key, value]) => [key, typeof value === 'object' && value !== null ? Object.keys(value).length : value]));
304+
}

0 commit comments

Comments
 (0)