@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.
- package/dist/analytics.d.ts +28 -62
- package/dist/analytics.js +57 -82
- package/dist/consent.d.ts +56 -108
- package/dist/consent.js +83 -156
- package/package.json +1 -1
package/dist/analytics.d.ts
CHANGED
|
@@ -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
|
|
10
|
-
* non-production guard ·
|
|
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
|
-
*
|
|
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
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
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
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
|
59
|
-
* non-production guard ·
|
|
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
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
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(
|
|
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
|
-
|
|
141
|
-
|
|
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",{
|
|
144
|
-
gtag("
|
|
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
|
-
|
|
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
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
|
|
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
|
|
68
|
-
export declare function
|
|
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
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* The consent
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* cookie on
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
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.
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
"
|
|
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
|
-
/**
|
|
88
|
-
|
|
89
|
-
|
|
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
|
|
93
|
-
*
|
|
94
|
-
*
|
|
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
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
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
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
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
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
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
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
143
|
-
*
|
|
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.
|
|
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
|
|
156
|
-
var
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
var
|
|
160
|
-
if(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
|
168
|
-
if(!
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
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.
|
|
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": {
|