# README
Analytics
The purpose of the analytics package is to create a simple interface to use mixpanel event tracking feature.
You can learn more about mixpanel at https://wwww.mixpanel.com
Usage
Default analytics
This require you to have a environment variable ANALYTICS_MIXPANEL_TOKEN for supplying token and api url will default to api.mixpanel.com.
package main
import (
"log"
"github.com/facily-tech/go-core/analytics"
)
func main() {
if err := analytics.TrackSync("sample event", map[string]interface{}{"id": 123}); err != nil {
log.Println(err)
}
}
Custom analytics
You may want to change token, logger, url etc.
package main
import (
"log"
"github.com/facily-tech/go-core/analytics"
)
func main() {
a := &analytics.Analytics{}
a.WithMixpanelURL("no token", "")
if err := a.TrackSync("sample event", map[string]interface{}{"id": 123}); err != nil {
log.Println(err)
}
}
# Functions
Close is a wrapper around DefaultClient.Close.
Track is a wrapper around DefaultClient.Track.
TrackSync is a wrapper around DefaultClient.TrackSync.
WithLogger is a wrapper around DefaultClient.WithLogger.
WithMixpanelURL is a wrapper around DefaultClient.WithMixpanelURL.
WithWorkerPool is a wrapper around DefaultClient.WithWorkerPool.
# Variables
DefaultAnalytics is used if you didn't create your own instance.
ErrEmptyToken error when token is empty.
ErrUnexpectedType error when we can't cast/type assert interface to (T).