columns

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package columns provides generic column implementations for session data tracking.

Index

Constants

View Source
const (
	// EventPlatformWeb is a const value for core.d8a.tech/events/platform for events
	// received using web trackers
	EventPlatformWeb = "web"
	// EventPlatformMobile is a const value for core.d8a.tech/events/platform for events
	// received using mobile trackers
	EventPlatformMobile = "mobile"
	// EventPlatformServer is a const value for core.d8a.tech/events/platform for events
	// received using server trackers
	EventPlatformServer = "server"
)

Variables

View Source
var CoreInterfaces = struct {
	EventID                 schema.Interface
	EventName               schema.Interface
	EventTimestamp          schema.Interface
	EventDate               schema.Interface
	EventPageTitle          schema.Interface
	EventPageReferrer       schema.Interface
	EventPagePath           schema.Interface
	EventPageLocation       schema.Interface
	EventPageHostname       schema.Interface
	EventClientID           schema.Interface
	EventUserID             schema.Interface
	EventPropertyID         schema.Interface
	EventTrackingProtocol   schema.Interface
	EventPlatform           schema.Interface
	EventIPAddress          schema.Interface
	EventUtmMarketingTactic schema.Interface
	EventUtmSourcePlatform  schema.Interface
	EventUtmTerm            schema.Interface
	EventUtmContent         schema.Interface
	EventUtmSource          schema.Interface
	EventUtmMedium          schema.Interface
	EventUtmCampaign        schema.Interface
	EventUtmID              schema.Interface
	EventUtmCreativeFormat  schema.Interface
	SessionID               schema.Interface
	SessionDuration         schema.Interface
	SessionFirstEventTime   schema.Interface
	SessionLastEventTime    schema.Interface
	SessionTotalEvents      schema.Interface
	SSESessionHitNumber     schema.Interface
	SSESessionPageNumber    schema.Interface
	// Click ids
	EventClickIDGclid   schema.Interface
	EventClickIDDclid   schema.Interface
	EventClickIDSrsltid schema.Interface
	EventClickIDGbraid  schema.Interface
	EventClickIDWbraid  schema.Interface
	EventClickIDMsclkid schema.Interface

	// Device
	DeviceCategory               schema.Interface
	DeviceMobileBrandName        schema.Interface
	DeviceMobileModelName        schema.Interface
	DeviceOperatingSystem        schema.Interface
	DeviceOperatingSystemVersion schema.Interface
	DeviceLanguage               schema.Interface
	DeviceWebBrowser             schema.Interface
	DeviceWebBrowserVersion      schema.Interface

	// Geo
	GeoContinent    schema.Interface
	GeoCountry      schema.Interface
	GeoRegion       schema.Interface
	GeoCity         schema.Interface
	GeoSubContinent schema.Interface
	GeoMetro        schema.Interface
}{
	EventID: schema.Interface{
		ID:      "core.d8a.tech/events/id",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "event_id", Type: arrow.BinaryTypes.String},
	},
	EventName: schema.Interface{
		ID:      "core.d8a.tech/events/name",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "event_name", Type: arrow.BinaryTypes.String},
	},
	EventTimestamp: schema.Interface{
		ID:      "core.d8a.tech/events/timestamp",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "timestamp", Type: arrow.FixedWidthTypes.Timestamp_s},
	},
	EventDate: schema.Interface{
		ID:      "core.d8a.tech/events/date",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "event_date", Type: arrow.FixedWidthTypes.Date32},
	},
	EventPageTitle: schema.Interface{
		ID:      "core.d8a.tech/events/page_title",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "page_title", Type: arrow.BinaryTypes.String},
	},
	EventPageReferrer: schema.Interface{
		ID:      "core.d8a.tech/events/page_referrer",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "page_referrer", Type: arrow.BinaryTypes.String},
	},
	EventPagePath: schema.Interface{
		ID:      "core.d8a.tech/events/page_path",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "page_path", Type: arrow.BinaryTypes.String},
	},
	EventPageLocation: schema.Interface{
		ID:      "core.d8a.tech/events/page_location",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "page_location", Type: arrow.BinaryTypes.String},
	},
	EventPageHostname: schema.Interface{
		ID:      "core.d8a.tech/events/page_hostname",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "page_hostname", Type: arrow.BinaryTypes.String},
	},
	EventClientID: schema.Interface{
		ID:      "core.d8a.tech/events/client_id",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "client_id", Type: arrow.BinaryTypes.String},
	},
	EventUserID: schema.Interface{
		ID:      "core.d8a.tech/events/user_id",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "user_id", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	EventTrackingProtocol: schema.Interface{
		ID:      "core.d8a.tech/events/tracking_protocol",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "tracking_protocol", Type: arrow.BinaryTypes.String},
	},
	EventPropertyID: schema.Interface{
		ID:      "core.d8a.tech/events/property_id",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "property_id", Type: arrow.BinaryTypes.String},
	},
	EventPlatform: schema.Interface{
		ID:      "core.d8a.tech/events/platform",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "platform", Type: arrow.BinaryTypes.String},
	},
	EventIPAddress: schema.Interface{
		ID:      "core.d8a.tech/events/ip_address",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "ip_address", Type: arrow.BinaryTypes.String},
	},
	EventUtmMarketingTactic: schema.Interface{
		ID:      "core.d8a.tech/events/utm_marketing_tactic",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "utm_marketing_tactic", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	EventUtmSourcePlatform: schema.Interface{
		ID:      "core.d8a.tech/events/utm_source_platform",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "utm_source_platform", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	EventUtmTerm: schema.Interface{
		ID:      "core.d8a.tech/events/utm_term",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "utm_term", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	EventUtmContent: schema.Interface{
		ID:      "core.d8a.tech/events/utm_content",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "utm_content", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	EventUtmSource: schema.Interface{
		ID:      "core.d8a.tech/events/utm_source",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "utm_source", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	EventUtmMedium: schema.Interface{
		ID:      "core.d8a.tech/events/utm_medium",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "utm_medium", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	EventUtmCampaign: schema.Interface{
		ID:      "core.d8a.tech/events/utm_campaign",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "utm_campaign", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	EventUtmID: schema.Interface{
		ID:      "core.d8a.tech/events/utm_id",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "utm_id", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	EventUtmCreativeFormat: schema.Interface{
		ID:      "core.d8a.tech/events/utm_creative_format",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "utm_creative_format", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	SessionID: schema.Interface{
		ID:      "core.d8a.tech/sessions/id",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "session_id", Type: arrow.BinaryTypes.String},
	},
	SessionDuration: schema.Interface{
		ID:      "core.d8a.tech/sessions/duration",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "duration", Type: arrow.PrimitiveTypes.Int64, Nullable: true},
	},
	SessionFirstEventTime: schema.Interface{
		ID:      "core.d8a.tech/sessions/first_event_time",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "first_event_time", Type: arrow.FixedWidthTypes.Timestamp_s, Nullable: true},
	},
	SessionLastEventTime: schema.Interface{
		ID:      "core.d8a.tech/sessions/last_event_time",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "last_event_time", Type: arrow.FixedWidthTypes.Timestamp_s, Nullable: true},
	},
	SessionTotalEvents: schema.Interface{
		ID:      "core.d8a.tech/sessions/total_events",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "total_events", Type: arrow.PrimitiveTypes.Int64, Nullable: true},
	},
	SSESessionHitNumber: schema.Interface{
		ID:      "core.d8a.tech/events/session_hit_number",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "session_hit_number", Type: arrow.PrimitiveTypes.Int64, Nullable: true},
	},
	SSESessionPageNumber: schema.Interface{
		ID:      "core.d8a.tech/events/session_page_number",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "session_page_number", Type: arrow.PrimitiveTypes.Int64, Nullable: true},
	},

	EventClickIDGclid: schema.Interface{
		ID:      "core.d8a.tech/events/click_id_gclid",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "click_id_gclid", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	EventClickIDDclid: schema.Interface{
		ID:      "core.d8a.tech/events/click_id_dclid",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "click_id_dclid", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	EventClickIDSrsltid: schema.Interface{
		ID:      "core.d8a.tech/events/click_id_srsltid",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "click_id_srsltid", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	EventClickIDGbraid: schema.Interface{
		ID:      "core.d8a.tech/events/click_id_gbraid",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "click_id_gbraid", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	EventClickIDWbraid: schema.Interface{
		ID:      "core.d8a.tech/events/click_id_wbraid",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "click_id_wbraid", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	EventClickIDMsclkid: schema.Interface{
		ID:      "core.d8a.tech/events/click_id_msclkid",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "click_id_msclkid", Type: arrow.BinaryTypes.String, Nullable: true},
	},

	DeviceCategory: schema.Interface{
		ID:      "core.d8a.tech/events/device_category",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "device_category", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	DeviceMobileBrandName: schema.Interface{
		ID:      "core.d8a.tech/events/device_mobile_brand_name",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "device_mobile_brand_name", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	DeviceMobileModelName: schema.Interface{
		ID:      "core.d8a.tech/events/device_mobile_model_name",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "device_mobile_model_name", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	DeviceOperatingSystem: schema.Interface{
		ID:      "core.d8a.tech/events/device_operating_system",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "device_operating_system", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	DeviceOperatingSystemVersion: schema.Interface{
		ID:      "core.d8a.tech/events/device_operating_system_version",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "device_operating_system_version", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	DeviceLanguage: schema.Interface{
		ID:      "core.d8a.tech/events/device_language",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "device_language", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	DeviceWebBrowser: schema.Interface{
		ID:      "core.d8a.tech/events/device_web_browser",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "device_web_browser", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	DeviceWebBrowserVersion: schema.Interface{
		ID:      "core.d8a.tech/events/device_web_browser_version",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "device_web_browser_version", Type: arrow.BinaryTypes.String, Nullable: true},
	},

	GeoContinent: schema.Interface{
		ID:      "core.d8a.tech/events/geo_continent",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "geo_continent", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	GeoCountry: schema.Interface{
		ID:      "core.d8a.tech/events/geo_country",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "geo_country", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	GeoRegion: schema.Interface{
		ID:      "core.d8a.tech/events/geo_region",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "geo_region", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	GeoCity: schema.Interface{
		ID:      "core.d8a.tech/events/geo_city",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "geo_city", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	GeoSubContinent: schema.Interface{
		ID:      "core.d8a.tech/events/geo_sub_continent",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "geo_sub_continent", Type: arrow.BinaryTypes.String, Nullable: true},
	},
	GeoMetro: schema.Interface{
		ID:      "core.d8a.tech/events/geo_metro",
		Version: "1.0.0",
		Field:   &arrow.Field{Name: "geo_metro", Type: arrow.BinaryTypes.String, Nullable: true},
	},
}

CoreInterfaces are the core columns that are always present in the schema.

Functions

func AlwaysNilEventColumn added in v0.6.0

func AlwaysNilEventColumn(
	id schema.InterfaceID,
	field *arrow.Field,
	options ...EventColumnOptions,
) schema.EventColumn

AlwaysNilEventColumn creates a new event column that always returns nil

func CastToBool

func CastToBool(columnID schema.InterfaceID) func(any) (any, error)

CastToBool casts a value to bool considering various truthy representations

func CastToFloat64OrNil

func CastToFloat64OrNil(columnID schema.InterfaceID) func(any) (any, error)

CastToFloat64OrNil casts a value to float64 or returns nil if conversion fails or value is empty

func CastToInt64OrNil

func CastToInt64OrNil(columnID schema.InterfaceID) func(any) (any, error)

CastToInt64OrNil casts a value to int64 or returns nil if conversion fails or value is empty

func CastToInt64OrZero

func CastToInt64OrZero(columnID schema.InterfaceID) func(any) (any, error)

CastToInt64OrZero casts a value to int64 or returns 0 if conversion fails or value is empty

func CastToString

func CastToString(_ schema.InterfaceID) func(any) (any, error)

CastToString casts a value to string or returns nil if conversion fails

func FromPageURLEventColumn

func FromPageURLEventColumn(
	id schema.InterfaceID,
	field *arrow.Field,
	utmTag string,
	options ...EventColumnOptions,
) schema.EventColumn

FromPageURLEventColumn creates a new event column from a UTM tag

func FromQueryParamEventColumn

func FromQueryParamEventColumn(
	id schema.InterfaceID,
	field *arrow.Field,
	queryParam string,
	options ...EventColumnOptions,
) schema.EventColumn

FromQueryParamEventColumn creates a new event column from a query param

func FromQueryParamSessionColumn

func FromQueryParamSessionColumn(
	id schema.InterfaceID,
	field *arrow.Field,
	queryParam string,
	options ...SessionColumnOptions,
) schema.SessionColumn

FromQueryParamSessionColumn creates a new session column from a query param

func GetAllCoreColumns

func GetAllCoreColumns() []schema.Interface

GetAllCoreColumns returns a slice of all core column interfaces for easy consumption.

func NewSimpleEventColumn

func NewSimpleEventColumn(
	id schema.InterfaceID,
	field *arrow.Field,
	getValue func(*schema.Event) (any, error),
	options ...EventColumnOptions,
) schema.EventColumn

NewSimpleEventColumn creates a new simple event column with the given configuration

func NewSimpleSessionColumn

func NewSimpleSessionColumn(
	id schema.InterfaceID,
	field *arrow.Field,
	getValue func(*schema.Session) (any, error),
	options ...SessionColumnOptions,
) schema.SessionColumn

NewSimpleSessionColumn creates a new simple session column with the given configuration

func NewSimpleSessionScopedEventColumn added in v0.2.0

func NewSimpleSessionScopedEventColumn(
	id schema.InterfaceID,
	field *arrow.Field,
	getValue func(*schema.Event, *schema.Session) (any, error),
	options ...SessionScopedEventColumnOptions,
) schema.SessionScopedEventColumn

NewSimpleSessionScopedEventColumn creates a new session-scoped event column with the given configuration

func NilIfError

func NilIfError(i func(any) (any, error)) func(any) (any, error)

NilIfError returns nil if the error is not nil

func StrErrIfEmpty

func StrErrIfEmpty(ifID schema.InterfaceID) func(any) (any, error)

StrErrIfEmpty casts a value to string or returns an error if conversion fails or value is empty

func StrNilIfErrorOrEmpty

func StrNilIfErrorOrEmpty(i func(any) (any, error)) func(any) (any, error)

StrNilIfErrorOrEmpty returns nil if the error is not nil or the value is an empty string

func URLElementColumn added in v0.2.0

func URLElementColumn(
	id schema.InterfaceID,
	field *arrow.Field,
	getValue func(e *schema.Event, url *url.URL) (any, error),
) schema.EventColumn

URLElementColumn creates a new event column from a URL element

Types

type BrokenEventError

type BrokenEventError struct {
	// contains filtered or unexported fields
}

BrokenEventError is an error that occurs when an event doesn't have

all required information in order to be processed.

func NewBrokenEventError

func NewBrokenEventError(message string) *BrokenEventError

NewBrokenEventError creates a new BrokenEventError.

func (*BrokenEventError) Error

func (e *BrokenEventError) Error() string

type BrokenSessionError

type BrokenSessionError struct {
	// contains filtered or unexported fields
}

BrokenSessionError is an error that occurs when a session is invalid.

func NewBrokenSessionError

func NewBrokenSessionError(message string) *BrokenSessionError

NewBrokenSessionError creates a new InvalidSessionError.

func (*BrokenSessionError) Error

func (e *BrokenSessionError) Error() string

type EventColumnOptions

type EventColumnOptions func(*simpleEventColumn)

EventColumnOptions configures a simple event column

func WithEventColumnCast

func WithEventColumnCast(castFunc func(any) (any, error)) EventColumnOptions

WithEventColumnCast sets the cast function for an event column

func WithEventColumnDependsOn

func WithEventColumnDependsOn(dependsOn ...schema.DependsOnEntry) EventColumnOptions

WithEventColumnDependsOn sets the dependencies for an event column

func WithEventColumnRequired

func WithEventColumnRequired(required bool) EventColumnOptions

WithEventColumnRequired sets whether an event column is required

type SessionColumnOptions

type SessionColumnOptions func(*simpleSessionColumn)

SessionColumnOptions configures a simple session column

func WithSessionColumnCast

func WithSessionColumnCast(castFunc func(any) (any, error)) SessionColumnOptions

WithSessionColumnCast sets the cast function for a session column

func WithSessionColumnDependsOn

func WithSessionColumnDependsOn(dependsOn ...schema.DependsOnEntry) SessionColumnOptions

WithSessionColumnDependsOn sets the dependencies for a session column

func WithSessionColumnRequired

func WithSessionColumnRequired(required bool) SessionColumnOptions

WithSessionColumnRequired sets whether a session column is required

type SessionScopedEventColumnOptions added in v0.2.0

type SessionScopedEventColumnOptions func(*simpleSessionScopedEventColumn)

SessionScopedEventColumnOptions configures a simple session-scoped event column

func WithSessionScopedEventColumnCast added in v0.2.0

func WithSessionScopedEventColumnCast(castFunc func(any) (any, error)) SessionScopedEventColumnOptions

WithSessionScopedEventColumnCast sets the cast function for a session-scoped event column

func WithSessionScopedEventColumnDependsOn added in v0.2.0

func WithSessionScopedEventColumnDependsOn(dependsOn ...schema.DependsOnEntry) SessionScopedEventColumnOptions

WithSessionScopedEventColumnDependsOn sets the dependencies for a session-scoped event column

func WithSessionScopedEventColumnRequired added in v0.2.0

func WithSessionScopedEventColumnRequired(required bool) SessionScopedEventColumnOptions

WithSessionScopedEventColumnRequired sets whether a session-scoped event column is required

Directories

Path Synopsis
nolint
nolint
Package eventcolumns provides column implementations for event data tracking.
Package eventcolumns provides column implementations for event data tracking.
Package sessioncolumns provides column implementations for session data tracking.
Package sessioncolumns provides column implementations for session data tracking.

Jump to

Keyboard shortcuts

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