analytics

package
v0.0.0-...-f7e086a Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UpdateAnalyticsBQSchema

func UpdateAnalyticsBQSchema(ctx context.Context, project, dataset, table string) error

UpdateAnalyticsBQSchema updates the bigquery schema if fields are added.

func WriteAnalyticsToBigQuery

func WriteAnalyticsToBigQuery(ctx context.Context, project, dataset, table string, data []*WebVital) error

WriteAnalyticsToBigQuery saves a webvital to bq.

Types

type WebVital

type WebVital struct {
	// The name of the metric (in acronym form).
	Name string `json:"name"`

	// The current value of the metric.
	Value float64 `json:"value"`

	// The delta between the current value and the last-reported value.
	// On the first report, `delta` and `value` will always be the same.
	Delta float64 `json:"delta"`

	// A unique ID representing this particular metric that's specific to the
	// current page. This ID can be used by an analytics tool to dedupe
	// multiple values sent for the same metric, or to group multiple deltas
	// together and calculate a total.
	ID string `json:"id"`

	// Type of metric (web-vital or custom).
	Label bigquery.NullString `json:"label"`

	// When we recorded this metric.
	Time bigquery.NullDateTime

	// What service this is for.
	Service bigquery.NullString
}

WebVital is a a version of https://web.dev/vitals/.

See also https://nextjs.org/docs/advanced-features/measuring-performance#build-your-own.

func ParseAnalytics

func ParseAnalytics(body, service string) (*WebVital, error)

ParseAnalytics parses a webvitals request body.

func (*WebVital) Validate

func (wv *WebVital) Validate() error

type WebVitalSummary

type WebVitalSummary struct {
	// The name of the metric (in acronym form).
	Name string `json:"name"`

	// The current value of the metric.
	Value float64 `json:"value"`

	Service string `json:"service"`

	Day bigquery.NullDate `json:"date"`
}

func GetAnalytics

func GetAnalytics(ctx context.Context, site, project, dataset, table string) ([]*WebVitalSummary, error)

Jump to

Keyboard shortcuts

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