request

package
v7.0.0-rc9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComparePeriod

type ComparePeriod struct {
	// From is the start date and time for the ComparePeriod.
	From time.Time

	// To is the end date and time for the ComparePeriod.
	To time.Time
}

ComparePeriod is the start and end date for a previous period for the Request.

type Direction

type Direction string

Direction is a direction to sort results.

const (
	DirectionASC  Direction = "ASC"
	DirectionDESC Direction = "DESC"
)

type Filter

type Filter struct {
	Operator  Operator
	Dimension dimensions.Dimension
	Values    []any
	Filter    []Filter
}

Filter filters for a Dimension connected by a logical Operator.

type FunnelRequest

type FunnelRequest struct {
	// Ctx can be used to set a timeout or to cancel queries.
	Ctx context.Context

	// SiteID is the site ID for the request.
	SiteID uint64

	// Period is the period and timezone for the report.FunnelReport.
	Period Period

	// Filter filters the results for a report.FunnelReport per step.
	// Top-level filters are connected using the AND operator by default.
	// To use other operators, they need to be set in the Filter recursively.
	Filter [][]Filter

	// Options are optional fields for the FunnelRequest.
	Options *Options
}

FunnelRequest generates a funnel.

func (*FunnelRequest) Validate

func (r *FunnelRequest) Validate() []error

Validate validates the FunnelRequest and returns an error if a report.FunnelReport cannot be constructed for the specified fields.

type Operator

type Operator int

Operator is an operator for a Filter.

const (
	OperatorAnd Operator = iota
	OperatorOr
	OperatorNot

	OperatorIs
	OperatorIsNot
	OperatorContains
	OperatorContainsNot
	OperatorMatches
	OperatorMatchesNot
)

type Options

type Options struct {
	// Sample sets the sampling size.
	Sample uint
}

Options are optional fields for a Request.

type OrderBy

type OrderBy struct {
	// Dimension to sort the results by. Either this field or Metric must be set.
	Dimension dimensions.Dimension

	// Metric to sor the results by. Either this field or Dimension must be set.
	Metric metrics.Metric

	// Direction to sort the results by (DirectionASC or DirectionDESC).
	Direction Direction
}

OrderBy is used to sort a Request.

type Pagination

type Pagination struct {
	// Offset limits the number of results. Offset <= 0 means no offset.
	Offset int

	// Limit limits the number of results. Limit <= 0 means unlimited.
	Limit int
}

Pagination limits the number of results for a Report.

type Period

type Period struct {
	// From is the start date and time for the Period.
	From time.Time

	// To is the end date and time for the Period.
	To time.Time

	// Timezone is the timezone for the Request and Report.
	// It is set to UTC by default.
	Timezone *time.Location

	// WeekdayMode sets the start day of the week (WeekdayMonday or WeekdaySunday).
	// WeekdayMonday by default.
	WeekdayMode WeekdayMode

	// IncludeTime determines whether the From and To times should be included.
	IncludeTime bool

	// Compare is optional. When set, the query runs for both periods and results are merged.
	Compare *ComparePeriod
}

Period is the start and end date and time for the Request, as well as the timezone.

type Request

type Request struct {
	// Ctx can be used to set a timeout or to cancel queries.
	Ctx context.Context

	// SiteID is the site ID for the request.
	SiteID uint64

	// Period is the period and timezone for the report.Report.
	Period Period

	// Metrics is a list of result fields for the report.Report.
	Metrics []metrics.Metric

	// Dimensions is a list of attributes for the Request.
	Dimensions []dimensions.Dimension

	// Filter filters the results for a report.Report.
	// Top-level filters are connected using the AND operator by default.
	// To use other operators, they need to be set in the Filter recursively.
	Filter []Filter

	// OrderBy sorts the result fields of a report.Report.
	OrderBy []OrderBy

	// Pagination limits the number of results for a report.Report.
	Pagination *Pagination

	// Options are optional fields for the Request.
	Options *Options
}

Request generates a report.Report.

func (*Request) Validate

func (r *Request) Validate() []error

Validate validates the Request and returns an error if a report.Report cannot be constructed for the specified fields.

type WeekdayMode

type WeekdayMode int

WeekdayMode sets the start day of the week (WeekdayMonday or WeekdaySunday).

var (
	WeekdayMonday WeekdayMode = 1
	WeekdaySunday WeekdayMode = 2
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL