Context
Change Type: Preview
Product area: Analytics
Component: Streaming Analytics
Deployed at: eu.latest.cumulocity.com, apj.cumulocity.com, jp.cumulocity.com, cumulocity.com, us.cumulocity.com, emea.cumulocity.com
Technical details
Build artifact: apama-in-c8y (27.33.0)
Internal ID: PAB-5076
Description
A new Smart Function block has been added to Analytics Builder. This block executes a JS Smart Function on the inputs and produces an output.
Preview
This feature is in Public Preview, that is, it is not enabled by default and may be subject to change in the future.
The Smart Function must export a function onInput(inputs, context) that returns a list of outputs.
Argument details:
-
inputsis a list of tenValueobjects, with membersvalue,properties, andtimestampcorresponding to the block inputs. -
contextis an object with the following members:blockParameters- List that contains the block parameters as specified in the block configuration.getState(key, def = null)- Method that retrieves a value previously stored in the context under the given key. If no value is found, returnsdef.setState(key, value)- Method that stores the given value in the context under the given key.
In addition, the console object has log, warn, error, and debug members that can be used to log messages to the microservice log.
The return value of the function is a list of up to ten values corresponding to the block outputs. These can either be bare values, or Value objects, with members value, properties, and timestamp. If the function does not generate a value, return null instead.