Hook redesign (guard-readonly.sh + guard-bash.sh): - ALLOW edits: /home/nosfortube/frontend_<port>/ (digits-only, all subdirs) + /home/nosfortube/orest/ (user working zone + screenshots) - DENY: lang variants (frontend_<port>_<lang>/), frontend_core/, .git/, system paths (/etc/, /usr/, /boot/, /var/* except /var/log/claude/) - 19/19 readonly + 18/19 bash tests pass (1 pre-existing sed-i regex gap) - Backup попередньої версії: .bak.2026-05-02 Doc updates: - New: PROJECT.md, ARCHITECTURE.md, DEPLOY.md, ADS.md, PERFORMANCE.md, INTERLINKING.md, ADMINS.md (topic-split docs/) - CLAUDE.md: 94-site scale, granular edit zones, doc index - INFRASTRUCTURE.md: hook table updated - SITES.md: scope note (14 backup-tracked of 94 total) - RECOMMENDATIONS.md: W1 (hook conflict) → DONE; W2-W3, D1-D4 added Site architecture findings (audit 2026-05-02): - 94 frontend_<port>/ sites, 71 in site-name-routing.csv, 14 backup-tracked - 3 ad-architectures coexist: 8148 modern bundle (1), modern partials (~23), legacy inline surstrom (31) - 8148 unique: ad-bundle.min.js source files, build-ad-bundle.sh, terser - Server IP 185.73.222.75 у t1.* allowlist (curl probes work) - CDN: custom + Cloudflare на 8081 etc; purge-cache при prod deploy Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
112 lines
5.6 KiB
Markdown
112 lines
5.6 KiB
Markdown
# tubev — Ads Integration
|
||
|
||
Реклама через **adspyglass.com**. Основне джерело монетизації — балансуємо CTR vs UX/PSI.
|
||
|
||
## Status
|
||
|
||
🟢 **Working knowledge** — Skeleton наповнюємо.
|
||
|
||
## Architecture
|
||
|
||
### Mirrors (зеркала)
|
||
|
||
Реклама вантажиться через **зеркала-домени**, не прямо `adspyglass.com`:
|
||
- `a5.g--o.info` — ad orchestration (preconnect target у modern setup)
|
||
- `surstrom.com` — inline ad-spot loader (legacy pattern)
|
||
- `agego.com` — verifycdn (`verifycdn.agego.com/v1/verify.js`)
|
||
- `g--o.info` — base domain
|
||
- (інші додаються на потребу)
|
||
|
||
**Чому зеркала:** anti-block — adblockers баняють відомі ad-домени. Зеркала маскують та ротуються.
|
||
|
||
**Mirror lifecycle:**
|
||
- Зеркала **періодично баняться** (adblock list updates)
|
||
- Заміна — **mass-operation через Адміна** (одразу на всі сайти)
|
||
- Ми не керуємо вибором зеркал — це адмінська функція
|
||
|
||
### Three architecture patterns coexist (audit 2026-05-02)
|
||
|
||
Site-level audit показав **3 patterns** — не uniform:
|
||
|
||
| Pattern | Sites | Як виглядає | Примітка |
|
||
|---------|-------|-------------|----------|
|
||
| **A) Modern bundle** | 1 (тільки 8148) | `<script src="/static/js/ad-bundle.min.js?v=<md5>" defer>` + `views/modules/banners/*adspy*.etlua` partials | Canonical — є build pipeline, source JS у `views/static/js/` |
|
||
| **B) Modern partials** | ~23 | `preconnect` → `a5.g--o.info` + adspy `.etlua` partials, але **без** ad-bundle.min.js | Modules orchestrate, no central bundle |
|
||
| **C) Legacy inline** | 31 (8112-style) | Inline `<script async src="//surstrom.com/<random>.js">` + iframes до `surstrom.com/api/spots/<id>` + `tb.load_frame_baner_v2()` API | Pre-modular epoch |
|
||
|
||
**77 із 94 сайтів** мають adspy banner modules у `views/modules/banners/*adspy*.etlua`. Решта (17) — legacy без banner partials або special structure.
|
||
|
||
### Build pipeline (тільки 8148)
|
||
|
||
`/home/nosfortube/frontend_8148/views/static/js/build-ad-bundle.sh` концатує+minify-їть 5 source JS-файлів у `ad-bundle.min.js`:
|
||
1. `ad-config.js` — config / placement IDs / mirror domains
|
||
2. `ad-core.js` — ядро ad-orchestration
|
||
3. `ad-mute.js` — mute / autoplay control
|
||
4. `vast-preroll.js` — pre-roll реклама перед video
|
||
5. `ad-bootstrap.js` — entry-point / init
|
||
|
||
**Source files:** усі у `/home/nosfortube/frontend_8148/views/static/js/` (унікально для 8148).
|
||
|
||
Tool: **terser** (concat + minify). Triggered by `~/git-save-all.sh` коли source новіший за bundle.
|
||
|
||
Cache-bust: md5 → `?v=...` у `layout.etlua` (детально у [DEPLOY.md](DEPLOY.md#cache-bust-механізм)).
|
||
|
||
## Monitoring
|
||
|
||
### adspyglass dashboard — best diagnostic signal
|
||
|
||
`https://app.adspyglass.com/dashboard`
|
||
|
||
**Чому це best signal:**
|
||
- Live графік показу реклами per site
|
||
- **Падіння графіка** = реклама не показується = ймовірно поломка (frontend/template/JS error / banned mirror / CDN cache stale)
|
||
- **Ріст** = трафік підріс або UX покращився
|
||
|
||
Юзер каже: "більший показник саме для мене це лайв графік реклами від АСГ" — реклама падає миттєво коли щось не так, ще до того як прийдуть алерти.
|
||
|
||
### Інші alerts
|
||
- **Telegram + email** — критичні (downtime, errors)
|
||
- Billing dashboard `https://billing.g--o.info/cs/oursites/dashboard/` — статистика (зазвичай не дивимось)
|
||
|
||
### Template patterns
|
||
|
||
**Pattern A (8148 modern):**
|
||
```etlua
|
||
<link rel="preconnect" href="https://a5.g--o.info" crossorigin>
|
||
<script src="/static/js/ad-bundle.min.js?v=<%= ad_bundle_v %>" defer></script>
|
||
...
|
||
<% render("views.modules.banners.header_mobile_adspy") %>
|
||
<% render("views.modules.banners.footer_mobile_adspy") %>
|
||
<% render("views.modules.banners.footer_descktop_adspy") %>
|
||
```
|
||
|
||
**Pattern C (8112 legacy inline):**
|
||
```etlua
|
||
<link rel="dns-prefetch" href="//surstrom.com">
|
||
...
|
||
<script async src="//surstrom.com/qDap9.js"></script>
|
||
<iframe class="na" src="//surstrom.com/api/spots/72437?p=1" sandbox="..." loading="lazy"></iframe>
|
||
...
|
||
tb.load_frame_baner_v2("//surstrom.com/api/spots/72437?p=1","#tb0",{...},{...});
|
||
```
|
||
|
||
## Що треба з'ясувати + задокументувати
|
||
|
||
### Architecture migration
|
||
- [ ] Чи планується мігрувати pattern C → B/A (legacy → modern)?
|
||
- [ ] 8148 — pilot для bundle-architecture, чи поширюватиметься?
|
||
|
||
### CSP / Security
|
||
- [ ] CSP exceptions для зеркал — як підтримуються?
|
||
- [ ] Mirror swap — чи треба update CSP при заміні?
|
||
|
||
### Performance impact
|
||
- [ ] PSI вплив реклами — % LCP / TBT (per pattern)?
|
||
- [ ] Lazy-load ads below-fold — реалізовано (видно `loading="lazy"` на iframes)?
|
||
|
||
## Open questions for developer
|
||
|
||
1. Як здійснюється mirror swap — sed-replace у всіх template/JS файлах через Адміна, runtime config, чи інший механізм?
|
||
2. 8148 ad-bundle — план поширити цю архітектуру на інші сайти, чи це 1-of-1?
|
||
3. Які pattern використовується для НЕ-77 сайтів (17 без adspy banner modules) — special-case structure, "no ads" сайти, чи щось інше?
|