diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a47ecc5..1837fc5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,6 +75,8 @@ jobs: cache: 'npm' - name: Install dependencies run: npm ci --prefer-offline + - name: Install Playwright browsers + run: npx playwright install --with-deps chromium - name: E2E Test run: npm run test:e2e - if: failure() diff --git a/app/client.ts b/app/client.ts index 054ff9a..72d6a89 100644 --- a/app/client.ts +++ b/app/client.ts @@ -1,5 +1,6 @@ import { createClient } from 'honox/client' import { setupAdControl } from './lib/adControl' +import { setupMakamujoBannerTracking } from './lib/makamujoBannerTracker' import { type GtagFn, setupScrollDepthTracking } from './lib/scrollDepthTracker' createClient() @@ -17,7 +18,7 @@ const gtagFn: GtagFn = import.meta.env.PROD } } : (command, name, params) => { - console.log('[scroll_depth]', command, name, params) + console.log('[gtag]', command, name, params) } setupScrollDepthTracking({ @@ -64,3 +65,19 @@ setupAdControl({ return 0 }, }) + +const whenReady = (fn: () => void) => { + if (document.readyState !== 'loading') { + fn() + } else { + document.addEventListener('DOMContentLoaded', fn, { once: true }) + } +} + +setupMakamujoBannerTracking({ + gtagFn, + whenReady, + getAreaElements: () => Array.from(document.querySelectorAll('area[data-gtag-event]')), + navigate: (href) => window.open(href, '_blank', 'noopener,noreferrer'), + maxDelayMs: 500, +}) diff --git a/app/components/Article.tsx b/app/components/Article.tsx index bdf92e5..2eb6c36 100644 --- a/app/components/Article.tsx +++ b/app/components/Article.tsx @@ -2,6 +2,7 @@ import { css } from 'hono/css' import { html } from 'hono/html' import type { ArticleLink } from '../lib/articles' import AdMax from './AdMax' +import MakamujoBanner from './MakamujoBanner' import RelatedArticles from './RelatedArticles' const articleClass = css` @@ -156,9 +157,12 @@ ${'' /*