# Vectry Log

> Emits a structured causal event to the Vectry Operational Intelligence Platform.

Source: https://docs.sommatic.ai/en/nodes/vectry.log/

- Slug: `vectry.log`
- Family: Operations
- Version: 1.0.0
- Status: Experimental. Always fails today: the worker calls `logger.debug`, which the runtime logger does not provide, so every run leaves through `error` with "logger.debug is not a function". Do not use it until it is fixed.
- Execution: fire-and-forget

Emits a structured causal event to the Vectry Operational Intelligence Platform.

Vectry uses these events to construct a Causal Graph of your system, enabling advanced XAI (Explainable AI), anomaly detection, and root cause analysis. Unlike standard logs, Vectry events are linked by entities and operations to model *cause and effect*.

**Key Concepts:**
- **Entity:** The noun (e.g., "Order", "User").
- **Operation:** The verb (e.g., "Created", "Updated").
- **Context:** Payload data that helps explain the event.

**Use Cases:**
- Reporting significant business milestones (e.g., "LoanApproved").
- Logging internal AI reasoning steps (SpikingBrain integration).
- Tracking distributed system interactions.

## Configuration

- `api_key` (string, required)
- `endpoint` (string, optional): Default: `https://api.vectry.io`.
- `system_domain` (string, optional)
- `system_entity` (string, optional)

Its configuration shows the shared execution settings, but this node does not apply retries (`retryOnFail`, `maxTries`) yet. `continueOnFail` is not applied by any node.

## Output ports

- `success` (default): Logged
- `error`: Error

## Input contract

- `operation` (string, required): Event Name
- `system_entity_id` (string, optional): Unique Entity ID
- `severity` (string, optional): Allowed values: `info`, `warn`, `error`, `debug`.
- `payload` (object, optional): Event Context
- `tags` (array<string>, optional)

## Output contract

- `success` (boolean, optional)

## In expressions

What a later node can read from this node's output with `$("Vectry Log").item.json.<path>` (write your node's label instead of `Vectry Log`). **Editor** marks the paths the workflow editor suggests under Previous Nodes (the output contract); **Worker** marks the paths the worker really returns through `success`, from the output shown in Ports.

- `$("Vectry Log").item.json.success` (boolean) = `true`
- `$("Vectry Log").item.json.port` (string) = `"success"` (Not suggested by the editor)


## How it works

Meant to send one event to the Vectry ingest API (`POST <endpoint>/v1/ingest`). In the current runtime it leaves through `error` with `logger.debug is not a function` right before the request, so no event is sent.

1. Merges the input item with the resolved config (config wins).
2. Leaves through `error` with `Missing 'api_key' for Vectry` when no API key is available, and with `Missing 'operation'` when `operation` is empty.
3. Builds the event name `<system_domain>.<system_entity>.<operation>` (both default to `default`) and the body `{ dataset, event, level, timestamp, data, tags, source: "sommatic-orchestrator" }`, where `data` is `payload` plus `entity_id` and `operation`.
4. Calls `logger.debug()`, which throws; the worker catches it and leaves through `error`. The step below is not reached today.
5. Sends the body with `Authorization: Bearer <api_key>` and returns `{ port: "success", success: true }`.

## In a workflow

### Node

```json
{
  "node_id": "node-log-order-shipped",
  "label": "Log order shipped",
  "operator_slug": "vectry.log",
  "operator_version": "1.0.0",
  "config": {
    "api_key": "<vectry_api_key>",
    "endpoint": "https://api.example.com",
    "system_domain": "sales",
    "system_entity": "order",
    "operation": "shipped",
    "system_entity_id": "{{ $json.order_id }}",
    "severity": "info"
  }
}
```

### Envelope

```json
{
  "ok": false,
  "port": "error",
  "data": {
    "port": "error",
    "success": false,
    "error": "logger.debug is not a function"
  }
}
```

## Output ports (behaviour in the code)

### `success`

Not reached in the current runtime: the `logger.debug()` call fails first. Shown with the shape the code builds.

```json
{
  "port": "success",
  "success": true
}
```

### `error`

Every run today. The output is the whole returned object, `{ port, success, error }`.

```json
{
  "port": "error",
  "success": false,
  "error": "logger.debug is not a function"
}
```

## Behaviour in the code

- `api_key`: A literal secret: the node has no `connection_id`, so the key is stored in the flow, its version history and Git.
- `endpoint`: Base URL; `/v1/ingest` is appended.
- `operation`: Not in the config schema (only in the input contract), but read from the node config or, when unset there, from the input item: `operation`, `system_entity_id`, `severity` (default `info`), `tags` (default `[]`) and `payload`.
- `payload`: The configured `payload`, or the node input item when none is configured. Its keys are spread into `data`.

## Errors

| Message | Port | Cause and fix |
| --- | --- | --- |
| `logger.debug is not a function` | `error` | The worker calls `logger.debug()`, which the runtime logger does not provide. It happens on every run; there is no configuration that avoids it. |
| `Missing 'api_key' for Vectry` | `error` | No API key is available for the call. Set `api_key`. |
| `Missing 'operation'` | `error` | `operation` is set neither on the node nor in the input item. |
| `Request failed with status code <status>` | `error` | Not reached today. It would mean Vectry rejected the event (for example a wrong key or endpoint). |

## Notes and limits

- The worker calls `logger.debug()`, which the runtime logger does not provide (it offers `info`, `warning`, `error`, `log` and `success`). The call throws on every run.
- Until it is fixed, send events with `io.http` to the same ingest endpoint and body.
- Leaving through `error` does not fail the run: the engine follows the edges wired to `error`, and if there are none the branch simply ends.
- The `execution` settings (`retryOnFail`, `maxTries`, `waitBetweenTries`, `continueOnFail`, `timeout_ms`) are accepted, but neither this worker nor the engine applies them.


## Contracts (JSON Schema)

### All (`*.definition.js`)

```json
{
  "slug": "vectry.log",
  "name": "Vectry Log",
  "category": "ops",
  "version": "1.0.0",
  "description": "Emits a structured causal event to the Vectry Operational Intelligence Platform.\n\n  Vectry uses these events to construct a Causal Graph of your system, enabling advanced XAI (Explainable AI), anomaly detection, and root cause analysis. Unlike standard logs, Vectry events are linked by entities and operations to model *cause and effect*.\n\n  **Key Concepts:**\n  - **Entity:** The noun (e.g., \"Order\", \"User\").\n  - **Operation:** The verb (e.g., \"Created\", \"Updated\").\n  - **Context:** Payload data that helps explain the event.\n\n  **Use Cases:**\n  - Reporting significant business milestones (e.g., \"LoanApproved\").\n  - Logging internal AI reasoning steps (SpikingBrain integration).\n  - Tracking distributed system interactions.",
  "capabilities": [
    "observability",
    "causal-ai",
    "vectry",
    "xai"
  ],
  "config_schema": {
    "type": "object",
    "required": [
      "api_key"
    ],
    "properties": {
      "api_key": {
        "type": "string",
        "title": "Vectry API Key",
        "format": "password"
      },
      "endpoint": {
        "type": "string",
        "default": "https://api.vectry.io",
        "title": "API Endpoint"
      },
      "system_domain": {
        "type": "string",
        "title": "Domain (e.g. Sales)"
      },
      "system_entity": {
        "type": "string",
        "title": "Entity Type (e.g. Order)"
      },
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    }
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "operation": {
        "type": "string",
        "description": "Event Name"
      },
      "system_entity_id": {
        "type": "string",
        "description": "Unique Entity ID"
      },
      "severity": {
        "type": "string",
        "enum": [
          "info",
          "warn",
          "error",
          "debug"
        ]
      },
      "payload": {
        "type": "object",
        "description": "Event Context"
      },
      "tags": {
        "type": "array",
        "items": {
          "type": "string"
        }
      }
    },
    "required": [
      "operation"
    ]
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "success": {
        "type": "boolean"
      }
    }
  },
  "ports": [
    {
      "port_id": "success",
      "label": "Logged",
      "is_default": true
    },
    {
      "port_id": "error",
      "label": "Error"
    }
  ],
  "execution_mode": "fire-and-forget",
  "tags": [
    "observability",
    "vectry",
    "ai"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_vectry",
    "profile": {
      "name": "Vectry Analytics",
      "verified": true,
      "url": "https://me.veripass.com/vectry",
      "logo_url": null
    }
  }
}
```

### config_schema

```json
{
  "type": "object",
  "required": [
    "api_key"
  ],
  "properties": {
    "api_key": {
      "type": "string",
      "title": "Vectry API Key",
      "format": "password"
    },
    "endpoint": {
      "type": "string",
      "default": "https://api.vectry.io",
      "title": "API Endpoint"
    },
    "system_domain": {
      "type": "string",
      "title": "Domain (e.g. Sales)"
    },
    "system_entity": {
      "type": "string",
      "title": "Entity Type (e.g. Order)"
    },
    "execution": {
      "type": "object",
      "title": "Execution Settings",
      "properties": {
        "alwaysOutputData": {
          "type": "boolean",
          "title": "Always Output Data",
          "description": "Always output data, even on error (if configured).",
          "default": false
        },
        "retryOnFail": {
          "type": "boolean",
          "title": "Retry On Fail",
          "description": "Retry the execution if it fails.",
          "default": false
        },
        "maxTries": {
          "type": "integer",
          "title": "Max Retries",
          "description": "Number of retries.",
          "default": 3,
          "displayOptions": {
            "show": {
              "retryOnFail": [
                true
              ]
            }
          }
        },
        "waitBetweenTries": {
          "type": "integer",
          "title": "Wait Between Retries (ms)",
          "default": 1000,
          "displayOptions": {
            "show": {
              "retryOnFail": [
                true
              ]
            }
          }
        },
        "continueOnFail": {
          "type": "boolean",
          "title": "Continue On Fail",
          "description": "Do not crash workflow on error.",
          "default": false
        },
        "timeout_ms": {
          "type": "integer",
          "title": "Timeout (ms)",
          "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
          "default": 300000
        }
      }
    }
  }
}
```

### input_contract_schema

```json
{
  "type": "object",
  "properties": {
    "operation": {
      "type": "string",
      "description": "Event Name"
    },
    "system_entity_id": {
      "type": "string",
      "description": "Unique Entity ID"
    },
    "severity": {
      "type": "string",
      "enum": [
        "info",
        "warn",
        "error",
        "debug"
      ]
    },
    "payload": {
      "type": "object",
      "description": "Event Context"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "operation"
  ]
}
```

### output_contract_schema

```json
{
  "type": "object",
  "properties": {
    "success": {
      "type": "boolean"
    }
  }
}
```

### ports

```json
[
  {
    "port_id": "success",
    "label": "Logged",
    "is_default": true
  },
  {
    "port_id": "error",
    "label": "Error"
  }
]
```
