posthog-upgrade-migration
Upgrade posthog-js and posthog-node SDKs with breaking change detection. Covers v4 to v5 posthog-node migration (sendFeatureFlags change), posthog-js autocapture API changes, and version-specific gotchas. Trigger: "upgrade posthog", "posthog breaking changes", "update posthog SDK", "posthog version", "posthog migration".
What this skill does
# PostHog Upgrade & Migration
## Current State
!`npm list posthog-js posthog-node 2>/dev/null | grep posthog || echo 'No PostHog SDK found'`
## Overview
Upgrade posthog-js and posthog-node SDKs safely. Covers version compatibility, breaking changes between major versions (notably the v5 sendFeatureFlags change in posthog-node), and a systematic upgrade procedure.
## Prerequisites
- PostHog SDK currently installed
- Git for branching
- Test suite covering PostHog integration
- Staging environment for validation
## Instructions
### Step 1: Audit Current Versions
```bash
set -euo pipefail
# Check installed versions
echo "=== posthog-js ==="
npm list posthog-js 2>/dev/null || echo "Not installed"
echo "=== posthog-node ==="
npm list posthog-node 2>/dev/null || echo "Not installed"
echo "=== Python posthog ==="
pip3 show posthog 2>/dev/null | grep Version || echo "Not installed"
# Check latest available versions
echo "=== Latest available ==="
npm view posthog-js version 2>/dev/null
npm view posthog-node version 2>/dev/null
```
### Step 2: Review Breaking Changes
**posthog-node v5.x Breaking Changes:**
```typescript
// BREAKING: sendFeatureFlags no longer automatic with local evaluation
// Before v5.5.0: feature flags auto-sent with events when using local evaluation
// After v5.5.0: must explicitly set sendFeatureFlags: true
// Before (implicit, worked in v4.x)
posthog.capture({
distinctId: 'user-1',
event: 'page_viewed',
// Feature flags were automatically included
});
// After (v5.5.0+, explicit required)
posthog.capture({
distinctId: 'user-1',
event: 'page_viewed',
sendFeatureFlags: true, // Must be explicit now
});
```
**posthog-js Recent Changes:**
```typescript
// Autocapture configuration moved to object format
// Before:
posthog.init('phc_...', { autocapture: true });
// Current: Fine-grained autocapture control
posthog.init('phc_...', {
autocapture: {
dom_event_allowlist: ['click', 'submit'],
element_allowlist: ['a', 'button', 'form', 'input'],
css_selector_allowlist: ['.track-click'],
url_ignorelist: ['/health', '/api/internal'],
},
});
// before_send replaces older event filtering approaches
posthog.init('phc_...', {
before_send: (event) => {
// Return null to drop event, or modified event
if (event.event === '$pageview' && event.properties?.$current_url?.includes('/admin')) {
return null; // Don't track admin pages
}
return event;
},
});
```
### Step 3: Upgrade Procedure
```bash
set -euo pipefail
# Create upgrade branch
git checkout -b upgrade/posthog-sdks
# Upgrade posthog-node
npm install posthog-node@latest
# Check for type errors
npx tsc --noEmit 2>&1 | grep -i posthog || echo "No PostHog type errors"
# Upgrade posthog-js
npm install posthog-js@latest
# Check for type errors
npx tsc --noEmit 2>&1 | grep -i posthog || echo "No PostHog type errors"
# Run tests
npm test
# If Python
pip install --upgrade posthog
```
### Step 4: Search for Deprecated Patterns
```bash
set -euo pipefail
# Find files using PostHog
grep -rn "posthog\|PostHog" --include="*.ts" --include="*.tsx" --include="*.js" src/ | \
grep -v node_modules | grep -v ".d.ts"
# Check for patterns that may need updating
echo "=== Checking for deprecated patterns ==="
# Old import style (posthog-node v3 and earlier)
grep -rn "from 'posthog-node'" --include="*.ts" src/ && echo "Import style: current" || true
# Direct API key in code (should be env var)
grep -rn "phc_\|phx_" --include="*.ts" --include="*.tsx" src/ && \
echo "WARNING: Hardcoded API key found" || echo "No hardcoded keys"
# Check for sendFeatureFlags usage
grep -rn "sendFeatureFlags" --include="*.ts" src/ || \
echo "NOTE: No explicit sendFeatureFlags — verify if needed after v5.5.0 upgrade"
```
### Step 5: Validate in Staging
```typescript
// Post-upgrade validation script
import { PostHog } from 'posthog-node';
async function validateUpgrade() {
const ph = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
host: 'https://us.i.posthog.com',
personalApiKey: process.env.POSTHOG_PERSONAL_API_KEY,
});
const checks = {
capture: false,
flags: false,
identify: false,
};
try {
// Test capture
ph.capture({ distinctId: 'upgrade-test', event: 'sdk_upgrade_validated' });
checks.capture = true;
// Test feature flags
const flags = await ph.getAllFlags('upgrade-test');
checks.flags = typeof flags === 'object';
// Test identify
ph.identify({ distinctId: 'upgrade-test', properties: { upgraded: true } });
checks.identify = true;
await ph.flush();
} catch (error) {
console.error('Validation failed:', error);
} finally {
await ph.shutdown();
}
console.log('Upgrade validation:', checks);
const allPassed = Object.values(checks).every(Boolean);
process.exit(allPassed ? 0 : 1);
}
validateUpgrade();
```
### Step 6: Rollback if Needed
```bash
set -euo pipefail
# Pin to previous version
npm install [email protected] --save-exact
npm install [email protected] --save-exact
# Verify rollback
npm test
```
## Version Compatibility
| Package | Node.js Requirement | Key Notes |
|---------|-------------------|-----------|
| posthog-node 5.x | 20+ | `sendFeatureFlags` must be explicit |
| posthog-node 4.x | 18+ | `sendFeatureFlags` was automatic with local eval |
| posthog-js latest | Modern browsers | `before_send` for event filtering, object-based autocapture |
## Error Handling
| Issue | Cause | Solution |
|-------|-------|----------|
| Type errors after upgrade | API changed | Check changelog, update types |
| Flags not sent with events | v5.5.0 change | Add `sendFeatureFlags: true` |
| Autocapture config ignored | Old boolean format | Migrate to object-based autocapture config |
| Test failures | Mock structure changed | Update mocks to match new SDK exports |
## Output
- Upgraded PostHog SDK to latest version
- Deprecated patterns identified and fixed
- All tests passing with new version
- Rollback procedure documented
## Resources
- [posthog-node Changelog](https://github.com/PostHog/posthog-node/releases)
- [posthog-js Changelog](https://github.com/PostHog/posthog-js/releases)
- [PostHog Migration Guides](https://posthog.com/docs/migrate)
## Next Steps
For CI integration during upgrades, see `posthog-ci-integration`.
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.