Skip to content

Commit

Permalink
feat(analytics): add analytics for local operations (#1051)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tieske authored Oct 18, 2023
1 parent e682e0f commit d30b35f
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const (
modeKonnect = iota
modeKong
modeKongEnterprise
modeLocal
)

var jsonOutput diff.JSONOutputObject
Expand Down Expand Up @@ -488,6 +489,8 @@ func sendAnalytics(cmd, kongVersion string, mode mode) error {
modeStr = "konnect"
case modeKongEnterprise:
modeStr = "enterprise"
case modeLocal:
modeStr = "local"
}
return utils.SendAnalytics(cmd, VERSION, kongVersion, modeStr)
}
Expand Down
1 change: 1 addition & 0 deletions cmd/file_addplugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var (
func executeAddPlugins(cmd *cobra.Command, cfgFiles []string) error {
verbosity, _ := cmd.Flags().GetInt("verbose")
logbasics.Initialize(log.LstdFlags, verbosity)
_ = sendAnalytics("file-add-plugins", "", modeLocal)

cmdAddPluginOutputFormat = strings.ToUpper(cmdAddPluginOutputFormat)

Expand Down
1 change: 1 addition & 0 deletions cmd/file_addtags.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var (
func executeAddTags(cmd *cobra.Command, tagsToAdd []string) error {
verbosity, _ := cmd.Flags().GetInt("verbose")
logbasics.Initialize(log.LstdFlags, verbosity)
_ = sendAnalytics("file-add-tags", "", modeLocal)

cmdAddTagsOutputFormat = strings.ToUpper(cmdAddTagsOutputFormat)

Expand Down
2 changes: 2 additions & 0 deletions cmd/file_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var (
)

func executeConvert(_ *cobra.Command, _ []string) error {
_ = sendAnalytics("file-convert", "", modeLocal)

sourceFormat, err := convert.ParseFormat(convertCmdSourceFormat)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions cmd/file_listtags.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var (
func executeListTags(cmd *cobra.Command, _ []string) error {
verbosity, _ := cmd.Flags().GetInt("verbose")
logbasics.Initialize(log.LstdFlags, verbosity)
_ = sendAnalytics("file-list-tags", "", modeLocal)

cmdListTagsOutputFormat = strings.ToUpper(cmdListTagsOutputFormat)

Expand Down
1 change: 1 addition & 0 deletions cmd/file_merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var (
func executeMerge(cmd *cobra.Command, args []string) error {
verbosity, _ := cmd.Flags().GetInt("verbose")
logbasics.Initialize(log.LstdFlags, verbosity)
_ = sendAnalytics("file-merge", "", modeLocal)

// do the work: read/merge
merged, info, err := merge.Files(args)
Expand Down
1 change: 1 addition & 0 deletions cmd/file_openapi2kong.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var (
func executeOpenapi2Kong(cmd *cobra.Command, _ []string) error {
verbosity, _ := cmd.Flags().GetInt("verbose")
logbasics.Initialize(log.LstdFlags, verbosity)
_ = sendAnalytics("file-openapi2kong", "", modeLocal)

if len(cmdO2KentityTags) == 0 {
cmdO2KentityTags = nil
Expand Down
1 change: 1 addition & 0 deletions cmd/file_patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var (
func executePatch(cmd *cobra.Command, args []string) error {
verbosity, _ := cmd.Flags().GetInt("verbose")
logbasics.Initialize(log.LstdFlags, verbosity)
_ = sendAnalytics("file-patch", "", modeLocal)

cmdPatchOutputFormat = strings.ToUpper(cmdPatchOutputFormat)

Expand Down
1 change: 1 addition & 0 deletions cmd/file_removetags.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var (
func executeRemoveTags(cmd *cobra.Command, tagsToRemove []string) error {
verbosity, _ := cmd.Flags().GetInt("verbose")
logbasics.Initialize(log.LstdFlags, verbosity)
_ = sendAnalytics("file-remove-tags", "", modeLocal)

cmdRemoveTagsOutputFormat = strings.ToUpper(cmdRemoveTagsOutputFormat)

Expand Down
1 change: 1 addition & 0 deletions cmd/file_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var (
)

func executeFileRenderCmd(_ *cobra.Command, _ []string) error {
_ = sendAnalytics("file-render", "", modeLocal)
return convert.Convert(
fileRenderCmdKongStateFile,
fileRenderCmdKongFileOutput,
Expand Down

0 comments on commit d30b35f

Please sign in to comment.