{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "title": "Fernhollow data layer",
 "description": "Every object pushed to window.dataLayer. One definition per event; unknown properties fail.",
 "oneOf": [
  {
   "$ref": "#/$defs/page_view"
  },
  {
   "$ref": "#/$defs/consent_update"
  },
  {
   "$ref": "#/$defs/cta_click"
  },
  {
   "$ref": "#/$defs/plan_selected"
  },
  {
   "$ref": "#/$defs/form_start"
  },
  {
   "$ref": "#/$defs/form_error"
  },
  {
   "$ref": "#/$defs/demo_request"
  },
  {
   "$ref": "#/$defs/asset_download"
  }
 ],
 "$defs": {
  "page_view": {
   "type": "object",
   "additionalProperties": false,
   "required": [
    "event",
    "event_id",
    "page_path",
    "page_type",
    "channel",
    "campaign_source",
    "campaign_medium",
    "campaign_name"
   ],
   "properties": {
    "event": {
     "const": "page_view"
    },
    "event_id": {
     "type": "string",
     "pattern": "^e[a-z0-9]{8,24}$"
    },
    "page_path": {
     "type": "string",
     "pattern": "^/"
    },
    "page_type": {
     "enum": [
      "home",
      "pricing",
      "demo",
      "thanks",
      "guide",
      "download",
      "resources",
      "article"
     ]
    },
    "channel": {
     "enum": [
      "direct",
      "organic",
      "paid",
      "email",
      "other"
     ]
    },
    "campaign_source": {
     "type": [
      "string",
      "null"
     ],
     "maxLength": 64
    },
    "campaign_medium": {
     "type": [
      "string",
      "null"
     ],
     "enum": [
      "paid_social",
      "paid_search",
      "email",
      null
     ]
    },
    "campaign_name": {
     "type": [
      "string",
      "null"
     ],
     "maxLength": 64
    }
   }
  },
  "consent_update": {
   "type": "object",
   "additionalProperties": false,
   "required": [
    "event",
    "event_id",
    "consent_state"
   ],
   "properties": {
    "event": {
     "const": "consent_update"
    },
    "event_id": {
     "type": "string",
     "pattern": "^e[a-z0-9]{8,24}$"
    },
    "consent_state": {
     "enum": [
      "granted",
      "denied"
     ]
    }
   }
  },
  "cta_click": {
   "type": "object",
   "additionalProperties": false,
   "required": [
    "event",
    "event_id",
    "cta_id",
    "page_type"
   ],
   "properties": {
    "event": {
     "const": "cta_click"
    },
    "event_id": {
     "type": "string",
     "pattern": "^e[a-z0-9]{8,24}$"
    },
    "cta_id": {
     "enum": [
      "nav_demo",
      "sticky_demo",
      "home_pricing",
      "home_resources",
      "pricing_talk"
     ]
    },
    "page_type": {
     "enum": [
      "home",
      "pricing",
      "demo",
      "thanks",
      "guide",
      "download",
      "resources",
      "article"
     ]
    }
   }
  },
  "plan_selected": {
   "type": "object",
   "additionalProperties": false,
   "required": [
    "event",
    "event_id",
    "plan_id",
    "billing_period",
    "annual_value",
    "currency"
   ],
   "properties": {
    "event": {
     "const": "plan_selected"
    },
    "event_id": {
     "type": "string",
     "pattern": "^e[a-z0-9]{8,24}$"
    },
    "plan_id": {
     "enum": [
      "starter",
      "growth",
      "enterprise"
     ]
    },
    "billing_period": {
     "enum": [
      "annual",
      "monthly"
     ]
    },
    "annual_value": {
     "type": "number",
     "minimum": 0,
     "maximum": 100000
    },
    "currency": {
     "enum": [
      "USD"
     ]
    }
   }
  },
  "form_start": {
   "type": "object",
   "additionalProperties": false,
   "required": [
    "event",
    "event_id",
    "form_id"
   ],
   "properties": {
    "event": {
     "const": "form_start"
    },
    "event_id": {
     "type": "string",
     "pattern": "^e[a-z0-9]{8,24}$"
    },
    "form_id": {
     "enum": [
      "demo_request",
      "asset_download"
     ]
    }
   }
  },
  "form_error": {
   "type": "object",
   "additionalProperties": false,
   "required": [
    "event",
    "event_id",
    "form_id",
    "field"
   ],
   "properties": {
    "event": {
     "const": "form_error"
    },
    "event_id": {
     "type": "string",
     "pattern": "^e[a-z0-9]{8,24}$"
    },
    "form_id": {
     "enum": [
      "demo_request",
      "asset_download"
     ]
    },
    "field": {
     "enum": [
      "work_email"
     ]
    }
   }
  },
  "demo_request": {
   "type": "object",
   "additionalProperties": false,
   "required": [
    "event",
    "event_id",
    "form_id",
    "lead_id",
    "company_size",
    "plan_id",
    "annual_value",
    "currency",
    "channel",
    "campaign_source",
    "campaign_medium",
    "campaign_name"
   ],
   "properties": {
    "event": {
     "const": "demo_request"
    },
    "event_id": {
     "type": "string",
     "pattern": "^e[a-z0-9]{8,24}$"
    },
    "form_id": {
     "const": "demo_request"
    },
    "lead_id": {
     "type": "string",
     "pattern": "^L[0-9]{9}$"
    },
    "company_size": {
     "enum": [
      "1-49",
      "50-199",
      "200-500"
     ]
    },
    "plan_id": {
     "enum": [
      "starter",
      "growth",
      "enterprise",
      "undecided"
     ]
    },
    "annual_value": {
     "type": "number",
     "minimum": 0,
     "maximum": 100000
    },
    "currency": {
     "enum": [
      "USD"
     ]
    },
    "channel": {
     "enum": [
      "direct",
      "organic",
      "paid",
      "email",
      "other"
     ]
    },
    "campaign_source": {
     "type": [
      "string",
      "null"
     ],
     "maxLength": 64
    },
    "campaign_medium": {
     "type": [
      "string",
      "null"
     ],
     "enum": [
      "paid_social",
      "paid_search",
      "email",
      null
     ]
    },
    "campaign_name": {
     "type": [
      "string",
      "null"
     ],
     "maxLength": 64
    }
   }
  },
  "asset_download": {
   "type": "object",
   "additionalProperties": false,
   "required": [
    "event",
    "event_id",
    "form_id",
    "lead_id",
    "asset_id",
    "channel",
    "campaign_source",
    "campaign_medium",
    "campaign_name"
   ],
   "properties": {
    "event": {
     "const": "asset_download"
    },
    "event_id": {
     "type": "string",
     "pattern": "^e[a-z0-9]{8,24}$"
    },
    "form_id": {
     "const": "asset_download"
    },
    "lead_id": {
     "type": "string",
     "pattern": "^L[0-9]{9}$"
    },
    "asset_id": {
     "enum": [
      "record-keeping-guide"
     ]
    },
    "channel": {
     "enum": [
      "direct",
      "organic",
      "paid",
      "email",
      "other"
     ]
    },
    "campaign_source": {
     "type": [
      "string",
      "null"
     ],
     "maxLength": 64
    },
    "campaign_medium": {
     "type": [
      "string",
      "null"
     ],
     "enum": [
      "paid_social",
      "paid_search",
      "email",
      null
     ]
    },
    "campaign_name": {
     "type": [
      "string",
      "null"
     ],
     "maxLength": 64
    }
   }
  }
 }
}
