ingest

package module
v0.0.0-...-63fb391 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2019 License: MIT Imports: 14 Imported by: 0

README

import "github.com/deduce-com/go-deduce-ingest"

godoc: https://godoc.org/github.com/deduce-com/go-deduce-ingest

Documentation

Overview

ingest implements Deduce data ingestion

Index

Constants

View Source
const (
	VERSION     = "1.1"
	COLLECT_URL = "//lore.deduce.com/p/collect"
	EVENT_URL   = "https://event.deduce.com/p/event" // always https
	TIMEOUT     = 2 * time.Second
)

Variables

This section is empty.

Functions

func WithBackfill

func WithBackfill(opt *Opt) error

WithBackfill can be used to enable backfill mode

dd, err := ingest.New("my site id", "my api key", ingest.WithBackfill)

func WithOutSSL

func WithOutSSL(opt *Opt) error

func WithSSL

func WithSSL(opt *Opt) error

func WithTestmode

func WithTestmode(opt *Opt) error

WithTestmode can be used to enable testmode

dd, err := ingest.New("my site id", "my api key", ingest.WithTestmode)

func WithWhatEvs

func WithWhatEvs(opt *Opt) error

Types

type D

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

func New

func New(site, key string, optf ...FunOpt) (*D, error)

New creates a new ingestion object

dd, err := ingest.New("my site id", "my api key")

or enable test mode:

dd, err := ingest.New("my site id", "my api key", ingest.WithTestmode)

func (*D) Event

func (d *D) Event(email, ip, event string, addtl map[string]interface{}, optf ...FunOpt) error

Event sends an event to Deduce

err := dd.Event(email, ip, event, additional)

additional should be a map[string]interface{} (or nil)

consult with Deduce to determine the event types and additional data. email, as well as any "cc" and "email_prev" will automatically be hashed + processed.

err := dd.Event("user@example.com", "192.0.2.37", "ate-food", nil)

err := dd.Event("user@example.com", "192.0.2.37", "ate-food", map[string]interface{}{
          "name":   "Bob Example",
          "weight": 1230,
          "meal":   map[string]string{"color": "orange", "flavor": "salty"},
     })

func (*D) Events

func (d *D) Events(evts []map[string]interface{}, optf ...FunOpt) error

Events sends several related events to Deduce

the events should be a slice of map[string]interface{} and should contain values for the event, ip, and email.

consult with Deduce to determine the event types and additional data. email, as well as any "cc" and "email_prev" will automatically be hashed + processed.

err := dd.Events( []map[string]interface{}{
         { "event": "thing-happened", "email": "user1@example.com", "ip": "192.0.2.37" },
         { "event": "thing-happened", "email": "user2@example.com", "ip": "192.0.2.38" },
       })

func (*D) Html

func (d *D) Html(email string, optf ...FunOpt) (string, error)

Html generates HTML to place on your web page.

html, err := dd.Html(email)

type FunOpt

type FunOpt func(*Opt) error

func WithInspector

func WithInspector(f func(string)) FunOpt

func WithTimeout

func WithTimeout(t time.Duration) FunOpt

WithTimeout can be used to change the event POST timeout

err := dd.Event(..., ingest.WithTimeout(10*time.Second))

func WithURL

func WithURL(url string) FunOpt

type Opt

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

Jump to

Keyboard shortcuts

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