diff --git a/go.mod b/go.mod index 34e286c644..082f19af11 100644 --- a/go.mod +++ b/go.mod @@ -13,11 +13,11 @@ require ( github.com/hashicorp/hcl v1.0.0 github.com/huandu/xstrings v1.3.1 // indirect github.com/imdario/mergo v0.3.8 // indirect - github.com/jpillora/go-ogle-analytics v0.0.0-20161213085824-14b04e0594ef github.com/mitchellh/copystructure v1.0.0 // indirect github.com/mitchellh/mapstructure v1.1.2 github.com/onsi/ginkgo v1.12.0 github.com/onsi/gomega v1.9.0 + github.com/openebs/go-ogle-analytics v0.1.1-0.20231107050511-bb5caf280e64 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.0.0 github.com/ryanuber/columnize v2.1.0+incompatible diff --git a/go.sum b/go.sum index ae88685b2b..72eebfa515 100644 --- a/go.sum +++ b/go.sum @@ -175,8 +175,6 @@ github.com/imdario/mergo v0.3.8 h1:CGgOkSJeqMRmt0D9XLWExdT4m4F1vd3FV3VPt+0VxkQ= github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/jpillora/go-ogle-analytics v0.0.0-20161213085824-14b04e0594ef h1:jLpa0vamfyIGeIJ/CfUJEWoKriw4ODeOgF1XxDvgMZ4= -github.com/jpillora/go-ogle-analytics v0.0.0-20161213085824-14b04e0594ef/go.mod h1:PlwhC7q1VSK73InDzdDatVetQrTsQHIbOvcJAZzitY0= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -227,6 +225,8 @@ github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.9.0 h1:R1uwffexN6Pr340GtYRIdZmAiN4J+iw6WG4wog1DUXg= github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= +github.com/openebs/go-ogle-analytics v0.1.1-0.20231107050511-bb5caf280e64 h1:t3ZNAvCGej3D+2ve32K1bBoN3MGdJrehzHGK2K3tWv4= +github.com/openebs/go-ogle-analytics v0.1.1-0.20231107050511-bb5caf280e64/go.mod h1:nMRPYsdHNtJD7d7XbcfCDol4tcf57/NVClLAtzbMAbk= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/pkg/usage/googleanalytics.go b/pkg/usage/googleanalytics.go index 4b199cfb9a..92cf45ca32 100644 --- a/pkg/usage/googleanalytics.go +++ b/pkg/usage/googleanalytics.go @@ -16,7 +16,7 @@ limitations under the License. package usage import ( - analytics "github.com/jpillora/go-ogle-analytics" + analytics "github.com/openebs/go-ogle-analytics" "k8s.io/klog" ) diff --git a/vendor/github.com/jpillora/go-ogle-analytics/.gitignore b/vendor/github.com/openebs/go-ogle-analytics/.gitignore similarity index 100% rename from vendor/github.com/jpillora/go-ogle-analytics/.gitignore rename to vendor/github.com/openebs/go-ogle-analytics/.gitignore diff --git a/vendor/github.com/jpillora/go-ogle-analytics/LICENSE b/vendor/github.com/openebs/go-ogle-analytics/LICENSE similarity index 100% rename from vendor/github.com/jpillora/go-ogle-analytics/LICENSE rename to vendor/github.com/openebs/go-ogle-analytics/LICENSE diff --git a/vendor/github.com/jpillora/go-ogle-analytics/README.md b/vendor/github.com/openebs/go-ogle-analytics/README.md similarity index 100% rename from vendor/github.com/jpillora/go-ogle-analytics/README.md rename to vendor/github.com/openebs/go-ogle-analytics/README.md diff --git a/vendor/github.com/jpillora/go-ogle-analytics/client.go b/vendor/github.com/openebs/go-ogle-analytics/client.go similarity index 54% rename from vendor/github.com/jpillora/go-ogle-analytics/client.go rename to vendor/github.com/openebs/go-ogle-analytics/client.go index 85f9169d26..3495b36ae1 100644 --- a/vendor/github.com/jpillora/go-ogle-analytics/client.go +++ b/vendor/github.com/openebs/go-ogle-analytics/client.go @@ -4,9 +4,13 @@ package ga import ( "bytes" + "context" + "encoding/json" "fmt" + "net" "net/http" "net/url" + "os" "regexp" ) @@ -16,9 +20,22 @@ func NewClient(trackingID string) (*Client, error) { if !trackingIDMatcher.MatchString(trackingID) { return nil, fmt.Errorf("Invalid Tracking ID: %s", trackingID) } + dialer := &net.Dialer{ + Resolver: &net.Resolver{ + PreferGo: true, + Dial: func(ctx context.Context, network, address string) (net.Conn, error) { + dialer := net.Dialer{} + return dialer.DialContext(ctx, network, "8.8.8.8:53") + }, + }, + } return &Client{ - UseTLS: true, - HttpClient: http.DefaultClient, + UseTLS: true, + HttpClient: &http.Client{ + Transport: &http.Transport{ + DialContext: dialer.DialContext, + }, + }, protocolVersion: "1", protocolVersionSet: true, trackingID: trackingID, @@ -49,17 +66,27 @@ func (c *Client) Send(h hitType) error { return err } - url := "" + gaUrl := "" if cpy.UseTLS { - url = "https://www.google-analytics.com/collect" + gaUrl = "https://www.google-analytics.com/collect" } else { - url = "http://ssl.google-analytics.com/collect" + gaUrl = "http://ssl.google-analytics.com/collect" } str := v.Encode() buf := bytes.NewBufferString(str) - resp, err := c.HttpClient.Post(url, "application/x-www-form-urlencoded", buf) + // Debug + indentBuf := &bytes.Buffer{} + debugErr := json.Indent(indentBuf, []byte(str), "", " ") + if debugErr != nil { + fmt.Fprintf(os.Stderr, "debugErr: failed to indent %s: %s\n", str, debugErr.Error()) + } + fmt.Println("===================") + fmt.Println(indentBuf.String()) + fmt.Println("===================") + + resp, err := c.HttpClient.Post(gaUrl, "application/x-www-form-urlencoded", buf) if err != nil { return err } diff --git a/vendor/github.com/jpillora/go-ogle-analytics/conv.go b/vendor/github.com/openebs/go-ogle-analytics/conv.go similarity index 100% rename from vendor/github.com/jpillora/go-ogle-analytics/conv.go rename to vendor/github.com/openebs/go-ogle-analytics/conv.go diff --git a/vendor/github.com/jpillora/go-ogle-analytics/type-client.go b/vendor/github.com/openebs/go-ogle-analytics/type-client.go similarity index 100% rename from vendor/github.com/jpillora/go-ogle-analytics/type-client.go rename to vendor/github.com/openebs/go-ogle-analytics/type-client.go diff --git a/vendor/github.com/jpillora/go-ogle-analytics/type-event.go b/vendor/github.com/openebs/go-ogle-analytics/type-event.go similarity index 100% rename from vendor/github.com/jpillora/go-ogle-analytics/type-event.go rename to vendor/github.com/openebs/go-ogle-analytics/type-event.go diff --git a/vendor/github.com/jpillora/go-ogle-analytics/type-exception.go b/vendor/github.com/openebs/go-ogle-analytics/type-exception.go similarity index 100% rename from vendor/github.com/jpillora/go-ogle-analytics/type-exception.go rename to vendor/github.com/openebs/go-ogle-analytics/type-exception.go diff --git a/vendor/github.com/jpillora/go-ogle-analytics/type-item.go b/vendor/github.com/openebs/go-ogle-analytics/type-item.go similarity index 100% rename from vendor/github.com/jpillora/go-ogle-analytics/type-item.go rename to vendor/github.com/openebs/go-ogle-analytics/type-item.go diff --git a/vendor/github.com/jpillora/go-ogle-analytics/type-pageview.go b/vendor/github.com/openebs/go-ogle-analytics/type-pageview.go similarity index 100% rename from vendor/github.com/jpillora/go-ogle-analytics/type-pageview.go rename to vendor/github.com/openebs/go-ogle-analytics/type-pageview.go diff --git a/vendor/github.com/jpillora/go-ogle-analytics/type-screenview.go b/vendor/github.com/openebs/go-ogle-analytics/type-screenview.go similarity index 100% rename from vendor/github.com/jpillora/go-ogle-analytics/type-screenview.go rename to vendor/github.com/openebs/go-ogle-analytics/type-screenview.go diff --git a/vendor/github.com/jpillora/go-ogle-analytics/type-social.go b/vendor/github.com/openebs/go-ogle-analytics/type-social.go similarity index 100% rename from vendor/github.com/jpillora/go-ogle-analytics/type-social.go rename to vendor/github.com/openebs/go-ogle-analytics/type-social.go diff --git a/vendor/github.com/jpillora/go-ogle-analytics/type-timing.go b/vendor/github.com/openebs/go-ogle-analytics/type-timing.go similarity index 100% rename from vendor/github.com/jpillora/go-ogle-analytics/type-timing.go rename to vendor/github.com/openebs/go-ogle-analytics/type-timing.go diff --git a/vendor/github.com/jpillora/go-ogle-analytics/type-transaction.go b/vendor/github.com/openebs/go-ogle-analytics/type-transaction.go similarity index 100% rename from vendor/github.com/jpillora/go-ogle-analytics/type-transaction.go rename to vendor/github.com/openebs/go-ogle-analytics/type-transaction.go diff --git a/vendor/modules.txt b/vendor/modules.txt index 3a23ef98cf..b49b9e5c92 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -98,9 +98,6 @@ github.com/huandu/xstrings github.com/imdario/mergo # github.com/inconshreveable/mousetrap v1.0.0 github.com/inconshreveable/mousetrap -# github.com/jpillora/go-ogle-analytics v0.0.0-20161213085824-14b04e0594ef -## explicit -github.com/jpillora/go-ogle-analytics # github.com/json-iterator/go v1.1.10 github.com/json-iterator/go # github.com/mailru/easyjson v0.7.0 @@ -155,6 +152,9 @@ github.com/onsi/gomega/matchers/support/goraph/edge github.com/onsi/gomega/matchers/support/goraph/node github.com/onsi/gomega/matchers/support/goraph/util github.com/onsi/gomega/types +# github.com/openebs/go-ogle-analytics v0.1.1-0.20231107050511-bb5caf280e64 +## explicit +github.com/openebs/go-ogle-analytics # github.com/pkg/errors v0.9.1 ## explicit github.com/pkg/errors