Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Commit

Permalink
upstream ga fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
verdverm committed May 14, 2020
1 parent fd27fb9 commit 2702d10
Show file tree
Hide file tree
Showing 26 changed files with 76 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .hof/Cli/cmd/mvs/cmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var ConvertCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
2 changes: 1 addition & 1 deletion .hof/Cli/cmd/mvs/cmd/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var GraphCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
2 changes: 1 addition & 1 deletion .hof/Cli/cmd/mvs/cmd/hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var HackCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
2 changes: 1 addition & 1 deletion .hof/Cli/cmd/mvs/cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var InfoCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
2 changes: 1 addition & 1 deletion .hof/Cli/cmd/mvs/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var InitCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
7 changes: 2 additions & 5 deletions .hof/Cli/cmd/mvs/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/mvs/lib"
Expand Down Expand Up @@ -58,7 +56,7 @@ var RootCmd = &cobra.Command{

PreRun: func(cmd *cobra.Command, args []string) {

ga.SendGaEvent("root", strings.Join(args, "/"), 0)
ga.SendGaEvent("root", "<omit>", 0)

},
}
Expand All @@ -68,8 +66,7 @@ func init() {
hf := RootCmd.HelpFunc()
f := func(cmd *cobra.Command, args []string) {
if RootCmd.Name() == cmd.Name() {
as := strings.Join(args, "/")
ga.SendGaEvent("root/help", as, 0)
ga.SendGaEvent("root/help", "<omit>", 0)
}
hf(cmd, args)
}
Expand Down
2 changes: 1 addition & 1 deletion .hof/Cli/cmd/mvs/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var StatusCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
2 changes: 1 addition & 1 deletion .hof/Cli/cmd/mvs/cmd/tidy.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var TidyCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
2 changes: 1 addition & 1 deletion .hof/Cli/cmd/mvs/cmd/vendor.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var VendorCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
2 changes: 1 addition & 1 deletion .hof/Cli/cmd/mvs/cmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var VerifyCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
38 changes: 24 additions & 14 deletions .hof/Cli/cmd/mvs/ga/ga.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,27 @@ import (
)

func SendGaEvent(action, label string, value int) {
// Do something here to lookup / create
// cid := "13b3ad64-9154-11ea-9eba-47f617ab74f7"
if os.Getenv("MVS_TELEMETRY_DISABLED") != "" {
return
}

cid, err := readGaId()
if err != nil {
fmt.Println("Error", err)
cid = "unknown"
}

ua := fmt.Sprintf(
"%s/%s %s/%s",
"mvs", verinfo.Version,
verinfo.BuildOS, verinfo.BuildArch,
)

cfg := yagu.GaConfig{
TID: "UA-103579574-5",
CID: cid,
UA: "mvs/" + verinfo.Version,
UA: ua,
CN: "mvs",
CS: "mvs",
CS: "mvs/" + verinfo.Version,
CM: verinfo.Version,
}

Expand All @@ -45,11 +52,15 @@ func SendGaEvent(action, label string, value int) {
}

func readGaId() (string, error) {
ucd := yagu.UserHomeDir()
// ucd := yagu.UserHomeDir()
ucd, err := os.UserConfigDir()
if err != nil {
return "", err
}
dir := filepath.Join(ucd, ".hof")
fn := filepath.Join(dir, ".uuid")

_, err := os.Lstat(fn)
_, err = os.Lstat(fn)
if err != nil {
// file does not exist, probably...
return writeGaId()
Expand All @@ -64,16 +75,17 @@ func readGaId() (string, error) {
}

func writeGaId() (string, error) {
// fmt.Println("writeGaId")
ucd := yagu.UserHomeDir()

dir := filepath.Join(ucd, ".hof")
err := yagu.Mkdir(dir)
ucd, err := os.UserConfigDir()
if err != nil {
return "", err
}

// fmt.Println("Mkdir:", dir)
dir := filepath.Join(ucd, ".hof")
err = yagu.Mkdir(dir)
if err != nil {
return "", err
}

fn := filepath.Join(dir, ".uuid")

Expand All @@ -82,8 +94,6 @@ func writeGaId() (string, error) {
return id.String(), err
}

// fmt.Println("writeGaId: ", id.String())

err = ioutil.WriteFile(fn, []byte(id.String()), 0644)
if err != nil {
return id.String(), err
Expand Down
2 changes: 1 addition & 1 deletion cmd/mvs/cmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var ConvertCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
2 changes: 1 addition & 1 deletion cmd/mvs/cmd/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var GraphCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
2 changes: 1 addition & 1 deletion cmd/mvs/cmd/hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var HackCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
2 changes: 1 addition & 1 deletion cmd/mvs/cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var InfoCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
2 changes: 1 addition & 1 deletion cmd/mvs/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var InitCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
7 changes: 2 additions & 5 deletions cmd/mvs/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/mvs/lib"
Expand Down Expand Up @@ -58,7 +56,7 @@ var RootCmd = &cobra.Command{

PreRun: func(cmd *cobra.Command, args []string) {

ga.SendGaEvent("root", strings.Join(args, "/"), 0)
ga.SendGaEvent("root", "<omit>", 0)

},
}
Expand All @@ -68,8 +66,7 @@ func init() {
hf := RootCmd.HelpFunc()
f := func(cmd *cobra.Command, args []string) {
if RootCmd.Name() == cmd.Name() {
as := strings.Join(args, "/")
ga.SendGaEvent("root/help", as, 0)
ga.SendGaEvent("root/help", "<omit>", 0)
}
hf(cmd, args)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/mvs/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var StatusCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
2 changes: 1 addition & 1 deletion cmd/mvs/cmd/tidy.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var TidyCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
2 changes: 1 addition & 1 deletion cmd/mvs/cmd/vendor.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var VendorCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
2 changes: 1 addition & 1 deletion cmd/mvs/cmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var VerifyCmd = &cobra.Command{

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)
ga.SendGaEvent(c, "<omit>", 0)

},

Expand Down
38 changes: 24 additions & 14 deletions cmd/mvs/ga/ga.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,27 @@ import (
)

func SendGaEvent(action, label string, value int) {
// Do something here to lookup / create
// cid := "13b3ad64-9154-11ea-9eba-47f617ab74f7"
if os.Getenv("MVS_TELEMETRY_DISABLED") != "" {
return
}

cid, err := readGaId()
if err != nil {
fmt.Println("Error", err)
cid = "unknown"
}

ua := fmt.Sprintf(
"%s/%s %s/%s",
"mvs", verinfo.Version,
verinfo.BuildOS, verinfo.BuildArch,
)

cfg := yagu.GaConfig{
TID: "UA-103579574-5",
CID: cid,
UA: "mvs/" + verinfo.Version,
UA: ua,
CN: "mvs",
CS: "mvs",
CS: "mvs/" + verinfo.Version,
CM: verinfo.Version,
}

Expand All @@ -45,11 +52,15 @@ func SendGaEvent(action, label string, value int) {
}

func readGaId() (string, error) {
ucd := yagu.UserHomeDir()
// ucd := yagu.UserHomeDir()
ucd, err := os.UserConfigDir()
if err != nil {
return "", err
}
dir := filepath.Join(ucd, ".hof")
fn := filepath.Join(dir, ".uuid")

_, err := os.Lstat(fn)
_, err = os.Lstat(fn)
if err != nil {
// file does not exist, probably...
return writeGaId()
Expand All @@ -64,16 +75,17 @@ func readGaId() (string, error) {
}

func writeGaId() (string, error) {
// fmt.Println("writeGaId")
ucd := yagu.UserHomeDir()

dir := filepath.Join(ucd, ".hof")
err := yagu.Mkdir(dir)
ucd, err := os.UserConfigDir()
if err != nil {
return "", err
}

// fmt.Println("Mkdir:", dir)
dir := filepath.Join(ucd, ".hof")
err = yagu.Mkdir(dir)
if err != nil {
return "", err
}

fn := filepath.Join(dir, ".uuid")

Expand All @@ -82,8 +94,6 @@ func writeGaId() (string, error) {
return id.String(), err
}

// fmt.Println("writeGaId: ", id.String())

err = ioutil.WriteFile(fn, []byte(id.String()), 0644)
if err != nil {
return id.String(), err
Expand Down
2 changes: 1 addition & 1 deletion cue.mods
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ module github.com/hofstadter-io/mvs
cue master

require (
github.com/hofstadter-io/hofmod-cli v0.5.2
github.com/hofstadter-io/hofmod-cli v0.5.3
)
2 changes: 2 additions & 0 deletions cue.sums
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ github.com/hofstadter-io/hofmod-cli v0.5.1 h1:a8Zworm73OyAUxtVPEzibspP5kImka/3D+
github.com/hofstadter-io/hofmod-cli v0.5.1/cue.mods h1:8TVLRMLOvfcVRZu6NqDr4VFmvuw/9Ca7YpCMo1fTRmU=
github.com/hofstadter-io/hofmod-cli v0.5.2 h1:LAtrhhLOnuPaAS/P+5E+9Rgq0XmcpRBwuS4iisKZQ1M=
github.com/hofstadter-io/hofmod-cli v0.5.2/cue.mods h1:8TVLRMLOvfcVRZu6NqDr4VFmvuw/9Ca7YpCMo1fTRmU=
github.com/hofstadter-io/hofmod-cli v0.5.3 h1:9QcITvHncO6lWHezRnM1YXkVTula6sfsHEQXQh2LI+E=
github.com/hofstadter-io/hofmod-cli v0.5.3/cue.mods h1:8TVLRMLOvfcVRZu6NqDr4VFmvuw/9Ca7YpCMo1fTRmU=
Loading

0 comments on commit 2702d10

Please sign in to comment.