diff --git a/go.mod b/go.mod index 343ab6d..1183ee9 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/fatih/color v1.13.0 github.com/go-errors/errors v1.4.2 github.com/google/go-github/v44 v44.1.0 + github.com/google/uuid v1.2.0 github.com/gruntwork-io/terratest v0.41.0 github.com/hashicorp/go-multierror v1.1.1 github.com/mattn/go-zglob v0.0.3 @@ -24,7 +25,6 @@ require ( golang.org/x/crypto v0.1.0 golang.org/x/exp v0.0.0-20221106115401-f9659909a136 golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c - vizzlo.com/mixpanel v1.2.0 ) require ( @@ -62,7 +62,6 @@ require ( github.com/google/go-github/v29 v29.0.2 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.1.0 // indirect - github.com/google/uuid v1.2.0 // indirect github.com/googleapis/gax-go/v2 v2.0.5 // indirect github.com/googleapis/gnostic v0.4.1 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect diff --git a/go.sum b/go.sum index 1cdac9c..f89adef 100644 --- a/go.sum +++ b/go.sum @@ -828,5 +828,3 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.3/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -vizzlo.com/mixpanel v1.2.0 h1:ip0yFM9mIgAKDB0yIkUB2y+C2n+6MXaQ0KQk3DyISjE= -vizzlo.com/mixpanel v1.2.0/go.mod h1:bmKnyCOO+/6SRhjujPG6ARtNJdTRepmA/TH+Nt/1GyU= diff --git a/telemetry/mixpanel.go b/telemetry/mixpanel.go index 05db292..8c1b60d 100644 --- a/telemetry/mixpanel.go +++ b/telemetry/mixpanel.go @@ -1,19 +1,20 @@ package telemetry import ( + "bytes" + "encoding/json" "github.com/google/uuid" "log" + "net/http" "time" - - "vizzlo.com/mixpanel" ) type MixpanelTelemetryTracker struct { - clientId string - client *mixpanel.Client - appName string - version string - runId string + client *http.Client + url string + appName string + version string + runId string } /* @@ -42,20 +43,33 @@ func (m MixpanelTelemetryTracker) TrackEvent(eventContext EventContext, eventPro // Combine our baseline props that we send for _ALL_ events with the passed in props from the event trackProps := mergeMaps(baseProps, eventProps) - err := m.client.Track(m.runId, eventContext.EventName, trackProps) - + request := map[string]interface{}{ + "id": m.runId, + "event": eventContext.EventName, + "eventProps": trackProps, + } + jsonStr, err := json.Marshal(request) + if err != nil { + log.Println(err.Error()) + return + } + resp, err := m.client.Post(m.url, "application/json", bytes.NewBuffer(jsonStr)) + if err != nil { + log.Println(err.Error()) + return + } + err = resp.Body.Close() if err != nil { log.Println(err.Error()) } } -func NewMixPanelTelemetryClient(clientId string, appName string, version string) MixpanelTelemetryTracker { - mixpanelClient := mixpanel.New(clientId) +func NewMixPanelTelemetryClient(url string, appName string, version string) MixpanelTelemetryTracker { return MixpanelTelemetryTracker{ - client: mixpanelClient, - clientId: clientId, - appName: appName, - version: version, - runId: uuid.New().String(), + client: &http.Client{}, + url: url, + appName: appName, + version: version, + runId: uuid.New().String(), } }