Safe Haskell | Safe-Infered |
---|
This module is meant to be imported qualified:
import qualified Web.KISSmetrics as KISSmetrics
- type APIKey = Ascii
- type SimpleText = Ascii
- type Property = (SimpleText, Text)
- data Timestamp
- call :: (EventName event, Identity ident) => Manager -> APIKey -> CallType event ident -> IO ()
- data CallType event ident
- class EventName event where
- fromEventName :: event -> SimpleText
- class Identity ident where
- fromIdentity :: ident -> SimpleText
Data types
type SimpleText = AsciiSource
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 SimpleText
s
documentation. The
property value, on the other hand, are only limited to 8 KiB
and don't have any other restrictions.
A timestamp used only to ignore duplicated events.
Making calls
:: (EventName event, Identity ident) | |
=> Manager | HTTP connection manager (cf. |
-> APIKey | Your KISSmetrics API key. |
-> CallType event ident | 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 event ident Source
A type of call that may be made to KISSmetrics. See also http://support.kissmetrics.com/apis/specifications.
Record | Record an event. |
| |
SetProps | Set user properties without recording an event. |
Alias | Alias two identities as the same one. |
Type classes
class 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.
fromEventName :: event -> SimpleTextSource
EventName ByteString | This is the same as |
class 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.
fromIdentity :: ident -> SimpleTextSource
Identity ByteString | This is the same as |