hissmetrics-0.4.0.2: Unofficial API bindings to KISSmetrics.

Safe HaskellNone

Web.KISSmetrics

Contents

Description

This module is meant to be imported qualified:

 import qualified Web.KISSmetrics as KISSmetrics

Synopsis

Data types

type APIKey = ByteStringSource

Your KISSmetrics API key.

type SimpleText = ByteStringSource

KISSmetrics names and identities are limited to at most 255 characters and all commas (,) and colons (:) are changed to spaces ( ). Nothing is checked by this Haskell library, so be careful =).

type Property = (SimpleText, Text)Source

A KISSmetrics property. The property names needs to follow the rules outlined on SimpleTexts documentation. The property value, on the other hand, are only limited to 8 KiB and don't have any other restrictions.

data Timestamp Source

A timestamp used only to ignore duplicated events.

Constructors

Automatic

Use KISSmetrics' servers time as the timestamp.

Manual UTCTime

Use given time as the timestamp. If possible, use Manual since it allows you to safely resend events that appear to have failed without being afraid of duplicates. See also generateTimestamp.

generateTimestamp :: IO TimestampSource

Generate a Manual timestamp with the current time.

Making calls

callSource

Arguments

:: Manager

HTTP connection manager (cf. newManager).

-> APIKey

Your KISSmetrics API key.

-> CallType

Which call you would like to make.

-> IO () 

Call KISSmetrics' API. See CallType for documentation about which calls you may make.

KISSmetrics does not return errors even when an error occurs and there's absolutely no way of knowing if your request went through. However, this function may throw an exception if we fail to make the request to KISSmetrics (e.g. if there's a problem with your server's Internet connection).

Note that official KISSmetrics' APIs provide many functions (usually four) while we provide just this one and a sum data type. This function alone does the work of record, set, identify and alias.

TODO: Currently there's no support for automatically retrying failed request, you need to retry yourself.

data CallType whereSource

A type of call that may be made to KISSmetrics. It's defined as a GADT where event names and identities are existential values.

Since Haddock currently has problems with GADTs, here's the documentation about each constructor:

Record
Record an event. eventName is the name of the event being recorded, identity is the identity of the person doing the event and properties are any other optional properties you may want.
SetProps
Set user properties without recording an event. identity is the identity of the person whose properties will be changed and properties are the properties to be set.
Alias
Alias two identities (identity and identity') as the same one.

See also http://support.kissmetrics.com/apis/specifications.

Constructors

Record :: (EventName event, Identity ident) => event -> ident -> Timestamp -> [Property] -> CallType 

Fields

eventName :: event
 
identity :: ident
 
timestamp :: Timestamp
 
properties :: [Property]
 
SetProps :: Identity ident => ident -> Timestamp -> [Property] -> CallType 

Fields

identity :: ident
 
timestamp :: Timestamp
 
properties :: [Property]
 
Alias :: (Identity ident, Identity ident') => ident -> ident' -> CallType 

Fields

identity :: ident
 
identity' :: ident'
 

Type classes

class Show event => EventName event whereSource

Type class of data types that are event names.

You may just use SimpleText (which is the only instance provided by default), but you may also create your own data type for event names and add an instance of this class.

Methods

fromEventName :: event -> SimpleTextSource

Instances

EventName ByteString

This is the same as SimpleText.

class Show ident => Identity ident whereSource

Type class of data types that are user identities.

You may just use SimpleText (which is the only instance provided by default), but you may also create your own data type for event names and add an instance of this class.

Methods

fromIdentity :: ident -> SimpleTextSource

Instances

Identity ByteString

This is the same as SimpleText.