Files
sdk/api_event.go

1770 lines
71 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
Hanzo Cloud API
The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
API version: v1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hanzoai
import (
"bytes"
"context"
"io"
"net/http"
"net/url"
"os"
"strings"
)
// EventAPIService EventAPI service
type EventAPIService service
type EventAPIGetEventEconomicRequest struct {
ctx context.Context
ApiService *EventAPIService
year *int64
counterparty *string
rail *string
cursor *string
limit *int64
}
// Year is the calendar year to read, UTC.
func (r EventAPIGetEventEconomicRequest) Year(year int64) EventAPIGetEventEconomicRequest {
r.year = &year
return r
}
// Counterparty keeps only payments with this org on the other side.
func (r EventAPIGetEventEconomicRequest) Counterparty(counterparty string) EventAPIGetEventEconomicRequest {
r.counterparty = &counterparty
return r
}
// Rail keeps only payments that moved on this rail.
func (r EventAPIGetEventEconomicRequest) Rail(rail string) EventAPIGetEventEconomicRequest {
r.rail = &rail
return r
}
// Cursor continues from the next of the page before; empty starts the year.
func (r EventAPIGetEventEconomicRequest) Cursor(cursor string) EventAPIGetEventEconomicRequest {
r.cursor = &cursor
return r
}
// Limit is how many events to answer, default 100 and at most 1000.
func (r EventAPIGetEventEconomicRequest) Limit(limit int64) EventAPIGetEventEconomicRequest {
r.limit = &limit
return r
}
func (r EventAPIGetEventEconomicRequest) Execute() (*EventEconomics, *http.Response, error) {
return r.ApiService.GetEventEconomicExecute(r)
}
/*
GetEventEconomic Returns, oldest first and paged, the payments the caller's org made or received in a year, with the ones a correction restates named and what either party disputes — for the org's admins.
Returns, oldest first and paged, the payments the caller's org made or received in
a year, with the ones a correction restates named and what either party disputes
— for the org's admins.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return EventAPIGetEventEconomicRequest
*/
func (a *EventAPIService) GetEventEconomic(ctx context.Context) EventAPIGetEventEconomicRequest {
return EventAPIGetEventEconomicRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return EventEconomics
func (a *EventAPIService) GetEventEconomicExecute(r EventAPIGetEventEconomicRequest) (*EventEconomics, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *EventEconomics
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EventAPIService.GetEventEconomic")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/event/economic"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.year == nil {
return localVarReturnValue, nil, reportError("year is required and must be specified")
}
parameterAddToHeaderOrQuery(localVarQueryParams, "year", r.year, "form", "")
if r.counterparty != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "counterparty", r.counterparty, "form", "")
}
if r.rail != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "rail", r.rail, "form", "")
}
if r.cursor != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "cursor", r.cursor, "form", "")
}
if r.limit != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type EventAPIGetEventErrorsRequest struct {
ctx context.Context
ApiService *EventAPIService
limit *int64
}
// Limit is how many rows to return, newest first. Default 50, maximum 200; a value at or below zero, or one that is not a number, takes the default.
func (r EventAPIGetEventErrorsRequest) Limit(limit int64) EventAPIGetEventErrorsRequest {
r.limit = &limit
return r
}
func (r EventAPIGetEventErrorsRequest) Execute() (*EventErrorList, *http.Response, error) {
return r.ApiService.GetEventErrorsExecute(r)
}
/*
GetEventErrors Returns the caller org's most recently captured errors, newest first.
Returns the caller org's most recently captured errors, newest first. The
error-tracking read view over event.error — the plane table the write core's error
facts land in (errors are DELIBERATELY not on event.event) — each with its captured
exception surfaced from the attributes map as a first-class field.
The org is the validated principal's — never a parameter — and this read requires a
real bearer, NEVER the write-only publishable key: pk- can attribute a write and can
read nothing. 401 without a validated bearer, 503 when the warehouse is unreachable.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return EventAPIGetEventErrorsRequest
*/
func (a *EventAPIService) GetEventErrors(ctx context.Context) EventAPIGetEventErrorsRequest {
return EventAPIGetEventErrorsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return EventErrorList
func (a *EventAPIService) GetEventErrorsExecute(r EventAPIGetEventErrorsRequest) (*EventErrorList, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *EventErrorList
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EventAPIService.GetEventErrors")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/event/errors"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.limit != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type EventAPIGetEventHealthRequest struct {
ctx context.Context
ApiService *EventAPIService
}
func (r EventAPIGetEventHealthRequest) Execute() (*EventHealthReport, *http.Response, error) {
return r.ApiService.GetEventHealthExecute(r)
}
/*
GetEventHealth Reports whether the event plane can take a write and the warehouse can answer a read.
Reports whether the event plane can take a write and the warehouse can
answer a read.
It reports the analytics subsystem's own liveness in BOTH directions: plane is
the event plane it WRITES (the bus and the JetStream stream every accepted
event is published to, both named in the report), and datastore is the
warehouse it READS, with each read lens's table reported as it is provisioned
(the LLM usage ledger and the product-event table).
EITHER ONE DOWN IS A 503, and the report says WHICH — they are probed
independently and never collapse into a single bit. A readiness gate on this
endpoint therefore gates on the write path as well as the read path: it
answers ready only when POST /v1/event can publish.
plane.ready IS A REAL PROBE and walks the ingest path itself — the same
connection and the same stream a publish uses — so it cannot answer ready while
a publish would 503. plane.reason carries the plane's own error text when it is
false.
datastore IS NOT PROBED WITH A QUERY. It is the state of the process's own
shared client — established, and not since closed — so a warehouse accepting
connections and failing reads still reports true. Degraded CARRIES the report
(status, the failing half, reason) as its body rather than an error envelope,
so a gate reads the cause off the same object it got at 200.
A MISSING LENS TABLE IS NOT A FAILURE and never moves the status: a lens
reported available:false answers honest-empty rather than erroring, so a fresh
deployment whose collector has not emitted yet is legitimately 200 with the
product-event lens unavailable. The lens block is reported whenever the
warehouse is REACHABLE — including on a report degraded by the plane, where the
tables genuinely were probed — and is absent only when the warehouse is not,
having nothing to say about tables it could not reach.
Unauthenticated on purpose — liveness has to be probe-able — and it reads NO
tenant data: table existence and stream presence only, never a row and never an
event.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return EventAPIGetEventHealthRequest
*/
func (a *EventAPIService) GetEventHealth(ctx context.Context) EventAPIGetEventHealthRequest {
return EventAPIGetEventHealthRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return EventHealthReport
func (a *EventAPIService) GetEventHealthExecute(r EventAPIGetEventHealthRequest) (*EventHealthReport, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *EventHealthReport
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EventAPIService.GetEventHealth")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/event/health"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 503 {
var v EventHealthReport
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type EventAPIGetEventInsightsEventsRequest struct {
ctx context.Context
ApiService *EventAPIService
limit *int64
impersonated *string
}
// Limit is how many rows to return, newest first. Default 50, maximum 200; a value at or below zero, or one that is not a number, takes the default.
func (r EventAPIGetEventInsightsEventsRequest) Limit(limit int64) EventAPIGetEventInsightsEventsRequest {
r.limit = &limit
return r
}
// Impersonated is which events to return against the mark a platform operator leaves acting as someone else: exclude (the default, the tenant's own traffic), include, or only. Anything else is a 400.
func (r EventAPIGetEventInsightsEventsRequest) Impersonated(impersonated string) EventAPIGetEventInsightsEventsRequest {
r.impersonated = &impersonated
return r
}
func (r EventAPIGetEventInsightsEventsRequest) Execute() (*EventEventList, *http.Response, error) {
return r.ApiService.GetEventInsightsEventsExecute(r)
}
/*
GetEventInsightsEvents Returns the caller org's most recent product events, newest first.
Returns the caller org's most recent product events, newest first.
The console's raw-event view over event.event — the same table the capture endpoints
fill — one row per stored event, with the row's attributes returned as the
properties object.
What a platform operator did acting as someone else is left out unless impersonated
asks for it; such a row carries impersonated and impersonated_by in its properties.
The org is the validated principal's — never a parameter — and a read requires a
real bearer, never the write-only publishable key. 401 without a validated bearer,
400 on an unknown impersonated value, 503 when the warehouse is unreachable.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return EventAPIGetEventInsightsEventsRequest
*/
func (a *EventAPIService) GetEventInsightsEvents(ctx context.Context) EventAPIGetEventInsightsEventsRequest {
return EventAPIGetEventInsightsEventsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return EventEventList
func (a *EventAPIService) GetEventInsightsEventsExecute(r EventAPIGetEventInsightsEventsRequest) (*EventEventList, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *EventEventList
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EventAPIService.GetEventInsightsEvents")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/event/insights/events"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.limit != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "")
}
if r.impersonated != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "impersonated", r.impersonated, "form", "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type EventAPIGetEventInsightsHealthRequest struct {
ctx context.Context
ApiService *EventAPIService
}
func (r EventAPIGetEventInsightsHealthRequest) Execute() (*EventInsightsStatus, *http.Response, error) {
return r.ApiService.GetEventInsightsHealthExecute(r)
}
/*
GetEventInsightsHealth Reports that the unified insights surface is serving.
Reports that the unified insights surface is serving. It reads no
tenant data and consults no dependency, so it answers 200 unconditionally and needs
no principal — liveness must be probe-able. The warehouse-connectivity probe is a
different question and lives at GET /v1/event/health.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return EventAPIGetEventInsightsHealthRequest
*/
func (a *EventAPIService) GetEventInsightsHealth(ctx context.Context) EventAPIGetEventInsightsHealthRequest {
return EventAPIGetEventInsightsHealthRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return EventInsightsStatus
func (a *EventAPIService) GetEventInsightsHealthExecute(r EventAPIGetEventInsightsHealthRequest) (*EventInsightsStatus, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *EventInsightsStatus
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EventAPIService.GetEventInsightsHealth")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/event/insights/health"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type EventAPIGetEventOverviewRequest struct {
ctx context.Context
ApiService *EventAPIService
range_ *string
start *string
end *string
impersonated *string
}
// Range is a relative window: a count and a unit — 24h, 7d, 90d, any <N>h or <N>d — or day, week, month, all. Default 24h. Ignored when both start and end are given. An unknown value, or one past the 730-day horizon, is a 400.
func (r EventAPIGetEventOverviewRequest) Range_(range_ string) EventAPIGetEventOverviewRequest {
r.range_ = &range_
return r
}
// Start is the inclusive lower bound of a custom window, RFC3339. Requires end.
func (r EventAPIGetEventOverviewRequest) Start(start string) EventAPIGetEventOverviewRequest {
r.start = &start
return r
}
// End is the exclusive upper bound of a custom window, RFC3339. Requires start.
func (r EventAPIGetEventOverviewRequest) End(end string) EventAPIGetEventOverviewRequest {
r.end = &end
return r
}
// Impersonated is which events the product-event lenses count against the mark a platform operator leaves acting as someone else: exclude (the default, the tenant's own traffic), include, or only. Anything else is a 400.
func (r EventAPIGetEventOverviewRequest) Impersonated(impersonated string) EventAPIGetEventOverviewRequest {
r.impersonated = &impersonated
return r
}
func (r EventAPIGetEventOverviewRequest) Execute() (*EventOverview, *http.Response, error) {
return r.ApiService.GetEventOverviewExecute(r)
}
/*
GetEventOverview Returns the caller org's analytics KPIs for one time window.
Returns the caller org's analytics KPIs for one time window. Three lenses
over one warehouse: llm is the live per-org LLM usage ledger (requests, tokens,
spend, models, providers, errors) and is always real; web (pageviews, visitors,
sessions) and commerce (orders, revenue, AOV) read the product-event table and
report available=false rather than fabricating zeros when it holds nothing yet.
The web and commerce lenses count the tenant's own traffic: what a platform
operator did while acting as someone else is left out unless impersonated asks for
it (include, or only). The LLM lens reads the usage ledger, which carries no such
mark, and counts every call.
The org is the validated principal's — never a parameter — so a caller can only
ever read its own tenant. 401 without a validated bearer, 400 on an unknown range
or impersonated value, 503 when the warehouse is unreachable.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return EventAPIGetEventOverviewRequest
*/
func (a *EventAPIService) GetEventOverview(ctx context.Context) EventAPIGetEventOverviewRequest {
return EventAPIGetEventOverviewRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return EventOverview
func (a *EventAPIService) GetEventOverviewExecute(r EventAPIGetEventOverviewRequest) (*EventOverview, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *EventOverview
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EventAPIService.GetEventOverview")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/event/overview"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.range_ != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "range", r.range_, "form", "")
}
if r.start != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "start", r.start, "form", "")
}
if r.end != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "end", r.end, "form", "")
}
if r.impersonated != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "impersonated", r.impersonated, "form", "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type EventAPIGetEventPixelByKeyRequest struct {
ctx context.Context
ApiService *EventAPIService
key string
}
func (r EventAPIGetEventPixelByKeyRequest) Execute() (*os.File, *http.Response, error) {
return r.ApiService.GetEventPixelByKeyExecute(r)
}
/*
GetEventPixelByKey A site's default pixel — a page view from an image, for a page that runs no script
Answers a transparent 1x1 GIF and records one page view for the project whose publishable key names the address:
<img src="https://api.hanzo.ai/v1/event/pixel/pk-….gif" alt="" width="1" height="1">
The page is `?u=` when given, else the Referer. The visitor is stamped from the request like every event, is one visitor for a day, and carries no cookie. Every view is recorded: it is the site's own first-party analytics. `?consent=analytics`, the visitor's choice as the embedding page knows it, is what it may be forwarded to Google Analytics under; Do-not-track and Global Privacy Control forward nothing, and a developer's own machine records nothing. The image is answered whatever happened to the view, with no-store.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param key
@return EventAPIGetEventPixelByKeyRequest
*/
func (a *EventAPIService) GetEventPixelByKey(ctx context.Context, key string) EventAPIGetEventPixelByKeyRequest {
return EventAPIGetEventPixelByKeyRequest{
ApiService: a,
ctx: ctx,
key: key,
}
}
// Execute executes the request
//
// @return *os.File
func (a *EventAPIService) GetEventPixelByKeyExecute(r EventAPIGetEventPixelByKeyRequest) (*os.File, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *os.File
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EventAPIService.GetEventPixelByKey")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/event/pixel/{key}"
localVarPath = strings.Replace(localVarPath, "{"+"key"+"}", url.PathEscape(parameterValueToString(r.key, "key")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"image/gif"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type EventAPIGetEventTagJsRequest struct {
ctx context.Context
ApiService *EventAPIService
}
func (r EventAPIGetEventTagJsRequest) Execute() (*os.File, *http.Response, error) {
return r.ApiService.GetEventTagJsExecute(r)
}
/*
GetEventTagJs The Hanzo event tag — the one-line install for a surface with no bundler
Serves the browser tag that autocaptures pageviews (initial and SPA) and uncaught errors onto the canonical wire at POST /v1/event.
Install is one line, and it is the same line for a Hanzo property and for a customer's own page:
<script defer src="https://api.hanzo.ai/v1/event/tag.js" data-key="pk-…"></script>
`data-key` is the publishable key the project mints; `data-product` optionally names the emitting surface. The key may also ride the src as `?key=` for a host that strips data attributes.
THE STREAM IS FIRST PARTY; THE THIRD PARTIES FOLLOW THE VISITOR'S REGION. Every page view, event, error and identify goes to the site's own stream for every visitor, under its anonymous id and session, whatever they chose and under Global Privacy Control or Do Not Track alike: it is the site's own analytics, never sold or shared. The rule for Google Analytics, the Meta pixel and the other platforms is the one GET /v1/project/tags serves for the visitor's region. `eu` (the EU, the EEA, the UK, Switzerland, and any visitor no edge placed): Google Analytics runs for everyone under Consent Mode v2 with all four flags denied (cookieless) and is upgraded by Performance and Targeted Advertising; Meta is init'ed after `fbq('consent','revoke')` and sends nothing until Marketing; no other platform loads before a choice. `us_privacy` (a US state with a privacy law, or no attested state) and `global`: everything runs at once under Consent Mode granted, and Targeted Advertising off is exactly `fbq('dataProcessingOptions',['LDU'],0,0)` and ad_storage, ad_user_data and ad_personalization denied. Under GPC or DNT no third party loads in any region, Google Analytics included. The choice is the `__Host-hz_consent` cookie, written by the @hanzo/ui consent banner or this tag's own, beside the version and the rule it was made under: `eu` counts only a choice made under `eu`, and the policy floor voids a choice's grants, never its refusals. Each event states the grants in force when it is sent, and that is what cloud may forward under.
`data-banner` draws Hanzo's consent design by region. In `eu`, for a visitor who has not chosen and whose browser has not refused: a card with Manage preferences, Accept all and a × that keeps essential cookies only, so refusing is as easy as accepting. In `global`, a notice ("We use cookies to improve your experience. By continuing to browse, you agree.") until the visitor closes it with ×. In `us_privacy`, no card: a "Your Privacy Choices" link with the opt-out icon at the foot of the page, unless the page carries its own (an element marked `data-hz-consent-link`). Manage preferences or the link opens the sheet — Strictly Necessary Cookies (always active, the site's own first-party analytics included), Performance (Google Analytics), Marketing (the Meta pixel), and Sell, Share, or Use Your Data for Targeted Advertising, each chosen apart; outside `eu` each is on by default and Targeted Advertising off is the opt-out. Withdrawing a category clears the third-party cookies it allowed, on every domain above the page, and never an essential one. The sheet links only the policies the page names: `data-cookies` its cookie policy, `data-banner`'s value its privacy policy, `data-terms` its terms. `window.hzConsent.open()` opens the sheet again from a page's own link.
WITHOUT A KEY THE TAG SENDS NOTHING. A keyless beacon is accepted 200 into $public, a reserved tenant the owning org cannot read — so silence is the honest failure, and the tag picks it rather than reporting success into a tenant nobody reads.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return EventAPIGetEventTagJsRequest
*/
func (a *EventAPIService) GetEventTagJs(ctx context.Context) EventAPIGetEventTagJsRequest {
return EventAPIGetEventTagJsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return *os.File
func (a *EventAPIService) GetEventTagJsExecute(r EventAPIGetEventTagJsRequest) (*os.File, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *os.File
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EventAPIService.GetEventTagJs")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/event/tag.js"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/javascript"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type EventAPIGetEventTimeseriesRequest struct {
ctx context.Context
ApiService *EventAPIService
range_ *string
start *string
end *string
}
// Range is a relative window: a count and a unit — 24h, 7d, 90d, any &lt;N&gt;h or &lt;N&gt;d — or day, week, month, all. Default 24h. Ignored when both start and end are given. An unknown value, or one past the 730-day horizon, is a 400.
func (r EventAPIGetEventTimeseriesRequest) Range_(range_ string) EventAPIGetEventTimeseriesRequest {
r.range_ = &range_
return r
}
// Start is the inclusive lower bound of a custom window, RFC3339. Requires end.
func (r EventAPIGetEventTimeseriesRequest) Start(start string) EventAPIGetEventTimeseriesRequest {
r.start = &start
return r
}
// End is the exclusive upper bound of a custom window, RFC3339. Requires start.
func (r EventAPIGetEventTimeseriesRequest) End(end string) EventAPIGetEventTimeseriesRequest {
r.end = &end
return r
}
func (r EventAPIGetEventTimeseriesRequest) Execute() (*EventTimeseries, *http.Response, error) {
return r.ApiService.GetEventTimeseriesExecute(r)
}
/*
GetEventTimeseries Returns the caller org's LLM usage over time as an evenly-spaced series.
Returns the caller org's LLM usage over time as an evenly-spaced series.
One point per hour or per day — the bucket the window implies, 24h giving hours and
7d/30d giving days — carrying requests, total tokens and spend in cents. Empty
buckets are filled with zeros so a client charts a continuous line.
The org is the validated principal's — never a parameter. 401 without a validated
bearer, 400 on an unknown range, 503 when the warehouse is unreachable.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return EventAPIGetEventTimeseriesRequest
*/
func (a *EventAPIService) GetEventTimeseries(ctx context.Context) EventAPIGetEventTimeseriesRequest {
return EventAPIGetEventTimeseriesRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return EventTimeseries
func (a *EventAPIService) GetEventTimeseriesExecute(r EventAPIGetEventTimeseriesRequest) (*EventTimeseries, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *EventTimeseries
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EventAPIService.GetEventTimeseries")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/event/timeseries"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.range_ != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "range", r.range_, "form", "")
}
if r.start != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "start", r.start, "form", "")
}
if r.end != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "end", r.end, "form", "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type EventAPIGetEventTopRequest struct {
ctx context.Context
ApiService *EventAPIService
range_ *string
start *string
end *string
limit *int64
impersonated *string
}
// Range is a relative window: a count and a unit — 24h, 7d, 90d, any &lt;N&gt;h or &lt;N&gt;d — or day, week, month, all. Default 24h. Ignored when both start and end are given. An unknown value, or one past the 730-day horizon, is a 400.
func (r EventAPIGetEventTopRequest) Range_(range_ string) EventAPIGetEventTopRequest {
r.range_ = &range_
return r
}
// Start is the inclusive lower bound of a custom window, RFC3339. Requires end.
func (r EventAPIGetEventTopRequest) Start(start string) EventAPIGetEventTopRequest {
r.start = &start
return r
}
// End is the exclusive upper bound of a custom window, RFC3339. Requires start.
func (r EventAPIGetEventTopRequest) End(end string) EventAPIGetEventTopRequest {
r.end = &end
return r
}
// Limit bounds every ranked lens in the response. Default 10, maximum 100; a value at or below zero, or one that is not a number, takes the default.
func (r EventAPIGetEventTopRequest) Limit(limit int64) EventAPIGetEventTopRequest {
r.limit = &limit
return r
}
// Impersonated is which events the product-event lenses count against the mark a platform operator leaves acting as someone else: exclude (the default, the tenant&#39;s own traffic), include, or only. Anything else is a 400.
func (r EventAPIGetEventTopRequest) Impersonated(impersonated string) EventAPIGetEventTopRequest {
r.impersonated = &impersonated
return r
}
func (r EventAPIGetEventTopRequest) Execute() (*EventTop, *http.Response, error) {
return r.ApiService.GetEventTopExecute(r)
}
/*
GetEventTop Returns the caller org's ranked lenses for one window, five of them at once.
Returns the caller org's ranked lenses for one window, five of them at once.
models ranks LLM models by spend and is always real; products ranks commerce orders
by revenue; topPages ranks requested paths, topReferrers the external referrer
domains ("(direct)" for a missing or same-origin one) and topSources the utm_source
campaigns ("(none)" when absent), each by pageviews. Every lens carries each row's
share of the in-window total, so a top-N honestly shows the long tail.
The four event lenses report available=false rather than fabricating zeros when the
product-event table holds nothing yet, and count the tenant's own traffic: what a
platform operator did acting as someone else is left out unless impersonated asks
for it (include, or only). Models reads the usage ledger, which carries no such
mark. The org is the validated principal's — never a parameter. 401 without a
validated bearer, 400 on an unknown range or impersonated value, 503 when the
warehouse is unreachable.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return EventAPIGetEventTopRequest
*/
func (a *EventAPIService) GetEventTop(ctx context.Context) EventAPIGetEventTopRequest {
return EventAPIGetEventTopRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return EventTop
func (a *EventAPIService) GetEventTopExecute(r EventAPIGetEventTopRequest) (*EventTop, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *EventTop
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EventAPIService.GetEventTop")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/event/top"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.range_ != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "range", r.range_, "form", "")
}
if r.start != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "start", r.start, "form", "")
}
if r.end != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "end", r.end, "form", "")
}
if r.limit != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "")
}
if r.impersonated != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "impersonated", r.impersonated, "form", "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type EventAPIPostEventRequest struct {
ctx context.Context
ApiService *EventAPIService
postEventRequest *PostEventRequest
}
func (r EventAPIPostEventRequest) PostEventRequest(postEventRequest PostEventRequest) EventAPIPostEventRequest {
r.postEventRequest = &postEventRequest
return r
}
func (r EventAPIPostEventRequest) Execute() (*CaptureResult, *http.Response, error) {
return r.ApiService.PostEventExecute(r)
}
/*
PostEvent Capture product events into your org's warehouse
Stores pageviews, browser errors, identifies and custom commerce events as rows in the caller's own tenant, and answers a receipt {accepted, dropped} that always totals what was sent — a beacon is never silently discarded.
THE STATUS SAYS WHETHER ANYTHING LANDED, so a green check can never mean an empty warehouse. 200 means at least one event was stored (or that nothing was sent), and a nonzero `dropped` beside a nonzero `accepted` is a PARTIAL batch, never a failed one — a batch is not refused whole for its worst element. If NOTHING was stored the request is an error, and it names the one thing that fixes it: 401 `ingest_key_required` when every event was refused for want of a credential (the same events land with a key), and 400 `unroutable_events` when the caller HAD capability and the body still named nothing storable.
ONE endpoint for every wire a Hanzo surface emits, dispatched by the SHAPE of the body and never by a second path: a bare event object, a bare array of them, the {batch:[…]} / {events:[…]} envelope, the team console's snake_case array, and the PostHog wire (spelled `distinct_id`/`api_key`, which the canonical wire never uses). BATCH IS A BODY, NOT A PATH — there is no /v1/event/batch, because an array already is one.
WHAT THE CALLER PRESENTS DECIDES WHAT IT MAY WRITE, and the endpoint itself grants nothing. A validated bearer or an org API key writes the full event at full fidelity. A PUBLISHABLE key (pk-, on Authorization: Bearer, x-hanzo-ingest-key, or ?ingest_key= for navigator.sendBeacon, which cannot set headers) does the same, and is the credential a browser bundle ships: it is deliberately NOT a secret, it resolves WHICH tenant a beacon belongs to and nothing more. A pk- never authenticates and can READ NOTHING — not this org's errors, not a lens, not any other route on this API — so a leaked one lets a stranger write into your stream, and never lets one read out of it. Reading these rows back always takes a real bearer. A Hanzo Team space token resolves its org at REDUCED capability: the signed account names the person, so a `distinctId` in the body cannot pin events on a colleague.
NO CREDENTIAL IS REFUSED: a write the server cannot attribute to a project is 401 `ingest_key_required`, and a credential that IS presented but resolves to no project is 403 `ingest_key_unknown`. Nothing is filed under a shared tenant — events nobody can read are worse than events nobody sent, because the caller is told it succeeded. A browser bundle therefore always ships a pk-, which is what /v1/event/tag.js takes.
THE STREAM IS FIRST PARTY. Every visitor's events are kept — page views, events, errors, identifies and the anonymous id — whatever they chose and under Global Privacy Control or Do Not Track alike: it is the org's own analytics, never sold or shared. Consent governs the third parties alone. Each event states the categories its visitor allowed in its `consent` property (`analytics,marketing,ads`), and that is all it may be forwarded under: Google Analytics needs analytics, the Meta pixel marketing, ad personalization ads. GPC or DNT on the request forwards nothing in any region (`consent_mode`: eu, us_privacy or global, from the country and US state the edge attests), whatever the event stated, and is stamped `refused`.
A REDUCED principal — a Hanzo Team space token — writes through the PROJECTION into its own org: narrowed to what the SERVER can name (pageviews and errors, plus the closed autocapture vocabulary $click, $input, $change, $submit, $view), where every one of those names is resolved through a server-owned table and stored as that table's value, so the name on the wire is never the name in the row. Stripped, too, to the fields the projection names, so revenue, personId, groupId and every property but the element annotation cannot reach a row — and an exception is carried only on an error, never on an interaction, so a click cannot ship a stack trace into a row's attributes. It does NOT name the person: the signed account is the identity, so a `distinctId` in the body cannot pin events on a colleague. Everything refused is counted in `dropped`.
The projected lane alone is bounded: 413 over 64 KiB, 400 over 50 events, 429 on the per-client-IP and per-peer caps. Two stored values carry their own bounds on top, because a request cap does not bound one value: an element annotation over 2 KiB (or a trail over 32 steps) and an exception class over 256 bytes are dropped from the row, which still lands. Authenticated bodies are offered to the observability plane first, which claims LLM-observability ingestion batches and declines everything else.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return EventAPIPostEventRequest
*/
func (a *EventAPIService) PostEvent(ctx context.Context) EventAPIPostEventRequest {
return EventAPIPostEventRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return CaptureResult
func (a *EventAPIService) PostEventExecute(r EventAPIPostEventRequest) (*CaptureResult, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *CaptureResult
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EventAPIService.PostEvent")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/event"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.postEventRequest
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type EventAPIPostEventEconomicDisputeRequest struct {
ctx context.Context
ApiService *EventAPIService
eventDisputeIn *EventDisputeIn
}
func (r EventAPIPostEventEconomicDisputeRequest) EventDisputeIn(eventDisputeIn EventDisputeIn) EventAPIPostEventEconomicDisputeRequest {
r.eventDisputeIn = &eventDisputeIn
return r
}
func (r EventAPIPostEventEconomicDisputeRequest) Execute() (*EventEconomicDispute, *http.Response, error) {
return r.ApiService.PostEventEconomicDisputeExecute(r)
}
/*
PostEventEconomicDispute Records that the caller's org disputes one payment it is party to — for the org's admins.
Records that the caller's org disputes one payment it is party to — for the org's
admins. A dispute is a record both parties read beside the payment, and it changes
nothing about it: the amount, the parties and the tax year stay as the rail stated
them, because only the rail that moved the money restates a payment.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return EventAPIPostEventEconomicDisputeRequest
*/
func (a *EventAPIService) PostEventEconomicDispute(ctx context.Context) EventAPIPostEventEconomicDisputeRequest {
return EventAPIPostEventEconomicDisputeRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return EventEconomicDispute
func (a *EventAPIService) PostEventEconomicDisputeExecute(r EventAPIPostEventEconomicDisputeRequest) (*EventEconomicDispute, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *EventEconomicDispute
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EventAPIService.PostEventEconomicDispute")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/event/economic/dispute"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.eventDisputeIn == nil {
return localVarReturnValue, nil, reportError("eventDisputeIn is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.eventDisputeIn
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type EventAPIPostEventReplayRequest struct {
ctx context.Context
ApiService *EventAPIService
replayBody *ReplayBody
}
func (r EventAPIPostEventReplayRequest) ReplayBody(replayBody ReplayBody) EventAPIPostEventReplayRequest {
r.replayBody = &replayBody
return r
}
func (r EventAPIPostEventReplayRequest) Execute() (*CaptureResult, *http.Response, error) {
return r.ApiService.PostEventReplayExecute(r)
}
/*
PostEventReplay Record a session-replay snapshot batch
Accepts a batch of rrweb events from a browser recorder and hands it to the session-replay pipeline, which stores the recording and derives the session summary a player reads back.
ONE REQUEST IS ONE BATCH, and it is all-or-nothing: the recording is made durable before this answers, so a 200 {"accepted":1} means stored and never "buffered somewhere". There is no partial count, because a half-written recording is not a recording.
`sessionId` is REQUIRED and bounded — at most 70 characters of ASCII letters, digits or '-'. It is the key every batch of one visit is grouped and ordered by, so an id outside that grammar is refused 400 here rather than accepted and dropped further down. `windowId` separates two tabs of one session and `distinctId` attributes the recording to a person; both are optional. `events` is the rrweb batch, each element a raw eventWithTime object, carried VERBATIM — the summary (click, keypress and mouse-activity counts, size) is derived downstream from exactly these bytes, so nothing is re-encoded or dropped.
THE CALLER'S CREDENTIAL DECIDES THE TENANT, and the body never does: the recording lands in the org the presented credential resolves to. It takes the SAME credentials as /v1/event — a validated bearer, an org API key, or a publishable pk- key on Authorization: Bearer, x-hanzo-ingest-key or ?ingest_key= — so a browser bundle already holding a pk- for events needs nothing new to record. A caller that presents nothing is 401 `ingest_key_required`; one whose key resolves to no project is 403 `ingest_key_unknown`; a reduced principal (a Hanzo Team space token) is 403 `insufficient_capability`, because a full-fidelity screen recording has no projected form that is safe for a guest to write into a host org.
BOUNDS: 413 over 512 KiB of body, and that is the only bound on one batch — a recorder is expected to chunk a long session rather than send it whole, and the cap is the size one message can carry rather than an arbitrary number. 503 when the pipeline cannot take the batch: honest unavailability the caller can retry, never a 200 over a discarded recording.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return EventAPIPostEventReplayRequest
*/
func (a *EventAPIService) PostEventReplay(ctx context.Context) EventAPIPostEventReplayRequest {
return EventAPIPostEventReplayRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return CaptureResult
func (a *EventAPIService) PostEventReplayExecute(r EventAPIPostEventReplayRequest) (*CaptureResult, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *CaptureResult
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EventAPIService.PostEventReplay")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/event/replay"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.replayBody
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}