Documentation ¶
Index ¶
- Constants
- Variables
- type Account
- func (a *Account) CreateFunnel(f *Funnel) error
- func (a *Account) CreateUser(u *User) error
- func (a *Account) Delete() error
- func (a *Account) Events(id string) ([]*Event, error)
- func (a *Account) Funnel(id int) (*Funnel, error)
- func (a *Account) Funnels() (Funnels, error)
- func (a *Account) GenerateAPIKey() error
- func (a *Account) ID() int
- func (a *Account) Load() error
- func (a *Account) Migrate() error
- func (a *Account) Reset() error
- func (a *Account) Resources() ([]string, error)
- func (a *Account) Save() error
- func (a *Account) SkyTable() *sky.Table
- func (a *Account) SkyTableName() string
- func (a *Account) Track(e *Event) error
- func (a *Account) Users() (Users, error)
- func (a *Account) Validate() error
- type Accounts
- type DB
- type Error
- type Event
- type Funnel
- type FunnelResult
- type FunnelStep
- type FunnelStepResult
- type Funnels
- type Tx
- func (t *Tx) Account(id int) (*Account, error)
- func (t *Tx) AccountByAPIKey(apiKey string) (*Account, error)
- func (t *Tx) Accounts() (Accounts, error)
- func (t *Tx) CreateAccount(a *Account) error
- func (t *Tx) Funnel(id int) (*Funnel, error)
- func (t *Tx) User(id int) (*User, error)
- func (t *Tx) UserByEmail(email string) (*User, error)
- type User
- type Users
Constants ¶
const ( // MinPasswordLength is the shortest a password can be. MinPasswordLength = 6 // MaxPasswordLength is the longest a password can be. MaxPasswordLength = 50 )
const SessionIdleTime = "2 HOURS"
SessionIdleTime is the amount of idle time that delimits sessions.
const UserPrefix = "@"
Variables ¶
var ( // ErrFunnelNotFound is returned when a funnel does not exist. ErrFunnelNotFound = &Error{"funnel not found", nil} // ErrFunnelNameRequired is returned when a funnel has a blank name. ErrFunnelNameRequired = &Error{"funnel name required", nil} // ErrFunnelStepsRequired is returned when a funnel has no steps. ErrFunnelStepsRequired = &Error{"funnel steps required", nil} )
var ( // ErrUserNotFound is returned when a user does not exist. ErrUserNotFound = &Error{"user not found", nil} // ErrUserEmailRequired is returned when a user has a blank email. ErrUserEmailRequired = &Error{"user email required", nil} // ErrUserEmailTaken is returned when a email already exists. ErrUserEmailTaken = &Error{"user email already in use", nil} // ErrUserPasswordRequired is returned when a user has a blank password. ErrUserPasswordRequired = &Error{"user password required", nil} // ErrUserPasswordTooShort is returned when a password is too short. ErrUserPasswordTooShort = &Error{"user password too short", nil} // ErrUserPasswordTooLong is returned when a password is too long. ErrUserPasswordTooLong = &Error{"user password too long", nil} // ErrUserNotAuthenticated is returned when a password doesn't match the hash. ErrUserNotAuthenticated = &Error{"user not authenticated", nil} )
var ( // ErrAccountNotFound is returned when an account with the given id does // not exist. ErrAccountNotFound = &Error{"account not found", nil} )
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { Tx *Tx APIKey string `json:"apiKey"` // contains filtered or unexported fields }
Account represents a collection of Users and Events.
func (*Account) CreateFunnel ¶
CreateFunnel creates a new Funnel for this account.
func (*Account) CreateUser ¶
CreateUser creates a new User for this account.
func (*Account) Funnel ¶
Funnel retrieves a funnel with a given ID. Only funnels associated with this account will be returned.
func (*Account) GenerateAPIKey ¶
GenerateAPIKey creates a new API key for an account.
func (*Account) SkyTable ¶
func (a *Account) SkyTable() *sky.Table
SkyTable returns a reference to the table used by Sky.
func (*Account) SkyTableName ¶
SkyTableName returns the name of the table used by Sky.
type DB ¶
DB represents a Bolt-backed data store. The DB stores all non-event data.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents an error condition within the database.
type Event ¶
type Event struct { Timestamp time.Time `json:"timestamp"` UserID string `json:"userID"` DeviceID string `json:"deviceID"` Channel string `json:"channel"` Resource string `json:"resource"` Action string `json:"action"` Data map[string]interface{} `json:"data"` }
Event represents an action or state change trigger by a tracked user.
func (*Event) Deserialize ¶
Deserialize converts a Sky event into a Skybox event.
func (*Event) IsAnonymous ¶
IsAnonymous returns whether the event is for an unidentified user.
type Funnel ¶
type Funnel struct { Tx *Tx AccountID int `json:"accountID"` Name string `json:"name"` Steps []*FunnelStep `json:"steps"` // contains filtered or unexported fields }
Funnel represents a multi-step query. A Funnel belongs to an Account.
func (*Funnel) Query ¶
func (f *Funnel) Query() (*FunnelResult, error)
Query executes a query against the funnel and returns the result.
func (*Funnel) QueryString ¶
QueryString generates a funnel query for use in Sky.
type FunnelResult ¶
type FunnelResult struct { Name string `json:"name"` Steps []*FunnelStepResult `json:"steps"` }
FunnelResult represents the results of an executed funnel query.
type FunnelStep ¶
type FunnelStep struct {
Condition string `json:"condition"`
}
FunnelStep represents a single step in a funnel.
type FunnelStepResult ¶
FunnelStepResult represents the result of one step in an executed funnel query.
type Tx ¶
func (*Tx) AccountByAPIKey ¶
AccountByAPIKey retrieves an acocunt from the database with the given API key.
func (*Tx) CreateAccount ¶
CreateAccount creates a new Account in the database.
type User ¶
type User struct { Tx *Tx AccountID int `json:"accountID"` Email string `json:"email"` Password string `json:"-"` Hash []byte `json:"hash"` // contains filtered or unexported fields }
User represents a user within the system. A User belongs to an Account.
func (*User) Authenticate ¶
Authenticate checks if a plaintext password matches the hash.
func (*User) GenerateHash ¶
GenerateHash generates a hashed password from the currently set password.