Skip to content

Commit

Permalink
Fix privacy link z-order, adjust an ad placement, enhance analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
xpdota committed Nov 4, 2024
1 parent ba83786 commit de0118c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/backend-resolver/src/server_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export function buildPreviewServer() {
addExtraScript(scriptUrl, {'async': ''});
}
});
doc.documentElement.setAttribute('scripts-injected', 'true');
}
return new Response(doc.documentElement.outerHTML, {
status: 200,
Expand Down
2 changes: 2 additions & 0 deletions packages/common-ui/styles/ads.less
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ body:not(.light-mode) {

border-top-right-radius: 6px;

z-index: var(--zi-privacy-link);

>* {
display: inline-block !important;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/common-ui/styles/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}
Expand Down
14 changes: 10 additions & 4 deletions packages/frontend/src/scripts/components/ads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}
Expand All @@ -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];
Expand Down

0 comments on commit de0118c

Please sign in to comment.