@justai/core 0.45.0 → 0.46.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.
@@ -6,77 +6,43 @@
6
6
  */
7
7
  export declare function measurementIdFor(host: string | null | undefined): string;
8
8
  /**
9
- * queries: analytics inline script · gtag block · consent defaults · why is dev traffic in GA4 ·
10
- * non-production guard · localhost 127.0.0.1 in analytics · how does a page start measuring
9
+ * queries: analytics inline script · gtag block · consent v2 · no google before consent · why is dev
10
+ * traffic in GA4 · non-production guard · reject cleanup · _ga _gcl cleanup · ga-disable
11
11
  *
12
12
  * The whole analytics head block, for any framework, given a measurement id.
13
13
  *
14
- * Everything load-bearing about it, in the order it matters:
14
+ * CONSENT v2 (2026-11-23, owner — replaces the 2026-07-25 "granted by default, the EEA asks first"
15
+ * doctrine, which the Consent & Privacy R0 audit measured against production: a Turkish visitor was
16
+ * asked "may I count your visit?" 1.1 s AFTER GA4, Google Ads, ga-audiences and the conversion
17
+ * linker had already counted it, because the dialog's timezone list was wider than the gtag region
18
+ * list). The model is now one rule, everywhere, with no geography in it:
15
19
  *
16
- * A NON-PRODUCTION PAGE MEASURES NOTHING. Found by reading the property through the analytics MCP:
17
- * `127.0.0.1` and `localhost` were its TOP "persona" — 546 sessions in four days, and on one of them
18
- * 127.0.0.1 alone outranked every real persona. Local dev and every headless verification sweep
19
- * loading built HTML. The guard also covers the edge's `dev-` preview hosts: previews are rehearsals,
20
- * not visits. Everything before 2026-07-24 in that property is inflated by this.
20
+ * NO ANSWER → NO GOOGLE. Nothing of Google is fetched, no cookie is written, no ping is sent —
21
+ * the gtag script is not even put in the document. `window.gtag` is a local stub.
22
+ * ALLOW → the tag loads, for analytics only: ad_storage / ad_user_data / ad_personalization
23
+ * denied, Google signals and ad personalisation off, ads data redacted. page_location
24
+ * keeps only Google's click ids and utm_* labels (never what a visitor typed into `?data=`) —
25
+ * a paid click is still a paid click to GA4. The stored answer is `v2:granted`.
26
+ * REJECT → nothing loads; a tag already running on this page stops (`ga-disable-<id>`, consent
27
+ * denied); every Google identifier on the apex is removed (`_ga`, `_ga_*`, `_gid`,
28
+ * `_gcl_*`, `_gac_*`, and the `_gcl_*` keys in localStorage). Stored as `v2:denied`.
21
29
  *
22
- * `gtag` GOES ON `window`, never `function gtag`. A framework that scopes an injected variable wraps
23
- * this in an IIFE, and a function declaration would then be trapped inside it — while the consent
24
- * dialog's own script, elsewhere on the page, calls `gtag`. The failure is silent and specific: a
25
- * European visitor clicks Allow, "gtag is not defined", the choice is never applied and the sheet
26
- * never closes. The stub is also assigned BEFORE the guard returns, so a silenced host still has a
27
- * callable `gtag` and that same script cannot throw there either.
30
+ * Only a v2 answer starts measuring. A pre-v2 "granted+ads" / "granted" was given to a different
31
+ * question under a different model, so it counts as NO answer (the visitor is asked again); a pre-v2
32
+ * "denied" stays a refusal. The answer is read from the apex cookie `justai-consent` (./consent —
33
+ * every persona is its own origin, so localStorage could never carry an answer across the apex).
28
34
  *
29
- * CONSENT DEFAULTS, twice — REVISED 2026-07-25 with the founder, and the revision IS the doctrine:
30
- * MEASUREMENT follows one rule everywhere (granted by default, EEA asks first), PROFILING is refused
31
- * everywhere forever. Globally: analytics_storage + ad_storage + ad_user_data granted — counting the
32
- * visit, and telling an ad its click worked; the dialog's question covers both, in the visitor's
33
- * language. ad_personalization is DENIED with no path anywhere, which is what keeps "never who"
34
- * true. The EEA + UK + CH region list denies everything until the dialog's answer — where consent is
35
- * owed we ask first; where it is not, measurement is simply on (the founder's explicit instruction).
35
+ * A NON-PRODUCTION PAGE MEASURES NOTHING: localhost, 127.0.0.1, ::1 and the edge's `dev-` previews.
36
36
  *
37
- * STORED CHOICES ARE VERSIONED: "granted+ads" replays the full grant, a legacy "granted" replays
38
- * analytics ONLY — a visitor who said yes to the narrower question is never silently upgraded to the
39
- * wider one. "denied" denies the measurement trio.
37
+ * `gtag` GOES ON `window`, never `function gtag` — the consent script elsewhere on the page calls it,
38
+ * and a framework that wraps this block in a function would trap a declaration inside it. The stub is
39
+ * assigned BEFORE the guard returns, so a silenced host still has a callable `gtag`.
40
40
  *
41
- * LEGAL POSTURE, noted with the founder: one sentence carries two purposes (counting + ad
42
- * measurement), both stated plainly — defensible at today's traffic; when traffic grows, granular
43
- * consent (two separate switches) should be revisited. ad_personalization staying dead is the
44
- * strongest card in that file.
41
+ * `page_title` IS PINNED at load (time shows a live clock in its tab).
45
42
  *
46
- * The region list has a sibling: the timezone list in the consent dialog's script. Change one and
47
- * the other must change, or a visitor is denied by region while never being offered the dialog.
43
+ * The tag loads on idle after `load` for a stored answer, and at once after a fresh Allow.
48
44
  *
49
- * `page_location` IS THE PAGE, PLUS THE CLICK THAT BROUGHT SOMEBODY TO IT — AND NOTHING ELSE.
50
- *
51
- * queries: paid clicks counted as organic · gclid stripped · cpc sessions dropped to zero · Google
52
- * Ads clicks missing in GA4 · page_location query string · organic search too high
53
- *
54
- * 2026-07-27 set `page_location` to `origin + pathname`, so that a WiFi password base64'd into a
55
- * qr link could never reach Google Analytics as the name of a page. Right, and still right. But
56
- * GA4 reads the Google Ads click id — `gclid` — from `page_location` and from nowhere else, so the
57
- * same line threw the click id away with the password. Measured on the property, week by week: the
58
- * fleet rebuilt on this core in the first days of August, `cpc` sessions fell from ~330 a week to
59
- * under 20 the week after, and `organic` rose by the same amount in the same week — while Google
60
- * Ads went on reporting 400–690 paid clicks a week. Every paid visit since has been counted as
61
- * organic search. The North Star readout (organic and direct growing while paid stays flat) was
62
- * reading its own defect: Search Console, which cannot be fooled this way, showed 82 organic
63
- * clicks in a month against GA4's 1,049 "organic" users.
64
- *
65
- * So the query is not dropped, it is FILTERED. What survives is the list below — Google's own click
66
- * ids and the utm_* campaign labels — which are ours and the ad network's, never the visitor's.
67
- * `?data=`, `?ref=`, `?lang=` and everything a person might have typed are still never sent. The
68
- * spec in harness/tests/unit.spec.mjs pins both halves: the click id survives, the data does not.
69
- *
70
- * `page_title` IS PINNED at load. Only one persona mutates `document.title` today — time shows a live
71
- * clock — and without this its analytics reports "13:32 · Amsterdam" as the page name. It costs every
72
- * other persona nothing and removes a trap the next persona that animates its tab would walk into.
73
- *
74
- * The tag itself loads on idle after `load`: measurement must never compete with the kernel.
75
- *
76
- * WRAPPED IN AN IIFE, and it has to be. The Astro binding used to get one for free from `define:vars`;
77
- * lifting the block out of the template removed it, and the locals became globals on every persona
78
- * page — three names a persona could collide with, leaked by the shell, with nothing to notice it. A
79
- * shared shell does not put anything in the global scope it did not mean to. `window.gtag` is still
80
- * assigned explicitly on window, which is the one thing that MUST escape.
45
+ * WRAPPED IN AN IIFE: a shared shell puts nothing in the global scope it did not mean to — only
46
+ * `gtag`, `__justaiMeasure` and `__justaiStopMeasure` (the consent script's two verbs) escape.
81
47
  */
82
48
  export declare function analyticsJs(gaId: string): string;
package/dist/analytics.js CHANGED
@@ -55,98 +55,73 @@ export function measurementIdFor(host) {
55
55
  return apex ? STREAMS[apex] : "";
56
56
  }
57
57
  /**
58
- * queries: analytics inline script · gtag block · consent defaults · why is dev traffic in GA4 ·
59
- * non-production guard · localhost 127.0.0.1 in analytics · how does a page start measuring
58
+ * queries: analytics inline script · gtag block · consent v2 · no google before consent · why is dev
59
+ * traffic in GA4 · non-production guard · reject cleanup · _ga _gcl cleanup · ga-disable
60
60
  *
61
61
  * The whole analytics head block, for any framework, given a measurement id.
62
62
  *
63
- * Everything load-bearing about it, in the order it matters:
64
- *
65
- * A NON-PRODUCTION PAGE MEASURES NOTHING. Found by reading the property through the analytics MCP:
66
- * `127.0.0.1` and `localhost` were its TOP "persona" — 546 sessions in four days, and on one of them
67
- * 127.0.0.1 alone outranked every real persona. Local dev and every headless verification sweep
68
- * loading built HTML. The guard also covers the edge's `dev-` preview hosts: previews are rehearsals,
69
- * not visits. Everything before 2026-07-24 in that property is inflated by this.
70
- *
71
- * `gtag` GOES ON `window`, never `function gtag`. A framework that scopes an injected variable wraps
72
- * this in an IIFE, and a function declaration would then be trapped inside it — while the consent
73
- * dialog's own script, elsewhere on the page, calls `gtag`. The failure is silent and specific: a
74
- * European visitor clicks Allow, "gtag is not defined", the choice is never applied and the sheet
75
- * never closes. The stub is also assigned BEFORE the guard returns, so a silenced host still has a
76
- * callable `gtag` and that same script cannot throw there either.
77
- *
78
- * CONSENT DEFAULTS, twice — REVISED 2026-07-25 with the founder, and the revision IS the doctrine:
79
- * MEASUREMENT follows one rule everywhere (granted by default, EEA asks first), PROFILING is refused
80
- * everywhere forever. Globally: analytics_storage + ad_storage + ad_user_data granted — counting the
81
- * visit, and telling an ad its click worked; the dialog's question covers both, in the visitor's
82
- * language. ad_personalization is DENIED with no path anywhere, which is what keeps "never who"
83
- * true. The EEA + UK + CH region list denies everything until the dialog's answer — where consent is
84
- * owed we ask first; where it is not, measurement is simply on (the founder's explicit instruction).
85
- *
86
- * STORED CHOICES ARE VERSIONED: "granted+ads" replays the full grant, a legacy "granted" replays
87
- * analytics ONLY — a visitor who said yes to the narrower question is never silently upgraded to the
88
- * wider one. "denied" denies the measurement trio.
89
- *
90
- * LEGAL POSTURE, noted with the founder: one sentence carries two purposes (counting + ad
91
- * measurement), both stated plainly — defensible at today's traffic; when traffic grows, granular
92
- * consent (two separate switches) should be revisited. ad_personalization staying dead is the
93
- * strongest card in that file.
94
- *
95
- * The region list has a sibling: the timezone list in the consent dialog's script. Change one and
96
- * the other must change, or a visitor is denied by region while never being offered the dialog.
97
- *
98
- * `page_location` IS THE PAGE, PLUS THE CLICK THAT BROUGHT SOMEBODY TO IT — AND NOTHING ELSE.
99
- *
100
- * queries: paid clicks counted as organic · gclid stripped · cpc sessions dropped to zero · Google
101
- * Ads clicks missing in GA4 · page_location query string · organic search too high
102
- *
103
- * 2026-07-27 set `page_location` to `origin + pathname`, so that a WiFi password base64'd into a
104
- * qr link could never reach Google Analytics as the name of a page. Right, and still right. But
105
- * GA4 reads the Google Ads click id — `gclid` — from `page_location` and from nowhere else, so the
106
- * same line threw the click id away with the password. Measured on the property, week by week: the
107
- * fleet rebuilt on this core in the first days of August, `cpc` sessions fell from ~330 a week to
108
- * under 20 the week after, and `organic` rose by the same amount in the same week — while Google
109
- * Ads went on reporting 400–690 paid clicks a week. Every paid visit since has been counted as
110
- * organic search. The North Star readout (organic and direct growing while paid stays flat) was
111
- * reading its own defect: Search Console, which cannot be fooled this way, showed 82 organic
112
- * clicks in a month against GA4's 1,049 "organic" users.
113
- *
114
- * So the query is not dropped, it is FILTERED. What survives is the list below — Google's own click
115
- * ids and the utm_* campaign labels — which are ours and the ad network's, never the visitor's.
116
- * `?data=`, `?ref=`, `?lang=` and everything a person might have typed are still never sent. The
117
- * spec in harness/tests/unit.spec.mjs pins both halves: the click id survives, the data does not.
118
- *
119
- * `page_title` IS PINNED at load. Only one persona mutates `document.title` today — time shows a live
120
- * clock — and without this its analytics reports "13:32 · Amsterdam" as the page name. It costs every
121
- * other persona nothing and removes a trap the next persona that animates its tab would walk into.
122
- *
123
- * The tag itself loads on idle after `load`: measurement must never compete with the kernel.
124
- *
125
- * WRAPPED IN AN IIFE, and it has to be. The Astro binding used to get one for free from `define:vars`;
126
- * lifting the block out of the template removed it, and the locals became globals on every persona
127
- * page — three names a persona could collide with, leaked by the shell, with nothing to notice it. A
128
- * shared shell does not put anything in the global scope it did not mean to. `window.gtag` is still
129
- * assigned explicitly on window, which is the one thing that MUST escape.
63
+ * CONSENT v2 (2026-11-23, owner — replaces the 2026-07-25 "granted by default, the EEA asks first"
64
+ * doctrine, which the Consent & Privacy R0 audit measured against production: a Turkish visitor was
65
+ * asked "may I count your visit?" 1.1 s AFTER GA4, Google Ads, ga-audiences and the conversion
66
+ * linker had already counted it, because the dialog's timezone list was wider than the gtag region
67
+ * list). The model is now one rule, everywhere, with no geography in it:
68
+ *
69
+ * NO ANSWER → NO GOOGLE. Nothing of Google is fetched, no cookie is written, no ping is sent —
70
+ * the gtag script is not even put in the document. `window.gtag` is a local stub.
71
+ * ALLOW → the tag loads, for analytics only: ad_storage / ad_user_data / ad_personalization
72
+ * denied, Google signals and ad personalisation off, ads data redacted. page_location
73
+ * keeps only Google's click ids and utm_* labels (never what a visitor typed into `?data=`) —
74
+ * a paid click is still a paid click to GA4. The stored answer is `v2:granted`.
75
+ * REJECT → nothing loads; a tag already running on this page stops (`ga-disable-<id>`, consent
76
+ * denied); every Google identifier on the apex is removed (`_ga`, `_ga_*`, `_gid`,
77
+ * `_gcl_*`, `_gac_*`, and the `_gcl_*` keys in localStorage). Stored as `v2:denied`.
78
+ *
79
+ * Only a v2 answer starts measuring. A pre-v2 "granted+ads" / "granted" was given to a different
80
+ * question under a different model, so it counts as NO answer (the visitor is asked again); a pre-v2
81
+ * "denied" stays a refusal. The answer is read from the apex cookie `justai-consent` (./consent —
82
+ * every persona is its own origin, so localStorage could never carry an answer across the apex).
83
+ *
84
+ * A NON-PRODUCTION PAGE MEASURES NOTHING: localhost, 127.0.0.1, ::1 and the edge's `dev-` previews.
85
+ *
86
+ * `gtag` GOES ON `window`, never `function gtag` — the consent script elsewhere on the page calls it,
87
+ * and a framework that wraps this block in a function would trap a declaration inside it. The stub is
88
+ * assigned BEFORE the guard returns, so a silenced host still has a callable `gtag`.
89
+ *
90
+ * `page_title` IS PINNED at load (time shows a live clock in its tab).
91
+ *
92
+ * The tag loads on idle after `load` for a stored answer, and at once after a fresh Allow.
93
+ *
94
+ * WRAPPED IN AN IIFE: a shared shell puts nothing in the global scope it did not mean to — only
95
+ * `gtag`, `__justaiMeasure` and `__justaiStopMeasure` (the consent script's two verbs) escape.
130
96
  */
131
- // THE STORED ANSWER is the apex's (2026-10-14, see ./consent): the `justai-consent` cookie on the
132
- // registrable domain first, this origin's localStorage only as the pre-apex fallback.
133
97
  export function analyticsJs(gaId) {
134
98
  return `(function(){
135
99
  window.gtag=window.gtag||function(){(window.dataLayer=window.dataLayer||[]).push(arguments)};
136
100
  var __h=location.hostname;
137
- if(!(__h==="localhost"||__h==="127.0.0.1"||__h==="::1"||__h==="[::1]"||__h.indexOf("dev-")===0)){
101
+ if(__h==="localhost"||__h==="127.0.0.1"||__h==="::1"||__h==="[::1]"||__h.indexOf("dev-")===0)return;
138
102
  var __g=${JSON.stringify(gaId)};
139
103
  if(!__g)return;
140
- window.dataLayer=window.dataLayer||[];
141
- window.gtag=window.gtag||function(){window.dataLayer.push(arguments)};
104
+ var __hp=__h.split("."),__ap=(__hp.length>2&&!/^[0-9.]+$/.test(__h))?__hp.slice(-2).join("."):__h;
105
+ var __on=false;
106
+ window.__justaiMeasure=function(now){
107
+ if(__on)return;__on=true;window["ga-disable-"+__g]=false;
142
108
  gtag("js",new Date());
143
- gtag("consent","default",{ad_storage:"granted",ad_user_data:"granted",ad_personalization:"denied",analytics_storage:"granted"});
144
- gtag("consent","default",{region:["AT","BE","BG","HR","CY","CZ","DK","EE","FI","FR","DE","GR","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","RO","SK","SI","ES","SE","IS","LI","NO","GB","CH"],ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied",analytics_storage:"denied"});
145
- try{var __m=document.cookie.match(/(?:^|; )justai-consent=([^;]*)/),__c=__m?decodeURIComponent(__m[1]):localStorage.getItem("consent");
146
- if(__c==="granted+ads")gtag("consent","update",{analytics_storage:"granted",ad_storage:"granted",ad_user_data:"granted"});
147
- else if(__c==="granted")gtag("consent","update",{analytics_storage:"granted"});
148
- else if(__c==="denied")gtag("consent","update",{analytics_storage:"denied",ad_storage:"denied",ad_user_data:"denied"})}catch(e){}
109
+ gtag("consent","default",{analytics_storage:"granted",ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied"});
110
+ gtag("set","ads_data_redaction",true);
149
111
  gtag("config",__g,{cookie_expires:60*60*24*60,page_title:document.title,page_location:(function(){var q=new URLSearchParams(location.search),k=["gclid","gbraid","wbraid","dclid","utm_source","utm_medium","utm_campaign","utm_term","utm_content"],o=[];for(var i=0;i<k.length;i++){var v=q.get(k[i]);if(v)o.push(k[i]+"="+encodeURIComponent(v))}return location.origin+location.pathname+(o.length?"?"+o.join("&"):"")})(),allow_google_signals:false,allow_ad_personalization_signals:false});
150
- addEventListener("load",function(){(window.requestIdleCallback||function(f){setTimeout(f,1200)})(function(){var s=document.createElement("script");s.async=true;s.src="https://www.googletagmanager.com/gtag/js?id="+__g;document.head.appendChild(s)})});
151
- }})();`;
112
+ var go=function(){var s=document.createElement("script");s.async=true;s.src="https://www.googletagmanager.com/gtag/js?id="+__g;document.head.appendChild(s)};
113
+ if(now)go();else addEventListener("load",function(){(window.requestIdleCallback||function(f){setTimeout(f,1200)})(go)});
114
+ };
115
+ window.__justaiStopMeasure=function(){
116
+ window["ga-disable-"+__g]=true;
117
+ if(__on){try{gtag("consent","update",{analytics_storage:"denied",ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied"})}catch(e){}}
118
+ var ds=["",__h,"."+__h,__ap,"."+__ap],cs=document.cookie.split(";");
119
+ for(var i=0;i<cs.length;i++){var n=cs[i].split("=")[0].trim();
120
+ if(/^(_ga|_gid|_gat)($|_)|^_gcl_|^_gac_/.test(n))for(var j=0;j<ds.length;j++)document.cookie=n+"=; Max-Age=0; Path=/"+(ds[j]?"; Domain="+ds[j]:"")}
121
+ try{for(var k=localStorage.length-1;k>=0;k--){var key=localStorage.key(k);if(key&&/^_gcl_|^_ga($|_)/.test(key))localStorage.removeItem(key)}}catch(e){}
122
+ };
123
+ try{var __m=document.cookie.match(/(?:^|; )justai-consent=([^;]*)/),__c=__m?decodeURIComponent(__m[1]):null;
124
+ if(__c==="v2:granted")window.__justaiMeasure(false);
125
+ else if(__c==="v2:denied"||__c==="denied")window.__justaiStopMeasure()}catch(e){}
126
+ })();`;
152
127
  }
package/dist/consent.d.ts CHANGED
@@ -5,121 +5,69 @@
5
5
  * and why its behaviour lives one level below @justai/cuts.
6
6
  */
7
7
  /**
8
- * queries: where does the consent dialog text live · change the consent wording · consentText ·
9
- * consentAllow consentDecline consentChoice · why is the consent copy not in the persona ·
10
- * feed cannot show the consent sheet · translate the consent question
11
- *
12
- * THE CONSENT COPY — the ecosystem's question to a visitor, in thirteen languages, said once.
13
- *
14
- * It used to live in every persona's own dictionary: thirteen languages across thirteen repos, and
15
- * measured before this moved, all 52 strings were byte-identical in all of them. That is the tell.
16
- * A persona's dictionary holds what makes it that persona; this is the ECOSYSTEM speaking, and the
17
- * same sentence copied into a hundred and sixty-nine files is not localisation, it is a maintenance
18
- * bill. Changing one word meant thirteen pull requests, and getting twelve of them right meant a
19
- * visitor somewhere read an older promise than the one we thought we were making.
20
- *
21
- * It is legally load-bearing text. There is exactly one place it may be edited, and this is it.
22
- *
23
- * WHY HERE rather than in @justai/cuts: `feed` renders on every persona's host and depends on core,
24
- * not on cuts. Putting the copy where only the Astro shell could reach it is what kept feed from
25
- * asking the question at all. Content, like behaviour, belongs at the layer every face can reach.
26
- *
27
- * REWRITTEN 2026-08-23, after a native Dutch speaker read it on app.zone and said the translations
28
- * were bad. He was right, and the fault was not in the Dutch — it was in the ENGLISH, which was
29
- * written in a way no translator could carry:
30
- *
31
- * "anonymously, never who" an elliptical construction with no equivalent in most languages. The
32
- * Dutch became "nooit wie", which a native reads as a fragment.
33
- * "let it know it worked" two pronouns with different referents and a dropped subject. The
34
- * Dutch lost the subject entirely — nobody could tell who told whom.
35
- * "Count me in" an idiom, calqued straight into "Tel me mee".
36
- *
37
- * So the source was fixed first: two nouns in parallel ("as a number, never a name") instead of the
38
- * ellipsis, two whole questions instead of one clause hanging off another, and "that ad" naming its
39
- * own antecedent. Only then were the twelve languages redone.
40
- *
41
- * THREE RULES CAME OUT OF DOING IT, and they are the reason this reads better than a translation:
42
- *
43
- * 1. The INTIMATE second person, everywhere the language has one — tu, du, je, sen, tú, ты. A
44
- * persona is a friend who is glad you came; the formal form turns a small warm question into a
45
- * terms-of-service notice, and three languages had silently drifted into it.
46
- * 2. Every clause names who is doing what TO WHOM. The recurring failure across five languages was
47
- * the advertisement sentence losing its recipient: "may I let it be known that it worked".
48
- * 3. Carry the feeling, not the figure of speech. English personifies the advertisement — you can
49
- * TELL an ad it worked. In Hindi and Chinese nobody speaks to an advertisement, so those two say
50
- * the ad was RECORDED as having worked. Same promise, no English showing through.
51
- *
52
- * The register and recipient checks are mechanical and worth repeating on any future edit: a formal
53
- * pronoun and a dropped indirect object are both invisible to a spell-check and both change what the
54
- * sentence means.
55
- *
56
- * A locale with no entry falls back to English rather than rendering an empty sheet — a missing
57
- * translation must never become a dialog with no question in it.
8
+ * queries: where does the consent text live · change the consent wording · consentText · consentAllow
9
+ * consentDecline consentSettings consentMeasure · consent v2 copy · translate the consent bar
10
+ *
11
+ * THE CONSENT COPY — the ecosystem's question to a visitor, in thirteen languages, said once. It is
12
+ * legally load-bearing text: there is exactly one place it may be edited, and this is it. It lives in
13
+ * core (not cuts) because `feed` renders on every persona's host and depends on core only.
14
+ *
15
+ * CONSENT v2 (2026-11-23, owner): SYSTEM WORDS, not a persona's. The question is plain and neutral —
16
+ * what is measured (anonymous usage), why (to improve the house), and what it never touches (your
17
+ * files). No heart, no "may I", no advertising: the house measures nothing for ads. Three answers —
18
+ * Settings (a text action), Reject and Allow, equal in size — and one setting, Usage measurement.
19
+ * `{site}` is the apex the page belongs to (app.zone, pin.games, justai.pro, cityinmotion.nl);
20
+ * Turkish takes its case suffix from the site's own sound (`app.zone'u`, `pin.games'i`).
58
21
  */
59
- /** The consent question and its two answers, for one language. */
22
+ /** The consent bar's words, for one language. */
60
23
  export interface ConsentStrings {
24
+ /** the sentence on the bar; `{site}` is filled by consentCopy */
61
25
  consentText: string;
62
26
  consentAllow: string;
63
27
  consentDecline: string;
28
+ consentSettings: string;
29
+ /** the one setting's name */
30
+ consentMeasure: string;
31
+ consentOn: string;
32
+ consentOff: string;
33
+ /** the change-your-mind door in footers, and the bar's accessible name */
64
34
  consentChoice: string;
65
35
  }
66
36
  export declare const CONSENT_COPY: Record<string, ConsentStrings>;
67
- /** The consent copy for a language, falling back to English. Never returns undefined. */
68
- export declare function consentCopy(lang: string | null | undefined): ConsentStrings;
37
+ /** The registrable apex of a site URL or host (`https://tabata.app.zone` → `app.zone`). */
38
+ export declare function consentSite(site: string | null | undefined): string;
39
+ /** The consent words for a language and a site, falling back to English. Never returns undefined. */
40
+ export declare function consentCopy(lang: string | null | undefined, site?: string | null): ConsentStrings;
69
41
  /**
70
- * queries: consent dialog script · why does the sheet not appear on some pages · consent is asked
71
- * per domain not per page · getElementById kernel · the sheet never opened on feed ·
72
- * only a choice may be remembered · the change-your-mind door · consent timezone list
73
- *
74
- * The consent dialog's behaviour — one copy, for every surface on a persona's origin.
75
- *
76
- * CONSENT IS SCOPED TO THE APEX — every persona under app.zone, pin.games, justai.pro, cityinmotion.nl
77
- * answers to one question (2026-10-14). It was scoped to the ORIGIN, on purpose: each persona honest
78
- * with its own visitor, so somebody arriving from search straight at qr was asked by qr. The founder,
79
- * from what visitors told him: *"app.zone'a giriyorum, count me. app.zone'daki bir app'e giriyorum,
80
- * count me… kullanıcıya gına geliyor"* — by the third or fourth persona people answer "stay invisible"
81
- * to make the asking stop, which is the question working against itself. So: an answer given on ANY
82
- * persona of an apex — either answer — is that apex's answer, and no sibling asks again. Nobody on the
83
- * apex has answered yet? The first persona visited asks, and its answer becomes everyone's. Another
84
- * apex is another household and asks for itself.
85
- *
86
- * HOW: a cookie on the registrable domain (`justai-consent`, Domain=<apex>), because localStorage is
87
- * per origin and every subdomain is its own origin — that is the whole reason each one asked. It
88
- * lives 13 months (foundations/15: a label must not outlive what it labels; the choice is re-asked
89
- * once a year, the usual ceiling for a stored consent in Europe). `localStorage["consent"]` is still
90
- * written, for shells on older cores, and an answer found only there is PROMOTED to the apex cookie on
91
- * the next visit — so everybody who answered any persona before this change is not asked by its
92
- * siblings after it. The "not now" (Escape) flag is an apex SESSION cookie for the same reason: one
93
- * dodge keeps the whole apex quiet for this visit, not just one persona. /me's erase must expire the
94
- * cookie on every plausible domain (it cannot read the Domain attribute back).
95
- *
96
- * Whichever page a visitor enters by, if the apex has never been answered, it asks — once. That is
97
- * what a consent flow IS, and it is worth stating because ours was accidentally page-scoped for three
98
- * weeks: the script used to bail on
99
- * `!document.getElementById("kernel")`, a DOM sniff added to avoid asking on a 404. Feed pages have
100
- * no kernel either, so on every /feed/* page in the fleet the question was never asked — silently,
101
- * with nothing to notice it. A trust decision must never be inferred from an unrelated layout
102
- * detail; the check is gone, and any page that renders the sheet may ask.
103
- *
104
- * ONLY A CHOICE MAY BE REMEMBERED AS A CHOICE. "confirm" is the heart, "denied" is a chosen
105
- * "Stay invisible". Anything else — Escape, a tap on the backdrop — is not an answer: nothing is
106
- * stored, the regional default stands, and the ask returns next visit. The session flag only keeps
107
- * THIS visit quiet, so one slip-away buys one visit of peace rather than an answer nobody gave.
108
- *
109
- * THE DOOR IS UNIVERSAL. The footer's hidden `[data-consent-open]` anchor is labelled, revealed and
110
- * wired here for EVERY visitor in EVERY region — a non-EEA visitor gets a real opt-out they were
111
- * never offered, and anyone can reverse either answer. Only the AUTO-ask has narrow gates.
112
- *
113
- * THE TIMEZONE LIST IS A PROXY for "consent is legally asked here", never the thing itself, and it is
114
- * the sibling of the region array in {@link analyticsJs}. `Europe/` carries almost all of the EEA but
115
- * not all of it: twelve zones sit on other continents. Change one list and you must change the other,
116
- * or a visitor is denied by region while never being offered the dialog.
117
- *
118
- * `returnValue` survives a close, so it is reset before every open or a stale answer replays.
119
- *
120
- * FOCUS IS GIVEN AT OPEN, not by an autofocus attribute. Chrome refuses to process `autofocus` in
121
- * any document whose URL carries a fragment and warns on every load — /me#profile met it first. So
122
- * the sheet ships no attribute, and the opener places focus by the genre's law: the ask genre puts
123
- * it on the invitation (here), the destructive genre on the cancel (that consumer's own open).
42
+ * queries: consent bar behaviour · consent v2 · no google before consent · reject cleans identifiers ·
43
+ * escape is not an answer · the change-your-mind door · consent settings switch · legacy
44
+ * granted+ads · consent cookie per apex
45
+ *
46
+ * The consent bar's behaviour — one copy, for every surface on a persona's origin. It drives the bar
47
+ * @justai/cuts renders (ConsentBar.astro: `#consent` with `[data-consent]` buttons) and the two verbs
48
+ * ./analytics puts on window (`__justaiMeasure`, `__justaiStopMeasure`).
49
+ *
50
+ * GLOBAL (2026-11-23, owner): every visitor, wherever they are, is asked; nothing is measured until
51
+ * they Allow. There is no timezone and no region list any more — the R0 audit proved the two lists
52
+ * disagreed, and a guess about where a visitor is must not decide what is done to them.
53
+ *
54
+ * NOT A DIALOG. The bar is a region at the bottom of the page: no backdrop, no focus trap, the page
55
+ * stays usable. Its buttons are plain `type=button` — never a <form>, so a measurement tag can never
56
+ * count the answer as a form interaction (R0: Reject was sent to GA4 as form_submit).
57
+ *
58
+ * THE ANSWER IS THE APEX'S: the `justai-consent` cookie on the registrable domain, because every
59
+ * persona is its own origin and localStorage could never carry one answer across tabata.app.zone,
60
+ * qr.app.zone and app.zone. It is the ONLY store (the pre-apex localStorage key is read once, then
61
+ * removed). Values: `v2:granted` · `v2:denied`. A pre-v2 "granted+ads" / "granted" is NOT carried —
62
+ * it answered a different question — so the visitor is asked again, unmeasured; a pre-v2 "denied"
63
+ * becomes `v2:denied`.
64
+ *
65
+ * ESCAPE IS NOT AN ANSWER: it puts the bar away for this visit (`justai-consent-later`, a session
66
+ * cookie on the apex) and stores nothing; measurement stays off, and the bar returns next visit. It
67
+ * closes the bar ONLY — caught on window, capture phase — so the surface under it (a profile, a sheet)
68
+ * is not closed by the same key.
69
+ *
70
+ * THE DOOR IS UNIVERSAL: every `[data-consent-open]` (footers, the profile) is labelled, revealed and
71
+ * opens the bar with Settings showing the current state.
124
72
  */
125
- export declare const CONSENT_JS = "(function(){try{\nvar h=location.hostname;\nif(h===\"localhost\"||h===\"127.0.0.1\"||h===\"::1\"||h===\"[::1]\"||h.indexOf(\"dev-\")===0)return;\nvar el=document.getElementById(\"consent\");if(!el||!el.showModal)return;\nvar hp=h.split(\".\"),ap=(hp.length>2&&!/^[0-9.]+$/.test(h))?hp.slice(-2).join(\".\"):h;\nvar AGE=34128000;\nvar rd=function(n){var m=document.cookie.match(new RegExp(\"(?:^|; )\"+n+\"=([^;]*)\"));return m?decodeURIComponent(m[1]):null};\nvar wr=function(n,v,age){document.cookie=n+\"=\"+encodeURIComponent(v)+\"; Domain=\"+ap+\"; Path=/\"+(age?\"; Max-Age=\"+age:\"\")+\"; SameSite=Lax; Secure\"};\nvar stored=function(){var c=rd(\"justai-consent\");if(c)return c;var l=null;try{l=localStorage.getItem(\"consent\")}catch(_){}if(l)wr(\"justai-consent\",l,AGE);return l};\nvar open=function(){if(!el.open){el.returnValue=\"\";el.showModal();var p=el.querySelector(\".preferred\");if(p)p.focus()}};\nel.addEventListener(\"close\",function(){\nvar rv=el.returnValue;\nvar v=rv===\"confirm\"?\"granted+ads\":rv===\"denied\"?\"denied\":null;\nif(v){var g=v===\"denied\"?\"denied\":\"granted\";\ngtag(\"consent\",\"update\",{analytics_storage:g,ad_storage:g,ad_user_data:g});\ntry{localStorage.setItem(\"consent\",v)}catch(_){}\nwr(\"justai-consent\",v,AGE)}\nelse{wr(\"justai-consent-later\",\"1\",0);try{sessionStorage.setItem(\"consent-later\",\"1\")}catch(_){}}\n});\nvar doors=document.querySelectorAll(\"[data-consent-open]\");\nfor(var i=0;i<doors.length;i++){var a=doors[i];\nif(!a.textContent)a.textContent=el.getAttribute(\"data-choice-label\")||\"privacy choice\";\na.hidden=false;var w=a.closest(\"[data-consent-door]\");if(w)w.hidden=false;\na.addEventListener(\"click\",function(ev){ev.preventDefault();open()})}\nif(stored())return;\nif(rd(\"justai-consent-later\"))return;\ntry{if(sessionStorage.getItem(\"consent-later\"))return}catch(_){}\nvar tz=Intl.DateTimeFormat().resolvedOptions().timeZone||\"\";\nvar asked=tz.indexOf(\"Europe/\")===0||[\n\"Asia/Nicosia\",\"Asia/Famagusta\",\n\"Atlantic/Canary\",\"Atlantic/Azores\",\"Atlantic/Madeira\",\"Atlantic/Reykjavik\",\n\"Arctic/Longyearbyen\",\n\"America/Guadeloupe\",\"America/Martinique\",\"America/Cayenne\",\n\"Indian/Reunion\",\"Indian/Mayotte\"].indexOf(tz)>=0;\nif(!asked)return;\nsetTimeout(open,700);\n}catch(_){}})();";
73
+ export declare const CONSENT_JS = "(function(){try{\nvar h=location.hostname;\nif(h===\"localhost\"||h===\"127.0.0.1\"||h===\"::1\"||h===\"[::1]\"||h.indexOf(\"dev-\")===0)return;\nvar el=document.getElementById(\"consent\");if(!el||!el.hasAttribute(\"data-consent-bar\"))return;\nvar hp=h.split(\".\"),ap=(hp.length>2&&!/^[0-9.]+$/.test(h))?hp.slice(-2).join(\".\"):h;\nvar AGE=34128000;\nvar rd=function(n){var m=document.cookie.match(new RegExp(\"(?:^|; )\"+n+\"=([^;]*)\"));return m?decodeURIComponent(m[1]):null};\nvar wr=function(n,v,age){document.cookie=n+\"=\"+encodeURIComponent(v)+\"; Domain=\"+ap+\"; Path=/\"+(age?\"; Max-Age=\"+age:\"\")+\"; SameSite=Lax; Secure\"};\nvar q=function(s){return el.querySelector('[data-consent=\"'+s+'\"]')};\nvar sw=q(\"switch\"),set=document.getElementById(\"consent-set\"),gear=q(\"settings\");\nvar state=function(){var c=rd(\"justai-consent\");\nif(c===\"v2:granted\")return\"granted\";if(c===\"v2:denied\")return\"denied\";\nvar l=null;try{l=localStorage.getItem(\"consent\");localStorage.removeItem(\"consent\")}catch(_){}\nif(c===\"denied\"||l===\"denied\"){wr(\"justai-consent\",\"v2:denied\",AGE);return\"denied\"}\nreturn null};\nvar paint=function(){var on=state()===\"granted\";if(sw){sw.setAttribute(\"aria-checked\",on?\"true\":\"false\")}};\nvar settings=function(open){if(set)set.hidden=!open;if(gear)gear.setAttribute(\"aria-expanded\",open?\"true\":\"false\");paint()};\nvar show=function(withSettings){settings(!!withSettings);el.hidden=false};\nvar hide=function(){el.hidden=true};\nvar answer=function(v,keep){wr(\"justai-consent\",\"v2:\"+v,AGE);\nif(v===\"granted\"){if(window.__justaiMeasure)window.__justaiMeasure(true)}else{if(window.__justaiStopMeasure)window.__justaiStopMeasure()}\npaint();if(!keep)hide()};\nvar a=q(\"allow\"),d=q(\"deny\");\nif(a)a.addEventListener(\"click\",function(){answer(\"granted\")});\nif(d)d.addEventListener(\"click\",function(){answer(\"denied\")});\nif(gear)gear.addEventListener(\"click\",function(){settings(set?set.hidden:false)});\nif(sw)sw.addEventListener(\"click\",function(){answer(sw.getAttribute(\"aria-checked\")===\"true\"?\"denied\":\"granted\",true)});\naddEventListener(\"keydown\",function(ev){if(ev.key===\"Escape\"&&!el.hidden){ev.preventDefault();ev.stopPropagation();hide();if(!state())wr(\"justai-consent-later\",\"1\",0)}},true);\nvar doors=document.querySelectorAll(\"[data-consent-open]\");\nfor(var i=0;i<doors.length;i++){var o=doors[i];\nif(!o.textContent)o.textContent=el.getAttribute(\"aria-label\")||\"privacy choice\";\no.hidden=false;var w=o.closest(\"[data-consent-door]\");if(w)w.hidden=false;\no.addEventListener(\"click\",function(ev){ev.preventDefault();show(true);var f=sw||a;if(f)f.focus()})}\nvar s0=state();\nif(s0===\"denied\"&&window.__justaiStopMeasure)window.__justaiStopMeasure();\nif(s0)return;\nif(rd(\"justai-consent-later\"))return;\nsetTimeout(function(){show(false)},600);\n}catch(_){}})();";
package/dist/consent.js CHANGED
@@ -5,179 +5,106 @@
5
5
  * and why its behaviour lives one level below @justai/cuts.
6
6
  */
7
7
  export const CONSENT_COPY = {
8
- "ar": {
9
- "consentText": "يسعدني أن أعرف أن أحدًا مرّ من هنا — رقمًا فقط، لا اسمًا أبدًا. هل لي أن أحسب زيارتك؟ وإذا كان إعلانٌ قد أوصلك إليّ، هل لي أن أخبره أنه نجح؟",
10
- "consentAllow": "احسب زيارتي ❤️",
11
- "consentDecline": "أبقني خفيًّا",
12
- "consentChoice": "خيار الخصوصية"
13
- },
14
- "de": {
15
- "consentText": "Ich würde mich freuen zu wissen, dass jemand vorbeigeschaut hat — nur als Zahl, nie als Name. Darf ich deinen Besuch mitzählen? Und wenn dich eine Anzeige hergebracht hat: Darf ich ihr sagen, dass sie funktioniert hat?",
16
- "consentAllow": "Zähl mich mit ❤️",
17
- "consentDecline": "Lass mich unsichtbar bleiben",
18
- "consentChoice": "Privatsphäre-Wahl"
19
- },
20
- "en": {
21
- "consentText": "I'd love to know that someone came by — as a number, never a name. May I count your visit? And if an ad brought you here, may I tell that ad it worked?",
22
- "consentAllow": "Count my visit ❤️",
23
- "consentDecline": "Keep me invisible",
24
- "consentChoice": "privacy choice"
25
- },
26
- "es": {
27
- "consentText": "Me encantaría saber que alguien pasó por aquí — como un número, nunca como un nombre. ¿Puedo contar tu visita? Y si un anuncio te trajo hasta aquí, ¿puedo decirle que funcionó?",
28
- "consentAllow": "Cuenta mi visita ❤️",
29
- "consentDecline": "Mantenme invisible",
30
- "consentChoice": "opciones de privacidad"
31
- },
32
- "fr": {
33
- "consentText": "J'aimerais savoir que quelqu'un est passé — comme un chiffre, jamais comme un nom. Je peux compter ta visite ? Et si une pub t'a amené ici, je peux lui dire qu'elle a marché ?",
34
- "consentAllow": "Compte ma visite ❤️",
35
- "consentDecline": "Garde-moi invisible",
36
- "consentChoice": "choix de confidentialité"
37
- },
38
- "hi": {
39
- "consentText": "मुझे यह जानकर अच्छा लगेगा कि कोई आया था — बस एक गिनती के तौर पर, नाम कभी नहीं। क्या मैं तुम्हारी विज़िट गिन लूँ? और अगर तुम किसी विज्ञापन से यहाँ पहुँचे हो, तो क्या मैं दर्ज कर लूँ कि वह विज्ञापन काम आया?",
40
- "consentAllow": "मेरी विज़िट गिन लो ❤️",
41
- "consentDecline": "मुझे गुमनाम ही रहने दो",
42
- "consentChoice": "गोपनीयता विकल्प"
43
- },
44
- "it": {
45
- "consentText": "Mi farebbe piacere sapere che qualcuno è passato — come un numero, mai come un nome. Posso contare la tua visita? E se un annuncio ti ha portato qui, posso dirgli che ha funzionato?",
46
- "consentAllow": "Conta la mia visita ❤️",
47
- "consentDecline": "Lasciami invisibile",
48
- "consentChoice": "scelta sulla privacy"
49
- },
50
- "ja": {
51
- "consentText": "誰かが来てくれたと知れるだけで嬉しいんだ — 名前ではなく、ただの数として。訪問を数えてもいい? それと、広告がきっかけで来てくれたなら、その広告に「うまくいったよ」と伝えてもいい?",
52
- "consentAllow": "訪問を数えてね ❤️",
53
- "consentDecline": "見えないままでいて",
54
- "consentChoice": "プライバシー設定"
55
- },
56
- "nl": {
57
- "consentText": "Ik zou het fijn vinden om te weten dat er iemand is langsgekomen — gewoon als een getalletje, nooit een naam. Mag ik je bezoek meetellen? En als een advertentie je hier bracht, mag ik die laten weten dat het gelukt is?",
58
- "consentAllow": "Tel me mee ❤️",
59
- "consentDecline": "Houd me onzichtbaar",
60
- "consentChoice": "privacykeuze"
61
- },
62
- "pt": {
63
- "consentText": "Eu adoraria saber que alguém passou por aqui — como um número, nunca como um nome. Posso contar sua visita? E se um anúncio trouxe você até aqui, posso avisar a ele que funcionou?",
64
- "consentAllow": "Conta minha visita ❤️",
65
- "consentDecline": "Me deixe invisível",
66
- "consentChoice": "escolha de privacidade"
67
- },
68
- "ru": {
69
- "consentText": "Мне бы хотелось знать, что кто-то заходил — как число, а не как имя. Можно посчитать твой визит? И если тебя привела реклама, можно сказать ей, что она сработала?",
70
- "consentAllow": "Посчитай мой визит ❤️",
71
- "consentDecline": "Оставь меня невидимым",
72
- "consentChoice": "выбор приватности"
73
- },
74
- "tr": {
75
- "consentText": "Birinin uğradığını bilmek isterim — bir isim olarak değil, sadece bir sayı olarak. Ziyaretini sayabilir miyim? Bir de, buraya bir reklamla geldiysen, o reklama işe yaradığını söyleyebilir miyim?",
76
- "consentAllow": "Ziyaretimi say ❤️",
77
- "consentDecline": "Görünmez kalayım",
78
- "consentChoice": "gizlilik tercihi"
79
- },
80
- "zh": {
81
- "consentText": "我想知道有人来过 — 只是一个数字,永远不是一个名字。可以把你这次来访算上吗?如果你是通过广告找到我的,可以记下这次广告起作用了吗?",
82
- "consentAllow": "算我一次 ❤️",
83
- "consentDecline": "让我隐身吧",
84
- "consentChoice": "隐私选项"
85
- }
8
+ "ar": { consentText: "يساعدنا القياس المجهول للاستخدام على تحسين {site}. ولا يصل إلى ملفاتك.", consentAllow: "السماح", consentDecline: "الرفض", consentSettings: "الإعدادات", consentMeasure: "قياس الاستخدام", consentOn: "تشغيل", consentOff: "إيقاف", consentChoice: "خيار الخصوصية" },
9
+ "de": { consentText: "Anonyme Nutzungsmessung hilft uns, {site} zu verbessern. Sie greift nicht auf deine Dateien zu.", consentAllow: "Erlauben", consentDecline: "Ablehnen", consentSettings: "Einstellungen", consentMeasure: "Nutzungsmessung", consentOn: "An", consentOff: "Aus", consentChoice: "Privatsphäre-Wahl" },
10
+ "en": { consentText: "Anonymous usage measurement helps us improve {site}. It does not access your files.", consentAllow: "Allow", consentDecline: "Reject", consentSettings: "Settings", consentMeasure: "Usage measurement", consentOn: "On", consentOff: "Off", consentChoice: "privacy choice" },
11
+ "es": { consentText: "La medición de uso anónima nos ayuda a mejorar {site}. No accede a tus archivos.", consentAllow: "Permitir", consentDecline: "Rechazar", consentSettings: "Ajustes", consentMeasure: "Medición de uso", consentOn: "Activada", consentOff: "Desactivada", consentChoice: "opciones de privacidad" },
12
+ "fr": { consentText: "La mesure d’usage anonyme nous aide à améliorer {site}. Elle n’accède pas à vos fichiers.", consentAllow: "Autoriser", consentDecline: "Refuser", consentSettings: "Réglages", consentMeasure: "Mesure d’usage", consentOn: "Activée", consentOff: "Désactivée", consentChoice: "choix de confidentialité" },
13
+ "hi": { consentText: "अनाम उपयोग माप हमें {site} को बेहतर बनाने में मदद करता है। यह आपकी फ़ाइलों तक नहीं पहुँचता।", consentAllow: "अनुमति दें", consentDecline: "अस्वीकार करें", consentSettings: "सेटिंग्स", consentMeasure: "उपयोग माप", consentOn: "चालू", consentOff: "बंद", consentChoice: "गोपनीयता विकल्प" },
14
+ "it": { consentText: "La misurazione anonima dell’uso ci aiuta a migliorare {site}. Non accede ai tuoi file.", consentAllow: "Consenti", consentDecline: "Rifiuta", consentSettings: "Impostazioni", consentMeasure: "Misurazione dell’uso", consentOn: "Attiva", consentOff: "Disattiva", consentChoice: "scelta sulla privacy" },
15
+ "ja": { consentText: "匿名の利用状況の計測は、{site} の改善に役立ちます。あなたのファイルにはアクセスしません。", consentAllow: "許可", consentDecline: "拒否", consentSettings: "設定", consentMeasure: "利用状況の計測", consentOn: "オン", consentOff: "オフ", consentChoice: "プライバシー設定" },
16
+ "nl": { consentText: "Anonieme gebruiksmeting helpt ons {site} te verbeteren. Ze heeft geen toegang tot je bestanden.", consentAllow: "Toestaan", consentDecline: "Weigeren", consentSettings: "Instellingen", consentMeasure: "Gebruiksmeting", consentOn: "Aan", consentOff: "Uit", consentChoice: "privacykeuze" },
17
+ "pt": { consentText: "A medição anônima de uso nos ajuda a melhorar o {site}. Ela não acessa seus arquivos.", consentAllow: "Permitir", consentDecline: "Recusar", consentSettings: "Configurações", consentMeasure: "Medição de uso", consentOn: "Ativada", consentOff: "Desativada", consentChoice: "escolha de privacidade" },
18
+ "ru": { consentText: "Анонимная статистика использования помогает нам улучшать {site}. Она не получает доступа к вашим файлам.", consentAllow: "Разрешить", consentDecline: "Отклонить", consentSettings: "Настройки", consentMeasure: "Статистика использования", consentOn: "Вкл.", consentOff: "Выкл.", consentChoice: "выбор приватности" },
19
+ "tr": { consentText: "Anonim kullanım ölçümü {site}{acc} geliştirmemize yardımcı olur. Dosyalarına erişmez.", consentAllow: "İzin ver", consentDecline: "Reddet", consentSettings: "Ayarlar", consentMeasure: "Kullanım ölçümü", consentOn: "Açık", consentOff: "Kapalı", consentChoice: "gizlilik tercihi" },
20
+ "zh": { consentText: "匿名使用统计帮助我们改进 {site}。它不会访问你的文件。", consentAllow: "允许", consentDecline: "拒绝", consentSettings: "设置", consentMeasure: "使用统计", consentOn: "开", consentOff: "关", consentChoice: "隐私选项" },
86
21
  };
87
- /** The consent copy for a language, falling back to English. Never returns undefined. */
88
- export function consentCopy(lang) {
89
- return CONSENT_COPY[String(lang || "en").toLowerCase()] || CONSENT_COPY.en;
22
+ /** Turkish accusative suffix by the apex's last syllable as it is said (app.zone → "zon" → ’u). */
23
+ const TR_ACC = { "app.zone": "’u", "pin.games": "’i", "justai.pro": "’yu", "cityinmotion.nl": "’yi" };
24
+ /** The registrable apex of a site URL or host (`https://tabata.app.zone` → `app.zone`). */
25
+ export function consentSite(site) {
26
+ let h = String(site || "");
27
+ try {
28
+ h = new URL(h).hostname;
29
+ }
30
+ catch { /* a bare host */ }
31
+ const p = h.split(".");
32
+ return p.length > 2 && !/^[0-9.]+$/.test(h) ? p.slice(-2).join(".") : h;
33
+ }
34
+ /** The consent words for a language and a site, falling back to English. Never returns undefined. */
35
+ export function consentCopy(lang, site) {
36
+ const c = CONSENT_COPY[String(lang || "en").toLowerCase()] || CONSENT_COPY.en;
37
+ const s = consentSite(site) || "app.zone";
38
+ return { ...c, consentText: c.consentText.replace("{site}", s).replace("{acc}", TR_ACC[s] ?? "’u") };
90
39
  }
91
40
  /**
92
- * queries: consent dialog script · why does the sheet not appear on some pages · consent is asked
93
- * per domain not per page · getElementById kernel · the sheet never opened on feed ·
94
- * only a choice may be remembered · the change-your-mind door · consent timezone list
95
- *
96
- * The consent dialog's behaviour — one copy, for every surface on a persona's origin.
97
- *
98
- * CONSENT IS SCOPED TO THE APEX — every persona under app.zone, pin.games, justai.pro, cityinmotion.nl
99
- * answers to one question (2026-10-14). It was scoped to the ORIGIN, on purpose: each persona honest
100
- * with its own visitor, so somebody arriving from search straight at qr was asked by qr. The founder,
101
- * from what visitors told him: *"app.zone'a giriyorum, count me. app.zone'daki bir app'e giriyorum,
102
- * count me… kullanıcıya gına geliyor"* — by the third or fourth persona people answer "stay invisible"
103
- * to make the asking stop, which is the question working against itself. So: an answer given on ANY
104
- * persona of an apex — either answer — is that apex's answer, and no sibling asks again. Nobody on the
105
- * apex has answered yet? The first persona visited asks, and its answer becomes everyone's. Another
106
- * apex is another household and asks for itself.
107
- *
108
- * HOW: a cookie on the registrable domain (`justai-consent`, Domain=<apex>), because localStorage is
109
- * per origin and every subdomain is its own origin — that is the whole reason each one asked. It
110
- * lives 13 months (foundations/15: a label must not outlive what it labels; the choice is re-asked
111
- * once a year, the usual ceiling for a stored consent in Europe). `localStorage["consent"]` is still
112
- * written, for shells on older cores, and an answer found only there is PROMOTED to the apex cookie on
113
- * the next visit — so everybody who answered any persona before this change is not asked by its
114
- * siblings after it. The "not now" (Escape) flag is an apex SESSION cookie for the same reason: one
115
- * dodge keeps the whole apex quiet for this visit, not just one persona. /me's erase must expire the
116
- * cookie on every plausible domain (it cannot read the Domain attribute back).
41
+ * queries: consent bar behaviour · consent v2 · no google before consent · reject cleans identifiers ·
42
+ * escape is not an answer · the change-your-mind door · consent settings switch · legacy
43
+ * granted+ads · consent cookie per apex
117
44
  *
118
- * Whichever page a visitor enters by, if the apex has never been answered, it asks — once. That is
119
- * what a consent flow IS, and it is worth stating because ours was accidentally page-scoped for three
120
- * weeks: the script used to bail on
121
- * `!document.getElementById("kernel")`, a DOM sniff added to avoid asking on a 404. Feed pages have
122
- * no kernel either, so on every /feed/* page in the fleet the question was never asked — silently,
123
- * with nothing to notice it. A trust decision must never be inferred from an unrelated layout
124
- * detail; the check is gone, and any page that renders the sheet may ask.
45
+ * The consent bar's behaviour — one copy, for every surface on a persona's origin. It drives the bar
46
+ * @justai/cuts renders (ConsentBar.astro: `#consent` with `[data-consent]` buttons) and the two verbs
47
+ * ./analytics puts on window (`__justaiMeasure`, `__justaiStopMeasure`).
125
48
  *
126
- * ONLY A CHOICE MAY BE REMEMBERED AS A CHOICE. "confirm" is the heart, "denied" is a chosen
127
- * "Stay invisible". Anything else — Escape, a tap on the backdrop — is not an answer: nothing is
128
- * stored, the regional default stands, and the ask returns next visit. The session flag only keeps
129
- * THIS visit quiet, so one slip-away buys one visit of peace rather than an answer nobody gave.
49
+ * GLOBAL (2026-11-23, owner): every visitor, wherever they are, is asked; nothing is measured until
50
+ * they Allow. There is no timezone and no region list any more — the R0 audit proved the two lists
51
+ * disagreed, and a guess about where a visitor is must not decide what is done to them.
130
52
  *
131
- * THE DOOR IS UNIVERSAL. The footer's hidden `[data-consent-open]` anchor is labelled, revealed and
132
- * wired here for EVERY visitor in EVERY region — a non-EEA visitor gets a real opt-out they were
133
- * never offered, and anyone can reverse either answer. Only the AUTO-ask has narrow gates.
53
+ * NOT A DIALOG. The bar is a region at the bottom of the page: no backdrop, no focus trap, the page
54
+ * stays usable. Its buttons are plain `type=button` — never a <form>, so a measurement tag can never
55
+ * count the answer as a form interaction (R0: Reject was sent to GA4 as form_submit).
134
56
  *
135
- * THE TIMEZONE LIST IS A PROXY for "consent is legally asked here", never the thing itself, and it is
136
- * the sibling of the region array in {@link analyticsJs}. `Europe/` carries almost all of the EEA but
137
- * not all of it: twelve zones sit on other continents. Change one list and you must change the other,
138
- * or a visitor is denied by region while never being offered the dialog.
57
+ * THE ANSWER IS THE APEX'S: the `justai-consent` cookie on the registrable domain, because every
58
+ * persona is its own origin and localStorage could never carry one answer across tabata.app.zone,
59
+ * qr.app.zone and app.zone. It is the ONLY store (the pre-apex localStorage key is read once, then
60
+ * removed). Values: `v2:granted` · `v2:denied`. A pre-v2 "granted+ads" / "granted" is NOT carried —
61
+ * it answered a different question — so the visitor is asked again, unmeasured; a pre-v2 "denied"
62
+ * becomes `v2:denied`.
139
63
  *
140
- * `returnValue` survives a close, so it is reset before every open or a stale answer replays.
64
+ * ESCAPE IS NOT AN ANSWER: it puts the bar away for this visit (`justai-consent-later`, a session
65
+ * cookie on the apex) and stores nothing; measurement stays off, and the bar returns next visit. It
66
+ * closes the bar ONLY — caught on window, capture phase — so the surface under it (a profile, a sheet)
67
+ * is not closed by the same key.
141
68
  *
142
- * FOCUS IS GIVEN AT OPEN, not by an autofocus attribute. Chrome refuses to process `autofocus` in
143
- * any document whose URL carries a fragment and warns on every load — /me#profile met it first. So
144
- * the sheet ships no attribute, and the opener places focus by the genre's law: the ask genre puts
145
- * it on the invitation (here), the destructive genre on the cancel (that consumer's own open).
69
+ * THE DOOR IS UNIVERSAL: every `[data-consent-open]` (footers, the profile) is labelled, revealed and
70
+ * opens the bar with Settings showing the current state.
146
71
  */
147
72
  export const CONSENT_JS = `(function(){try{
148
73
  var h=location.hostname;
149
74
  if(h==="localhost"||h==="127.0.0.1"||h==="::1"||h==="[::1]"||h.indexOf("dev-")===0)return;
150
- var el=document.getElementById("consent");if(!el||!el.showModal)return;
75
+ var el=document.getElementById("consent");if(!el||!el.hasAttribute("data-consent-bar"))return;
151
76
  var hp=h.split("."),ap=(hp.length>2&&!/^[0-9.]+$/.test(h))?hp.slice(-2).join("."):h;
152
77
  var AGE=34128000;
153
78
  var rd=function(n){var m=document.cookie.match(new RegExp("(?:^|; )"+n+"=([^;]*)"));return m?decodeURIComponent(m[1]):null};
154
79
  var wr=function(n,v,age){document.cookie=n+"="+encodeURIComponent(v)+"; Domain="+ap+"; Path=/"+(age?"; Max-Age="+age:"")+"; SameSite=Lax; Secure"};
155
- var stored=function(){var c=rd("justai-consent");if(c)return c;var l=null;try{l=localStorage.getItem("consent")}catch(_){}if(l)wr("justai-consent",l,AGE);return l};
156
- var open=function(){if(!el.open){el.returnValue="";el.showModal();var p=el.querySelector(".preferred");if(p)p.focus()}};
157
- el.addEventListener("close",function(){
158
- var rv=el.returnValue;
159
- var v=rv==="confirm"?"granted+ads":rv==="denied"?"denied":null;
160
- if(v){var g=v==="denied"?"denied":"granted";
161
- gtag("consent","update",{analytics_storage:g,ad_storage:g,ad_user_data:g});
162
- try{localStorage.setItem("consent",v)}catch(_){}
163
- wr("justai-consent",v,AGE)}
164
- else{wr("justai-consent-later","1",0);try{sessionStorage.setItem("consent-later","1")}catch(_){}}
165
- });
80
+ var q=function(s){return el.querySelector('[data-consent="'+s+'"]')};
81
+ var sw=q("switch"),set=document.getElementById("consent-set"),gear=q("settings");
82
+ var state=function(){var c=rd("justai-consent");
83
+ if(c==="v2:granted")return"granted";if(c==="v2:denied")return"denied";
84
+ var l=null;try{l=localStorage.getItem("consent");localStorage.removeItem("consent")}catch(_){}
85
+ if(c==="denied"||l==="denied"){wr("justai-consent","v2:denied",AGE);return"denied"}
86
+ return null};
87
+ var paint=function(){var on=state()==="granted";if(sw){sw.setAttribute("aria-checked",on?"true":"false")}};
88
+ var settings=function(open){if(set)set.hidden=!open;if(gear)gear.setAttribute("aria-expanded",open?"true":"false");paint()};
89
+ var show=function(withSettings){settings(!!withSettings);el.hidden=false};
90
+ var hide=function(){el.hidden=true};
91
+ var answer=function(v,keep){wr("justai-consent","v2:"+v,AGE);
92
+ if(v==="granted"){if(window.__justaiMeasure)window.__justaiMeasure(true)}else{if(window.__justaiStopMeasure)window.__justaiStopMeasure()}
93
+ paint();if(!keep)hide()};
94
+ var a=q("allow"),d=q("deny");
95
+ if(a)a.addEventListener("click",function(){answer("granted")});
96
+ if(d)d.addEventListener("click",function(){answer("denied")});
97
+ if(gear)gear.addEventListener("click",function(){settings(set?set.hidden:false)});
98
+ if(sw)sw.addEventListener("click",function(){answer(sw.getAttribute("aria-checked")==="true"?"denied":"granted",true)});
99
+ addEventListener("keydown",function(ev){if(ev.key==="Escape"&&!el.hidden){ev.preventDefault();ev.stopPropagation();hide();if(!state())wr("justai-consent-later","1",0)}},true);
166
100
  var doors=document.querySelectorAll("[data-consent-open]");
167
- for(var i=0;i<doors.length;i++){var a=doors[i];
168
- if(!a.textContent)a.textContent=el.getAttribute("data-choice-label")||"privacy choice";
169
- a.hidden=false;var w=a.closest("[data-consent-door]");if(w)w.hidden=false;
170
- a.addEventListener("click",function(ev){ev.preventDefault();open()})}
171
- if(stored())return;
101
+ for(var i=0;i<doors.length;i++){var o=doors[i];
102
+ if(!o.textContent)o.textContent=el.getAttribute("aria-label")||"privacy choice";
103
+ o.hidden=false;var w=o.closest("[data-consent-door]");if(w)w.hidden=false;
104
+ o.addEventListener("click",function(ev){ev.preventDefault();show(true);var f=sw||a;if(f)f.focus()})}
105
+ var s0=state();
106
+ if(s0==="denied"&&window.__justaiStopMeasure)window.__justaiStopMeasure();
107
+ if(s0)return;
172
108
  if(rd("justai-consent-later"))return;
173
- try{if(sessionStorage.getItem("consent-later"))return}catch(_){}
174
- var tz=Intl.DateTimeFormat().resolvedOptions().timeZone||"";
175
- var asked=tz.indexOf("Europe/")===0||[
176
- "Asia/Nicosia","Asia/Famagusta",
177
- "Atlantic/Canary","Atlantic/Azores","Atlantic/Madeira","Atlantic/Reykjavik",
178
- "Arctic/Longyearbyen",
179
- "America/Guadeloupe","America/Martinique","America/Cayenne",
180
- "Indian/Reunion","Indian/Mayotte"].indexOf(tz)>=0;
181
- if(!asked)return;
182
- setTimeout(open,700);
109
+ setTimeout(function(){show(false)},600);
183
110
  }catch(_){}})();`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justai/core",
3
- "version": "0.45.0",
3
+ "version": "0.46.0",
4
4
  "description": "The framework-free heart of the persona shell — 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": {