Websockets Track Create

source
The path to the source Flow.
destination
A list of possible destination Flows.

Optional Fields


filter
Filter statement, used to denote elements and values of a Drop added to the source Flow which are required to "activate" the Track. If unspecified, all Drops incoming to the source Flow will activate the Track.
js
A javascript function that takes a Drop matching the filter from the source Flow as its first argument and then returns a Drop to be written to the destination Flow. The API may be accessed from within the js in order to enhance Drops with data from other flows by utilizing Flow.js

Request


Example

  {
    "msgId" : "my-request",
    "object": "track",
    "type": "create",
    "value": {
      "source" : "/bob/my_source",
      "destination" : "/bob/my_destination",
      "filter" : "elems.rating > 25",
      "js" : "function f(input) {
                       var output = input;
                       output.elems['stars'] = {
                         'type' : 'float',
                         'value' : input.elems['rating'].value/25
                       };
                       delete output.elems['rating'];
                       return output;
                   }"
    }
  }

Response


Example

  {
    "head": {
      "msgId": "my-request",
      "ok": true,
      "errors": [],
      "messages": [ "Your request has been processed successfully. A new resource has been created." ]
    },
    "body": {
      "id": "t53b1d1600cf27b75148de02e",
      "source" : "/bob/my_source",
      "destination" : "/bob/my_destination",
      "filter" : "elems.rating > 25",
      "js" : "function f(input) { var output = input; output.elems['stars'] = {'type' : 'float', 'value' : input.elems['rating'].value/25 }; delete output.elems['rating']; return output; }"
    }
  }