@farming-labs/astro-theme 0.2.117 → 0.2.119

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/astro-theme",
3
- "version": "0.2.117",
3
+ "version": "0.2.119",
4
4
  "description": "Astro UI components for @farming-labs/docs — layout, sidebar, TOC, search, and theme toggle",
5
5
  "keywords": [
6
6
  "astro",
@@ -129,8 +129,8 @@
129
129
  },
130
130
  "dependencies": {
131
131
  "sugar-high": "^0.9.5",
132
- "@farming-labs/docs": "0.2.117",
133
- "@farming-labs/astro": "0.2.117"
132
+ "@farming-labs/astro": "0.2.119",
133
+ "@farming-labs/docs": "0.2.119"
134
134
  },
135
135
  "peerDependencies": {
136
136
  "astro": ">=4.0.0"
@@ -166,12 +166,22 @@ const staticExport = !!(config as { staticExport?: boolean }).staticExport;
166
166
  const aiConfig = config?.ai;
167
167
  const showFloatingAI = !staticExport && aiConfig?.mode === "floating" && !!aiConfig?.enabled;
168
168
  const showSearch = !staticExport;
169
+ const telemetryConfig =
170
+ config?.telemetry && typeof config.telemetry === "object" ? config.telemetry : undefined;
171
+ const telemetryEnabled = config?.telemetry !== false && telemetryConfig?.enabled !== false;
169
172
  ---
170
173
 
171
174
  <script is:inline set:html={themeInitScript}></script>
172
175
  {overrideCSS && <style set:html={overrideCSS} />}
173
176
 
174
- <div id="nd-docs-layout" data-fd-framework="astro" class="fd-layout">
177
+ <div
178
+ id="nd-docs-layout"
179
+ data-fd-framework="astro"
180
+ data-fd-telemetry-enabled={String(telemetryEnabled)}
181
+ data-fd-telemetry-endpoint={telemetryConfig?.endpoint}
182
+ data-fd-telemetry-site-origin={telemetryConfig?.siteOrigin}
183
+ class="fd-layout"
184
+ >
175
185
  <header class="fd-header">
176
186
  <button class="fd-menu-btn" id="fd-menu-toggle" aria-label="Toggle sidebar">
177
187
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
@@ -423,6 +433,43 @@ const showSearch = !staticExport;
423
433
  )}
424
434
 
425
435
  <script>
436
+ import { emitDocsTelemetryPageViewEvent } from "@farming-labs/docs/browser";
437
+
438
+ function emitMaintainerPageView() {
439
+ const root = document.getElementById("nd-docs-layout");
440
+ if (!root) return;
441
+
442
+ const url = new URL(window.location.href);
443
+ const locale = url.searchParams.get("lang") ?? url.searchParams.get("locale") ?? undefined;
444
+ const pageKey = `${url.pathname}|${locale ?? ""}`;
445
+ const target = window as typeof window & { __fdTelemetryPageViewKey__?: string };
446
+ if (target.__fdTelemetryPageViewKey__ === pageKey) return;
447
+ target.__fdTelemetryPageViewKey__ = pageKey;
448
+
449
+ const telemetry =
450
+ root.dataset.fdTelemetryEnabled === "false"
451
+ ? false
452
+ : {
453
+ enabled: true,
454
+ ...(root.dataset.fdTelemetryEndpoint
455
+ ? { endpoint: root.dataset.fdTelemetryEndpoint }
456
+ : {}),
457
+ ...(root.dataset.fdTelemetrySiteOrigin
458
+ ? { siteOrigin: root.dataset.fdTelemetrySiteOrigin }
459
+ : {}),
460
+ };
461
+
462
+ emitDocsTelemetryPageViewEvent(telemetry, {
463
+ framework: "astro",
464
+ siteOrigin: window.location.origin,
465
+ path: url.pathname.replace(/\/$/, "") || "/",
466
+ locale,
467
+ });
468
+ }
469
+
470
+ document.addEventListener("astro:page-load", emitMaintainerPageView);
471
+ emitMaintainerPageView();
472
+
426
473
  // Sidebar toggle
427
474
  const menuBtn = document.getElementById('fd-menu-toggle');
428
475
  const sidebar = document.getElementById('fd-sidebar');