hits

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2025 License: MIT Imports: 4 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"`
	// PropertyID uses GA nomenclature. In other than GA protocols, it holds the analogous concept, like app, website, etc
	PropertyID         string            `cbor:"pi"`
	IP                 string            `cbor:"ip"`
	Host               string            `cbor:"h"`
	ServerReceivedTime string            `cbor:"srt"`
	QueryParams        url.Values        `cbor:"qp"`
	Body               []byte            `cbor:"bd"`
	Path               string            `cbor:"p"`
	Method             string            `cbor:"m"`
	Headers            url.Values        `cbor:"he"`
	Metadata           map[string]string `cbor:"md"`
	Timestamp          time.Time         `cbor:"ts"`
	UserID             *string           `cbor:"uid"`
}

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 (*Hit) Copy

func (h *Hit) Copy() Hit

Copy creates a deep copy of the Hit

func (*Hit) SessionStamp

func (h *Hit) SessionStamp() string

SessionStamp returns a unique identifier for the session

func (*Hit) Size

func (h *Hit) Size() uint32

Size returns the total byte size of the Hit struct including all its fields

type HitProcessingTask

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

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

Jump to

Keyboard shortcuts

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