Skip to content

feat: add PostHog analytics to the extension#5

Open
sonpiaz wants to merge 1 commit into
mainfrom
feat/posthog-extension-analytics
Open

feat: add PostHog analytics to the extension#5
sonpiaz wants to merge 1 commit into
mainfrom
feat/posthog-extension-analytics

Conversation

@sonpiaz

@sonpiaz sonpiaz commented Jun 14, 2026

Copy link
Copy Markdown
Owner

What

Cắm PostHog vào extension, dùng chung project với website (echolyhq.com) để có số liệu sử dụng thật.

Why

Trả lời được các câu cụ thể: giọng nào được Start nhiều nhất (mục tiêu rút gọn top 3 voices), ngôn ngữ đích phổ biến, tỉ lệ realtime vs standard, và funnel mở popup → dub.

Events

Event Khi nào Props chính
extension_installed / extension_updated cài / cập nhật version
popup_opened mở popup
dub_started Start thành công voice, target_language, tier, api_mode
dub_failed Start lỗi + error
dub_stopped dừng / hết video + duration_seconds, reason

Design notes

  • MV3 CSP (script-src 'self') cấm nạp posthog-js từ CDN + không có bundler → analytics.js là client mini POST thẳng vào capture endpoint từ service worker.
  • Privacy: anonymous (random distinct_id trong storage), không gửi email / Kyma key / tên provider/routing; tắt person profiles.
  • Mọi event đi qua background SW (popup gửi qua TRACK message) để né CSP/CORS ở content script.
  • Thêm host permission us.i.posthog.com; bump 0.6.3 → 0.6.4.

Verification

  • Capture endpoint trả HTTP 200 với key + payload thật.
  • node --check (analytics/background/popup) + JSON validate đều pass.

🤖 Generated with Claude Code

Instrument the Echoly extension with the same PostHog project the website
uses (echolyhq.com), so we can see real usage — most-Started voices,
popular target languages, realtime vs standard split, and open→dub funnel.

- analytics.js: tiny MV3-safe PostHog client. MV3 CSP forbids the posthog-js
  CDN and there is no bundler, so it POSTs straight to the capture endpoint
  from the service worker. Anonymous: random distinct_id in storage, no email,
  no Kyma key, no provider/routing detail; person profiles disabled.
- background.js: emit extension_installed/updated, dub_started, dub_failed,
  dub_stopped (with duration). All session events route through the SW.
- popup.js: emit popup_opened via a TRACK passthrough message.
- manifest.json: add us.i.posthog.com host permission; bump 0.6.3 -> 0.6.4.

Verified: capture endpoint returns HTTP 200; JS/JSON syntax checks pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant