From de0118cdc181876699808eb0a87c0cefac46d57c Mon Sep 17 00:00:00 2001 From: XP Date: Mon, 4 Nov 2024 10:00:01 -0800 Subject: [PATCH] Fix privacy link z-order, adjust an ad placement, enhance analytics --- packages/backend-resolver/src/server_builder.ts | 1 + packages/common-ui/styles/ads.less | 2 ++ packages/common-ui/styles/common.less | 3 ++- packages/frontend/src/scripts/components/ads.ts | 14 ++++++++++---- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/backend-resolver/src/server_builder.ts b/packages/backend-resolver/src/server_builder.ts index a88b3000..769cf330 100644 --- a/packages/backend-resolver/src/server_builder.ts +++ b/packages/backend-resolver/src/server_builder.ts @@ -225,6 +225,7 @@ export function buildPreviewServer() { addExtraScript(scriptUrl, {'async': ''}); } }); + doc.documentElement.setAttribute('scripts-injected', 'true'); } return new Response(doc.documentElement.outerHTML, { status: 200, diff --git a/packages/common-ui/styles/ads.less b/packages/common-ui/styles/ads.less index b846732a..0389df1e 100644 --- a/packages/common-ui/styles/ads.less +++ b/packages/common-ui/styles/ads.less @@ -60,6 +60,8 @@ body:not(.light-mode) { border-top-right-radius: 6px; + z-index: var(--zi-privacy-link); + >* { display: inline-block !important; } diff --git a/packages/common-ui/styles/common.less b/packages/common-ui/styles/common.less index 05203c20..c50039f7 100644 --- a/packages/common-ui/styles/common.less +++ b/packages/common-ui/styles/common.less @@ -269,7 +269,7 @@ body { .header-area, .gear-sheet-editor-area { p { .standard-paragraph; - width: min(1200px, max(600px, calc(100% - 420px))) + max-width: 600px; } } @@ -325,6 +325,7 @@ body { --zi-tiering-expansion: 185; --zi-toolbar-popout: 186; --zi-loading-blocker: 190; + --zi-privacy-link: 195; --zi-add-sim-dialog: 200; --zi-true-modal: 300; } diff --git a/packages/frontend/src/scripts/components/ads.ts b/packages/frontend/src/scripts/components/ads.ts index f1613b35..bb9e5bc7 100644 --- a/packages/frontend/src/scripts/components/ads.ts +++ b/packages/frontend/src/scripts/components/ads.ts @@ -246,12 +246,19 @@ export function insertAds(element: HTMLElement) { if (currentAds.length === 0) { // Analytics setTimeout(() => { + // Everything good if (adsEnabled()) { - recordEvent('adsEnabled'); + recordEvent('adsEnabled', {'page': document.location.search}); } + // Script present, but blocked from working correctly else if (Array.from(document.head.querySelectorAll('script')).find(script => script.src && script.src.includes('nitro'))) { - recordEvent('adsDisabled'); + recordEvent('adsDisabled', {'page': document.location.search}); } + // Script injected, but was later removed + else if (document.documentElement.getAttribute('scripts-injected') === 'true') { + recordEvent('adsScriptRemoved', {'page': document.location.search}); + } + // Script not injected by server else { recordEvent('adsNotInjected', {'page': document.location.search}); } @@ -264,8 +271,7 @@ export function insertAds(element: HTMLElement) { const sideWideShortCond: DisplayCondition = (w, h) => w >= 1900 && h > 350 && !sideWideCond(w, h); // Display on less wide 2-column, or wide 1-column const sideNarrowCond: DisplayCondition = (w, h) => - ((w >= 1560 && h > 650) - || (w <= 1210 && w >= 1012 && h > 650)) + h > 650 && (w >= 1560 || (w <= 1210 && w >= 950)) && !sideWideCond(w, h) && !sideWideShortCond(w, h); { const size: AdSize = [300, 600];