@justai/cuts 0.16.0 → 0.17.0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/Base.astro +16 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justai/cuts",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "A persona's named parts — the page shell that holds them, and the cuts themselves.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
package/src/Base.astro CHANGED
@@ -184,6 +184,18 @@ const localePath = (l: string) => (l === defaultLocale ? "/" : `/${l}/`);
184
184
  ten that measure themselves exactly nothing. */}
185
185
  {gaId && (
186
186
  <script is:inline define:vars={{ gaId }}>
187
+ // A non-production page measures NOTHING. Found by the first read through the analytics MCP:
188
+ // 127.0.0.1 + localhost were the property's TOP "persona" (562 fake users in 28 days — local
189
+ // dev, plus every headless verification sweep loading the built HTML). The guard also covers
190
+ // the edge's dev- preview hosts: previews are rehearsals, not visits. gtag is still defined
191
+ // (as the same queue-stub) even on a silenced host, so the consent script can never hit
192
+ // "gtag is not defined" — the exact trap documented below. The whole block sits in an if
193
+ // rather than behind an early return: Astro 7's compiler rejects a top-level `return` in an
194
+ // inline script at BUILD time (the define:vars IIFE only exists later, at runtime).
195
+ window.gtag = window.gtag || function () { (window.dataLayer = window.dataLayer || []).push(arguments); };
196
+ var __h = location.hostname;
197
+ var __nonprod = __h === "localhost" || __h === "127.0.0.1" || __h === "::1" || __h === "[::1]" || __h.indexOf("dev-") === 0;
198
+ if (!__nonprod) {
187
199
  window.dataLayer = window.dataLayer || [];
188
200
  // gtag is put on WINDOW, not declared as `function gtag`, and this is load-bearing: `define:vars`
189
201
  // wraps this inline script in an IIFE to scope the injected `gaId`, so a `function gtag` here
@@ -213,6 +225,7 @@ const localePath = (l: string) => (l === defaultLocale ? "/" : `/${l}/`);
213
225
  document.head.appendChild(s);
214
226
  });
215
227
  });
228
+ }
216
229
  </script>
217
230
  )}
218
231
  </head>
@@ -263,6 +276,9 @@ const localePath = (l: string) => (l === defaultLocale ? "/" : `/${l}/`);
263
276
  <script is:inline>
264
277
  (function () {
265
278
  try {
279
+ // same non-production guard as the analytics block: no measurement → nothing to consent to
280
+ var h = location.hostname;
281
+ if (h === "localhost" || h === "127.0.0.1" || h === "::1" || h === "[::1]" || h.indexOf("dev-") === 0) return;
266
282
  if (localStorage.getItem("consent")) return;
267
283
  if (!document.getElementById("kernel")) return; // no kernel = not a content page (e.g. 404) — don't ask for consent on a dead end
268
284
  if ((Intl.DateTimeFormat().resolvedOptions().timeZone || "").indexOf("Europe/") !== 0) return;