d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (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 / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
121 lines
3.7 KiB
TypeScript
121 lines
3.7 KiB
TypeScript
import type {
|
|
AmplitudeUserProfileParams,
|
|
AmplitudeUserProfileResponse,
|
|
} from '@/tools/amplitude/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const userProfileTool: ToolConfig<AmplitudeUserProfileParams, AmplitudeUserProfileResponse> =
|
|
{
|
|
id: 'amplitude_user_profile',
|
|
name: 'Amplitude User Profile',
|
|
description:
|
|
'Get a user profile including properties, cohort memberships, and computed properties. Not available for EU data-residency projects.',
|
|
version: '1.0.0',
|
|
|
|
params: {
|
|
secretKey: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'Amplitude Secret Key',
|
|
},
|
|
userId: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'External user ID (required if no device_id)',
|
|
},
|
|
deviceId: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Device ID (required if no user_id)',
|
|
},
|
|
getAmpProps: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Include Amplitude user properties (true/false, default: false)',
|
|
},
|
|
getCohortIds: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Include cohort IDs the user belongs to (true/false, default: false)',
|
|
},
|
|
getComputations: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Include computed user properties (true/false, default: false)',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params) => {
|
|
const url = new URL('https://profile-api.amplitude.com/v1/userprofile')
|
|
if (params.userId) url.searchParams.set('user_id', params.userId.trim())
|
|
if (params.deviceId) url.searchParams.set('device_id', params.deviceId.trim())
|
|
if (params.getAmpProps) url.searchParams.set('get_amp_props', params.getAmpProps)
|
|
if (params.getCohortIds) url.searchParams.set('get_cohort_ids', params.getCohortIds)
|
|
if (params.getComputations) url.searchParams.set('get_computations', params.getComputations)
|
|
return url.toString()
|
|
},
|
|
method: 'GET',
|
|
headers: (params) => ({
|
|
Authorization: `Api-Key ${params.secretKey}`,
|
|
}),
|
|
},
|
|
|
|
transformResponse: async (response: Response) => {
|
|
const data = await response.json()
|
|
|
|
if (!response.ok) {
|
|
throw new Error(data.error || `Amplitude User Profile API error: ${response.status}`)
|
|
}
|
|
|
|
const userData = data.userData ?? {}
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
userId: (userData.user_id as string) ?? null,
|
|
deviceId: (userData.device_id as string) ?? null,
|
|
ampProps: (userData.amp_props as Record<string, unknown>) ?? null,
|
|
cohortIds: (userData.cohort_ids as string[]) ?? null,
|
|
computations: (userData.computations as Record<string, unknown>) ?? null,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
userId: {
|
|
type: 'string',
|
|
description: 'External user ID',
|
|
optional: true,
|
|
},
|
|
deviceId: {
|
|
type: 'string',
|
|
description: 'Device ID',
|
|
optional: true,
|
|
},
|
|
ampProps: {
|
|
type: 'json',
|
|
description:
|
|
'Amplitude user properties (library, first_used, last_used, custom properties)',
|
|
optional: true,
|
|
},
|
|
cohortIds: {
|
|
type: 'array',
|
|
description: 'List of cohort IDs the user belongs to',
|
|
optional: true,
|
|
items: { type: 'string' },
|
|
},
|
|
computations: {
|
|
type: 'json',
|
|
description: 'Computed user properties',
|
|
optional: true,
|
|
},
|
|
},
|
|
}
|