chore: import upstream snapshot with attribution
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
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
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
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,155 @@
|
||||
import type {
|
||||
AmplitudeUserActivityParams,
|
||||
AmplitudeUserActivityResponse,
|
||||
} from '@/tools/amplitude/types'
|
||||
import { getDashboardHost } from '@/tools/amplitude/utils'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const userActivityTool: ToolConfig<
|
||||
AmplitudeUserActivityParams,
|
||||
AmplitudeUserActivityResponse
|
||||
> = {
|
||||
id: 'amplitude_user_activity',
|
||||
name: 'Amplitude User Activity',
|
||||
description: 'Get the event stream for a specific user by their Amplitude ID.',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Amplitude API Key',
|
||||
},
|
||||
secretKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Amplitude Secret Key',
|
||||
},
|
||||
amplitudeId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Amplitude internal user ID',
|
||||
},
|
||||
offset: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Offset for pagination (default 0)',
|
||||
},
|
||||
limit: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Maximum number of events to return (default 1000, max 1000)',
|
||||
},
|
||||
direction: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Sort direction: "latest" or "earliest" (default: latest)',
|
||||
},
|
||||
dataResidency: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Data residency region: "us" (default) or "eu"',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const url = new URL(`${getDashboardHost(params.dataResidency)}/api/2/useractivity`)
|
||||
url.searchParams.set('user', params.amplitudeId.trim())
|
||||
if (params.offset) url.searchParams.set('offset', params.offset)
|
||||
if (params.limit) url.searchParams.set('limit', params.limit)
|
||||
if (params.direction) url.searchParams.set('direction', params.direction)
|
||||
return url.toString()
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Basic ${btoa(`${params.apiKey}:${params.secretKey}`)}`,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.error || `Amplitude User Activity API error: ${response.status}`)
|
||||
}
|
||||
|
||||
const events = (data.events ?? []).map(
|
||||
(e: Record<string, unknown>) =>
|
||||
({
|
||||
eventType: (e.event_type as string) ?? '',
|
||||
eventTime: (e.event_time as string) ?? '',
|
||||
eventProperties: (e.event_properties as Record<string, unknown>) ?? {},
|
||||
userProperties: (e.user_properties as Record<string, unknown>) ?? {},
|
||||
sessionId: (e.session_id as number) ?? null,
|
||||
platform: (e.platform as string) ?? null,
|
||||
country: (e.country as string) ?? null,
|
||||
city: (e.city as string) ?? null,
|
||||
}) as const
|
||||
)
|
||||
|
||||
const ud = data.userData as Record<string, unknown> | undefined
|
||||
const userData = ud
|
||||
? {
|
||||
userId: (ud.user_id as string) ?? null,
|
||||
canonicalAmplitudeId: (ud.canonical_amplitude_id as number) ?? null,
|
||||
numEvents: (ud.num_events as number) ?? null,
|
||||
numSessions: (ud.num_sessions as number) ?? null,
|
||||
platform: (ud.platform as string) ?? null,
|
||||
country: (ud.country as string) ?? null,
|
||||
firstUsed: (ud.first_used as string) ?? null,
|
||||
lastUsed: (ud.last_used as string) ?? null,
|
||||
}
|
||||
: null
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
events,
|
||||
userData,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
events: {
|
||||
type: 'array',
|
||||
description: 'List of user events',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
eventType: { type: 'string', description: 'Type of event' },
|
||||
eventTime: { type: 'string', description: 'Event timestamp' },
|
||||
eventProperties: { type: 'json', description: 'Custom event properties' },
|
||||
userProperties: { type: 'json', description: 'User properties at event time' },
|
||||
sessionId: { type: 'number', description: 'Session ID' },
|
||||
platform: { type: 'string', description: 'Platform' },
|
||||
country: { type: 'string', description: 'Country' },
|
||||
city: { type: 'string', description: 'City' },
|
||||
},
|
||||
},
|
||||
},
|
||||
userData: {
|
||||
type: 'json',
|
||||
description: 'User metadata',
|
||||
optional: true,
|
||||
properties: {
|
||||
userId: { type: 'string', description: 'External user ID' },
|
||||
canonicalAmplitudeId: { type: 'number', description: 'Canonical Amplitude ID' },
|
||||
numEvents: { type: 'number', description: 'Total event count' },
|
||||
numSessions: { type: 'number', description: 'Total session count' },
|
||||
platform: { type: 'string', description: 'Primary platform' },
|
||||
country: { type: 'string', description: 'Country' },
|
||||
firstUsed: { type: 'string', description: 'Date the user first appeared' },
|
||||
lastUsed: { type: 'string', description: 'Date of most recent user activity' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user