@justai/core 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +9 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justai/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
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": {
|
package/src/index.js
CHANGED
|
@@ -112,9 +112,16 @@ export function measurementIdFor(host) {
|
|
|
112
112
|
* other persona nothing and removes a trap the next persona that animates its tab would walk into.
|
|
113
113
|
*
|
|
114
114
|
* The tag itself loads on idle after `load`: measurement must never compete with the kernel.
|
|
115
|
+
*
|
|
116
|
+
* WRAPPED IN AN IIFE, and it has to be. The Astro binding used to get one for free from `define:vars`;
|
|
117
|
+
* lifting the block out of the template removed it, and the locals became globals on every persona
|
|
118
|
+
* page — three names a persona could collide with, leaked by the shell, with nothing to notice it. A
|
|
119
|
+
* shared shell does not put anything in the global scope it did not mean to. `window.gtag` is still
|
|
120
|
+
* assigned explicitly on window, which is the one thing that MUST escape.
|
|
115
121
|
*/
|
|
116
122
|
export function analyticsJs(gaId) {
|
|
117
|
-
return `
|
|
123
|
+
return `(function(){
|
|
124
|
+
window.gtag=window.gtag||function(){(window.dataLayer=window.dataLayer||[]).push(arguments)};
|
|
118
125
|
var __h=location.hostname;
|
|
119
126
|
if(!(__h==="localhost"||__h==="127.0.0.1"||__h==="::1"||__h==="[::1]"||__h.indexOf("dev-")===0)){
|
|
120
127
|
var __g=${JSON.stringify(gaId)};
|
|
@@ -126,5 +133,5 @@ gtag("consent","default",{region:["AT","BE","BG","HR","CY","CZ","DK","EE","FI","
|
|
|
126
133
|
try{var __c=localStorage.getItem("consent");if(__c)gtag("consent","update",{analytics_storage:__c})}catch(e){}
|
|
127
134
|
gtag("config",__g,{cookie_expires:60*60*24*60,page_title:document.title,allow_google_signals:false,allow_ad_personalization_signals:false});
|
|
128
135
|
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)})});
|
|
129
|
-
}
|
|
136
|
+
}})();`;
|
|
130
137
|
}
|