FormidableLabs / envy

Node.js Telemetry & Network Viewer
https://envy-webui.vercel.app
MIT License
110 stars 0 forks source link

Search enhancement for systems #187

Closed kgpax closed 11 months ago

kgpax commented 1 year ago

Summary

Add the ability for a system to help inform whether a trace matches the current search term, so that the "search" function in the header can find traces based on more than just the URL.

For example:

Extend the System<T> interface to add the following (optional) function interface:

getKeywords?(context: TraceContext<T>): string[]

Update the logic which calculates the traces to display (in ApplicationContext#traces()) to, for each trace:

An alternative approach to consider might be to have a isSearchMatch function interface instead...

isSearchMatch?(context: TraceContext<T>, searchTerm: string): boolean

...which means that the current search term is used in a call to this and the system can return true/false based on whether the search term matches the trace

How might this be useful?

Take an example of a trace which lists product data. We might have the product ID in the URL meaning that the current search would find that trace if you type the product ID, but if it did not exist in the URL then it wouldn't. With this capability, we can expose the product ID(s) as keywords.

A further enhancement is that, if we have the trace response, we could expose some of the response data as keywords such as the name of the product, meaning that we can search by the product name and find the relevant trace(s).

Considerations

Performance will need to be considered, as we'd have to interrogate each trace to determine its system and (potential) keywords every time we update the trace list (including every time we change the search term).