{
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1",
    "saveDataErrorExecution": "all",
    "saveDataSuccessExecution": "all"
  },
  "name": "ezGPT - Error Log",
  "nodes": [
    {
      "id": "38a315c8-ca73-422a-a529-c89838a824a0",
      "name": "Error Trigger",
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "parameters": {},
      "position": [
        0,
        0
      ]
    },
    {
      "id": "7c1e50fa-ec71-4b40-bf3c-0ca09fcb92c5",
      "name": "Prepare Error",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const text = value => value == null ? '' : String(value);\nreturn $input.all().map((item, index) => {\n  const event = item.json;\n  const execution = event.execution ?? {};\n  const trigger = event.trigger ?? {};\n  const error = execution.error ?? trigger.error ?? {};\n  return {\n    json: {\n      execution_id: text(execution.id),\n      workflow_id: text(event.workflow?.id),\n      workflow_name: text(event.workflow?.name),\n      failed_node: text(execution.lastNodeExecuted ?? error.node?.name),\n      error_code: error.message === 'DEMO_TECHNICAL_FAILURE'\n        ? 'demo_failed' : 'workflow_failed',\n      execution_mode: text(execution.mode ?? trigger.mode),\n      recorded_at: new Date().toISOString(),\n    },\n    pairedItem: { item: index },\n  };\n});"
      },
      "position": [
        240,
        0
      ]
    },
    {
      "id": "5ebdcbab-e3f8-47e0-831f-56cbb5f84116",
      "name": "Save Error",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "parameters": {
        "resource": "row",
        "operation": "insert",
        "dataTableId": {
          "__rl": true,
          "mode": "name",
          "value": "ezgpt_error_log"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {}
        },
        "options": {}
      },
      "position": [
        480,
        0
      ]
    }
  ],
  "connections": {
    "Error Trigger": {
      "main": [
        [
          {
            "node": "Prepare Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Error": {
      "main": [
        [
          {
            "node": "Save Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
