eventexporter

package module
v0.0.0-...-e22c9f8 Latest Latest
Warning

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

Go to latest
Published: May 12, 2015 License: MIT Imports: 3 Imported by: 0

README

eventexporter Build Status

eventexporter is a library to export events to 3rd party services.

Usage

key := "segment api token"
size := "size of events to accumulate before flushing"

event := &eventexporter.Event{
  Name: "test event",
  User: &eventexporter.User{
    Username:"indianajones", Email: "indiana@gmail.com"
  },
  Body: &eventexporter.Body{Content: "Hello world"},
  Properties: map[string]interface{}{"occupation" : "explorer" },
}

client := eventexporter.NewSegementIOExporter(key, size)
client.Send(event)

FakeExporter is an implementation of Exporter to be used in tests.

import (
  "github.com/koding/eventexporter"
)

event := &eventexporter.Event{Name: "test event"}

client := eventexporter.NewFakeExporter()
client.Send(event)

fmt.Println(client.Events)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSegmentIOUsernameEmpty = errors.New("username is empty")
	ErrSegmentIOEmailEmpty    = errors.New("email is empty")
	ErrSegmentIOEventEmpty    = errors.New("event is empty")
	ErrSendgridBodyEmpty      = errors.New("email body is empty")
)
View Source
var DateLayout = "Jan 2, 2006"

Functions

This section is empty.

Types

type Body

type Body struct {
	Type    BodyType // text or html
	Content string
}

Body is used to send text or html of event directly to 3rd party. Ideally none of html should exist in codebase so it's easy to change, however legacy html code still exists.

type BodyType

type BodyType int
const (
	TextBodyType BodyType = iota
	HtmlBodyType
)

type Event

type Event struct {
	Name       string                 // name of event
	User       *User                  // user who did event
	Body       *Body                  // body of event; text or html
	Properties map[string]interface{} // any additional properties
}

Event represent an action in time that is done by an user, has body and optionally some properties.

type Exporter

type Exporter interface {
	Send(*Event) error
	Close() error
}

Exporter is the interface to export events to a 3rd party service. Currently third party services: SegementIO and Sendgrid are implemented.

type FakeExporter

type FakeExporter struct {
	Events []*Event
}

func NewFakeExporter

func NewFakeExporter() *FakeExporter

func (*FakeExporter) Close

func (l *FakeExporter) Close() error

func (*FakeExporter) Send

func (l *FakeExporter) Send(event *Event) error

type SegmentIOExporter

type SegmentIOExporter struct {
	Client *analytics.Client
}

func NewSegmentIOExporter

func NewSegmentIOExporter(key string, size int) *SegmentIOExporter

func (*SegmentIOExporter) Close

func (s *SegmentIOExporter) Close() error

func (*SegmentIOExporter) Send

func (s *SegmentIOExporter) Send(event *Event) error

type User

type User struct {
	Email    string
	Username string
}

Jump to

Keyboard shortcuts

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