@justai/core 0.36.0 → 0.37.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.
@@ -4,23 +4,6 @@
4
4
  * Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
5
5
  * and why its behaviour lives one level below @justai/cuts.
6
6
  */
7
- /**
8
- * queries: which measurement id does this host use · wrong GA4 stream · a persona reports into the
9
- * wrong property · G-13L3BP6XCW vs G-K2J4FQTQ8L · how does feed pick its analytics tag
10
- *
11
- * THE ECOSYSTEM'S STREAM LAYOUT, declared once.
12
- *
13
- * One GA4 property, two web streams: `G-13L3BP6XCW` for app.zone and its personas, `G-K2J4FQTQ8L`
14
- * for justai.pro and its own sub-domains. A page reports into whichever stream ITS CODE loads, so
15
- * "app.zone versus justai.pro" is a fact about our code rather than a rule the platform enforces —
16
- * put a persona on the wrong one and nothing errors, nothing is missing, the numbers simply land in
17
- * the wrong column. That is why the mapping is a function here and not a constant copied per repo.
18
- *
19
- * A STATIC persona cannot call this — it has no host at build time — so @justai/cuts keeps its own
20
- * default and `justai` passes the override. A SERVER-rendered surface (feed) knows the Host header
21
- * and must use this. The two must agree; if a third stream ever appears, this is the one place it
22
- * is added.
23
- */
24
7
  export declare function measurementIdFor(host: string | null | undefined): string;
25
8
  /**
26
9
  * queries: analytics inline script · gtag block · consent defaults · why is dev traffic in GA4 ·
package/dist/analytics.js CHANGED
@@ -6,24 +6,53 @@
6
6
  */
7
7
  /**
8
8
  * queries: which measurement id does this host use · wrong GA4 stream · a persona reports into the
9
- * wrong property · G-13L3BP6XCW vs G-K2J4FQTQ8L · how does feed pick its analytics tag
9
+ * wrong property · G-13L3BP6XCW vs G-K2J4FQTQ8L · pin.games analytics · a game reports into
10
+ * app.zone · how does feed pick its analytics tag · adding an apex to analytics ·
11
+ * measurementIdFor returns empty
10
12
  *
11
- * THE ECOSYSTEM'S STREAM LAYOUT, declared once.
13
+ * THE ECOSYSTEM'S STREAM LAYOUT — A ROW PER HOUSEHOLD.
12
14
  *
13
- * One GA4 property, two web streams: `G-13L3BP6XCW` for app.zone and its personas, `G-K2J4FQTQ8L`
14
- * for justai.pro and its own sub-domains. A page reports into whichever stream ITS CODE loads, so
15
- * "app.zone versus justai.pro" is a fact about our code rather than a rule the platform enforces —
16
- * put a persona on the wrong one and nothing errors, nothing is missing, the numbers simply land in
17
- * the wrong column. That is why the mapping is a function here and not a constant copied per repo.
15
+ * One GA4 property, a web stream per apex. A page reports into whichever stream ITS CODE loads, so
16
+ * which household a persona belongs to is a fact about our code rather than a rule the platform
17
+ * enforces — put a persona on the wrong one and nothing errors, nothing is missing, the numbers
18
+ * simply land in the wrong column. That is why the mapping is a function here and not a constant
19
+ * copied per repo.
20
+ *
21
+ * IT WAS A TERNARY, AND THE TERNARY WAS ALREADY WRONG. The previous version read
22
+ * `justai.pro ? K2J4 : 13L3` — everything that was not justai.pro reported into APP.ZONE's stream,
23
+ * pin.games included, while the comment above it promised that a third stream would be added *here*.
24
+ * pin.games got its stream (`G-PPMLN9SYD2`), the promise was not kept, and the mistake stayed
25
+ * invisible because it only shows on a SERVER-rendered surface: a static game persona carries its id
26
+ * from the template and is correct, while `/feed/*` on the same host would have counted as app.zone.
27
+ * Found on 2026-08-24 while standing up a third apex — which is exactly the moment a two-branch shape
28
+ * stops being able to hold the truth.
29
+ *
30
+ * AN UNKNOWN APEX RETURNS THE EMPTY STRING, and `analyticsJs` then measures nothing. That is the
31
+ * whole difference between the old shape and this one: a household we have not been told about must
32
+ * produce NO data rather than SOMEBODY ELSE'S data. Silence is a gap you can see in a report; a wrong
33
+ * column is a number you will trust. When a new apex arrives its row goes here — and until its stream
34
+ * exists, its pages honestly count as nobody.
35
+ *
36
+ * `cityinmotion.nl` was that case for exactly one day. It was added to this table the moment its GA4
37
+ * data stream existed, and the ORDER is the point: the stream is created first, and the row follows.
38
+ * A row written in anticipation would name an id that measures into nothing, which looks identical to
39
+ * a row that works.
18
40
  *
19
41
  * A STATIC persona cannot call this — it has no host at build time — so @justai/cuts keeps its own
20
- * default and `justai` passes the override. A SERVER-rendered surface (feed) knows the Host header
21
- * and must use this. The two must agree; if a third stream ever appears, this is the one place it
22
- * is added.
42
+ * default and `justai` passes the override, while `templates/bin/new.mjs` writes the id at birth from
43
+ * its own apex table. A SERVER-rendered surface (feed) knows the Host header and must use this. All
44
+ * of them must agree, and this is the file that is right by construction.
23
45
  */
46
+ const STREAMS = {
47
+ "app.zone": "G-13L3BP6XCW",
48
+ "pin.games": "G-PPMLN9SYD2",
49
+ "justai.pro": "G-K2J4FQTQ8L",
50
+ "cityinmotion.nl": "G-JY34Z58S16",
51
+ };
24
52
  export function measurementIdFor(host) {
25
53
  const h = String(host || "").toLowerCase().split(":")[0];
26
- return h === "justai.pro" || h.endsWith(".justai.pro") ? "G-K2J4FQTQ8L" : "G-13L3BP6XCW";
54
+ const apex = Object.keys(STREAMS).find((a) => h === a || h.endsWith("." + a));
55
+ return apex ? STREAMS[apex] : "";
27
56
  }
28
57
  /**
29
58
  * queries: analytics inline script · gtag block · consent defaults · why is dev traffic in GA4 ·
@@ -84,6 +113,7 @@ window.gtag=window.gtag||function(){(window.dataLayer=window.dataLayer||[]).push
84
113
  var __h=location.hostname;
85
114
  if(!(__h==="localhost"||__h==="127.0.0.1"||__h==="::1"||__h==="[::1]"||__h.indexOf("dev-")===0)){
86
115
  var __g=${JSON.stringify(gaId)};
116
+ if(!__g)return;
87
117
  window.dataLayer=window.dataLayer||[];
88
118
  window.gtag=window.gtag||function(){window.dataLayer.push(arguments)};
89
119
  gtag("js",new Date());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justai/core",
3
- "version": "0.36.0",
3
+ "version": "0.37.0",
4
4
  "description": "The framework-free heart of the persona shell \u2014 the load-bearing behaviour (auth capture, reveal, ready) as plain strings, so Astro and Next inject the SAME logic instead of each re-writing it.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {