From d03fdc235a7926eed5ad127ffb9c4a5f9c1008b7 Mon Sep 17 00:00:00 2001
From: John Bowdre <61015723+jbowdre@users.noreply.github.com>
Date: Mon, 06 May 2024 16:30:21 +0000
Subject: [PATCH] feat(analytics): Tinylytics support (#1118)

---
 quartz/plugins/emitters/componentResources.ts |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/quartz/plugins/emitters/componentResources.ts b/quartz/plugins/emitters/componentResources.ts
index 81d3af2..e6725d9 100644
--- a/quartz/plugins/emitters/componentResources.ts
+++ b/quartz/plugins/emitters/componentResources.ts
@@ -136,6 +136,14 @@
       posthog.init('${cfg.analytics.apiKey}',{api_host:'${cfg.analytics.host ?? "https://app.posthog.com"}'})\`
       document.head.appendChild(posthogScript)
     `)
+  } else if (cfg.analytics?.provider === "tinylytics") {
+    const siteId = cfg.analytics.siteId
+    componentResources.afterDOMLoaded.push(`
+      const tinylyticsScript = document.createElement("script")
+      tinylyticsScript.src = "https://tinylytics.app/embed/${siteId}.js"
+      tinylyticsScript.defer = true
+      document.head.appendChild(tinylyticsScript)
+    `)
   }
 
   if (cfg.enableSPA) {

--
Gitblit v1.10.0