trackers

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 2 Imported by: 0

README

trackers-go

Go implementations of event tracking.

Mparticle Usage

You will need:

  • a configured input feed for mparticle for your api key and secret.
  • the url which in most cases is https://s2s.mparticle.com/v2
  • your types generated from your data plan.

First install using go get github.com/utilitywarehouse/trackers-go

Then you need to import the tracker and use your configured mparticle input feed.

httpClient := &http.Client{
		Timeout: 5 * time.Second,
	}

	tracker := mparticle.NewMParticleTracker("url", "key", "secret", httpClient, true)

Then an event can be tracked by calling the track method.

err := tracker.Track(
		context.Background(),
		trackers.NoSchema,
		&schema.Identity{CustomerPersonId: trackers.CustomerPersonIDFromAccountNumber("0000000")},
		[]trackers.Event{
			&schema.HomeInsuranceQuoteAttemptedEvent{
				QuoteId:        "abc",
				QuoteReference: "fef",
				Product:        schema.ProductContents,
				QuoteType:      schema.QuoteTypeRenewal,
			},
		},
		[]trackers.Attribute{
			schema.HomeInsuranceRenewalDateAttribute("2016-01-21"),
		},
	)

Documentation

Index

Constants

View Source
const NoSchema = schema("")

Variables

This section is empty.

Functions

func CustomerPersonIDFromAccountID

func CustomerPersonIDFromAccountID(accountID string) string

func CustomerPersonIDFromAccountNumber

func CustomerPersonIDFromAccountNumber(accountNumber string) string

Types

type Attribute

type Attribute interface {
	Name() string
	Value() interface{}
}

type Batch

type Batch struct {
	Schema     SchemaInfo
	Identity   Identity
	Events     []Event
	Attributes []Attribute
}

type BulkTracker

type BulkTracker interface {
	BulkTrack(ctx context.Context, batches []Batch) error
}

type Event

type Event interface {
	Payload() map[string]string
	Name() string
}

type Identity

type Identity interface {
	Map() map[string]string
}

type SchemaInfo

type SchemaInfo interface {
	Name() string
	Version() int64
}

type Tracker

type Tracker interface {
	Track(
		ctx context.Context,
		schema SchemaInfo,
		identity Identity,
		events []Event,
		attributes []Attribute,
	) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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