hits

package
v0.18.3 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package hits provides functionality for handling and processing tracking hits

Index

Constants

View Source
const HitProcessingTaskName = "process-hits"

HitProcessingTaskName is the name of the task used for processing hits

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientID

type ClientID string

ClientID represents an ID stored client-side. Be it cookie or device ID.

type Hit

type Hit struct {
	// Random UUID of every hit.
	ID string `cbor:"i"`
	// AuthoritativeClientID is the ID of first hit of a proto-session the current hit belongs to.
	// In normal cases this will be the same as ClientID, but if for example another client ID
	// will be mappend by a session stamp, the AuthoritativeClientID will change to the ClientID of the hit
	// that claimed the session stamp.
	// This ID should not be used for reporting and is only internal detail of the tracker.
	AuthoritativeClientID ClientID `cbor:"ai"`
	ClientID              ClientID `cbor:"ci"`
	EventName             string   `cbor:"en"`
	// PropertyID uses GA nomenclature. In other than GA protocols, it holds the analogous concept, like app, website, etc
	PropertyID string  `cbor:"pi"`
	UserID     *string `cbor:"uid"`

	Metadata map[string]string `cbor:"md"`
	Request  *ParsedRequest    `cbor:"sa"`
}

Hit stores information about a single `/collect` endpoint call

func New

func New() *Hit

New creates a new Hit with random ID and current time

func NewWithServerAttributes added in v0.18.0

func NewWithServerAttributes(serverAttributes *ParsedRequest) *Hit

NewWithServerAttributes creates a new Hit with the given ServerAttributes

func (*Hit) Copy

func (h *Hit) Copy() Hit

Copy creates a deep copy of the Hit

func (*Hit) MustParsedRequest added in v0.18.0

func (h *Hit) MustParsedRequest() *ParsedRequest

func (*Hit) Size

func (h *Hit) Size() uint32

Size returns the total byte size of the Hit struct including all its fields. This includes the struct itself, all string data, slice data, and map overhead.

type HitProcessingTask

type HitProcessingTask struct {
	Hits []*Hit `cbor:"h"`
}

HitProcessingTask represents a task containing a batch of hits to be processed

type ParsedRequest added in v0.18.0

type ParsedRequest struct {
	IP                 string      `cbor:"ip"`
	Host               string      `cbor:"h"`
	ServerReceivedTime time.Time   `cbor:"srt"`
	QueryParams        url.Values  `cbor:"qp"`
	Body               []byte      `cbor:"bd"`
	Path               string      `cbor:"p"`
	Method             string      `cbor:"m"`
	Headers            http.Header `cbor:"he"`
}

func (*ParsedRequest) Clone added in v0.18.0

func (s *ParsedRequest) Clone() *ParsedRequest

type ProtocolAttributes added in v0.18.0

type ProtocolAttributes struct {
	AuthoritativeClientID ClientID `cbor:"ai"`
	ClientID              ClientID `cbor:"ci"`
	EventName             string   `cbor:"en"`
	PropertyID            string   `cbor:"pi"`
	UserID                *string  `cbor:"uid"`
}

Jump to

Keyboard shortcuts

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