integration-astro-hybrid

PostHog integration for Astro hybrid rendering, applicable to both static and server-rendered pages, including page metadata (Author: PostHog, Version: 1.9.4).

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "integration-astro-hybrid" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-79ae0ded4fe758853dfef0994eeadeccc150bc3a3539b3057a5097a514137a58. Verify the upstream source and version against https://skills.sh/posthog/skills/integration-astro-hybrid before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skills.sh

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

PostHog integration for Astro hybrid rendering, applicable to both static and server-rendered pages, including page metadata (Author: PostHog, Version: 1.9.4).

0 Downloads

Introduction source: third_party · posthog · 1.0.0 Reference

SkillPi interpretation

Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: integration-astro-hybrid
description: >-
  PostHog integration for Astro hybrid rendering with both static and
  server-rendered pages
metadata:
  author: PostHog
  version: 1.9.4

PostHog integration for Astro (Hybrid)

This skill helps you add PostHog analytics to Astro (Hybrid) applications.

Workflow

Follow these steps in order to complete the integration:

  1. basic-integration-1.0-begin.md - PostHog Setup - Begin ← Start here
  2. basic-integration-1.1-edit.md - PostHog Setup - Edit
  3. basic-integration-1.2-revise.md - PostHog Setup - Revise
  4. basic-integration-1.3-conclude.md - PostHog Setup - Conclusion

Reference files

  • references/EXAMPLE.md - Astro (Hybrid) example project code
  • references/astro.md - Astro - docs
  • references/identify-users.md - Identify users - docs
  • references/basic-integration-1.0-begin.md - PostHog setup - begin
  • references/basic-integration-1.1-edit.md - PostHog setup - edit
  • references/basic-integration-1.2-revise.md - PostHog setup - revise
  • references/basic-integration-1.3-conclude.md - PostHog setup - conclusion

The example project shows the target implementation pattern. Consult the documentation for API details.

Key principles

  • Environment variables: Always use environment variables for PostHog keys. Never hardcode them.
  • Minimal changes: Add PostHog code alongside existing integrations. Don't replace or restructure existing code.
  • Match the example: Your implementation should follow the example project's patterns as closely as possible.

Framework guidelines

  • Always use the is:inline directive on PostHog script tags to prevent Astro from processing them and causing TypeScript errors
  • Use PUBLIC_ prefix for client-side environment variables in Astro (e.g., PUBLIC_POSTHOG_PROJECT_TOKEN)
  • Create a posthog.astro component in src/components/ for reusable initialization across pages
  • Import the PostHog component in a Layout and wrap all pages with that layout
  • Use posthog-node in API routes under src/pages/api/ for server-side event tracking
  • Store the posthog-node client instance in a singleton pattern (src/lib/posthog-server.ts) to avoid creating multiple clients
  • In Astro 5, use output static (the default) with an adapter - pages are prerendered by default
  • Use export const prerender = false to opt specific pages into SSR when they need server-side rendering
  • Only pages that need server-side PostHog tracking (like API-backed forms) should opt out of prerendering

Identifying users

Identify users during login and signup events. Refer to the example code and documentation for the correct identify pattern for this framework. If both frontend and backend code exist, pass the client-side session and distinct ID using X-POSTHOG-DISTINCT-ID and X-POSTHOG-SESSION-ID headers to maintain correlation.

Error tracking

Add PostHog error tracking to relevant files, particularly around critical user flows and API boundaries.

Current listing version

1.0.0

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value75/100

Highlights

  • 提供 PostHog 与 Astro 混合渲染的集成方案,解决开发者实际痛点
  • 适用于静态页面和服务器渲染页面,覆盖常见使用场景
Trigger Precision90/100

Highlights

  • 触发描述清晰明确,准确说明适用框架和渲染模式
  • 边界定义清楚,不易与其他集成工具混淆
Structure and Standards75/100

Areas to improve

  • 缺少端到端完整示例 Reported severity: Minor

    文档提供了参考文件列表和关键原则,但缺少一个完整的端到端实现示例代码

    Recommendation: 建议补充一个完整的示例项目结构展示,包括主要组件和配置文件的代码示例

Highlights

  • Workflow 步骤划分清晰,有明确的执行顺序
  • Key principles 和 Framework guidelines 提供了实用的开发指导
Execution Reliability75/100

Areas to improve

  • 异常处理覆盖不全 Reported severity: Minor

    虽然提到了错误跟踪,但对网络失败、配置错误等常见异常情况的处理建议不够详细

    Recommendation: 建议补充常见异常场景的处理方案,如 PostHog 服务不可用时的降级策略

Highlights

  • 工具来源明确,使用官方 PostHog 库
  • 参数使用规范,强调环境变量和 PUBLIC_ 前缀的正确用法
  • 提供了服务器端单例模式的实现建议
Evidence Verifiability (mean of the first four)79/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.