← Files note Workspace|ROGNALIAARCHIVED FILE

skills/note-tracker/references/schemas/metrics-history-event-v2.schema.json

6.89 KB · Oct 5, 2026 · 18:34 UTC

↓ Download file

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:rognalia:note-workspace:schema:metrics-history-event:2",
  "title": "note Workspace current dashboard metrics history event",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version", "event_type", "request_id", "payload_sha256", "workspace_id",
    "run_id", "collection_mode", "observed_at", "data_as_of", "recorded_at",
    "dashboard_surface", "period", "scope", "metrics", "referrers", "note",
    "external_actions"
  ],
  "properties": {
    "schema_version": {"const": 2},
    "event_type": {"const": "metrics_observed"},
    "request_id": {"type": "string", "pattern": "^[a-z0-9][a-z0-9._:-]{7,127}$"},
    "payload_sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
    "workspace_id": {"type": "string", "pattern": "^nw-[a-z0-9][a-z0-9-]{5,63}$"},
    "run_id": {"type": "string", "pattern": "^run-[a-z0-9][a-z0-9._:-]{6,127}$"},
    "collection_mode": {"enum": ["manual", "scheduled"]},
    "observed_at": {"type": "string", "format": "date-time"},
    "data_as_of": {"type": ["string", "null"], "format": "date-time"},
    "recorded_at": {"type": "string", "format": "date-time"},
    "dashboard_surface": {"const": "note_browser_dashboard"},
    "period": {"$ref": "#/$defs/period"},
    "scope": {"$ref": "#/$defs/scope"},
    "metrics": {
      "type": "array",
      "minItems": 5,
      "maxItems": 5,
      "items": {"$ref": "#/$defs/metric"}
    },
    "referrers": {"$ref": "#/$defs/referrers"},
    "note": {"type": ["string", "null"], "maxLength": 500},
    "external_actions": {"const": []}
  },
  "$defs": {
    "period": {
      "type": "object",
      "additionalProperties": false,
      "required": ["range_type", "start_date", "end_date", "completeness"],
      "properties": {
        "range_type": {"enum": ["bounded", "all_time"]},
        "start_date": {"type": ["string", "null"], "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"},
        "end_date": {"type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"},
        "completeness": {"enum": ["completed", "includes_current_day"]}
      },
      "allOf": [{
        "if": {"properties": {"range_type": {"const": "bounded"}}, "required": ["range_type"]},
        "then": {"properties": {"start_date": {"type": "string"}}},
        "else": {"properties": {"start_date": {"type": "null"}}}
      }]
    },
    "article": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "origin", "article_id", "article_revision", "registry_event_sha256",
        "title", "public_url", "published_at"
      ],
      "properties": {
        "origin": {"enum": ["workspace_draft", "existing_public_article"]},
        "article_id": {"type": "string", "pattern": "^article-[a-z0-9][a-z0-9-]{2,63}$"},
        "article_revision": {"type": ["integer", "null"], "minimum": 1},
        "registry_event_sha256": {"type": ["string", "null"], "pattern": "^[0-9a-f]{64}$"},
        "title": {"type": "string", "minLength": 1, "maxLength": 200},
        "public_url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://(?:www\\.)?note\\.com/(?:[A-Za-z0-9_-]+/)?n/[A-Za-z0-9_-]+$",
          "maxLength": 1000
        },
        "published_at": {"type": ["string", "null"], "format": "date-time"}
      },
      "allOf": [{
        "if": {"properties": {"origin": {"const": "workspace_draft"}}, "required": ["origin"]},
        "then": {
          "properties": {
            "article_revision": {"type": "integer", "minimum": 1},
            "registry_event_sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}
          }
        },
        "else": {
          "properties": {
            "article_revision": {"type": "null"},
            "registry_event_sha256": {"type": "null"}
          }
        }
      }]
    },
    "scope": {
      "type": "object",
      "additionalProperties": false,
      "required": ["type", "article"],
      "properties": {
        "type": {"enum": ["article", "account"]},
        "article": {"oneOf": [{"$ref": "#/$defs/article"}, {"type": "null"}]}
      },
      "allOf": [{
        "if": {"properties": {"type": {"const": "article"}}, "required": ["type"]},
        "then": {"properties": {"article": {"$ref": "#/$defs/article"}}},
        "else": {"properties": {"article": {"type": "null"}}}
      }]
    },
    "metric": {
      "type": "object",
      "_comment": "sales uses integer JPY; the other four metrics use event counts.",
      "additionalProperties": false,
      "required": ["metric", "status", "value", "source", "reason"],
      "properties": {
        "metric": {"enum": ["impressions", "page_views", "likes", "comments", "sales"]},
        "status": {"enum": ["available", "unavailable", "not_visible", "fetch_failed", "not_applicable", "not_collected"]},
        "value": {"type": ["integer", "null"], "minimum": 0},
        "source": {"enum": ["note_browser_dashboard", "manual_user_report", "not_observed"]},
        "reason": {"type": ["string", "null"], "maxLength": 500}
      },
      "allOf": [{
        "if": {"properties": {"status": {"const": "available"}}, "required": ["status"]},
        "then": {
          "properties": {
            "value": {"type": "integer", "minimum": 0},
            "source": {"enum": ["note_browser_dashboard", "manual_user_report"]},
            "reason": {"type": "null"}
          }
        },
        "else": {
          "properties": {
            "value": {"type": "null"},
            "reason": {"type": "string", "minLength": 1, "maxLength": 500}
          }
        }
      }]
    },
    "referrers": {
      "type": "object",
      "additionalProperties": false,
      "required": ["status", "source", "items", "reason"],
      "properties": {
        "status": {"enum": ["available", "unavailable", "not_visible", "fetch_failed", "not_applicable", "not_collected"]},
        "source": {"enum": ["note_browser_dashboard", "manual_user_report", "not_observed"]},
        "items": {
          "type": "array",
          "maxItems": 100,
          "uniqueItems": true,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["referrer", "page_views"],
            "properties": {
              "referrer": {"type": "string", "minLength": 1, "maxLength": 200},
              "page_views": {"type": "integer", "minimum": 0}
            }
          }
        },
        "reason": {"type": ["string", "null"], "maxLength": 500}
      },
      "allOf": [{
        "if": {"properties": {"status": {"const": "available"}}, "required": ["status"]},
        "then": {
          "properties": {
            "source": {"enum": ["note_browser_dashboard", "manual_user_report"]},
            "reason": {"type": "null"}
          }
        },
        "else": {
          "properties": {
            "items": {"maxItems": 0},
            "reason": {"type": "string", "minLength": 1, "maxLength": 500}
          }
        }
      }]
    }
  }
}

SHA-256: ee936553ad1d7e35873c13a2ee5e5fa43cc2a0fd9def462d4e2d8a1e29661f4a