Skip to content

Commit

Permalink
return telemetry event
Browse files Browse the repository at this point in the history
  • Loading branch information
D-B-Hawk committed Dec 11, 2023
1 parent 8bc2bf2 commit a9762be
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions internal/segment/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,32 @@ import (
"github.com/kubefirst/kubefirst/configs"
"github.com/kubefirst/metrics-client/pkg/telemetry"
"github.com/kubefirst/runtime/pkg/k3d"

"github.com/segmentio/analytics-go"
)

const (
kubefirstClient string = "api"
)

func InitClient(clusterId, clusterType, gitProvider string) *telemetry.SegmentClient {
func InitClient(clusterId, clusterType, gitProvider string) telemetry.TelemetryEvent {

machineID, _ := machineid.ID()
sc := analytics.New(telemetry.SegmentIOWriteKey)

c := telemetry.SegmentClient{
TelemetryEvent: telemetry.TelemetryEvent{
CliVersion: configs.K1Version,
CloudProvider: k3d.CloudProvider,
ClusterID: clusterId,
ClusterType: clusterType,
DomainName: k3d.DomainName,
GitProvider: gitProvider,
InstallMethod: "kubefirst-launch",
KubefirstClient: kubefirstClient,
KubefirstTeam: os.Getenv("KUBEFIRST_TEAM"),
KubefirstTeamInfo: os.Getenv("KUBEFIRST_TEAM_INFO"),
MachineID: machineID,
ErrorMessage: "",
UserId: machineID,
MetricName: telemetry.ClusterInstallStarted,
},
Client: sc,
c := telemetry.TelemetryEvent{
CliVersion: configs.K1Version,
CloudProvider: k3d.CloudProvider,
ClusterID: clusterId,
ClusterType: clusterType,
DomainName: k3d.DomainName,
GitProvider: gitProvider,
InstallMethod: "kubefirst-launch",
KubefirstClient: kubefirstClient,
KubefirstTeam: os.Getenv("KUBEFIRST_TEAM"),
KubefirstTeamInfo: os.Getenv("KUBEFIRST_TEAM_INFO"),
MachineID: machineID,
ErrorMessage: "",
MetricName: telemetry.ClusterInstallStarted,
UserId: machineID,
}

return &c
return c
}

0 comments on commit a9762be

Please sign in to comment.