@@ -14,9 +14,11 @@ class DeclutterProperty {
1414}
1515
1616class DeclutterTimeProperty extends DeclutterProperty {
17- time = 100 ;
17+ DEFAULT_TIME = 100 ;
1818
19- constructor ( on = true , defaultValue = true , time = 100 ) {
19+ time = this . DEFAULT_TIME ;
20+
21+ constructor ( on = true , defaultValue = true , time = DeclutterTimeProperty . DEFAULT_TIME ) {
2022 super ( on , defaultValue ) ;
2123
2224 this . time = time ;
@@ -46,6 +48,8 @@ class DeclutterExternalPathsProperty extends DeclutterProperty {
4648 }
4749}
4850
51+ const ROOT_EVENT_LABELS = [ 'cli.command' , 'job.perform' , 'message.handle' ] ;
52+
4953class Declutter {
5054 limitRootEvents = new DeclutterProperty ( ) ;
5155 hideMediaRequests = new DeclutterProperty ( ) ;
@@ -130,9 +134,24 @@ export default class AppMapFilter {
130134 } , new Set ( ) ) ;
131135 }
132136
133- // Include only subtrees of an HTTP server request , unless there are no HTTP server requests .
137+ // Include only subtrees of "command"-type events , unless there are no commands .
134138 if ( this . declutter . limitRootEvents . on ) {
135- events = includeSubtrees ( events , ( e ) => e . httpServerRequest , false ) ;
139+ // Return true if the event is a "command". Types of commands recognized by this test include:
140+ // - HTTP server request - the event has http_server_request data
141+ // - cli.command - command of a CLI application
142+ // - job.perform - a background job
143+ // - message.handle - a handler for a message queue
144+ //
145+ // @param {Event } e
146+ const isCommand = ( e ) => {
147+ if ( e . httpServerRequest ) return true ;
148+
149+ const { labels } = e . codeObject ;
150+
151+ return ROOT_EVENT_LABELS . find ( ( label ) => labels . has ( label ) ) ;
152+ } ;
153+
154+ events = includeSubtrees ( events , isCommand , false ) ;
136155 }
137156
138157 // Include only subtrees of a specified root object. This could also be stored and managed
0 commit comments