To use JavaScript in , there are some mandatory variables and APIs that you require.
Variables/Functions | Description | Examples |
---|---|---|
audit | To control the custom user audit function. The supported types are:
Syntax audit.count(key);
Syntax audit.sum(key,value);
Syntax audit.set(key,value); | audit.set
audit.sum
audit.count
|
log | An object that contains logging functionality for the severity levels: info, warning, and error.
Note
Note! Currently, the Console object in JavaScript, which provides access to the browser's debugging console, is disabled. | Example
|
| The payload variable contains all the information of the current record/object. | Example
|
| The The following metadata is accessible using the Script Flush tab:
| Example using S3 Forwarder If you choose to add properties to In the Script Function, Example const moment = require("moment"); if (!meta.simDate) { meta.simDate = moment(new Date()).format('YYYYMMDD'); } In the Amazon S3 forwarder, add this in the Filename field: For more information, please see Configuring Dynamic Naming in Fields. |
push(<event>) | To send data downstream. You need to invoke this Function using | To send data to the next Function(s) in the stream. Example
|
| This is to keep the state across records. The state is only available during one stream execution. The information stored in the The
Note Refer to Best Practices to Avoid Stateful Stream Design for tips to not lose memory in case of any issue with stream execution or system downtime. | Example of node
Example of stream
|
| These three operations functions as a key-value store. The key must be a string. Value can be of any type, for example: string, number, date, JSON object, and array.
Note! If a value exceeding the maximum limit is entered, the value is automatically set to the designed maximum.
| Example
Example:
Example:
|
| With shared persistent storage, streams can access the same data. For example, one stream writes data to the shared persistent storage that can be used by one or more streams. The key must be a string. Value can be of any type, for example, string, number, date, JSON object, and array. Note! Streams sharing data must belong to the same solution. You must use the
Note! If a value exceeding the maximum limit is entered, the value is automatically set to the designed maximum.
| Example
Example
Example
|
Error message example
This really simplistic example shows the log when the keyword "payload" is spelled with a capital 'P'. The following example uses the Summarize Monthly Usage Data example stream.