### Install PostHog Go Library Source: https://posthog.com/docs/feature-flags/installation/go Install the PostHog Go library using the go get command. This is a required step before configuring the client. ```bash go get "github.com/posthog/posthog-go" ``` -------------------------------- ### Install PostHog SDKs Source: https://posthog.com/docs/libraries/tanstack-start Install the necessary dependencies for both client-side React integration and server-side Node.js event tracking. ```bash npm install @posthog/react posthog-node ``` -------------------------------- ### Setup PostHog Migration Tool Source: https://posthog.com/docs/migrate/migrate-to-cloud Clones the official migration repository and installs the necessary Python dependencies to prepare the environment for data transfer. ```bash git clone https://github.com/PostHog/posthog-migration-tools cd posthog-migration-tools pip3 install -r requirements.txt ``` -------------------------------- ### Install PostHog Go Library Source: https://posthog.com/docs/experiments/installation/go Installs the PostHog Go client library using the go get command. This is the first step to integrating PostHog features into your Go application. ```bash go get "github.com/posthog/posthog-go" ``` -------------------------------- ### Install and Setup PostHog Node.js for Server-side Source: https://posthog.com/docs/experiments/installation/nuxt Installs the posthog-node package and demonstrates how to capture events within a Nuxt server route. ```bash npm install posthog-node yarn add posthog-node pnpm add posthog-node ``` ```javascript import { PostHog } from 'posthog-node' export default defineEventHandler(async (event) => { const runtimeConfig = useRuntimeConfig() const posthog = new PostHog( runtimeConfig.public.posthogPublicKey, { host: runtimeConfig.public.posthogHost } ) posthog.capture({ distinctId: 'distinct_id_of_the_user', event: 'event_name' }) await posthog.shutdown() }) ``` -------------------------------- ### Install via HTML snippet Source: https://posthog.com/docs/libraries/js Embed the PostHog initialization script directly into your HTML. Replace with your actual project token. ```html ``` -------------------------------- ### Configure exception autocapture Source: https://posthog.com/docs/error-tracking/installation/node Enables automatic capturing of uncaught exceptions and unhandled rejections. Includes specific setup for Express framework applications. ```javascript import { PostHog } from 'posthog-node' const client = new PostHog( '', { host: 'https://us.i.posthog.com', enableExceptionAutocapture: true } ) ``` ```javascript import express from 'express' import { PostHog, setupExpressErrorHandler } from 'posthog-node' const app = express() const posthog = new PostHog(POSTHOG_PROJECT_TOKEN) setupExpressErrorHandler(posthog, app) ``` -------------------------------- ### Download and Run PostHog Hobby Installer Source: https://posthog.com/docs/self-host Use this command to download and execute the PostHog hobby installer script. It sets up a self-hosted instance. ```bash curl -OfsSL https://github.com/PostHog/posthog/releases/download/hobby-latest/hobby-installer chmod +x hobby-installer ./hobby-installer ``` -------------------------------- ### Import and Initialize PostHog in Vue Router Source: https://posthog.com/docs/experiments/installation/vue Integrates the `usePostHog` composable into the Vue router setup. This ensures PostHog is initialized when the application starts and the router is created. ```javascript import { createRouter, createWebHistory } from 'vue-router' import HomeView from '../views/HomeView.vue' import { usePostHog } from '@/composables/usePostHog' const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes: [ { path: '/', name: 'home', component: HomeView, }, { path: '/about', name: 'about', component: () => import('../views/AboutView.vue'), }, ], }) const { posthog } = usePostHog() export default router ``` -------------------------------- ### Install PostHog PHP SDK Source: https://posthog.com/docs/error-tracking/installation/php Install the SDK using Composer. ```bash composer require posthog/posthog-php ``` -------------------------------- ### Users Two Factor Start Setup Retrieve API Source: https://posthog.com/llms.txt API endpoint to retrieve information for starting the two-factor authentication setup. ```APIDOC ## GET /users/two_factor/start_setup/retrieve ### Description Retrieves the necessary information to begin the two-factor authentication setup process for a user. ### Method GET ### Endpoint /users/two_factor/start_setup/retrieve ### Parameters #### Query Parameters - **user_id** (string) - Required - The ID of the user. ### Response #### Success Response (200) - **setup_details** (object) - Details required for setting up 2FA, such as a secret key or QR code URL. #### Response Example ```json { "setup_details": { "qr_code": "otpauth://totp/...", "secret": "ABCDEFG12345" } } ``` ``` -------------------------------- ### Cursor Configuration Example Source: https://posthog.com/docs/model-context-protocol/cursor Example JSON configuration for setting up the PostHog MCP server for a cursor. ```APIDOC ## Cursor Configuration ### Description Example configuration for `.cursor/mcp.json` to connect to the PostHog MCP server. ### File `.cursor/mcp.json` ### Content Example ```json { "mcpServers": { "posthog": { "url": "https://mcp.posthog.com/mcp?features=flags&tools=dashboard-get", "headers": { "Authorization": "Bearer phx_your_api_key_here" } } } } ``` ### Fields - **mcpServers** (object) - Configuration for MCP servers. - **posthog** (object) - Configuration specific to the PostHog server. - **url** (string) - The MCP endpoint URL, potentially including query parameters for filtering. - **headers** (object) - HTTP headers to be sent with requests. - **Authorization** (string) - Bearer token for authentication. ``` -------------------------------- ### Users Start 2FA Setup Retrieve API Source: https://posthog.com/llms.txt API endpoint to initiate the two-factor authentication setup process. ```APIDOC ## GET /users/start_2fa_setup/retrieve ### Description Initiates the setup process for two-factor authentication (2FA) for a user. ### Method GET ### Endpoint /users/start_2fa_setup/retrieve ### Parameters #### Query Parameters - **user_id** (string) - Required - The ID of the user. ### Response #### Success Response (200) - **setup_info** (object) - Information needed to start 2FA setup, possibly including a QR code URL or secret key. #### Response Example ```json { "setup_info": { "qr_code_url": "otpauth://totp/...", "secret_key": "JBSWY3DPEHPK3PXP" } } ``` ``` -------------------------------- ### Install PostHog PHP Library Source: https://posthog.com/docs/experiments/installation/laravel Installs the official PostHog PHP SDK via Composer. This is a required dependency for interacting with the PostHog API from a Laravel backend. ```bash composer require posthog/posthog-php ``` -------------------------------- ### Run posthog-live CLI Source: https://posthog.com/docs/activity Execute the tool to start streaming events and authenticate via the browser. ```bash ./posthog-live ``` -------------------------------- ### POST /api/environments/{project_id}/mcp_server_installations/install_custom/ Source: https://posthog.com/docs/open-api-spec/mcp_server_installations_install_custom_create Installs a custom MCP server for the specified project. ```APIDOC ## POST /api/environments/{project_id}/mcp_server_installations/install_custom/ ### Description Installs a custom MCP server for a given project. This endpoint supports JSON, form-urlencoded, and multipart/form-data request bodies. ### Method POST ### Endpoint /api/environments/{project_id}/mcp_server_installations/install_custom/ ### Parameters #### Path Parameters - **project_id** (string) - Required - Project ID of the project you're trying to access. #### Request Body - **name** (string) - Required - Name of the MCP server (max 200 chars). - **url** (string) - Required - URL of the MCP server (max 2048 chars). - **auth_type** (enum) - Required - Authentication type for the server. - **api_key** (string) - Optional - API key for authentication. - **description** (string) - Optional - Description of the server. - **install_source** (enum) - Optional - Source of the installation (default: posthog). - **posthog_code_callback_url** (string) - Optional - Callback URL for PostHog code. ### Response #### Success Response (200) - **redirect_url** (string) - The URL to redirect to for OAuth flows. #### Success Response (201) - **id** (string) - Unique identifier for the installation. - **name** (string) - Name of the installation. - **created_at** (string) - Timestamp of creation. ``` -------------------------------- ### Initialize PostHog client Source: https://posthog.com/docs/feature-flags/installation/ruby Configure the client with your project token and host URL. ```ruby require 'posthog' posthog = PostHog::Client.new({ api_key: "", host: "https://us.i.posthog.com", on_error: Proc.new { |status, msg| print msg } }) ``` -------------------------------- ### GET /api/environments/{project_id}/mcp_server_installations/authorize/ Source: https://posthog.com/docs/open-api-spec/mcp_server_installations_authorize_retrieve Retrieves and authorizes MCP server installations for a given project. This endpoint allows specifying installation source and callback URLs. ```APIDOC ## GET /api/environments/{project_id}/mcp_server_installations/authorize/ ### Description Retrieves and authorizes MCP server installations for a given project. This endpoint allows specifying installation source and callback URLs. ### Method GET ### Endpoint /api/environments/{project_id}/mcp_server_installations/authorize/ ### Parameters #### Path Parameters - **project_id** (string) - Required - Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/. #### Query Parameters - **install_source** (string) - Optional - Specifies the installation source. Allowed values are `posthog` and `posthog-code`. Defaults to `posthog`. - **posthog_code_callback_url** (string) - Optional - The callback URL for posthog-code installations. Defaults to an empty string. - **server_id** (string) - Required - The ID of the server to authorize. ### Request Example ```json { "install_source": "posthog", "posthog_code_callback_url": "", "project_id": "your_project_id", "server_id": "your_server_id" } ``` ### Response #### Success Response (200) This endpoint does not return a response body upon successful authorization. ``` -------------------------------- ### Install PostHog Unity SDK Source: https://posthog.com/docs/session-replay/installation/unity Use this Git URL in the Unity Package Manager to install the PostHog SDK. ```text https://github.com/PostHog/posthog-unity.git?path=com.posthog.unity ``` -------------------------------- ### Cursor Configuration Example Source: https://posthog.com/docs/model-context-protocol Example JSON configuration for setting up the PostHog MCP server in a cursor environment, including URL and authorization headers. ```APIDOC ## Cursor Configuration (`.cursor/mcp.json`) ### Description Configuration file for the cursor editor to connect to the PostHog MCP server. ### File `.cursor/mcp.json` ### Content Example ```json { "mcpServers": { "posthog": { "url": "https://mcp.posthog.com/mcp?features=flags&tools=dashboard-get", "headers": { "Authorization": "Bearer phx_your_api_key_here" } } } } ``` ### Fields - **mcpServers** (object) - Contains configurations for different MCP servers. - **posthog** (object) - Configuration for the PostHog MCP server. - **url** (string) - The URL of the MCP endpoint. - **headers** (object) - HTTP headers to include in requests. - **Authorization** (string) - Bearer token for authentication. ``` -------------------------------- ### Install PostHog Rust SDK dependency Source: https://posthog.com/docs/product-analytics/installation/rust Add the posthog-rs crate to your Cargo.toml file to enable product analytics in your Rust application. This is the standard installation method for the default async client. ```toml [dependencies] posthog-rs = "0.3.5" ``` -------------------------------- ### Initialize PostHog Source: https://posthog.com/docs/llm-analytics/installation/manual-capture Configure the PostHog client with your project token and host URL. ```php ', [ 'host' => 'https://us.i.posthog.com' ]); ``` -------------------------------- ### Install PostHog for React using npm, Yarn, pnpm, or Bun Source: https://posthog.com/docs/libraries/react Installs the necessary PostHog libraries for React applications using various package managers. Ensure you have Node.js and your chosen package manager installed. ```bash npm install --save posthog-js @posthog/react ``` ```bash yarn add posthog-js @posthog/react ``` ```bash pnpm add posthog-js @posthog/react ``` ```bash bun add posthog-js @posthog/react ``` -------------------------------- ### Install posthog-node with npm Source: https://posthog.com/docs/surveys/installation/nextjs Install the PostHog Node.js SDK using npm. ```bash npm install posthog-node ``` -------------------------------- ### Initialize PostHog Client Source: https://posthog.com/docs/libraries/python Import the Posthog library and initialize the client with your project token and host before making any calls. Consider using environment variables for sensitive information like tokens. ```python from posthog import Posthog posthog = Posthog('', host='https://us.i.posthog.com') ``` -------------------------------- ### Install PostHog via CLI Wizard Source: https://posthog.com/docs/product-os The PostHog wizard is a command-line tool designed to simplify the installation process. It automates the setup of PostHog within your project environment. ```bash npx @posthog/wizard ``` -------------------------------- ### POST /api/environments/{project_id}/mcp_server_installations/ Source: https://posthog.com/docs/open-api-spec/mcp_server_installations_create Creates a new MCP server installation for the specified project. ```APIDOC ## POST /api/environments/{project_id}/mcp_server_installations/ ### Description Creates a new MCP server installation within the context of a specific project. This endpoint requires project write permissions. ### Method POST ### Endpoint /api/environments/{project_id}/mcp_server_installations/ ### Parameters #### Path Parameters - **project_id** (string) - Required - The unique identifier of the project. #### Request Body - **display_name** (string) - Optional - The display name for the installation. - **url** (string) - Optional - The URI of the MCP server. - **description** (string) - Optional - A description of the installation. - **auth_type** (string) - Optional - Authentication type: 'api_key' or 'oauth'. - **is_enabled** (boolean) - Optional - Whether the installation is enabled. ### Request Example { "display_name": "My MCP Server", "url": "https://mcp.example.com", "auth_type": "api_key", "is_enabled": true } ### Response #### Success Response (201) - **id** (string) - The unique ID of the created installation. - **created_at** (string) - ISO timestamp of creation. #### Response Example { "id": "550e8400-e29b-41d4-a716-446655440000", "display_name": "My MCP Server", "created_at": "2023-10-27T10:00:00Z" } ``` -------------------------------- ### Install PostHog SDK via Package Manager Source: https://posthog.com/docs/error-tracking/installation/web Commands to add the PostHog JavaScript SDK dependency to your project using common package managers. ```bash npm install posthog-js yarn add posthog-js pnpm add posthog-js ``` -------------------------------- ### Install PostHog Android SDK dependency Source: https://posthog.com/docs/experiments/installation/android Adds the PostHog Android SDK to your project via Gradle. This is a required step to enable PostHog functionality in your Android application. ```gradle dependencies { implementation("com.posthog:posthog-android:3.+") } ``` -------------------------------- ### Start Caddy Server Source: https://posthog.com/docs/advanced/proxy/caddy Run this command from the same directory as your Caddyfile to start the Caddy server. Caddy will automatically provision a TLS certificate from Let's Encrypt for your subdomain. ```bash caddy start ``` -------------------------------- ### GET /api/users/{uuid}/two_factor_start_setup/ Source: https://posthog.com/docs/open-api-spec/users_two_factor_start_setup_retrieve Retrieves the status or initiates the setup process for two-factor authentication for a specific user. ```APIDOC ## GET /api/users/{uuid}/two_factor_start_setup/ ### Description Retrieves the status or initiates the setup process for two-factor authentication for a specific user. ### Method GET ### Endpoint /api/users/{uuid}/two_factor_start_setup/ ### Parameters #### Path Parameters - **uuid** (string) - Required - The unique identifier of the user. ### Request Example (No request body for this GET request) ### Response #### Success Response (200) No response body is returned upon successful retrieval or initiation of the two-factor setup process. ``` -------------------------------- ### Install posthog-live CLI Source: https://posthog.com/docs/activity Download and make the posthog-live binary executable for macOS Apple Silicon systems. ```bash curl -L https://github.com/PostHog/posthog/releases/download/posthog-live-latest/posthog-live-darwin-arm64 -o posthog-live && chmod +x posthog-live ``` -------------------------------- ### Initialize PostHog Client Source: https://posthog.com/docs/error-tracking/installation/php Initialize the client with your project token and instance address. ```php PostHog\PostHog::init( '', ['host' => 'https://us.i.posthog.com'] ); ``` -------------------------------- ### GET /api/environments/{project_id}/mcp_server_installations/ Source: https://posthog.com/docs/open-api-spec/mcp_server_installations_list Retrieves a paginated list of MCP server installations for a given project ID. ```APIDOC ## GET /api/environments/{project_id}/mcp_server_installations/ ### Description Retrieves a list of MCP server installations configured for the specified project. Supports pagination via limit and offset parameters. ### Method GET ### Endpoint /api/environments/{project_id}/mcp_server_installations/ ### Parameters #### Path Parameters - **project_id** (string) - Required - Project ID of the project you're trying to access. #### Query Parameters - **limit** (integer) - Optional - Number of results to return per page. - **offset** (integer) - Optional - The initial index from which to return the results. ### Request Example GET /api/environments/my-project-id/mcp_server_installations/?limit=10 ### Response #### Success Response (200) - **count** (integer) - Total number of installations. - **next** (string) - URL for the next page of results. - **previous** (string) - URL for the previous page of results. - **results** (array) - List of MCPServerInstallation objects. #### Response Example { "count": 1, "next": null, "previous": null, "results": [ { "id": "550e8400-e29b-41d4-a716-446655440000", "name": "example-server", "is_enabled": true, "created_at": "2023-10-27T10:00:00Z" } ] } ``` -------------------------------- ### Install PostHog Web Snippet Source: https://posthog.com/docs/session-replay/installation/framer The PostHog web snippet initializes the tracking library. It requires a project token and an API host to capture user interactions for session replay. ```html ``` -------------------------------- ### Install posthog-node with yarn Source: https://posthog.com/docs/surveys/installation/nextjs Install the PostHog Node.js SDK using yarn. ```bash yarn add posthog-node ``` -------------------------------- ### Start Pi Coding Agent Source: https://posthog.com/docs/llm-analytics/installation/pi Starts the Pi coding agent after PostHog environment variables have been configured. The PostHog extension initializes automatically and begins capturing events. ```bash pi ``` -------------------------------- ### GET /api/users/{uuid}/start_2fa_setup/ Source: https://posthog.com/docs/open-api-spec/users_start_2fa_setup_retrieve Initiates the two-factor authentication (2FA) setup process for a specific user identified by their UUID. ```APIDOC ## GET /api/users/{uuid}/start_2fa_setup/ ### Description Initiates the two-factor authentication (2FA) setup process for a specific user. This endpoint triggers the necessary backend logic to prepare the user account for 2FA configuration. ### Method GET ### Endpoint /api/users/{uuid}/start_2fa_setup/ ### Parameters #### Path Parameters - **uuid** (string) - Required - The unique identifier of the user. ### Request Example GET /api/users/123e4567-e89b-12d3-a456-426614174000/start_2fa_setup/ ### Response #### Success Response (200) - **status** (string) - Indicates the operation was successful. #### Response Example { "status": "success" } ``` -------------------------------- ### Install PostHog PHP SDK Source: https://posthog.com/docs/libraries/php Add the dependency to your composer.json and run the install command. ```json { "require": { "posthog/posthog-php": "3.0.*" } } ``` ```bash composer install ``` -------------------------------- ### Configure PostHog Client in Go Source: https://posthog.com/docs/feature-flags/installation/go Initialize the PostHog client with your project token and endpoint. Ensure to defer client closing for proper resource management. ```go package main import ( "github.com/posthog/posthog-go" ) func main() { client, _ := posthog.NewWithConfig("", posthog.Config{Endpoint: "https://us.i.posthog.com"}) defer client.Close() } ``` -------------------------------- ### GET /api/organizations/{organization_id}/invites/ Source: https://posthog.com/docs/open-api-spec/invites_list Retrieves a paginated list of invites for a given organization. You can control the number of results and the starting offset. ```APIDOC ## GET /api/organizations/{organization_id}/invites/ ### Description Retrieves a paginated list of invites for a given organization. You can control the number of results and the starting offset. ### Method GET ### Endpoint /api/organizations/{organization_id}/invites/ ### Parameters #### Path Parameters - **organization_id** (string) - Required - The ID of the organization. #### Query Parameters - **limit** (integer) - Optional - Number of results to return per page. - **offset** (integer) - Optional - The initial index from which to return the results. ### Request Example ```json { "example": "" } ``` ### Response #### Success Response (200) - **count** (integer) - The total number of invites. - **next** (string) - URL for the next page of results. - **previous** (string) - URL for the previous page of results. - **results** (array) - A list of organization invites. - **id** (string) - The unique identifier for the invite. - **target_email** (string) - The email address of the invited user. - **first_name** (string) - The first name of the invited user. - **emailing_attempt_made** (boolean) - Indicates if an email invitation attempt was made. - **level** (integer) - The membership level for the invite. - **is_expired** (boolean) - Indicates if the invite has expired. - **created_by** (object) - Basic information about the user who created the invite. - **created_at** (string) - The timestamp when the invite was created. - **updated_at** (string) - The timestamp when the invite was last updated. - **message** (string) - An optional message included with the invite. - **private_project_access** (object) - Access levels to private projects. - **send_email** (boolean) - Whether to send an email invitation (write-only). - **combine_pending_invites** (boolean) - Whether to combine pending invites (write-only). #### Response Example ```json { "count": 1, "next": null, "previous": null, "results": [ { "id": "d8f3a1b2-c4e6-8f0a-1b2c-3d4e5f6a7b8c", "target_email": "test@example.com", "first_name": "Test", "emailing_attempt_made": false, "level": 1, "is_expired": false, "created_by": { "id": 1, "username": "admin" }, "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z", "message": null, "private_project_access": null } ] } ``` ``` -------------------------------- ### Set up PostHog Provider Source: https://posthog.com/docs/experiments/installation/remix Create a `provider.tsx` file to initialize PostHog after hydration. Ensure you replace '' with your actual project token. ```typescript import { useEffect, useState } from "react"; import posthog from "posthog-js"; import { PostHogProvider } from "@posthog/react"; export function PHProvider({ children }: { children: React.ReactNode }) { const [hydrated, setHydrated] = useState(false); useEffect(() => { posthog.init("", { api_host: "https://us.i.posthog.com", defaults: "2026-01-30" }); setHydrated(true); }, []); if (!hydrated) return <>{children}; return {children}; } ``` -------------------------------- ### Python SDK - Prompts API Source: https://posthog.com/docs/llm-analytics/prompts Demonstrates how to initialize the Prompts SDK in Python, fetch prompt templates, and compile them with variables. ```APIDOC ## Python SDK - Prompts API ### Description This section details the usage of the PostHog AI Prompts SDK in Python. It covers initialization with a PostHog client or directly, fetching prompt templates (latest or specific versions), and compiling templates with dynamic variables. ### Method N/A (SDK Usage) ### Endpoint N/A (SDK Usage) ### Parameters N/A (SDK Usage) ### Request Example ```python from posthog import Posthog from posthog.ai.prompts import Prompts # Initialize with PostHog client posthog = Posthog( '', host='https://us.posthog.com', personal_api_key='' ) prompts = Prompts(posthog) # Or initialize directly prompts = Prompts( personal_api_key='', project_api_key='', host='https://us.posthog.com' ) # Fetch the latest version of a prompt template = prompts.get( 'support-system-prompt', cache_ttl_seconds=600, # Override default 5-minute cache fallback='You are a helpful assistant.' # Used if fetch fails ) # Or fetch a specific version template = prompts.get( 'support-system-prompt', version=2, fallback='You are a helpful assistant.' ) # Compile with variables system_prompt = prompts.compile(template, { 'company': 'Acme Corp', 'tier': 'premium', 'user_name': 'Alice' }) # Use in your LLM call # ... your OpenAI/Anthropic call here ``` ### Response N/A (SDK Usage - returns prompt template strings or compiled strings) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### GET /api/environments/{project_id}/user_interviews/ Source: https://posthog.com/docs/open-api-spec/user_interviews_list Retrieves a paginated list of user interviews for a given project. You can control the number of results and the starting offset. ```APIDOC ## GET /api/environments/{project_id}/user_interviews/ ### Description Retrieves a paginated list of user interviews associated with a specific project. ### Method GET ### Endpoint /api/environments/{project_id}/user_interviews/ ### Parameters #### Path Parameters - **project_id** (string) - Required - Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/. #### Query Parameters - **limit** (integer) - Optional - Number of results to return per page. - **offset** (integer) - Optional - The initial index from which to return the results. ### Response #### Success Response (200) - **count** (integer) - The total number of user interviews. - **next** (string) - URL for the next page of results. - **previous** (string) - URL for the previous page of results. - **results** (array) - An array of UserInterview objects. #### Response Example ```json { "count": 123, "next": "http://api.example.org/accounts/?offset=400&limit=100", "previous": "http://api.example.org/accounts/?offset=200&limit=100", "results": [ { "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "created_by": { "id": 1, "uuid": "f0e9d8c7-b6a5-4321-0987-654321fedcba", "distinct_id": "user123", "first_name": "John", "last_name": "Doe", "email": "john.doe@example.com", "is_email_verified": true, "hedgehog_config": {}, "role_at_organization": "member" }, "created_at": "2023-10-27T10:00:00Z", "interviewee_emails": [ "interviewee1@example.com", "interviewee2@example.com" ], "transcript": "This is the transcript of the user interview.", "summary": "A brief summary of the interview.", "audio": "http://example.com/audio/interview.wav" } ] } ``` ``` -------------------------------- ### GET /api/environments/{project_id}/mcp_server_installations/{id}/ Source: https://posthog.com/docs/open-api-spec/mcp_server_installations_retrieve Retrieves the details of a specific MCP server installation using its UUID and the associated project ID. ```APIDOC ## GET /api/environments/{project_id}/mcp_server_installations/{id}/ ### Description Retrieves the full configuration and status details for a specific MCP server installation identified by its UUID. ### Method GET ### Endpoint /api/environments/{project_id}/mcp_server_installations/{id}/ ### Parameters #### Path Parameters - **project_id** (string) - Required - The unique identifier of the project. - **id** (string/uuid) - Required - The unique UUID of the MCP server installation. ### Request Example GET /api/environments/my-project-id/mcp_server_installations/550e8400-e29b-41d4-a716-446655440000/ ### Response #### Success Response (200) - **id** (string) - The UUID of the installation. - **name** (string) - The internal name of the server. - **display_name** (string) - The user-friendly display name. - **url** (string) - The URI of the MCP server. - **is_enabled** (boolean) - Whether the installation is currently enabled. - **auth_type** (string) - The authentication method used (api_key or oauth). - **created_at** (string) - ISO timestamp of creation. #### Response Example { "id": "550e8400-e29b-41d4-a716-446655440000", "name": "my-mcp-server", "display_name": "My MCP Server", "is_enabled": true, "auth_type": "api_key", "created_at": "2023-10-27T10:00:00Z" } ``` -------------------------------- ### Initialize and Fetch Prompts with PostHog AI Source: https://posthog.com/docs/llm-analytics/prompts Demonstrates how to initialize the Prompts client either via an existing PostHog instance or directly, and how to fetch and compile prompt templates with variable injection. ```python from posthog import Posthog from posthog.ai.prompts import Prompts # Initialize with PostHog client posthog = Posthog( '', host='https://us.posthog.com', personal_api_key='' ) prompts = Prompts(posthog) # Fetch and compile template = prompts.get('support-system-prompt', cache_ttl_seconds=600, fallback='You are a helpful assistant.') system_prompt = prompts.compile(template, {'company': 'Acme Corp', 'tier': 'premium', 'user_name': 'Alice'}) ``` ```typescript import { Prompts } from '@posthog/ai' import { PostHog } from 'posthog-node' // Initialize with PostHog client const posthog = new PostHog('', { host: 'https://us.posthog.com', personalApiKey: '' }) const prompts = new Prompts({ posthog }) // Fetch and compile const template = await prompts.get('support-system-prompt', { cacheTtlSeconds: 600, fallback: 'You are a helpful assistant.' }) const systemPrompt = prompts.compile(template, { company: 'Acme Corp', tier: 'premium', userName: 'Alice' }) ``` -------------------------------- ### Configure the OpenTelemetry SDK Source: https://posthog.com/docs/logs/installation/go Set up the logger provider and OTLP exporter to send logs to PostHog. Replace with your actual project token. ```go package main import ( "os" "context" "log" "log/slog" "go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp" "go.opentelemetry.io/otel/exporters/stdout/stdoutlog" "go.opentelemetry.io/contrib/bridges/otelslog" otellog "go.opentelemetry.io/otel/sdk/log" "go.opentelemetry.io/otel/log/global" ) func main() { ctx := context.Background() // Create OTLP HTTP exporter exporter, err := otlploghttp.New(ctx, otlploghttp.WithEndpoint("us.i.posthog.com"), otlploghttp.WithURLPath("/i/v1/logs"), otlploghttp.WithHeaders(map[string]string{ "Authorization": "Bearer ", }), ) if err != nil { panic(err) } // you could also set this outside your application os.Setenv("OTEL_SERVICE_NAME", "my-service") stdoutExporter, _ := stdoutlog.New() // Create logger provider loggerProvider := otellog.NewLoggerProvider( otellog.WithProcessor(otellog.NewBatchProcessor(exporter)), // optional, also log to stdout otellog.WithProcessor(otellog.NewSimpleProcessor(stdoutExporter)), ) defer func() { loggerProvider.Shutdown(context.Background()) }() global.SetLoggerProvider(loggerProvider) slog.SetDefault(otelslog.NewLogger("")) log.Println("this is a log line") } ``` ```go otlploghttp.WithURLPath("/i/v1/logs?token=") ``` -------------------------------- ### GET /api/projects/{project_id}/elements/ Source: https://posthog.com/docs/open-api-spec/elements_list Retrieves a paginated list of elements within a specified project. You can control the number of results and the starting offset. ```APIDOC ## GET /api/projects/{project_id}/elements/ ### Description Retrieves a paginated list of elements within a specified project. You can control the number of results and the starting offset. ### Method GET ### Endpoint /api/projects/{project_id}/elements/ ### Parameters #### Path Parameters - **project_id** (string) - Required - Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/. #### Query Parameters - **limit** (integer) - Optional - Number of results to return per page. - **offset** (integer) - Optional - The initial index from which to return the results. ### Request Example ```json { "example": "Not applicable for GET request" } ``` ### Response #### Success Response (200) - **count** (integer) - The total number of elements. - **next** (string) - URL for the next page of results. - **previous** (string) - URL for the previous page of results. - **results** (array) - An array of element objects. - **text** (string) - The text content of the element. - **tag_name** (string) - The HTML tag name of the element. - **attr_class** (array) - An array of CSS classes applied to the element. - **href** (string) - The href attribute of the element (if applicable). - **attr_id** (string) - The id attribute of the element (if applicable). - **nth_child** (integer) - The nth-child position of the element. - **nth_of_type** (integer) - The nth-of-type position of the element. - **attributes** (object) - Other HTML attributes of the element. - **order** (integer) - The order of the element. #### Response Example ```json { "count": 123, "next": "http://api.example.org/accounts/?offset=400&limit=100", "previous": "http://api.example.org/accounts/?offset=200&limit=100", "results": [ { "text": "Example Text", "tag_name": "div", "attr_class": ["example-class"], "href": null, "attr_id": null, "nth_child": 1, "nth_of_type": 1, "attributes": {}, "order": 1 } ] } ``` ```