installing-posthog-in-a-codebase
Skill này làm gì
Skill này để agent cài thư viện phân tích của PostHog trong một codebase mà agent có thể đọc và chỉnh sửa. Skill dành cho lập trình viên muốn thêm phân tích sản phẩm và session replay vào ứng dụng của họ.
Khi nào nên dùng
- ✓Khi bạn yêu cầu thêm PostHog, phân tích sản phẩm hoặc session replay vào ứng dụng.
- ✓Khi bạn muốn thư viện PostHog được cài cho framework của mình, chẳng hạn React hoặc Next.js.
- ✓Khi bạn muốn agent giữ project token và cài đặt host ở đúng chỗ.
Liên kết skill
https://github.com/PostHog/posthog/blob/master/products/wizard/skills/installing-posthog-in-a-codebase/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Hãy thêm phân tích PostHog vào ứng dụng Next.js của tôi theo cách thiết lập hiện tại trong tài liệu của họ.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent nhận diện framework của bạn từ các tệp dự án và đọc trang tài liệu PostHog tương ứng. Sau đó nó cài gói mới nhất, thêm project token và cài đặt host, rồi viết mã thiết lập.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Installing PostHog in a codebase
Use this skill when you can read and edit the user's code.
If you can't access their code, as is common in ChatGPT on the web or Claude on the web, use installing-posthog-from-chat.
PostHog's docs are the source of truth for each SDK's setup. Init options, file locations and recommended settings change between SDK releases, so read the docs page for the framework before you write code, and follow it rather than what you remember.
1. Find the framework and read its docs
Detect the framework from the manifest files (package.json, pyproject.toml, requirements.txt, Gemfile, composer.json, go.mod, and so on) and the app's entry points.
A web app with its own backend usually needs a client SDK and a server SDK, so read both pages.
For a framework that isn't listed, call docs-search with the framework name.
2. Install the latest SDK
Add each package with the project's own package manager and no version, for example npm install posthog-js, pnpm add posthog-node, uv add posthog or bundle add posthog-ruby.
That resolves the newest release.
Don't type a version into the manifest from memory, because that pins an old release.
In a monorepo, install into the package that runs the app, not the workspace root.
3. Get the token and host
Call project-get without an ID.
Use api_token as the project token and api_host as the SDK's host option.
- Read both from environment variables in code, using the names the docs page uses (for example
NEXT_PUBLIC_POSTHOG_PROJECT_TOKENandNEXT_PUBLIC_POSTHOG_HOST). - Write the real values to the env file the framework loads, such as
.env.localor.env. If the project has an example env file, add the variable names there with empty values. - Never hard-code the
Câu hỏi thường gặp
Agent có dựa vào trí nhớ để thiết lập PostHog không?
Không. Nó đọc tài liệu hiện tại cho framework của bạn trước, vì chi tiết thiết lập thay đổi giữa các bản phát hành.
Nếu tôi không thể cho agent truy cập mã của mình thì sao?
Khi đó dùng một skill khác, chỉ dẫn từng bước thiết lập trong khung chat và gửi kết quả dưới dạng pull request.
Những framework nào được bao quát?
Các framework web phổ biến như React, Next.js, Vue và Nuxt, cùng vài ngôn ngữ máy chủ, mỗi cái có trang tài liệu riêng.
Chi tiết
Mô tả gốc của tác giả
Install and configure a PostHog SDK in a repository you can read and edit, following PostHog's docs for the framework. Use when a user working in their codebase asks to add, install, or set up PostHog, product analytics, session replay, or a PostHog SDK. Covers finding the right docs page, installing the latest package, getting the project token and ingestion host from project-get, keeping them in the env file, server-side setup, identifying users, and verifying the change. If you can't access the user's code, as is common in ChatGPT on the web or Claude on the web, use installing-posthog-from
repo: PostHog/posthog
Độ phổ biến
- Sao GitHub
- 41k
- Vị trí xếp hạng
- #6979
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
depot-ci
41kGiúp agent của bạn thiết lập và chạy quy trình Depot CI, một lựa chọn thay thế GitHub Actions, gồm chuyển các quy trình hiện có và đọc nhật ký chạy.
depot-container-builds
41kGiúp agent của bạn build image Docker trên các builder từ xa của Depot, gồm image đa nền tảng, đẩy lên registry và sửa lỗi build.
depot-github-runners
41kGiúp agent của bạn chuyển các job GitHub Actions sang runner do Depot quản lý, chọn kích thước và nhãn runner, và xử lý lỗi thiết lập runner.
editing-agents-md
41kGiúp agent của bạn quyết định một quy tắc nên nằm trong file AGENTS.md hay CLAUDE.md, và viết sao cho quy tắc được tuân thủ mà file không bị phình to.
Skill tương tự
diffs
394kGiúp agent của bạn tạo một diff có thể chia sẻ về các chỉnh sửa, dưới dạng liên kết xem hoặc file ảnh, thay vì một bản tóm tắt viết tay.
coding-agent
394kGiúp agent của bạn giao một việc lập trình lớn cho Codex, Claude Code hoặc OpenCode chạy nền, rồi theo dõi tiến độ của nó.
gh-issues
394kGiúp agent của bạn tìm issue trên GitHub, chọn những issue cần xử lý và mở pull request với bản sửa, kể cả theo dõi nhận xét đánh giá.