AgentSkillsCN

posthog-upgrade-migration

分析、规划并执行 PostHog SDK 升级,同时检测破坏性变更。 在升级 PostHog SDK 版本、检测弃用或迁移到新 API 版本时使用。 可通过诸如“升级 posthog”、“posthog 迁移”、“posthog 破坏性变更”、“更新 posthog SDK”、“分析 posthog 版本”等短语触发。

SKILL.md
--- frontmatter
name: posthog-upgrade-migration
description: |
  Analyze, plan, and execute PostHog SDK upgrades with breaking change detection.
  Use when upgrading PostHog SDK versions, detecting deprecations,
  or migrating to new API versions.
  Trigger with phrases like "upgrade posthog", "posthog migration",
  "posthog breaking changes", "update posthog SDK", "analyze posthog version".
allowed-tools: Read, Write, Edit, Bash(npm:*), Bash(git:*)
version: 1.0.0
license: MIT
author: Jeremy Longshore <jeremy@intentsolutions.io>

PostHog Upgrade & Migration

Overview

Guide for upgrading PostHog SDK versions and handling breaking changes.

Prerequisites

  • Current PostHog SDK installed
  • Git for version control
  • Test suite available
  • Staging environment

Instructions

Step 1: Check Current Version

bash
npm list @posthog/sdk
npm view @posthog/sdk version

Step 2: Review Changelog

bash
open https://github.com/posthog/sdk/releases

Step 3: Create Upgrade Branch

bash
git checkout -b upgrade/posthog-sdk-vX.Y.Z
npm install @posthog/sdk@latest
npm test

Step 4: Handle Breaking Changes

Update import statements, configuration, and method signatures as needed.

Output

  • Updated SDK version
  • Fixed breaking changes
  • Passing test suite
  • Documented rollback procedure

Error Handling

SDK VersionAPI VersionNode.jsBreaking Changes
3.x2024-0118+Major refactor
2.x2023-0616+Auth changes
1.x2022-0114+Initial release

Examples

Import Changes

typescript
// Before (v1.x)
import { Client } from '@posthog/sdk';

// After (v2.x)
import { PostHogClient } from '@posthog/sdk';

Configuration Changes

typescript
// Before (v1.x)
const client = new Client({ key: 'xxx' });

// After (v2.x)
const client = new PostHogClient({
  apiKey: 'xxx',
});

Rollback Procedure

bash
npm install @posthog/sdk@1.x.x --save-exact

Deprecation Handling

typescript
// Monitor for deprecation warnings in development
if (process.env.NODE_ENV === 'development') {
  process.on('warning', (warning) => {
    if (warning.name === 'DeprecationWarning') {
      console.warn('[PostHog]', warning.message);
      // Log to tracking system for proactive updates
    }
  });
}

// Common deprecation patterns to watch for:
// - Renamed methods: client.oldMethod() -> client.newMethod()
// - Changed parameters: { key: 'x' } -> { apiKey: 'x' }
// - Removed features: Check release notes before upgrading

Resources

Next Steps

For CI integration during upgrades, see posthog-ci-integration.