From 09cfb90a0e0596c02b336aefae946573b91cc220 Mon Sep 17 00:00:00 2001 From: Sigurd Spieckermann Date: Sat, 18 Nov 2023 19:21:55 +0100 Subject: [PATCH 1/2] Fixed `extra:analytics` schema for custom providers --- docs/schema/extra.json | 210 ++++++++++++++++++++++++----------------- 1 file changed, 122 insertions(+), 88 deletions(-) diff --git a/docs/schema/extra.json b/docs/schema/extra.json index c53f418fa..7daaa3749 100644 --- a/docs/schema/extra.json +++ b/docs/schema/extra.json @@ -13,99 +13,80 @@ "title": "Analytics provider", "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics", "type": "object", - "properties": { - "provider": { - "title": "Analytics provider", - "anyOf": [ - { - "title": "Google Analytics", - "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics", - "enum": [ - "google" - ] - }, - { - "type": "string" - } - ] - }, - "property": { - "anyOf": [ - { - "title": "Google Analytics 4", - "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics", - "pattern": "^G-\\w{10}$" - }, - { - "title": "Universal Analytics", - "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics", - "pattern": "^UA-\\w{9}-\\w$" - }, - { - "title": "Unknown property", - "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics", - "type": "string" - } - ] - }, - "feedback": { - "title": "Was this page helpful?", - "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful", - "type": "object", - "properties": { - "title": { - "title": "Feedback widget title", - "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful", - "type": "string", - "default": "Was this page helpful?" - }, - "ratings": { - "title": "Feedback ratings", - "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful", - "type": "array", - "items": { - "title": "Feedback rating", - "type": "object", - "properties": { - "icon": { - "$ref": "#/$defs/icon" - }, - "name": { - "title": "Feedback rating name", - "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.name", - "type": "string" - }, - "data": { - "title": "Feedback rating data", - "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.data", - "type": "number" - }, - "note": { - "title": "Feedback rating data", - "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.note", - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "icon", - "name", - "data", - "note" + "allOf": [ + { + "if": { + "properties": { + "provider": { + "enum": [ + "google" ] } } }, - "additionalProperties": false, - "required": [ - "title" - ] + "then": { + "properties": { + "provider": { + "title": "Google Analytics", + "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics", + "enum": [ + "google" + ] + }, + "property": { + "anyOf": [ + { + "title": "Google Analytics 4", + "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics", + "pattern": "^G-\\w{10}$" + }, + { + "title": "Universal Analytics", + "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics", + "pattern": "^UA-\\w{9}-\\w$" + }, + { + "title": "Unknown property", + "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics", + "type": "string" + } + ] + }, + "feedback": { + "$ref": "#/$defs/feedback" + } + }, + "required": [ + "provider", + "property" + ], + "additionalProperties": false + } + }, + { + "if": { + "properties": { + "provider": { + "type": "string" + } + } + }, + "then": { + "properties": { + "provider": { + "title": "Custom analytics provider", + "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#custom-site-analytics", + "type": "string" + }, + "feedback": { + "$ref": "#/$defs/feedback" + } + }, + "required": [ + "provider" + ] + } } - }, - "additionalProperties": false, - "required": [ - "provider", - "property" ], "defaultSnippets": [ { @@ -406,6 +387,59 @@ "type": "string" } ] + }, + "feedback": { + "title": "Was this page helpful?", + "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful", + "type": "object", + "properties": { + "title": { + "title": "Feedback widget title", + "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful", + "type": "string", + "default": "Was this page helpful?" + }, + "ratings": { + "title": "Feedback ratings", + "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#was-this-page-helpful", + "type": "array", + "items": { + "title": "Feedback rating", + "type": "object", + "properties": { + "icon": { + "$ref": "#/$defs/icon" + }, + "name": { + "title": "Feedback rating name", + "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.name", + "type": "string" + }, + "data": { + "title": "Feedback rating data", + "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.data", + "type": "number" + }, + "note": { + "title": "Feedback rating data", + "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#+analytics.feedback.ratings.note", + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "icon", + "name", + "data", + "note" + ] + } + } + }, + "additionalProperties": false, + "required": [ + "title" + ] } }, "defaultSnippets": [ From f528598540b992daaa84baec109b2f9b551a0a5d Mon Sep 17 00:00:00 2001 From: Sigurd Spieckermann Date: Sun, 19 Nov 2023 10:07:10 +0100 Subject: [PATCH 2/2] Dropped schema for Google Universal Analytics --- docs/schema/extra.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/docs/schema/extra.json b/docs/schema/extra.json index 7daaa3749..c154cf70a 100644 --- a/docs/schema/extra.json +++ b/docs/schema/extra.json @@ -40,11 +40,6 @@ "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics", "pattern": "^G-\\w{10}$" }, - { - "title": "Universal Analytics", - "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics", - "pattern": "^UA-\\w{9}-\\w$" - }, { "title": "Unknown property", "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-analytics/#google-analytics", @@ -448,7 +443,7 @@ "body": { "analytics": { "provider": "${1:google}", - "property": "${2:UA-XXXXXXXX-X}" + "property": "${2:G-XXXXXXXXXX}" } } }