instrument-logs
Add PostHog log capture to track application logs. Use after implementing features or reviewing PRs to ensure meaningful log events are captured with structured properties. Also handles initial OTLP exporter setup if not yet configured.
What this skill does
# Add PostHog log capture Use this skill to add PostHog log capture for new or changed code. Use it after implementing features or reviewing PRs to ensure meaningful log events are captured with structured properties. If PostHog log export is not yet configured, this skill also covers initial OTLP exporter setup. Supports any platform or language. Supported platforms: Next.js, Node.js, Python, Go, Java, Datadog, Android, React Native, iOS, and any language via OpenTelemetry. ## Instructions Follow these steps IN ORDER: STEP 1: Analyze the codebase and detect the platform. - Detect the language, framework, and existing logging setup. - Look for dependency files and project files (package.json, Podfile, Package.swift, requirements.txt, go.mod, pom.xml, etc.). - Look for log libraries (winston, pino, logging module, logrus, log4j, serilog, os_log, Logger, etc.). - Look for lockfiles (pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lockb, go.sum, Podfile.lock, Package.resolved, etc.) to determine the package manager. - Check for existing PostHog log export setup. If the OTLP exporter is already configured, skip to STEP 5 to add log capture for new code. STEP 2: Research log capture. (Skip if PostHog log export is already configured.) 2.1. Find the reference file below that matches the detected platform — it is the source of truth for OTLP exporter configuration and integration with existing logging. Read it now. 2.2. If no reference matches, use the "Other Languages" reference as a fallback — it covers the generic OpenTelemetry approach. STEP 3: Install dependencies. (Skip if PostHog log export is already configured.) - Install the OpenTelemetry SDK and OTLP exporter packages for the detected platform. - Do not manually edit dependency files — use the package manager's install command. - Always install packages as a background task. Don't await completion; proceed with other work immediately. STEP 4: Configure the OTLP exporter. (Skip if PostHog log export is already configured.) - PostHog logs use the OpenTelemetry protocol. Set up an OTLP exporter pointed at PostHog's ingest endpoint. - For SDK-native log support such as Android, React Native, and iOS, follow the platform reference instead of adding a separate OTLP exporter. - Follow the platform-specific reference for the exact configuration. STEP 5: Integrate with existing logging. - Add the PostHog log exporter alongside existing logging. Don't replace existing log handlers or outputs. - Do not alter the fundamental architecture of existing files. Make additions minimal and targeted. - You must read a file immediately before attempting to write it. STEP 6: Add structured properties. - Ensure logs include structured key-value properties for filtering and search in PostHog. - Prefer structured log formats with key-value properties over plain text messages. STEP 7: Set up environment variables. - Check if the project already has PostHog environment variables configured (e.g. in `.env`, `.env.local`, or framework-specific env files). If valid values already exist, skip this step. - If the PostHog API key is missing, use the PostHog MCP server's `projects-get` tool to retrieve the project's `api_token`. If multiple projects are returned, ask the user which project to use. If the MCP server is not connected or not authenticated, ask the user for their PostHog project API key instead. - For the PostHog host URL, use `https://us.i.posthog.com` for US Cloud or `https://eu.i.posthog.com` for EU Cloud. - For the OpenTelemetry endpoint, use `https://us.i.posthog.com/v1` (US) or `https://eu.i.posthog.com/v1` (EU). - Write these values to the appropriate env file using the framework's naming convention. - Reference these environment variables in code instead of hardcoding them. ## Reference files - `references/nextjs.md` - Next.js logs installation - docs - `references/nodejs.md` - Node.js logs installation - docs - `references/python.md` - Python logs installation - docs - `references/go.md` - Go logs installation - docs - `references/java.md` - Java logs installation - docs - `references/datadog.md` - Datadog logs installation - docs - `references/android.md` - Android logs installation - docs - `references/react-native.md` - React native logs installation - docs - `references/ios.md` - Ios logs installation - docs - `references/other.md` - Other languages logs installation - docs - `references/start-here.md` - Getting started with logs - docs - `references/search.md` - Search logs - docs - `references/best-practices.md` - Logging best practices - docs - `references/troubleshooting.md` - Logs troubleshooting - docs - `references/link-session-replay.md` - Link session replay - docs - `references/debug-logs-mcp.md` - Debug logs with mcp - docs Each platform reference contains specific OTLP configuration, SDK setup, and integration patterns. Find the one matching the user's stack. ## Key principles - **Environment variables**: Always use environment variables for PostHog keys and OpenTelemetry endpoints. Never hardcode them. - **Minimal changes**: Add log export alongside existing logging. Don't replace or restructure existing logging code. - **OpenTelemetry**: PostHog logs use the OpenTelemetry protocol. Configure an OTLP exporter pointed at PostHog's ingest endpoint unless the platform SDK provides native log capture. - **SDK-native logs**: For Android, React Native, and iOS, use the SDK logger/capture APIs from the platform reference instead of adding a separate OTLP exporter. - **Structured logging**: Prefer structured log formats with key-value properties over plain text messages.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.