Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(event): update ua to ga4 analytics #268

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ go 1.19
require (
github.com/container-storage-interface/spec v1.8.0
github.com/docker/go-units v0.4.0
github.com/jpillora/go-ogle-analytics v0.0.0-20161213085824-14b04e0594ef
github.com/kubernetes-csi/csi-lib-utils v0.9.0
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.27.4
github.com/openebs/lib-csi v0.8.0
github.com/openebs/go-ogle-analytics v0.1.1-0.20231110084411-b4989b1cee82
github.com/openebs/lib-csi v0.8.2
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.15.1
github.com/spf13/cobra v1.6.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7P
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
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.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
Expand Down Expand Up @@ -312,8 +310,10 @@ github.com/onsi/gomega v1.27.1/go.mod h1:aHX5xOykVYzWOV4WqQy0sy8BQptgukenXpCXfad
github.com/onsi/gomega v1.27.3/go.mod h1:5vG284IBtfDAmDyrK+eGyZmUgUlmi+Wngqo557cZ6Gw=
github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E=
github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3q3fQ=
github.com/openebs/lib-csi v0.8.0 h1:lxhv/SRjS7DBz7vTLkaDPd/FJnUftofxSFTU4fdZzW0=
github.com/openebs/lib-csi v0.8.0/go.mod h1:4yc0Q1thH+oU80z73zGELfrOw2yeLdLNIRmcrxBxsBc=
github.com/openebs/go-ogle-analytics v0.1.1-0.20231110084411-b4989b1cee82 h1:aMJHous5CfQ2ieYftSwxZW5ry6+hud9As4I0oJPkK/A=
github.com/openebs/go-ogle-analytics v0.1.1-0.20231110084411-b4989b1cee82/go.mod h1:4xapXO4MRDVgGyUZdCD/5GQkPSwMgoen0f0qayOdW94=
github.com/openebs/lib-csi v0.8.2 h1:HmoiZX3VXFPglwqnRPnRus7K58ixDWBa19OpPZGk2Ws=
github.com/openebs/lib-csi v0.8.2/go.mod h1:4yc0Q1thH+oU80z73zGELfrOw2yeLdLNIRmcrxBxsBc=
github.com/pborman/uuid v0.0.0-20170612153648-e790cca94e6c/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34=
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=
Expand Down
15 changes: 7 additions & 8 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,11 @@ var SupportedVolumeCapabilityAccessModes = []*csi.VolumeCapability_AccessMode{
}

// sendEventOrIgnore sends anonymous local-pv provision/delete events
func sendEventOrIgnore(pvcName, pvName, capacity, stgType, method string) {
func sendEventOrIgnore(pvcName, pvName, capacity, method string) {
if lvm.GoogleAnalyticsEnabled == "true" {
analytics.New().Build().ApplicationBuilder().
SetVolumeType(stgType, method).
SetDocumentTitle(pvName).
SetCampaignName(pvcName).
analytics.New().CommonBuild().ApplicationBuilder().
SetVolumeName(pvName).
SetVolumeClaimName(pvcName).
SetLabel(analytics.EventLabelCapacity).
SetReplicaCount(analytics.LocalPVReplicaCount, method).
SetCategory(method).
Expand Down Expand Up @@ -232,7 +231,7 @@ func (cs *controller) init() error {
go pvcInformer.Informer().Run(stopCh)

if lvm.GoogleAnalyticsEnabled == "true" {
analytics.New().Build().InstallBuilder(true).Send()
analytics.New().CommonBuild().InstallBuilder(true).Send()
go analytics.PingCheck()
}

Expand Down Expand Up @@ -367,7 +366,7 @@ func (cs *controller) CreateVolume(
}
sendEventOrIgnore(params.PVCName, volName,
strconv.FormatInt(int64(size), 10),
"lvm-localpv", analytics.VolumeProvision)
analytics.VolumeProvision)

topology := map[string]string{lvm.LVMTopologyKey: vol.Spec.OwnerNodeID}
cntx := map[string]string{lvm.VolGroupKey: vol.Spec.VolGroup, lvm.OpenEBSCasTypeKey: lvm.LVMCasTypeName}
Expand Down Expand Up @@ -419,7 +418,7 @@ func (cs *controller) deleteVolume(ctx context.Context, volumeID string) error {
if err = lvm.WaitForLVMVolumeDestroy(ctx, volumeID); err != nil {
return err
}
sendEventOrIgnore("", volumeID, vol.Spec.Capacity, "lvm-localpv", analytics.VolumeDeprovision)
sendEventOrIgnore("", volumeID, vol.Spec.Capacity, analytics.VolumeDeprovision)
return nil
}

Expand Down
25 changes: 4 additions & 21 deletions pkg/usage/googleanalytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package usage

import (
analytics "github.com/jpillora/go-ogle-analytics"
"k8s.io/klog/v2"
)

Expand All @@ -27,26 +26,10 @@ import (
func (u *Usage) Send() {
// Instantiate a Gclient with the tracking ID
go func() {
// Un-wrap the gaClient struct back here
gaClient, err := analytics.NewClient(u.Gclient.trackID)
if err != nil {
return
}
gaClient.ClientID(u.clientID).
CampaignSource(u.campaignSource).
CampaignContent(u.clientID).
CampaignName(u.campaignName).
ApplicationID(u.appID).
ApplicationVersion(u.appVersion).
DataSource(u.dataSource).
ApplicationName(u.appName).
ApplicationInstallerID(u.appInstallerID).
DocumentTitle(u.documentTitle)
// Un-wrap the Event struct back here
event := analytics.NewEvent(u.category, u.action)
event.Label(u.label)
event.Value(u.value)
if err := gaClient.Send(event); err != nil {
client := u.AnalyticsClient
event := u.OpenebsEventBuilder.Build()

if err := client.Send(event); err != nil {
klog.Errorf(err.Error())
return
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/usage/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func PingCheck() {
duration := getPingPeriod()
ticker := time.NewTicker(duration)
for range ticker.C {
u.Build().
u.CommonBuild().
InstallBuilder(true).
SetCategory(Ping).
Send()
Expand Down
Loading
Loading