Skip to content

Commit

Permalink
refactor: telemetry package consolidation
Browse files Browse the repository at this point in the history
  • Loading branch information
alexplischke committed Nov 14, 2024
1 parent 46a14b7 commit dcc3fcd
Show file tree
Hide file tree
Showing 46 changed files with 67 additions and 101 deletions.
5 changes: 3 additions & 2 deletions cmd/saucectl/saucectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"os/signal"
"time"

"github.com/saucelabs/saucectl/internal/usage"

"github.com/fatih/color"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
Expand All @@ -21,7 +23,6 @@ import (
"github.com/saucelabs/saucectl/internal/cmd/run"
"github.com/saucelabs/saucectl/internal/cmd/signup"
"github.com/saucelabs/saucectl/internal/cmd/storage"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/saucelabs/saucectl/internal/version"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -57,7 +58,7 @@ func main() {

cmd.PersistentPreRun = func(_ *cobra.Command, _ []string) {
setupLogging(*verbosity, *noColor)
segment.DefaultClient.Enabled = !*noTracking
usage.DefaultClient.Enabled = !*noTracking
}

cmd.AddCommand(
Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/apit/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"errors"
"time"

"github.com/saucelabs/saucectl/internal/usage"

"github.com/saucelabs/saucectl/internal/credentials"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/region"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/spf13/cobra"
)

Expand All @@ -32,7 +33,7 @@ func Command(preRun func(cmd *cobra.Command, args []string)) *cobra.Command {
return errors.New("invalid region")
}
if reg == region.Staging {
segment.DefaultClient.Enabled = false
usage.DefaultClient.Enabled = false
}

creds := credentials.Get()
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/apit/deletefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/saucelabs/saucectl/internal/usage"
)

Expand All @@ -35,7 +34,7 @@ Use [--project] to specify the project by its name or run without [--project] to
return fmt.Errorf("invalid HTTP_PROXY value")
}

tracker := segment.DefaultClient
tracker := usage.DefaultClient

go func() {
tracker.Collect(
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/apit/downloadfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/saucelabs/saucectl/internal/apitest"
cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/saucelabs/saucectl/internal/usage"
)

Expand All @@ -37,7 +36,7 @@ Use [--project] to specify the project by its name or run without [--project] to
return fmt.Errorf("invalid HTTP_PROXY value")
}

tracker := segment.DefaultClient
tracker := usage.DefaultClient

go func() {
tracker.Collect(
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/apit/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/saucelabs/saucectl/internal/usage"
"github.com/spf13/cobra"
)
Expand All @@ -28,7 +27,7 @@ Use [--project] to specify the project by its name or run without [--project] to
return fmt.Errorf("invalid HTTP_PROXY value")
}

tracker := segment.DefaultClient
tracker := usage.DefaultClient

go func() {
tracker.Collect(
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/apit/getsnippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/saucelabs/saucectl/internal/usage"
"github.com/spf13/cobra"
)
Expand All @@ -33,7 +32,7 @@ Use [--project] to specify the project by its name or run without [--project] to
return fmt.Errorf("invalid HTTP_PROXY value")
}

tracker := segment.DefaultClient
tracker := usage.DefaultClient

go func() {
tracker.Collect(
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/apit/getvariable.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/saucelabs/saucectl/internal/usage"
"github.com/spf13/cobra"
)
Expand All @@ -32,7 +31,7 @@ Use [--project] to specify the project by its name or run without [--project] to
return fmt.Errorf("invalid HTTP_PROXY value")
}

tracker := segment.DefaultClient
tracker := usage.DefaultClient

go func() {
tracker.Collect(
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/apit/listfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/saucelabs/saucectl/internal/usage"
)

Expand All @@ -27,7 +26,7 @@ Use [--project] to specify the project by its name or run without [--project] to
return fmt.Errorf("invalid HTTP_PROXY value")
}

tracker := segment.DefaultClient
tracker := usage.DefaultClient

go func() {
tracker.Collect(
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/apit/setsnippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/saucelabs/saucectl/internal/apitest"
cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/saucelabs/saucectl/internal/usage"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -44,7 +43,7 @@ cat snippet2.xml | saucectl apit vault set-snippet snip2 - --project "smoke test
return fmt.Errorf("invalid HTTP_PROXY value")
}

tracker := segment.DefaultClient
tracker := usage.DefaultClient

go func() {
tracker.Collect(
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/apit/setvariable.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/saucelabs/saucectl/internal/apitest"
cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/saucelabs/saucectl/internal/usage"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -38,7 +37,7 @@ Use [--project] to specify a project by its name or run without [--project] to c
return fmt.Errorf("invalid HTTP_PROXY value")
}

tracker := segment.DefaultClient
tracker := usage.DefaultClient

go func() {
tracker.Collect(
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/apit/uploadfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/saucelabs/saucectl/internal/usage"
)

Expand All @@ -35,7 +34,7 @@ Use [--project] to specify the project by its name or run without [--project] to
return fmt.Errorf("invalid HTTP_PROXY value")
}

tracker := segment.DefaultClient
tracker := usage.DefaultClient

go func() {
tracker.Collect(
Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/artifacts/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"errors"
"time"

"github.com/saucelabs/saucectl/internal/usage"

"github.com/saucelabs/saucectl/internal/credentials"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/region"
"github.com/saucelabs/saucectl/internal/saucecloud"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -37,7 +38,7 @@ func Command(preRun func(cmd *cobra.Command, args []string)) *cobra.Command {
return errors.New("invalid region")
}
if reg == region.Staging {
segment.DefaultClient.Enabled = false
usage.DefaultClient.Enabled = false
}

creds := credentials.Get()
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/artifacts/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/fpath"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/saucelabs/saucectl/internal/usage"
"github.com/schollz/progressbar/v3"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -39,7 +38,7 @@ func DownloadCommand() *cobra.Command {
return fmt.Errorf("invalid HTTP_PROXY value")
}

tracker := segment.DefaultClient
tracker := usage.DefaultClient

go func() {
tracker.Collect(
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/artifacts/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/jedib0t/go-pretty/v6/text"
cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/saucelabs/saucectl/internal/usage"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -83,7 +82,7 @@ func ListCommand() *cobra.Command {
return fmt.Errorf("invalid HTTP_PROXY value")
}

tracker := segment.DefaultClient
tracker := usage.DefaultClient

go func() {
tracker.Collect(
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/artifacts/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/saucelabs/saucectl/internal/usage"
"github.com/schollz/progressbar/v3"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -37,7 +36,7 @@ func UploadCommand() *cobra.Command {
return fmt.Errorf("invalid HTTP_PROXY value")
}

tracker := segment.DefaultClient
tracker := usage.DefaultClient

go func() {
tracker.Collect(
Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/configure/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (
"os"
"strings"

"github.com/saucelabs/saucectl/internal/usage"

"github.com/AlecAivazis/survey/v2"
"github.com/fatih/color"
"github.com/rs/zerolog/log"
cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/credentials"
"github.com/saucelabs/saucectl/internal/iam"
"github.com/saucelabs/saucectl/internal/msg"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/spf13/cobra"
)

Expand All @@ -35,7 +36,7 @@ func Command() *cobra.Command {
Example: configureExample,
SilenceUsage: true,
Run: func(cmd *cobra.Command, _ []string) {
tracker := segment.DefaultClient
tracker := usage.DefaultClient

go func() {
tracker.Collect(
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/docker/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
dockermsg "github.com/moby/moby/pkg/jsonmessage"
cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/progress"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/saucelabs/saucectl/internal/usage"
"github.com/schollz/progressbar/v3"
"github.com/spf13/cobra"
Expand All @@ -38,7 +37,7 @@ func PushCommand() *cobra.Command {
return nil
},
PreRun: func(cmd *cobra.Command, _ []string) {
tracker := segment.DefaultClient
tracker := usage.DefaultClient

go func() {
tracker.Collect(
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/imagerunner/artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/saucelabs/saucectl/internal/fileio"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/imagerunner"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/saucelabs/saucectl/internal/usage"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -98,7 +97,7 @@ func downloadCommand() *cobra.Command {
return fmt.Errorf("invalid HTTP_PROXY value")
}

tracker := segment.DefaultClient
tracker := usage.DefaultClient

go func() {
tracker.Collect(
Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/imagerunner/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"errors"
"time"

"github.com/saucelabs/saucectl/internal/usage"

"github.com/saucelabs/saucectl/internal/credentials"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/region"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/spf13/cobra"
)

Expand All @@ -31,7 +32,7 @@ func Command(preRun func(cmd *cobra.Command, args []string)) *cobra.Command {
return errors.New("invalid region")
}
if reg == region.Staging {
segment.DefaultClient.Enabled = false
usage.DefaultClient.Enabled = false
}

creds := credentials.Get()
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/imagerunner/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/jedib0t/go-pretty/v6/table"
cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/saucelabs/saucectl/internal/usage"
"github.com/spf13/cobra"
)
Expand All @@ -26,7 +25,7 @@ func ListCommand() *cobra.Command {
return fmt.Errorf("invalid HTTP_PROXY value")
}

tracker := segment.DefaultClient
tracker := usage.DefaultClient

go func() {
tracker.Collect(
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/imagerunner/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/http"
imgrunner "github.com/saucelabs/saucectl/internal/imagerunner"
"github.com/saucelabs/saucectl/internal/segment"
"github.com/saucelabs/saucectl/internal/usage"
"github.com/spf13/cobra"
)
Expand All @@ -32,7 +31,7 @@ func LogsCommand() *cobra.Command {
return fmt.Errorf("invalid HTTP_PROXY value")
}

tracker := segment.DefaultClient
tracker := usage.DefaultClient

go func() {
tracker.Collect(
Expand Down
Loading

0 comments on commit dcc3fcd

Please sign in to comment.