6bf8bebf51
CI / Test and Build (push) Failing after 1s
CI / Migrate Dev DB (push) Has been skipped
CI / Migrate DB (push) Has been skipped
CodeQL / Analyze actions (push) Has been cancelled
CodeQL / Analyze javascript-typescript (push) Has been cancelled
CI / Detect Version (push) Has been cancelled
CI / Detect Desktop Changes (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/cron.Dockerfile, ubuntu-latest, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build AMD64 (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/cron.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/db.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/pii.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/realtime.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-8vcpu-ubuntu-2404-arm, ./docker/app.Dockerfile, linux-arm64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
Helm Chart / Lint, test, and validate chart (push) Has been cancelled
Helm Chart / Chart version bumped (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Build Dev ECR (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core) (push) Has been cancelled
CI / Promote Images (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Check Desktop Signing Secrets (push) Has been cancelled
CI / Desktop Release (push) Has been cancelled
CI / Create Desktop Prerelease (push) Has been cancelled
CI / Desktop Prerelease Build (push) Has been cancelled
CI / Publish Desktop Prerelease (push) Has been cancelled
CI / Prune Desktop Prereleases (push) Has been cancelled
Helm Chart / Install on kind and run helm test (push) Has been cancelled
142 lines
4.7 KiB
TypeScript
142 lines
4.7 KiB
TypeScript
import { getPostHogAppBaseUrl } from '@/tools/posthog/utils'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export interface PostHogListProjectsParams {
|
|
apiKey: string
|
|
region?: 'us' | 'eu'
|
|
host?: string
|
|
}
|
|
|
|
interface PostHogProject {
|
|
id: number
|
|
uuid: string
|
|
organization: string
|
|
api_token: string
|
|
app_urls: string[]
|
|
name: string
|
|
slack_incoming_webhook: string
|
|
created_at: string
|
|
updated_at: string
|
|
anonymize_ips: boolean
|
|
completed_snippet_onboarding: boolean
|
|
ingested_event: boolean
|
|
test_account_filters: any[]
|
|
is_demo: boolean
|
|
timezone: string
|
|
data_attributes: string[]
|
|
}
|
|
|
|
export interface PostHogListProjectsResponse {
|
|
success: boolean
|
|
output: {
|
|
projects: PostHogProject[]
|
|
}
|
|
error?: string
|
|
}
|
|
|
|
export const listProjectsTool: ToolConfig<PostHogListProjectsParams, PostHogListProjectsResponse> =
|
|
{
|
|
id: 'posthog_list_projects',
|
|
name: 'PostHog List Projects',
|
|
description:
|
|
'List all projects in the organization. Returns project details including IDs, names, API tokens, and settings. Useful for getting project IDs needed by other endpoints.',
|
|
version: '1.0.0',
|
|
errorExtractor: 'posthog-errors',
|
|
|
|
params: {
|
|
apiKey: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'PostHog Personal API Key',
|
|
},
|
|
region: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-only',
|
|
description: 'Cloud region: us or eu (default: us)',
|
|
},
|
|
host: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-only',
|
|
description:
|
|
'Self-hosted PostHog instance host (e.g., "posthog.mycompany.com"). Overrides the region setting when provided.',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params) => {
|
|
const baseUrl = getPostHogAppBaseUrl(params.region, params.host)
|
|
return `${baseUrl}/api/projects/`
|
|
},
|
|
method: 'GET',
|
|
headers: (params) => ({
|
|
Authorization: `Bearer ${params.apiKey}`,
|
|
'Content-Type': 'application/json',
|
|
}),
|
|
},
|
|
|
|
transformResponse: async (response: Response) => {
|
|
const data = await response.json()
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
projects: (data.results || []).map((project: any) => ({
|
|
id: project.id,
|
|
uuid: project.uuid,
|
|
organization: project.organization,
|
|
api_token: project.api_token,
|
|
app_urls: project.app_urls || [],
|
|
name: project.name,
|
|
slack_incoming_webhook: project.slack_incoming_webhook,
|
|
created_at: project.created_at,
|
|
updated_at: project.updated_at,
|
|
anonymize_ips: project.anonymize_ips,
|
|
completed_snippet_onboarding: project.completed_snippet_onboarding,
|
|
ingested_event: project.ingested_event,
|
|
test_account_filters: project.test_account_filters || [],
|
|
is_demo: project.is_demo,
|
|
timezone: project.timezone,
|
|
data_attributes: project.data_attributes || [],
|
|
})),
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
projects: {
|
|
type: 'array',
|
|
description: 'List of projects with their configuration and settings',
|
|
items: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'number', description: 'Project ID' },
|
|
uuid: { type: 'string', description: 'Project UUID' },
|
|
organization: { type: 'string', description: 'Organization UUID' },
|
|
api_token: { type: 'string', description: 'Project API token for ingestion' },
|
|
app_urls: { type: 'array', description: 'Allowed app URLs' },
|
|
name: { type: 'string', description: 'Project name' },
|
|
slack_incoming_webhook: {
|
|
type: 'string',
|
|
description: 'Slack webhook URL for notifications',
|
|
},
|
|
created_at: { type: 'string', description: 'Project creation timestamp' },
|
|
updated_at: { type: 'string', description: 'Last update timestamp' },
|
|
anonymize_ips: { type: 'boolean', description: 'Whether IP anonymization is enabled' },
|
|
completed_snippet_onboarding: {
|
|
type: 'boolean',
|
|
description: 'Whether snippet onboarding is completed',
|
|
},
|
|
ingested_event: { type: 'boolean', description: 'Whether any event has been ingested' },
|
|
test_account_filters: { type: 'array', description: 'Filters for test accounts' },
|
|
is_demo: { type: 'boolean', description: 'Whether this is a demo project' },
|
|
timezone: { type: 'string', description: 'Project timezone' },
|
|
data_attributes: { type: 'array', description: 'Custom data attributes' },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|