Skip to content

Commit

Permalink
Merge pull request #214 from kubefirst/subdomain
Browse files Browse the repository at this point in the history
fix: moving subdomain out of runtime
  • Loading branch information
johndietz authored Oct 21, 2023
2 parents 84f0a60 + 70a206b commit 826799f
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pkg/telemetryShim/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ package telemetryShim

import (
"os"
"strings"
"time"

"github.com/denisbrodbeck/machineid"
"github.com/kubefirst/kubefirst-api/pkg/segment"
pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types"
"github.com/kubefirst/runtime/pkg"
"github.com/segmentio/analytics-go"
log "github.com/sirupsen/logrus"
)
Expand All @@ -40,7 +40,7 @@ func SetupTelemetry(cl pkgtypes.Cluster) (*segment.SegmentClient, error) {
kubefirstVersion = "development"
}

strippedDomainName, err := pkg.RemoveSubdomainV2(cl.DomainName)
strippedDomainName, err := RemoveSubdomainV2(cl.DomainName)
if err != nil {
return &segment.SegmentClient{}, nil
}
Expand Down Expand Up @@ -71,3 +71,17 @@ func Transmit(segmentClient *segment.SegmentClient, metricName string, errorMess
log.Info(segmentMsg)
}
}

func RemoveSubdomainV2(domainName string) (string, error) {

domainName = strings.TrimRight(domainName, ".")
domainSlice := strings.Split(domainName, ".")

if len(domainSlice) < 2 {
return "", nil
}

domainName = strings.Join([]string{domainSlice[len(domainSlice)-2], domainSlice[len(domainSlice)-1]}, ".")

return domainName, nil
}

0 comments on commit 826799f

Please sign in to comment.