8000 GitHub - hawx/elm-mixpanel
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

hawx/elm-mixpanel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elm-mixpanel

Pure Elm library for sending events to Mixpanel and tracking profiles.

type alias Model =
    { config : Mixpanel.Config
    , userId : String
    }

type Msg = NoOp | Save String

update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case msg of
        Save item ->
            { model | items = item :: items }
            ! [ do <| Mixpanel.track model.config
                    { event = "Saved"
                    , properties = [ ("distinct_id", Json.Encode.string model.userId ) ]
                    }
              , do <| Mixpanel.peopleAppend model.config
                    { distinctId = model.userId }
                    [ ( "Items", Json.Encode.string item ) ]
              ]

        NoOp -> model ! []

do : Task a e -> Cmd Msg
do task =
    Task.attempt (\_ -> NoOp) task

Packages

No packages published
0