More tweaks to pipeline and some script tweaks
This commit is contained in:
@@ -11,6 +11,33 @@
|
||||
var BANNER_VISIBLE_CLASS = 'is-visible';
|
||||
var hasLoadedThirdParty = false;
|
||||
|
||||
// Trusted Types support (for CSP `require-trusted-types-for 'script'`)
|
||||
var ttPolicy = null;
|
||||
try {
|
||||
if (
|
||||
window.trustedTypes &&
|
||||
typeof window.trustedTypes.createPolicy === 'function'
|
||||
) {
|
||||
ttPolicy = window.trustedTypes.createPolicy('mifi-ventures-policy', {
|
||||
createScriptURL: function (url) {
|
||||
return url;
|
||||
},
|
||||
});
|
||||
}
|
||||
} catch (_) {
|
||||
ttPolicy = null;
|
||||
}
|
||||
|
||||
function setScriptSrc(el, url) {
|
||||
if (!el) return;
|
||||
if (ttPolicy) {
|
||||
// When Trusted Types are enforced, wrap URLs via our policy
|
||||
el.src = ttPolicy.createScriptURL(url);
|
||||
} else {
|
||||
el.src = url;
|
||||
}
|
||||
}
|
||||
|
||||
function loadThirdPartyAnalytics() {
|
||||
if (hasLoadedThirdParty) return;
|
||||
hasLoadedThirdParty = true;
|
||||
@@ -19,14 +46,16 @@
|
||||
try {
|
||||
var gtagScript = document.createElement('script');
|
||||
gtagScript.async = true;
|
||||
gtagScript.src =
|
||||
'https://www.googletagmanager.com/gtag/js?id=G-36F29PDKRT';
|
||||
setScriptSrc(
|
||||
gtagScript,
|
||||
'https://www.googletagmanager.com/gtag/js?id=G-36F29PDKRT',
|
||||
);
|
||||
|
||||
gtagScript.onload = function () {
|
||||
// Load the existing ga-init.js helper once gtag is ready
|
||||
var gaInit = document.createElement('script');
|
||||
gaInit.defer = true;
|
||||
gaInit.src = '/assets/js/ga-init.js';
|
||||
setScriptSrc(gaInit, '/assets/js/ga-init.js');
|
||||
document.head.appendChild(gaInit);
|
||||
};
|
||||
|
||||
@@ -40,7 +69,10 @@
|
||||
try {
|
||||
var clarityScript = document.createElement('script');
|
||||
clarityScript.defer = true;
|
||||
clarityScript.src = 'https://www.clarity.ms/tag/vuo5q3yf79?ref=bwt';
|
||||
setScriptSrc(
|
||||
clarityScript,
|
||||
'https://www.clarity.ms/tag/vuo5q3yf79?ref=bwt',
|
||||
);
|
||||
document.head.appendChild(clarityScript);
|
||||
} catch (e2) {
|
||||
console.error('Failed to load Microsoft Clarity', e2);
|
||||
|
||||
Reference in New Issue
Block a user