@@ -31,6 +31,7 @@ import (
3131
3232 clientset "github.com/openebs/lvm-localpv/pkg/generated/clientset/internalclientset"
3333 informers "github.com/openebs/lvm-localpv/pkg/generated/informer/externalversions"
34+ "github.com/openebs/lvm-localpv/pkg/version"
3435
3536 "github.com/container-storage-interface/spec/lib/go/csi"
3637 "golang.org/x/net/context"
@@ -45,12 +46,12 @@ import (
4546 "github.com/openebs/lib-csi/pkg/common/errors"
4647 schd "github.com/openebs/lib-csi/pkg/scheduler"
4748
49+ analytics "github.com/openebs/google-analytics-4/usage"
4850 lvmapi "github.com/openebs/lvm-localpv/pkg/apis/openebs.io/lvm/v1alpha1"
4951 "github.com/openebs/lvm-localpv/pkg/builder/snapbuilder"
5052 "github.com/openebs/lvm-localpv/pkg/builder/volbuilder"
5153 "github.com/openebs/lvm-localpv/pkg/lvm"
5254 csipayload "github.com/openebs/lvm-localpv/pkg/response"
53- analytics "github.com/openebs/lvm-localpv/pkg/usage"
5455)
5556
5657// size constants
@@ -59,6 +60,16 @@ const (
5960 GB = 1000 * 1000 * 1000
6061 Mi = 1024 * 1024
6162 Gi = 1024 * 1024 * 1024
63+
64+ // Ping event is sent periodically
65+ Ping string = "lvm-ping"
66+
67+ // DefaultCASType Event application name constant for volume event
68+ DefaultCASType string = "lvm-localpv"
69+
70+ // LocalPVReplicaCount is the constant used by usage to represent
71+ // replication factor in LocalPV
72+ LocalPVReplicaCount string = "1"
6273)
6374
6475// controller is the server implementation
@@ -99,14 +110,13 @@ var SupportedVolumeCapabilityAccessModes = []*csi.VolumeCapability_AccessMode{
99110}
100111
101112// sendEventOrIgnore sends anonymous local-pv provision/delete events
102- func sendEventOrIgnore (pvcName , pvName , capacity , stgType , method string ) {
113+ func sendEventOrIgnore (pvcName , pvName , capacity , method string ) {
103114 if lvm .GoogleAnalyticsEnabled == "true" {
104- analytics .New ().Build ().ApplicationBuilder ().
105- SetVolumeType (stgType , method ).
106- SetDocumentTitle (pvName ).
107- SetCampaignName (pvcName ).
115+ analytics .New ().CommonBuild (DefaultCASType ).ApplicationBuilder ().
116+ SetVolumeName (pvName ).
117+ SetVolumeClaimName (pvcName ).
108118 SetLabel (analytics .EventLabelCapacity ).
109- SetReplicaCount (analytics . LocalPVReplicaCount , method ).
119+ SetReplicaCount (LocalPVReplicaCount , method ).
110120 SetCategory (method ).
111121 SetVolumeCapacity (capacity ).Send ()
112122 }
@@ -232,8 +242,9 @@ func (cs *controller) init() error {
232242 go pvcInformer .Informer ().Run (stopCh )
233243
234244 if lvm .GoogleAnalyticsEnabled == "true" {
235- analytics .New ().Build ().InstallBuilder (true ).Send ()
236- go analytics .PingCheck ()
245+ analytics .RegisterVersionGetter (version .GetVersionDetails )
246+ analytics .New ().CommonBuild (DefaultCASType ).InstallBuilder (true ).Send ()
247+ go analytics .PingCheck (DefaultCASType , Ping )
237248 }
238249
239250 if cs .leakProtection , err = csipv .NewLeakProtectionController (kubeClient ,
@@ -367,7 +378,7 @@ func (cs *controller) CreateVolume(
367378 }
368379 sendEventOrIgnore (params .PVCName , volName ,
369380 strconv .FormatInt (int64 (size ), 10 ),
370- "lvm-localpv" , analytics .VolumeProvision )
381+ analytics .VolumeProvision )
371382
372383 topology := map [string ]string {lvm .LVMTopologyKey : vol .Spec .OwnerNodeID }
373384 cntx := map [string ]string {lvm .VolGroupKey : vol .Spec .VolGroup , lvm .OpenEBSCasTypeKey : lvm .LVMCasTypeName }
@@ -419,7 +430,7 @@ func (cs *controller) deleteVolume(ctx context.Context, volumeID string) error {
419430 if err = lvm .WaitForLVMVolumeDestroy (ctx , volumeID ); err != nil {
420431 return err
421432 }
422- sendEventOrIgnore ("" , volumeID , vol .Spec .Capacity , "lvm-localpv" , analytics .VolumeDeprovision )
433+ sendEventOrIgnore ("" , volumeID , vol .Spec .Capacity , analytics .VolumeDeprovision )
423434 return nil
424435}
425436
0 commit comments