{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/fillo-so/json-schema/fillo-so-form-insights-schema.json",
  "title": "FormInsights",
  "description": "The same computation the dashboard's Insights page renders. Epoch-millisecond timestamps.",
  "x-generated": "2026-11-07",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/fillo-so-openapi.json#/components/schemas/FormInsights",
  "type": "object",
  "required": [
    "range",
    "total",
    "timeline",
    "sources",
    "surfaces",
    "fields"
  ],
  "properties": {
    "range": {
      "type": "string",
      "enum": [
        "7d",
        "30d",
        "90d",
        "all"
      ]
    },
    "total": {
      "type": "integer"
    },
    "firstAt": {
      "type": [
        "integer",
        "null"
      ]
    },
    "lastAt": {
      "type": [
        "integer",
        "null"
      ]
    },
    "medianDurationMs": {
      "type": [
        "integer",
        "null"
      ]
    },
    "durationCount": {
      "type": "integer"
    },
    "lastSevenDays": {
      "type": "integer"
    },
    "previousSevenDays": {
      "type": "integer"
    },
    "sevenDayChange": {
      "type": [
        "number",
        "null"
      ]
    },
    "sampled": {
      "type": "boolean"
    },
    "versionCount": {
      "type": "integer"
    },
    "legacyHistoryIncomplete": {
      "type": "boolean"
    },
    "timeline": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "day",
          "count"
        ],
        "properties": {
          "day": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          }
        }
      }
    },
    "sources": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/InsightBreakdownRow"
      }
    },
    "surfaces": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/InsightBreakdownRow"
      }
    },
    "funnel": {
      "type": [
        "object",
        "null"
      ],
      "description": "started, completed, excluded, completionRate, multiPage, and a per-page reached/pct list."
    },
    "drafts": {
      "type": [
        "object",
        "null"
      ],
      "description": "open, identified, and byPage — the same counts the drafts endpoint returns."
    },
    "fields": {
      "type": "array",
      "description": "One entry per field ever answered: id, label, kind, inCurrentSchema, answered, skipped, fillRate, and a `summary` discriminated on `type` (choice, multi, ranking, scale, number, boolean, matrix, text, date, file, generic).",
      "items": {
        "type": "object"
      }
    },
    "segment": {
      "type": [
        "object",
        "null"
      ],
      "description": "Present when `by` is supplied: the cohort's size, share, its own `fields`, and the `differences` that separate it from the baseline."
    },
    "segmentIgnored": {
      "type": "boolean",
      "description": "True when `by` named a field the current data cannot segment on."
    }
  },
  "$defs": {
    "InsightBreakdownRow": {
      "type": "object",
      "required": [
        "key",
        "label",
        "count",
        "pct"
      ],
      "properties": {
        "key": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "count": {
          "type": "integer"
        },
        "pct": {
          "type": "number"
        }
      }
    }
  }
}