Skip to main content

tag-enrichment-plugin

This plugin extends the tag extraction feature by allowing to dereference / enrich a tag from data of your own system and inject these in the UI.

For instance, a tag could extract the city id of the client of the requests, and get the city name from the system under monitoring. Then filtering becomes easier, and Excel extract, statistics and grid becomes more meaningful.

Signature

function myOwnPlugin({
inputs: {name, values, mode},
parameters: {},
callbacks: {setDecodedTags, onShowInfo, onShowError, onShowWarning },
libs: {React}
}){}

The plugin is called:

  • For each row, and each displayed Tag in the Grid or Excel export
  • For each group for stats grouped by Tag and Excel export
  • For each Tag in the HTTP details panel
  • For all Tag values for the Filters component in the grid header
  • To display the Tag value in the filter badge when it is selected

Depending on the call, the output is requested in REACT components mode (grids and details) or in TEXT mode (Excel, filters)

Input

NameDescription
nameName of the tag
valuesArray of tag values
modeREACT or TEXT for the output type

Callbacks

onShowInfo(message)

Displays an Information toast with the message.

onShowWarning(message)

Displays a Warning toast with the message.

onShowError(message)

Displays an Error toast with the message.

setDecodeTags([])

Callback expected in output.
Expects an array of decoded values, in the same order, without holes as the values array input.

Output

Output must be sent both:

  • Using setDecodedTags callback
  • With a return value (of the promise)

Plugin example

Streetsmart park tag enrichment plugin

The plugin dereferences Park tags to display park name and parkCode.

For the plugin to work, Spider tags must be configured to extract park id from the HTTP requests & responses.

Parameters

The plugin takes 3 parameters:

tag-enrichment-params.png

  • Environment: Streetsmart environment to calls to dereference the filters
  • Login & password: Account used to connect to Streetsmart
    • The account must exists on the selected environment.
    • For now, it has been created in SIT0, SIT1 and SVT2

Result

  • In grid

  • In filter list

  • In selected filters

  • In details

  • In stats

  • In excel exports

Code

The code is private in Flowbird bitbucket repo: sss-park-tag-enrichment-spiderplugin

The plugin:

  • Request /park/{id} if less than 5 parks to resolve
  • Build queryString queries if more than 5 parks, by grouping by 25 parks buckets
  • Cache the results not to ask several times
  • Blocks parallel requests not to ask simultaneously resolving of the same park

All this in a few lines, many nice patterns to reuse !! :-D