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
134 lines
3.7 KiB
TypeScript
134 lines
3.7 KiB
TypeScript
import type {
|
|
AmplitudeGetRevenueParams,
|
|
AmplitudeGetRevenueResponse,
|
|
} from '@/tools/amplitude/types'
|
|
import { getDashboardHost } from '@/tools/amplitude/utils'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const getRevenueTool: ToolConfig<AmplitudeGetRevenueParams, AmplitudeGetRevenueResponse> = {
|
|
id: 'amplitude_get_revenue',
|
|
name: 'Amplitude Get Revenue',
|
|
description: 'Get revenue LTV data including ARPU, ARPPU, total revenue, and paying user counts.',
|
|
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',
|
|
},
|
|
start: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Start date in YYYYMMDD format',
|
|
},
|
|
end: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'End date in YYYYMMDD format',
|
|
},
|
|
metric: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Metric: 0 (ARPU), 1 (ARPPU), 2 (Total Revenue), 3 (Paying Users)',
|
|
},
|
|
interval: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Time interval: 1 (daily), 7 (weekly), or 30 (monthly)',
|
|
},
|
|
groupBy: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Property name to group by (limit: one)',
|
|
},
|
|
segment: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'JSON segment definition(s) applied to the query',
|
|
},
|
|
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/revenue/ltv`)
|
|
url.searchParams.set('start', params.start)
|
|
url.searchParams.set('end', params.end)
|
|
if (params.metric) url.searchParams.set('m', params.metric)
|
|
if (params.interval) url.searchParams.set('i', params.interval)
|
|
if (params.groupBy) url.searchParams.set('g', params.groupBy)
|
|
if (params.segment) url.searchParams.set('s', params.segment)
|
|
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 Revenue API error: ${response.status}`)
|
|
}
|
|
|
|
const result = data.data ?? {}
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
series: result.series ?? [],
|
|
seriesLabels: result.seriesLabels ?? [],
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
series: {
|
|
type: 'array',
|
|
description:
|
|
'Revenue data series [{dates: [YYYY-MM-DD], values: {<date>: {r1d..r90d, count, paid, total_amount}}}]',
|
|
items: {
|
|
type: 'json',
|
|
properties: {
|
|
dates: {
|
|
type: 'array',
|
|
description: 'Dates covered by this series',
|
|
items: { type: 'string' },
|
|
},
|
|
values: {
|
|
type: 'json',
|
|
description:
|
|
'Per-date metric values keyed by date (r1d..r90d, count, paid, total_amount)',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
seriesLabels: {
|
|
type: 'array',
|
|
description: 'Labels for each data series',
|
|
items: { type: 'string' },
|
|
},
|
|
},
|
|
}
|