Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Dashboard: **Stripe** (immediate, connection test), **PayPal** (immediate, conne

## Advertising

Dashboard: **Google AdSense** (immediate).
Dashboard: **Google AdSense** (immediate), **Adsterra** (immediate), **Ad placements** (immediate).

## Analytics

Expand Down
78 changes: 78 additions & 0 deletions docs/production-repair/ads-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Advertising — Adsterra units, AdSense priority, placements

## Where it is configured (one system)

Admin → Settings → **Advertising** now has three sections, all in the same settings service as before:

* **Google AdSense** (existing): publisher ID, Auto ads, ads.txt.
* **Adsterra** (new): on/off, ad server host (`bauval.org`) and the six unit keys, pre-filled with the supplied codes, plus *Frame isolation*.
* **Ad placements** (new): placements on/off, preferred provider, "My AdSense site and ad units are approved", and an optional AdSense unit ID per placement.

## The six units (unchanged IDs, keys, domain and sizes)

| Unit | Key / ID | Script |
|---|---|---|
| Native Banner | `2551bb0538e1d6f96d5844f91de7e70d` | `https://bauval.org/21/<id>` + `<div id="container-<id>">` |
| 468 × 60 | `c48a5f48afbd920b94c779e34cbe26f8` | `atOptions` + `https://bauval.org/22/<key>` |
| 300 × 250 | `71f63cdca7866f4ff5d8f2c07764ccdd` | 〃 |
| 160 × 600 | `8f136dfb344bddf64040a81be40b2730` | 〃 |
| 728 × 90 | `f66f57ed50fa3f1c7686f5fda2f6b167` | 〃 |
| 320 × 50 | `ce450a64b7d6fcc6866e4901d5e8153b` | 〃 |

The E2E test fetches every frame and compares it with the supplied code character for character.

## How one unit is rendered (isolation)

The supplied codes share the global `atOptions`, and placing several on one page lets the last one overwrite the others. So **each placement is its own document**:

```
page ── <aside aria-label="Advertisement"> "Advertisement" label + reserved box
└─ <iframe src="/ads/frame/300x250" sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox">
└─ exactly the supplied code for that one unit (its own atOptions)
```

* `/ads/frame/<unit>` serves only units configured in Settings. Keys must be 32 hex characters and the host a plain host name, so no other script can be injected and listing content never reaches it. It sends its own Content-Security-Policy (the ad network loads scripts and frames from changing hosts), `frame-ancestors 'self'` and `X-Frame-Options: SAMEORIGIN`. The **page's own strict CSP is unchanged**; only `frame-src 'self'` is kept explicit.
* **Sandboxed.** The ad cannot read Webcenta's DOM or cookies, cannot navigate or redirect the page (no `allow-top-navigation`), and clicks open in a new tab. If sandboxed units stay empty because a network refuses sandboxed frames, switch *Frame isolation* to *Standard* (adds `allow-same-origin`).
* **Loaded once per placement and page view**, only when the placement is near the viewport (IntersectionObserver), and only if the screen is wide enough. React re-renders never reload it; leaving the page removes it. A native unit reports its height to the page (postMessage, checked against the frame), so the reserved box fits.
* **Failures never break the page.** A blocked or failed provider collapses the box or leaves it empty. Failures are reported to `/api/ads/log` (placement, provider, reason; rate-limited) and written to the server log. No secrets are involved.
* Service worker: `/ads/*` is never cached.

## Provider selection (deterministic, one provider per placement)

1. **AdSense** when: the AdSense section is enabled with a publisher ID, *and* "My AdSense site and ad units are approved" is ticked, *and* the preferred provider is AdSense, *and* the placement has an AdSense unit ID. Entering a publisher ID alone never activates AdSense units.
2. Otherwise **Adsterra** (if enabled).
3. In the browser, an AdSense unit that is unfilled (`data-ad-status="unfilled"`) or whose script is blocked is replaced by the placement's Adsterra unit, once. The two never show at the same time.

The decision is made on the server per request from settings, so it does not flip between renders.

## Placements

| Placement | Unit | Shown at | Where |
|---|---|---|---|
| Homepage native | Native | all widths | after the 2nd homepage section |
| Homepage display | 300 × 250 | all widths | after the 4th homepage section |
| App page | 300 × 250 | all widths | below the description and features, above reviews, with a divider |
| Mobile compact | 320 × 50 | < 500 px | after results on search, category and Apps pages |
| Smaller banner | 468 × 60 | 500–1023 px | same position |
| Desktop leaderboard | 728 × 90 | ≥ 1024 px | same position |
| Desktop sidebar | 160 × 600 | ≥ 1280 px | bottom of the app page sidebar (sticky) |

The three banner sizes share one position, so each screen gets exactly one banner there and a 728 or 160 unit never loads on a phone (E2E tested at 390 and 1440 px).

Never on sign-in, registration, account or profile forms, developer or admin portals, or the leaving-Webcenta page. Ads sit **between** whole sections, never inside a row of app cards, and are always labelled "Advertisement". The fixed tab bar stays above them (z-index). Reserved space reduces layout shift.

## Consent and policies

* Ads load only after a visitor accepts **advertising cookies** in the cookie banner (the same rule as AdSense). Visitors who decline or have not answered see no ads. This is the conservative, compliant choice, and it also reduces impressions.
* The Cookie Policy, Privacy Policy and the Advertising policy name Adsterra. The Advertising policy says ads are labelled, never styled as listings, and that pop-under/redirect formats are not used. Policies stored in the database at first setup keep their old text until republished in Admin → Settings → Content.
* **Not enabled:** Popunder, Smartlink, Social Bar, interstitials and any other intrusive format (not supported at all).

## Owner actions in the Adsterra dashboard (cannot be done from code)

1. Under *Websites → webcenta.com*, block **adult**, gambling and other unsuitable ad categories, and turn off any "aggressive/anti-adblock" options.
2. If Adsterra asks for an ads.txt line, add it in Admin → Settings → Google AdSense → *Extra ads.txt lines* (served at `/ads.txt`).
3. Check revenue and fill after a day. If sandboxed units never fill, try *Frame isolation → Standard*.

## AdSense later

When Google approves webcenta.com: create display units in AdSense (300×250, 728×90, 468×60, 320×50, 160×600, and an in-feed/display unit for the homepage), enter their numeric `data-ad-slot` IDs in Settings → Ad placements, tick *approved*, and keep the preferred provider on AdSense. The CSP then allows Google's ad servers on those pages automatically.
81 changes: 81 additions & 0 deletions docs/production-repair/checklist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Production repair — checklist

Status: ☑ fixed and verified · ◐ fixed, partly verifiable here (reason given) · ✗ not possible here / owner action.
Baseline: `main` at `8b824e3` (PR #10). Branch: `claude/youthful-cerf-4xclco`. Evidence: [test-results.md](test-results.md), [screenshots](screenshots/).

## 1. Adsterra integration — ☑ (◐ live ad fill)
- **Problem:** six Adsterra units to integrate; the supplied snippets share the global `atOptions`.
- **Root cause / constraint:** several snippets on one page overwrite each other, and adding them inline would mean loosening the page's strict CSP.
- **Fix:** *Adsterra* and *Ad placements* sections in the existing Admin → Settings → Advertising group. Each unit is served by `/ads/frame/<unit>` with exactly the supplied code and its own CSP, inside a sandboxed iframe: one unit per document. Seven responsive placements, lazy-loaded once per page view, with reserved space, an "Advertisement" label, and failure reporting. See [ads-setup.md](ads-setup.md).
- **Tests:** DB test (codes, keys and sizes exact; one `atOptions` per frame; disabled → no unit). E2E (all six frames byte-exact; CSP and frame headers; unknown unit and admin host → 404; sandbox without same-origin or top-navigation; placements per width; none on sign-in/sign-up; none without consent; no overflow).
- **Limitation:** real ad fill cannot be tested here (no outbound network; tests use a non-existent ad host so they never create impressions). Check fill on the live site. Category blocking (no adult ads) is set in the Adsterra dashboard.

## 2. AdSense priority and fallback — ☑
- **Fix:** AdSense only when enabled, preferred, the owner confirmed approval, and the placement has a unit ID; otherwise Adsterra. An unfilled or blocked AdSense unit falls back to Adsterra once, never both at the same time. The choice is made per request on the server (deterministic).
- **Tests:** DB test (publisher ID alone → Adsterra; approved + slot → AdSense with Adsterra fallback; placement without slot → Adsterra; "Adsterra only" overrides).
- **Limitation:** AdSense is not approved yet, so live AdSense rendering was not exercised.

## 3. Mobile push notifications — ☑ (◐ physical devices)
- **Problem:** admin notifications appeared in the in-app centre but not reliably on phones; desktop worked.
- **Root causes:** (1) normal-urgency pushes, which Android defers in Doze; (2) phone subscriptions never re-confirmed, so stale, unlinked or wrong-account subscriptions; no `pushsubscriptionchange` handling; (3) the service worker could fail to install when one precache download failed; (4) announcements beyond 100 devices depended on the scheduler, which never ran; (5) no per-attempt delivery log.
- **Fix:** high urgency + topic + TTL; browser re-sync of the subscription linked to the current account; `pushsubscriptionchange`; resilient SW install; badge icon; display fallback; `PushDelivery` log; per-subscription error state; iOS Home Screen guidance; denied-state guidance; a "Send a test notification" button; an admin delivery report. See [notification-diagnostics.md](notification-diagnostics.md).
- **Tests:** DB (urgency and TTL sent, payload, accepted/failed/expired logged, expired removed, errors categorised, account link/unlink on sign-out, replaced endpoint removed, test push only to the asking browser, diagnostics counts). E2E (real announcement → attempt recorded with platform → honest "0 accepted" message → report visible).
- **Limitation:** no physical Android phone or iPhone here, so device display is unverified; steps for the owner are in notification-diagnostics.md.

## 4–5. Android / iOS — ◐
- Android: same service worker and subscription for Chrome, Edge, Firefox, Samsung Internet and installed PWA; `showNotification` from the push handler, valid icons, destination focus/navigate/open.
- iOS: push only in a Home Screen web app on iOS/iPadOS 16.4+; Safari tabs show installation steps instead of a toggle.
- Not testable without devices (see above).

## 6. Import and bulk publishing — ☑
- **Problems:** Import sometimes did nothing; imports did not reach the queue; multi-select and bulk publishing were unreliable; failures were unexplained.
- **Root causes:** (1) **the scheduler never ran** (§10), so queued imports were never imported and imported apps were never security-checked, and bulk publishing refused every unchecked import ("checks have not finished"); (2) the per-row "Import now" button posted through a separate server action with no pending state or result, so it looked like nothing happened (and double clicks ran twice); (3) "Add to queue" reported "already in the queue or invalid" without saying which; (4) the claim was not atomic, so a second click or an overlapping run could import one website twice; (5) a check that crashed left its revision stuck in "automated checks"; (6) approval was not atomic, so two simultaneous publishes could both run.
- **Fix:** every table action goes through one form with feedback (`op:<id>` for row buttons), buttons disabled while pending, a selected-count, select-all/deselect-all, confirmation dialogs with counts, and new actions *Run security checks*, *Retry selected*, *Retry all failed*, *Queue again*. Failures record stage, category, retryable, attempts, time and job ID. Atomic claims for imports, checks and approvals. "Add to queue" lists added, already queued, already listed and invalid.
- **Tests:** DB (claim prevents double import; retry; concurrent approval → exactly one publish and one status change). E2E (2 URLs → "2 added" → same URLs → recognised → select/deselect/count → *Import selected now* "Imported: 2" → *Run security checks* "Checked: 2" → *Publish selected* "Published: 2" → DB: PUBLISHED with exactly one publish event each → publishing again "Nothing changed" → a down website "Not imported (job #…), stage fetch").

## 7. Bulk publishing results — ☑ (see §6)

## 8. Duplicate detection — ☑
- Canonical host (lower case, no `www.`, no trailing dot), the registrable domain (except shared hosting platforms such as `*.vercel.app`), existing listings (any status except removed), and other queued, importing or imported candidates. Checked when adding, when importing, and hourly by `imports.dedupe` (the earliest of two queued twins keeps its place).
- Tests: DB (www/sub-domain/path variants; shared-host exception; queued twins; listed site) and E2E (re-adding the same sites).

## 9. Description enrichment — ☑ (◐ live sites)
- `imports.enrich` (hourly, 4 listings per run): imported editorial listings without a developer and with < 300 characters. Reads only the app's own homepage (meta/manifest description, explanatory paragraphs of the main content, feature list) and drops navigation, cookie notices and footers. It invents nothing: no pricing, platforms or claims the site does not make. A proposal needs ≥ 250 characters and 1.5× the current text.
- **Review, not overwrite:** a published listing gets a revision *under review* in Admin → Submissions (the previous text is in the revision history and the reviewer notes). A pending import has its pending text improved, with the original kept in the notes. Developer-managed listings are never touched. `Listing.enrichedAt` and `enrichmentResult` record each attempt; it re-checks after 30 days.
- Tests: unit (extraction, composition, no invented claims, no proposal when not clearly better).
- Limitation: production listings will be processed by the scheduler after deployment (4 per hour); results are visible in Admin → Submissions.

## 10. Scheduler — ☑
- **Root cause:** no Hostinger cron job existed for webcenta.com (API listing, 13 Nov). In addition, `node` is not on the cron `PATH`, and the documented curl command required the secret in the command.
- **Fix:** `cron-tick.mjs` (no secret in the command), an atomic scheduler lease (no overlap), per-job start/duration/result/error, JobRun trigger/skipped, stale recovery, pause/resume, Run now, an admin Scheduler page, schedules by workload, and the Hostinger cron entry. See [cron-setup.md](cron-setup.md).
- **Tests:** DB (run + results + failure recorded; overlap skipped; lease expiry; concurrent ticks → one works; paused jobs not scheduled; Run now). E2E (the exact cron script against the production build: HTTP 200 and a JobRun row; held lease → "skipped"; GET 405; missing or wrong secret 401; admin Run now → SUCCEEDED).

## 11–12. Hostinger cron configuration and evidence — see [cron-setup.md](cron-setup.md) and [test-results.md](test-results.md)

## 13. Profile and settings on phones — ☑
- **Problem:** account screens wider than phones; a horizontal strip of settings tabs; every form shown at once.
- **Fix:** phones get `/account` as a list of sections (icon, name, hint), each section on its own screen with "‹ Account"; desktop gets the navigation on the left and the section on the right. New `/account/profile` and `/account/security`. Profile shows the details with **Edit profile**; Security shows **Change password** before the form. `min-w-0`, `overflow-wrap` and responsive rows everywhere.
- **Tests:** E2E at 320 and 390 px (list, back link, no form until requested, no overflow on all 10 account pages, no tab strip) and at 1280 px (sidebar with the current section). Responsive audit at 10 viewports.

## 14. Bottom navigation — ☑
- Exactly **Home, Games, Apps, Search**. Saved apps stay in the account area (account menu → Saved apps, `/account/favorites`); no saved records were touched. E2E checks the four labels and every link.

## 15. Google login — ☑
- Google's standard multicolour G and button style (white with grey outline; dark variant in dark mode), "Continue with Google", accessible name, responsive. A GitHub mark too. OAuth code unchanged.
- Tests: E2E at 320 and 1280 px on sign-in and sign-up (G mark paths, colours, within the screen, no overflow).
- Limitation: the real Google sign-in round trip needs the live site; it is not claimed tested.

## 16. Developer domain verification — ☑
- Step-by-step instructions for every method with exact values and Copy buttons. TXT: type, host (`@` or the sub-domain label, with notes for providers), value, domain, TTL. **New HTML file method**: `webcenta-domain-verification-<16 hex>.html` (unique per code), exact content with Download, upload location and expected address. Meta tag: exact tag and where to put it. A "Check verification" button for each.
- Security: 144-bit CSPRNG codes per organisation and domain, **expire after 14 days** if not proven, and are checked server-side over HTTPS on the domain itself, with no redirect to another host and SSRF-safe fetching. Another organisation's code never matches.
- Tests: DB (unique codes and file names, TXT host labels, expiry) and E2E (HTML file: instructions, wrong content refused, correct file verified).

## 17. Filters — ☑
- One slim bar (result count, sort that applies on change, "Filters" with the active count). Phones: a bottom sheet with backdrop, Escape, scroll lock, Reset and Apply. Desktop: a compact panel under the bar. Every filter kept; it still works without JavaScript (a GET form inside `<details>`).
- Tests: E2E (sheet within 375×812, apply → URL, count badge, Reset; desktop bar < 60 px tall, panel ≤ 600 px).

## 18. Responsive testing — ☑ (◐ real devices)
- `responsive-audit.spec.ts`: 16 pages (public + every account section) × 10 viewports (320×568, 360×800, 375×812, 390×844, 430×932, 768×1024, 1024×768, 1280×800, 1440×900, 1920×1080). Checks horizontal overflow, elements beyond the screen, the fixed tab bar inside the screen, console and runtime errors. Results in [responsive-audit.json](responsive-audit.json); screenshots for 320/390/768/1440 in `screenshots/responsive/`.
- Limitation: Chromium device emulation; no physical iOS Safari.

## 19–22. Regression, Git, deployment, manual configuration — see [test-results.md](test-results.md)
Loading
Loading