integration-astro-hybrid

PostHog 在 Astro 混合渲染场景下的集成,适用于静态页面和服务器渲染页面,包含页面元数据(作者:PostHog,版本:1.9.4)。

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "integration-astro-hybrid":https://skillpi.com/zh/skills/deepskill-79ae0ded4fe758853dfef0994eeadeccc150bc3a3539b3057a5097a514137a58。安装前核对上游来源和版本:https://skills.sh/posthog/skills/integration-astro-hybrid。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

skills.sh

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

PostHog 在 Astro 混合渲染场景下的集成,适用于静态页面和服务器渲染页面,包含页面元数据(作者:PostHog,版本:1.9.4)。

0 下载

介绍来源: third_party · posthog · 1.0.0 参考来源

SkillPi 解读

实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
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.

当前收录版本

1.0.0

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值75/100

亮点

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

亮点

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

待提升项

  • 缺少端到端完整示例 原报告严重程度:轻微

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

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

亮点

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

待提升项

  • 异常处理覆盖不全 原报告严重程度:轻微

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

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

亮点

  • 工具来源明确,使用官方 PostHog 库
  • 参数使用规范,强调环境变量和 PUBLIC_ 前缀的正确用法
  • 提供了服务器端单例模式的实现建议
证据可验 (前四项均值)79/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

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

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。