event

package
v0.0.0-...-0f8d847 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	City       string
	Country    string
	PostalCode string
	State      string
	Street     string
}

type AgentBrandVersion

type AgentBrandVersion struct {
	Brand   string // i think this is for storing the browsers brand, for example, firefox or chromium
	Version string // also this is the property for storing the version of the browser
}

type Campaign

type Campaign struct {
	Name       string
	Source     string
	Medium     string
	CustomData CustomData
}

type Company

type Company struct {
	Name          string
	ID            string // Unique ID in your database for a company
	EmployeeCount int
}

type Context

type Context struct {
	Active        bool
	IP            net.IP    // Current user's IP address.
	Locale        string    // Locale string for the current user, for example en-US.
	Location      *Location // Dictionary of information about the user’s current location.
	Page          *Page     // Dictionary of information about the current web page.
	UserAgent     string
	UserAgentData *UserAgentData // User agent data returned by the Client Hints API
	Library       *Library       // the name of the library(sdk) and the version of it
	Traits        *Traits
	Campaign      *Campaign // Dictionary of information about the campaign that resulted in the API call, containing name, source, medium, term, content, and any other custom UTM parameter.
	Referrer      *Referrer // Dictionary of information about the way the user was referred to the website or app.
	CustomData    *CustomData
}

This is an implementation of Context class similar to the `CoreExtraContext` in segment js SDK.

type CoreEvent

type CoreEvent struct {
	MessageID string
	Type      Type // track, page , ...

	// Category  string // specific to page event
	Name string

	Properties *Properties

	Integration []*Integrations
	Ctx         *Context

	SendAt            time.Time
	ReceivedAt        time.Time
	OriginalTimeStamp time.Time // TODO: don't know the difference between this and Timestamp example(2023-11-19T12:04:25.271Z)
	Timestamp         time.Time // 2023-11-19T12:04:25.779Z

	AnonymousID string
	UserID      string
	GroupID     string
	PreviousID  string

	Event string

	WriteKey string
	MetaData MetaData // TODO: all fields had ambiguity so did not added yet

	Options *Options
}

type CustomData

type CustomData map[string]string // TODO: there are multiple places where segment in javascript allow user to post additional custom properties like here but as is GO a typed programming language I don't know a way to handle it, but to add a dictionary field like this

type Integrations

type Integrations struct {
	All    bool
	Config Properties // TODO: i don't think this is a proper name for this field but, didn't have a better name on my mind
}

type Library

type Library struct {
	Name    string // analytics-node-next/latest
	Version string // 1.43.1
}

type Location

type Location struct {
	City      string
	Country   string
	Latitude  string
	Longitude string
	Region    string
	// TODO: i'm not sure what speed is in this context?
	Speed int
}

type MetaData

type MetaData struct{}

type Options

type Options struct {
	Integrations *Integrations
	Timestamp    time.Time
	Ctx          *Context
	AnonymousID  string
	UserID       string
	Traits       Traits
	CustomData   *CustomData
}

type Page

type Page struct {
	Path     string  // academy/
	Referrer url.URL // https://www.foo.com/
	Search   string  // projectId=123
	Title    string  // Analytics Academy
	URL      url.URL // https://segment.com/academy/
}

type ProcessedEvent

type ProcessedEvent struct {
	// required fields
	SourceID      string            // Write key or sourceID shows that which source, events coming from
	TracerCarrier map[string]string // use this for trace with OTel
	Integration   entity.Integration
	MessageID     string // Automatically collected by Segment, a unique identifier for each message
	EventType     Type   // Type of message, corresponding to the API method: 'identify', 'group', 'track', 'page', 'screen' or 'alias'.
	Version       uint8  // The version of the Tracking API

	SentAt            time.Time // Time on client device when call was sent or sentAt value manually passed in.
	ReceivedAt        time.Time // Time on server clock when call was received
	OriginalTimestamp time.Time // Time on the client device when call was invoked
	Timestamp         time.Time // Calculated by Server to correct client-device clock skew using the following formula: receivedAt - (sentAt - originalTimestamp)

	// optional fields
	UserID      *string     // Unique identifier for the user in your database. A userId or an anonymousId is required.
	AnonymousID *string     // A uniqueID substitute for a User ID, for cases when you don’t have an absolutely unique identifier.
	Event       *string     // track
	Name        *string     // page | screen
	GroupID     *string     // group
	PreviousID  *string     // alias
	Context     *Context    // Dictionary of extra information that provides useful context about a message
	Properties  *Properties // Custom information about the event
	Traits      *Traits     // identify | group
}

func (ProcessedEvent) DestinationType

func (e ProcessedEvent) DestinationType() entity.DestinationType

func (ProcessedEvent) ID

func (e ProcessedEvent) ID() string

type Properties

type Properties map[string]string

type Referrer

type Referrer struct {
	ReferrerType string
	Name         string
	URL          url.URL
	Link         string
}

type Traits

type Traits struct {
	CustomTraits CustomData
}

type Type

type Type string
const (
	TrackEventType    Type = "track"
	PageEventType     Type = "page"
	IdentityEventType Type = "identity"
	GroupEventType    Type = "group"
	AliasEventType    Type = "alias"
	ScreenEventType   Type = "screen"
)

type UserAgentData

type UserAgentData struct {
	Mobile          bool
	Platform        string
	Architecture    string
	Bitness         string
	Model           string
	PlatformVersion string
	WOW64           bool
	Brands          []AgentBrandVersion

	FullVersionList []AgentBrandVersion // TODO: i don't know why this exists??

}

type UserTraits

type UserTraits struct {
	Traits

	ID       string // Unique ID in your database for a user
	Industry string // Industry a user works in

	FirstName   string
	LastName    string
	Name        string // Full name of a user. If you only pass a first and last name Segment automatically fills in the full name for you.
	PhoneNumber string
	Username    string

	Title string // Title of a user, usually related to their position at a specific company.

	Website url.URL // User's website
	Address Address

	Age      int
	Avatar   url.URL // URL to an avatar image for the user.\
	Birthday time.Time

	Company Company

	Plan string //  Plan that a user is in. example(enterprise)

	CreatedAt time.Time

	Description string // Description of user, such as bio.
	Email       string
	Gender      string
}

Jump to

Keyboard shortcuts

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