Documentation
¶
Overview ¶
Package analytics is the money and KPI screens of the hub (docs/hub/analytics.md). This part is the person's own view, /api/me/*: their money, their sessions and their KPI, in any organization or none.
Index ¶
- type AccountMoney
- type AccountView
- type AccountWindows
- type AccountsResponse
- type Change
- type ChangeMarker
- type ChangesResponse
- type Chats
- type Currency
- type DailyLine
- type DailySpend
- type DayMoney
- type DayValue
- type Deps
- type Effect
- type EffectResponse
- type EffectsResponse
- type Efficiency
- type EfficiencyRow
- type KpiSeries
- type KpiSeriesResponse
- type KpiValue
- type KpisResponse
- type LimitBar
- type LimitRequestEvent
- type LimitRequestResponse
- type LimitWindowsResponse
- type MRs
- type MachineRef
- type MachinesResponse
- type MeSession
- type MeSessionsResponse
- type MeStatsResponse
- type MeSwitchesResponse
- type MeUsageResponse
- type MeWeek
- type ModelMoney
- type Money
- type OverviewResponse
- type PeopleResponse
- type PeopleTotal
- type Period
- type PersonSpend
- type Reached
- type SeriesPoint
- type SeriesSplit
- type Service
- func (s *Service) CheckOrg(ctx context.Context, orgID string) error
- func (s *Service) Mount(mux *http.ServeMux)
- func (s *Service) RunLive(ctx context.Context, active func() []events.Listener)
- func (s *Service) Tick(ctx context.Context, active []events.Listener)
- func (s *Service) Trigger(orgID string)
- func (s *Service) UseEvents(p events.Publisher)
- func (s *Service) UseFeatures(g features.Gate)
- func (s *Service) UseLeader(leads func() bool)
- func (s *Service) UseMachines(m *machines.Service)
- func (s *Service) UseSwitches(g switches.Gate)
- type Signal
- type SignalAction
- type SignalEvent
- type SignalSubject
- type SignalsResponse
- type SpendResponse
- type SpendRow
- type SpendSum
- type SpendTotal
- type StatsDay
- type StatsReport
- type StatsRuntime
- type StatsSession
- type Subscription
- type SubscriptionShare
- type SubscriptionsResponse
- type Tile
- type Today
- type TodayPerson
- type Tokens
- type ToolCaller
- type ToolItem
- type ToolsResponse
- type UsageTick
- type WasteItem
- type WasteKind
- type WasteResponse
- type WindowCycleView
- type WindowHistory
- type WindowView
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountMoney ¶
type AccountView ¶
type AccountView struct {
ID string `json:"id"`
Label string `json:"label"`
Provider string `json:"provider"`
Kind string `json:"kind"`
Plan string `json:"plan"`
Funding string `json:"funding"`
MonthlyFee Money `json:"monthlyFee"`
Discovered bool `json:"discovered"`
Scope orgs.ScopeView `json:"scope"`
Owner *orgs.PersonRef `json:"owner"`
MonthList Money `json:"monthList"`
People []orgs.PersonRef `json:"people"`
CreatedAt string `json:"createdAt"`
}
AccountView is one account of GET …/accounts.
type AccountWindows ¶ added in v0.16.154
type AccountWindows struct {
AccountID string `json:"accountId"`
Label string `json:"label"`
Provider string `json:"provider"`
Plan string `json:"plan"`
Windows []WindowHistory `json:"windows"`
}
AccountWindows is the history of the windows of one account.
type AccountsResponse ¶
type AccountsResponse struct {
Currency Currency `json:"currency"`
Accounts []AccountView `json:"accounts"`
}
AccountsResponse is GET /api/orgs/{org}/accounts.
type Change ¶
type Change struct {
ID string `json:"id"`
Scope orgs.ScopeView `json:"scope"`
Kind string `json:"kind"`
Title string `json:"title"`
At string `json:"at"`
Author *orgs.PersonRef `json:"author"`
Source string `json:"source"`
Machines int `json:"machines"`
}
Change is Change of web/app/hub-api/analytics.ts.
type ChangeMarker ¶
type ChangeMarker struct {
ChangeID string `json:"changeId"`
At string `json:"at"`
Title string `json:"title"`
// Layer is the level the change was made at: org, tenant or team.
Layer string `json:"layer"`
// Author is who made the change; null for a detected one or a person who has gone.
Author *orgs.PersonRef `json:"author"`
// Icon is the mark to draw: edit (written by a person), rocket (a new version of a tool) or announce (anything else).
Icon string `json:"icon"`
Verdict *string `json:"verdict"`
}
ChangeMarker is a change on the chart, with the KPI's verdict over the change.
type ChangesResponse ¶
type ChangesResponse struct {
Changes []Change `json:"changes"`
}
ChangesResponse is the changes of a scope and its ancestors, oldest first.
type DailyLine ¶
type DailyLine struct {
Key string `json:"key"`
// USD at API prices.
Values []float64 `json:"values"`
}
DailyLine is one team's or model's spend, a value per day of DailySpend.Days.
type DailySpend ¶
type DailySpend struct {
Scope orgs.ScopeView `json:"scope"`
Period Period `json:"period"`
Split string `json:"split"`
// Days are the period's days, oldest first, YYYY-MM-DD in the organization's time zone.
Days []string `json:"days"`
Lines []DailyLine `json:"lines"`
// CmpTotalUSD is the comparison period's spend at API prices; null unless cmpFrom/cmpTo were asked.
CmpTotalUSD *float64 `json:"cmpTotalUsd"`
}
DailySpend is the answer of …/spend/daily.
type Deps ¶
type Deps struct {
DB *store.DB
// Gate wraps an endpoint in the session check and HUB_ORGS (orgs.Service.Gate).
Gate func(orgs.Handler) httpx.Handler
Log *slog.Logger
Now func() time.Time
// Rates is the exchange rate money is shown in; nil shows dollars.
Rates *rates.Book
// Cache is how long an answer of a heavy screen is served as it is (cache.go); zero computes every request.
Cache time.Duration
}
Deps are what the service is built from.
type Effect ¶
type Effect struct {
Kpi string `json:"kpi"`
Scope orgs.ScopeView `json:"scope"`
Before *float64 `json:"before"`
After *float64 `json:"after"`
Delta *float64 `json:"delta"`
Noise *float64 `json:"noise"`
NBefore int `json:"nBefore"`
NAfter int `json:"nAfter"`
Verdict string `json:"verdict"`
}
Effect is one KPI before and after a change.
type EffectResponse ¶
type EffectResponse struct {
Change Change `json:"change"`
Before Period `json:"before"`
After Period `json:"after"`
Overlaps []string `json:"overlaps"`
Effects []Effect `json:"effects"`
}
EffectResponse is the effect of a change on a scope.
type EffectsResponse ¶ added in v0.16.154
type EffectsResponse struct {
Effects []EffectResponse `json:"effects"`
}
EffectsResponse is the effect of every change of a list, in the list's order.
type Efficiency ¶
type Efficiency struct {
// Teams are the teams of the scope (and «Без команды» when it has sessions), the most tasks per person first.
Teams []EfficiencyRow `json:"teams"`
// Reached is the share of the scope's chats of 3 turns or more that made a merge request (the completion KPI).
Reached Reached `json:"reached"`
}
Efficiency is «Эффективность»: the tasks closed per person by team, and how many chats reach a result.
type EfficiencyRow ¶
type EfficiencyRow struct {
Key string `json:"key"`
Label string `json:"label"`
People int `json:"people"`
// Closed are the sessions of the team that ended in the period with a merge request.
Closed int `json:"closed"`
// PerPersonMonth is Closed ÷ People, per calendar month for a period of whole months and scaled to 30 days for
// any other; null without people.
PerPersonMonth *float64 `json:"perPersonMonth"`
Reached Reached `json:"reached"`
}
EfficiencyRow is one team.
type KpiSeriesResponse ¶
type KpiSeriesResponse struct {
Kpi string `json:"kpi"`
Unit string `json:"unit"`
By string `json:"by"`
Points []SeriesPoint `json:"points"`
Splits []SeriesSplit `json:"splits"`
Markers []ChangeMarker `json:"markers"`
}
KpiSeriesResponse is KpiSeriesResponse of web/app/hub-api/analytics.ts.
type KpiValue ¶
type KpiValue struct {
Kpi string `json:"kpi"`
Unit string `json:"unit"`
BetterWhen string `json:"betterWhen"`
Value *float64 `json:"value"`
N int `json:"n"`
CmpValue *float64 `json:"cmpValue"`
CmpN int `json:"cmpN"`
Delta *float64 `json:"delta"`
Noise *float64 `json:"noise"`
Verdict string `json:"verdict"`
// Spark is the value by day of the period (by week past 45 days), CmpSpark the same of the comparison; a bucket with
// too few sessions is null. They draw the small charts of the KPI cards.
Spark []*float64 `json:"spark,omitempty"`
CmpSpark []*float64 `json:"cmpSpark,omitempty"`
}
KpiValue is one KPI with its comparison.
type KpisResponse ¶
type KpisResponse struct {
Scope any `json:"scope"` // "me" or the organization's scope
Period Period `json:"period"`
CmpPeriod Period `json:"cmpPeriod"`
Kpis []KpiValue `json:"kpis"`
Series []KpiSeries `json:"series"`
}
KpisResponse is GET /api/me/kpis (scope 'me') and the organization's KPI.
type LimitBar ¶
type LimitBar struct {
RuleID string `json:"ruleId"`
Amount Money `json:"amount"`
Pct float64 `json:"pct"`
Status string `json:"status"`
SetBy *orgs.PersonRef `json:"setBy"`
}
LimitBar is the limit a row is held to.
type LimitRequestEvent ¶
type LimitRequestEvent struct {
SignalID string `json:"signalId"`
UserID string `json:"userId"`
Name string `json:"name"`
Scope struct {
Kind string `json:"kind"`
ID string `json:"id"`
} `json:"scope"`
}
LimitRequestEvent is the payload of limit.request: somebody asked for more.
type LimitRequestResponse ¶
type LimitRequestResponse struct {
Request struct {
ID string `json:"id"`
Status string `json:"status"`
To []orgs.PersonRef `json:"to"`
} `json:"request"`
}
LimitRequestResponse is the answer of POST /api/me/limit-requests.
type LimitWindowsResponse ¶ added in v0.16.154
type LimitWindowsResponse struct {
Scope orgs.ScopeView `json:"scope"`
Period Period `json:"period"`
Accounts []AccountWindows `json:"accounts"`
}
LimitWindowsResponse is GET …/limit-windows.
type MachineRef ¶
type MachinesResponse ¶
type MachinesResponse struct {
Scope orgs.ScopeView `json:"scope"`
Currency Currency `json:"currency"`
Machines []machines.HubMachine `json:"machines"`
}
MachinesResponse is GET …/machines (docs/hub/analytics.md, «Machines»).
type MeSession ¶
type MeSession struct {
SessionKey string `json:"sessionKey"`
Provider string `json:"provider"`
StartedAt string `json:"startedAt"`
EndedAt *string `json:"endedAt"`
Machine *MachineRef `json:"machine"`
Models []string `json:"models"`
List Money `json:"list"`
Paid Money `json:"paid"`
Funding string `json:"funding"`
Origin string `json:"origin"`
Turns int64 `json:"turns"`
MRs int64 `json:"mrs"`
Subagents int `json:"subagents"`
}
MeSession is a session of /api/me/sessions: its price and result, no text.
type MeSessionsResponse ¶
type MeSessionsResponse struct {
Currency Currency `json:"currency"`
Sessions []MeSession `json:"sessions"`
Next *string `json:"next"`
}
MeSessionsResponse is GET /api/me/sessions.
type MeStatsResponse ¶
type MeStatsResponse struct {
Viewer string `json:"viewer"`
Runtimes []StatsRuntime `json:"runtimes"`
}
MeStatsResponse is GET /api/me/stats.
type MeSwitchesResponse ¶
MeSwitchesResponse is GET /api/me/switches: which pages of the person read from the hub (rollout switches hub-stats and hub-projects, docs/hub/rollout-switches.md). A page asks once; off, it reads from the machine as before.
type MeUsageResponse ¶
type MeUsageResponse struct {
Period Period `json:"period"`
Currency Currency `json:"currency"`
AccountedUntil *string `json:"accountedUntil"`
Total struct {
List Money `json:"list"`
Paid Money `json:"paid"`
} `json:"total"`
ByDay []DayMoney `json:"byDay"`
ByModel []ModelMoney `json:"byModel"`
ByAccount []AccountMoney `json:"byAccount"`
}
MeUsageResponse is GET /api/me/usage.
type MeWeek ¶
MeWeek is GET /api/me/week: «Чатов за неделю» and «MR за неделю» of the member's overview.
type ModelMoney ¶
type OverviewResponse ¶
type OverviewResponse struct {
Scope orgs.ScopeView `json:"scope"`
Period Period `json:"period"`
Currency Currency `json:"currency"`
Spend SpendTotal `json:"spend"`
Tiles struct {
ActivePeople Tile `json:"activePeople"`
Sessions Tile `json:"sessions"`
MRs Tile `json:"mrs"`
MoneyPerMR Tile `json:"moneyPerMr"`
} `json:"tiles"`
Attention []Signal `json:"attention"`
// Today is the day's numbers with their 14-day strips, Efficiency the closed tasks per person and the chats that
// reached a result.
Today Today `json:"today"`
Efficiency Efficiency `json:"efficiency"`
SpendBy struct {
By string `json:"by"`
Rows []SpendRow `json:"rows"`
Totals SpendSum `json:"totals"`
} `json:"spendBy"`
Subscriptions []Subscription `json:"subscriptions"`
AccountedUntil *string `json:"accountedUntil"`
}
OverviewResponse is GET …/overview.
type PeopleResponse ¶
type PeopleResponse struct {
Scope orgs.ScopeView `json:"scope"`
Period Period `json:"period"`
Currency Currency `json:"currency"`
Total PeopleTotal `json:"total"`
Week Period `json:"week"`
People []PersonSpend `json:"people"`
}
PeopleResponse is GET …/people.
type PeopleTotal ¶
type PeopleTotal struct {
List Money `json:"list"`
Paid Money `json:"paid"`
Limit *LimitBar `json:"limit"`
// Tone is ok, warn (the limit used to 75%) or risk (90%); null without a limit.
Tone *string `json:"tone"`
}
PeopleTotal is the scope's spend with its own limit.
type PersonSpend ¶
type PersonSpend struct {
UserID string `json:"userId"`
Name string `json:"name"`
// Role is the person's role in the tenant of the scope ("" when they have none there).
Role string `json:"role"`
List Money `json:"list"`
Paid Money `json:"paid"`
Share *float64 `json:"share"`
// Limit is the person's own monthly limit with its use; null when they have none.
Limit *LimitBar `json:"limit"`
// Hot is whether the personal limit is used to hotPct or more.
Hot bool `json:"hot"`
// Chats and MRs are of the last week, as the member sees them.
Chats Chats `json:"chats"`
MRs MRs `json:"mrs"`
}
PersonSpend is one person of «Расход по людям».
type Reached ¶
Reached is a share of chats with the chats behind it; the value is null below minSessions of them.
type SeriesPoint ¶
SeriesPoint is one bucket of a KPI: its first day, its value (nil below minSessions) and its sessions.
type SeriesSplit ¶
type SeriesSplit struct {
Key string `json:"key"`
Label string `json:"label"`
Points []SeriesPoint `json:"points"`
}
SeriesSplit is the points of one team.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service serves the analytics endpoints.
func (*Service) CheckOrg ¶
CheckOrg runs the signal rules of one organization: it keeps what they find and resolves what they no longer do.
func (*Service) RunLive ¶
RunLive does the service's background work until ctx ends: the ticks, the triggered checks and the five-minute check. active lists the organizations and tenants somebody listens to (events.OrgBus.Active).
func (*Service) Tick ¶
Tick publishes usage.tick for every organization and tenant somebody is listening to. The numbers of the organization are for its administrators, those of a tenant for its leads and only on the stream of that tenant.
func (*Service) Trigger ¶
Trigger asks for the signal rules of an organization to run soon, after something happened that may change them (a machine went offline, a limit was set). Triggers within triggerAfter of each other are one run.
func (*Service) UseEvents ¶
UseEvents gives the service the organization's event bus; without it nothing is published.
func (*Service) UseFeatures ¶
UseFeatures gives the service the organizations' flags, which switch the signal checker on (ui.hx).
func (*Service) UseLeader ¶
UseLeader makes the checks of every organization (at the start and every five minutes) run only while leads says so: with several replicas, on the leader alone (docs/hub/replicas.md). The checks one replica triggers run there.
func (*Service) UseMachines ¶
UseMachines gives the service the machines that build the list's rows; without them the list does not exist.
func (*Service) UseSwitches ¶
UseSwitches gives the rollout switches GET /api/me/switches tells the page of; without them every one is off.
type Signal ¶
type Signal struct {
ID string `json:"id"`
Rule string `json:"rule"`
Severity string `json:"severity"`
Scope orgs.ScopeView `json:"scope"`
Subject SignalSubject `json:"subject"`
Title string `json:"title"`
Detail string `json:"detail"`
FirstAt string `json:"firstAt"`
LastAt string `json:"lastAt"`
SnoozedUntil *string `json:"snoozedUntil"`
Escalated bool `json:"escalated"`
Action *SignalAction `json:"action"`
}
Signal is one line of «Требует внимания».
type SignalAction ¶
type SignalAction struct {
Kind string `json:"kind"`
Label string `json:"label"`
Target string `json:"target,omitempty"`
// raise_limit, open_kpi
Scope orgs.ScopeView `json:"scope"`
// raise_limit
UserID *string `json:"userId"`
// move_account
FromAccountID string `json:"fromAccountId,omitempty"`
ToAccountID string `json:"toAccountId,omitempty"`
// open_machine, open_chat
MachineID string `json:"machineId,omitempty"`
// resend_invite
InviteID string `json:"inviteId,omitempty"`
TenantID string `json:"tenantId,omitempty"`
// register_account
AccountID string `json:"accountId,omitempty"`
// open_kpi
KPI string `json:"kpi,omitempty"`
// open_chat
SessionKey string `json:"sessionKey,omitempty"`
// open_prices
Model string `json:"model,omitempty"`
}
SignalAction is the one button of a signal. Which fields it carries depends on Kind (the variants of SignalAction in web/app/hub-api/analytics.ts); Target is the id of the object the button leads to, for every kind.
func (SignalAction) MarshalJSON ¶
func (a SignalAction) MarshalJSON() ([]byte, error)
MarshalJSON writes the fields of the kind's variant only.
type SignalEvent ¶
type SignalEvent struct {
Signal Signal `json:"signal"`
}
SignalEvent is the payload of signal.new.
type SignalSubject ¶
type SignalSubject struct {
Kind string `json:"kind"`
ID string `json:"id"`
Label string `json:"label"`
}
SignalSubject is what a signal is about.
type SignalsResponse ¶
type SignalsResponse struct {
Signals []Signal `json:"signals"`
}
SignalsResponse is GET …/signals.
type SpendResponse ¶
type SpendResponse struct {
Scope orgs.ScopeView `json:"scope"`
By string `json:"by"`
Period Period `json:"period"`
Currency Currency `json:"currency"`
Total SpendTotal `json:"total"`
Rows []SpendRow `json:"rows"`
AccountedUntil *string `json:"accountedUntil"`
}
SpendResponse is GET …/spend.
type SpendRow ¶
type SpendRow struct {
Key string `json:"key"`
Label string `json:"label"`
List Money `json:"list"`
Paid Money `json:"paid"`
Calls int64 `json:"calls"`
UnpricedCalls int64 `json:"unpricedCalls"`
Tokens Tokens `json:"tokens"`
Limit *LimitBar `json:"limit"`
Forecast *Money `json:"forecast"`
ForecastList *Money `json:"forecastList"`
}
SpendRow is one row of a spend breakdown.
type SpendSum ¶
type SpendSum struct {
List Money `json:"list"`
Paid Money `json:"paid"`
Tokens int64 `json:"tokens"`
}
SpendSum is the money and tokens of all rows of a breakdown: the base its shares are taken of, in any of the units.
type SpendTotal ¶
type SpendTotal struct {
List Money `json:"list"`
Paid Money `json:"paid"`
Limit *LimitBar `json:"limit"`
Forecast *Money `json:"forecast"`
ForecastList *Money `json:"forecastList"` // the same pace at API prices: next to the list spend the screens show
}
SpendTotal is the sum of the rows with the scope's own limit.
type StatsDay ¶
type StatsDay struct {
Prompts float64 `json:"prompts"`
Sessions float64 `json:"sessions"`
TurnMs float64 `json:"turnMs"`
Tools float64 `json:"tools"`
ToolErrors float64 `json:"toolErrors"`
Interrupts float64 `json:"interrupts"`
Denials float64 `json:"denials"`
Compactions float64 `json:"compactions"`
PRs float64 `json:"prs"`
Hours []float64 `json:"hours"`
}
StatsDay is one day's activity in the shape of a runtime's usage report (internal/usagereport). The hub keeps the sums of a session, not the moments inside it, so a session's turns, working time, tool calls and merge requests are counted on the day it started.
type StatsReport ¶
type StatsReport struct {
Version int `json:"version"`
Person string `json:"person"`
Machine string `json:"machine"`
GeneratedAt string `json:"generatedAt"`
Timezone string `json:"timezone"`
Days map[string]StatsDay `json:"days"`
Usage [][]any `json:"usage"`
Sessions []StatsSession `json:"sessions"`
Collecting any `json:"collecting"`
HubMissing []string `json:"hubMissing"`
}
StatsReport is the report the «Статистика» page reads (the answer of a runtime's <platform API>/stats, shape=report), made of the hub's facts. Usage rows are [day, provider, model, project, input, output, cacheRead, cacheWrite, costUsd, apiCalls]; the cost is the list price in dollars. HubMissing names the blocks of the page the hub holds no facts for.
type StatsRuntime ¶
type StatsRuntime struct {
Person string `json:"person"`
MachineID string `json:"machineId"`
MachineName string `json:"machineName"`
Report *StatsReport `json:"report"`
}
StatsRuntime and MeStatsResponse make the answer a team of one, as a runtime's own answer is.
type StatsSession ¶
type StatsSession struct {
ID string `json:"id"`
Provider string `json:"provider"`
Title *string `json:"title"`
Project *string `json:"project"`
Start float64 `json:"start"`
End float64 `json:"end"`
Prompts float64 `json:"prompts"`
TurnMs float64 `json:"turnMs"`
Input float64 `json:"input"`
Output float64 `json:"output"`
CacheRead float64 `json:"cacheRead"`
CacheWrite float64 `json:"cacheWrite"`
Cost float64 `json:"cost"`
SubagentCost float64 `json:"subagentCost"`
Model *string `json:"model"`
Tasks []string `json:"tasks"`
PRs []string `json:"prs"`
}
StatsSession is a session in the shape of a runtime report's session. Time is in seconds.
type Subscription ¶
type Subscription struct {
AccountID string `json:"accountId"`
Label string `json:"label"`
Provider string `json:"provider"`
Plan string `json:"plan"`
MonthlyFee Money `json:"monthlyFee"`
Preliminary bool `json:"preliminary"`
Windows []WindowView `json:"windows"`
}
Subscription is one subscription account.
type SubscriptionShare ¶
type SubscriptionShare struct {
}
SubscriptionShare is one person's part of a subscription's fee.
type SubscriptionsResponse ¶
type SubscriptionsResponse struct {
Scope orgs.ScopeView `json:"scope"`
Period Period `json:"period"`
Currency Currency `json:"currency"`
Subscriptions []Subscription `json:"subscriptions"`
}
SubscriptionsResponse is GET …/subscriptions.
type Tile ¶
type Tile struct {
Value *float64 `json:"value"`
CmpValue *float64 `json:"cmpValue"`
Unit string `json:"unit"`
}
Tile is one number of the overview with its comparison.
type Today ¶
type Today struct {
Day string `json:"day"`
Spend struct {
// Paid and List are the organization's money (funding 'org') since midnight of its zone; Tokens are the tokens
// of all funding of the scope, as usage.tick counts them.
Paid Money `json:"paid"`
List Money `json:"list"`
Tokens int64 `json:"tokens"`
} `json:"spend"`
Active struct {
// People had a live session going on today; Of is the people of the scope.
People int `json:"people"`
Of int `json:"of"`
// Who are all the people of the scope with their day, the working first, then by the last time they worked.
Who []TodayPerson `json:"who"`
} `json:"active"`
Tasks struct {
// Closed are the sessions that ended today with a merge request; InWork the chats going on now.
Closed int `json:"closed"`
InWork int `json:"inWork"`
} `json:"tasks"`
// Sparks are the last sparkDays days, oldest first, today included. spend is the day's dollars at API prices.
Sparks struct {
Spend []DayValue `json:"spend"`
Active []DayValue `json:"active"`
Tasks []DayValue `json:"tasks"`
} `json:"sparks"`
}
Today is the day of the scope: the money spent, the people at work and the tasks.
type TodayPerson ¶
type TodayPerson struct {
UserID string `json:"userId"`
Name string `json:"name"`
Email string `json:"email"`
// Working: a chat of theirs was heard from in the last minutes; Chats are their chats going on at some moment of today.
Working bool `json:"working"`
Chats int `json:"chats"`
// Closed are their chats that ended today with a merge request.
Closed int `json:"closed"`
// LastAt is when they last worked through a machine (any day; RFC 3339), null when never.
LastAt *string `json:"lastAt"`
// Paid and List are today's money of the organization's accounts by them; Tokens of all their funding.
Paid Money `json:"paid"`
List Money `json:"list"`
Tokens int64 `json:"tokens"`
}
TodayPerson is one person's day: the «Активны сегодня» tile opens the list of them.
type Tokens ¶
type Tokens struct {
// Total is the four kinds added up, for the «Токены» unit of the breakdowns.
Total int64 `json:"total"`
Input int64 `json:"input"`
Output int64 `json:"output"`
CacheRead int64 `json:"cacheRead"`
CacheWrite int64 `json:"cacheWrite"`
}
Tokens are a row's tokens.
type ToolCaller ¶ added in v0.16.154
type ToolCaller struct {
UserID string `json:"userId"`
Name string `json:"name"`
Calls int64 `json:"calls"`
Errors int64 `json:"errors"`
}
ToolCaller is one person's calls of a tool.
type ToolItem ¶ added in v0.16.154
type ToolItem struct {
Kind string `json:"kind"`
Name string `json:"name"`
ItemID string `json:"itemId,omitempty"`
Calls int64 `json:"calls"`
Errors int64 `json:"errors"`
// Users and Teams count who called it.
Users int `json:"users"`
Teams int `json:"teams"`
LastAt int64 `json:"lastAt"`
Days []int64 `json:"days"`
People []ToolCaller `json:"people"`
}
ToolItem is one tool (an MCP server, a skill or a built-in tool) over the period.
type ToolsResponse ¶ added in v0.16.154
type ToolsResponse struct {
Scope orgs.ScopeView `json:"scope"`
Period Period `json:"period"`
// Days are the period's days, the keys of every item's Days.
Days []string `json:"days"`
Calls int64 `json:"calls"`
Items []ToolItem `json:"items"`
}
ToolsResponse is GET …/tools.
type UsageTick ¶
type UsageTick struct {
SpendToday Money `json:"spendToday"`
TokensToday int64 `json:"tokensToday"`
ActiveNow int `json:"activeNow"`
ChatsNow int `json:"chatsNow"`
}
UsageTick is the payload of the usage.tick event: the numbers of «Сегодня» of the scope watched.
type WasteItem ¶
type WasteItem struct {
Kind WasteKind `json:"kind"`
Title string `json:"title"`
Amount Money `json:"amount"`
Money Money `json:"money"`
Sessions int `json:"sessions"`
Hint string `json:"hint"`
Explain string `json:"explain"`
}
WasteItem is one way money goes to waste. Title, Amount and Hint are the first version's fields and stay; Money is Amount under the name the screens use, and Explain says how the number was counted.
type WasteResponse ¶
type WasteResponse struct {
Scope orgs.ScopeView `json:"scope"`
Period Period `json:"period"`
Currency Currency `json:"currency"`
Items []WasteItem `json:"items"`
}
WasteResponse is GET …/waste.
type WindowCycleView ¶ added in v0.16.154
type WindowCycleView struct {
EndsAt string `json:"endsAt"`
PeakPct float64 `json:"peakPct"`
Measures int `json:"measures"`
}
WindowCycleView is one cycle of a window.
type WindowHistory ¶ added in v0.16.154
type WindowHistory struct {
Name string `json:"name"`
Scope string `json:"scope"`
LengthSec int64 `json:"lengthSec"`
// Cycles are oldest first.
Cycles []WindowCycleView `json:"cycles"`
// AvgPeakPct is the mean of the cycles' highest use; FullCycles the number that reached fullPct.
AvgPeakPct float64 `json:"avgPeakPct"`
FullCycles int `json:"fullCycles"`
}
WindowHistory is the cycles of one window of an account.
type WindowView ¶
type WindowView struct {
Name string `json:"name"`
Scope string `json:"scope"`
LengthSec int64 `json:"lengthSec"`
UsedPct *float64 `json:"usedPct"`
ResetsAt *string `json:"resetsAt"`
MeasuredAt string `json:"measuredAt"`
Confidence string `json:"confidence"`
Waiting bool `json:"waiting"`
ForecastFullAt *string `json:"forecastFullAt"`
}
WindowView is one measured rate-limit window of an account.