@contrast/library-analysis
Advanced tools
Comparing version 1.13.1 to 1.14.0
@@ -34,2 +34,4 @@ /* | ||
libraryUsage.bufferedEvents = new Set(); | ||
function registerCodeEvent({ script }) { | ||
@@ -68,18 +70,12 @@ const nmIndex = script.lastIndexOf('node_modules'); | ||
libraryUsage.codeEventListener = (codeEvent) => { | ||
if ( | ||
codeEvent.type !== type || | ||
codeEvent.script?.indexOf(`node_modules${path.sep}`) === -1 || | ||
!codeEvent.func | ||
) return; | ||
try { | ||
if ( | ||
codeEvent.type !== type || | ||
codeEvent.script.indexOf(`node_modules${path.sep}`) === -1 || | ||
!codeEvent.func | ||
) { | ||
return; | ||
} | ||
const { info, updated } = registerCodeEvent(codeEvent); | ||
if (updated) { | ||
messages.emit(Event.LIBRARY_USAGE, { | ||
id: info.hash, | ||
names: Array.from(info.names), | ||
}); | ||
libraryUsage.bufferedEvents.add(info); | ||
} | ||
@@ -94,5 +90,17 @@ } catch (err) { | ||
libraryUsage.report = function() { | ||
for (const info of libraryUsage.bufferedEvents) { | ||
messages.emit(Event.LIBRARY_USAGE, { | ||
id: info.hash, | ||
names: Array.from(info.names), | ||
}); | ||
libraryUsage.bufferedEvents.delete(info); | ||
} | ||
}; | ||
libraryUsage.install = function () { | ||
const evalInterval = config.agent.node.library_usage.reporting.interval_ms; | ||
setCodeEventListener(libraryUsage.codeEventListener, evalInterval); | ||
setInterval(libraryUsage.report, 2000).unref(); | ||
}; | ||
@@ -99,0 +107,0 @@ |
{ | ||
"name": "@contrast/library-analysis", | ||
"version": "1.13.1", | ||
"version": "1.14.0", | ||
"description": "Handles library reporting and library usage analysis", | ||
@@ -5,0 +5,0 @@ "license": "SEE LICENSE IN LICENSE", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18196
464