Skip to content

Bugfix/public event vars #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ 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 (
Expand Down Expand Up @@ -118,5 +119,4 @@ require (
k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.0.3 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
vizzlo.com/mixpanel v1.2.0 // indirect
)
14 changes: 11 additions & 3 deletions telemetry/mixpanel.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package telemetry

import (
"github.com/google/uuid"
"log"
"time"

Expand All @@ -12,6 +13,7 @@ type MixpanelTelemetryTracker struct {
client *mixpanel.Client
appName string
version string
runId string
}

/*
Expand All @@ -33,14 +35,14 @@ func (m MixpanelTelemetryTracker) TrackEvent(eventContext EventContext, eventPro
baseProps := map[string]interface{}{
"timestamp": time.Now().Unix(),
"context": m.appName,
"command": eventContext.command,
"command": eventContext.Command,
"version": m.version,
}

// 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.clientId, eventContext.eventName, trackProps)
err := m.client.Track(m.runId, eventContext.EventName, trackProps)

if err != nil {
log.Fatal(err)
Expand All @@ -49,5 +51,11 @@ func (m MixpanelTelemetryTracker) TrackEvent(eventContext EventContext, eventPro

func NewMixPanelTelemetryClient(clientId string, appName string, version string) MixpanelTelemetryTracker {
mixpanelClient := mixpanel.New(clientId)
return MixpanelTelemetryTracker{client: mixpanelClient, clientId: clientId, appName: appName, version: version}
return MixpanelTelemetryTracker{
client: mixpanelClient,
clientId: clientId,
appName: appName,
version: version,
runId: uuid.New().String(),
}
}
4 changes: 2 additions & 2 deletions telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ type telemetryTracker interface {
}

type EventContext struct {
command string
eventName string
Command string
EventName string
}