@@ -31,17 +31,19 @@ type (
3131 }
3232
3333 CliStepData struct {
34- Event CliEventType
34+ Step CliStep
3535 Status CliStepStatus
3636 Description string
3737 Err error
3838 }
3939
40- CliEventType string
40+ CliStep string
4141 CliStepStatus string
42+ FlowType string
4243
4344 segmentAnalyticsReporter struct {
4445 client analytics.Client
46+ flowType FlowType
4547 flowId string
4648 userId string
4749 userName string
@@ -53,41 +55,46 @@ type (
5355)
5456
5557const (
58+ cliEvent string = "cli-runtime-operations"
59+
5660 // Install
57- InstallStepPreChecks CliEventType = "install.pre-installation-checks"
58- InstallStepDownloadRuntimeDefinitions CliEventType = "install.download-runtime-definitions"
59- InstallStepGetServerAddress CliEventType = "install.get-server-address"
60- InstallStepCreateRuntimeOnPlatform CliEventType = "install.create-runtime-on-platform"
61- InstallStepBootstrapRepo CliEventType = "install.bootstrap-repo"
62- InstallStepCreateProject CliEventType = "install.create-project"
63- InstallStepCreateConfigMap CliEventType = "install.create-codefresh-cm"
64- InstallStepCreateComponent CliEventType = "install.create-component"
65- InstallStepInstallComponenets CliEventType = "install.install-components"
66- InstallStepCreateGitsource CliEventType = "install.create-gitsource"
67- InstallStepCreateMarketplaceGitsource CliEventType = "install.create-marketplace-gitsource"
68- InstallStepCompleteRuntimeInstallation CliEventType = "install.complete-runtime-installation"
69- InstallStepCreateDefaultGitIntegration CliEventType = "install.create-default-git-integration"
61+ InstallStepPreChecks CliStep = "install.pre-installation-checks"
62+ InstallStepDownloadRuntimeDefinitions CliStep = "install.download-runtime-definitions"
63+ InstallStepGetServerAddress CliStep = "install.get-server-address"
64+ InstallStepCreateRuntimeOnPlatform CliStep = "install.create-runtime-on-platform"
65+ InstallStepBootstrapRepo CliStep = "install.bootstrap-repo"
66+ InstallStepCreateProject CliStep = "install.create-project"
67+ InstallStepCreateConfigMap CliStep = "install.create-codefresh-cm"
68+ InstallStepCreateComponent CliStep = "install.create-component"
69+ InstallStepInstallComponenets CliStep = "install.install-components"
70+ InstallStepCreateGitsource CliStep = "install.create-gitsource"
71+ InstallStepCreateMarketplaceGitsource CliStep = "install.create-marketplace-gitsource"
72+ InstallStepCompleteRuntimeInstallation CliStep = "install.complete-runtime-installation"
73+ InstallStepCreateDefaultGitIntegration CliStep = "install.create-default-git-integration"
7074
7175 // Uninstall
72- UninstallStepCheckRuntimeExists CliEventType = "uninstall.check-runtime-exists"
73- UninstallStepUninstallRepo CliEventType = "uninstall.uninstall-repo"
74- UninstallStepDeleteRuntimeFromPlatform CliEventType = "uninstall.delete-runtime-from-platform"
75- UninstallStepCompleteRuntimeUninstallation CliEventType = "uninstall.complete-runtime-uninstall"
76+ UninstallStepCheckRuntimeExists CliStep = "uninstall.check-runtime-exists"
77+ UninstallStepUninstallRepo CliStep = "uninstall.uninstall-repo"
78+ UninstallStepDeleteRuntimeFromPlatform CliStep = "uninstall.delete-runtime-from-platform"
79+ UninstallStepCompleteRuntimeUninstallation CliStep = "uninstall.complete-runtime-uninstall"
7680
7781 // General
78- SIGNAL_TERMINATION CliEventType = "signal-termination"
82+ SIGNAL_TERMINATION CliStep = "signal-termination"
7983
8084 SUCCESS CliStepStatus = "SUCCESS"
8185 FAILURE CliStepStatus = "FAILURE"
8286 CANCELED CliStepStatus = "CANCELED"
87+
88+ InstallFlow FlowType = "installation"
89+ UninstallFlow FlowType = "uninstallation"
8390)
8491
8592// G returns the global reporter
8693func G () AnalyticsReporter {
8794 return ar
8895}
8996
90- func Init (user * codefresh.User ) {
97+ func Init (user * codefresh.User , flow FlowType ) {
9198 writeKey := store .Get ().SegmentWriteKey
9299 if writeKey == "" {
93100 log .G ().Debug ("No segment write key was provided. Using the noop reporter." )
@@ -99,29 +106,32 @@ func Init(user *codefresh.User) {
99106 ar = & segmentAnalyticsReporter {
100107 client : analytics .New (writeKey ),
101108 flowId : uuid .New ().String (),
109+ flowType : flow ,
102110 userId : user .ID ,
103111 userName : user .Name ,
104112 accountId : account .ID ,
105113 accountName : account .Name ,
106114 }
107115}
108116
109- func (r * segmentAnalyticsReporter ) ReportStep (step CliStepData ) {
117+ func (r * segmentAnalyticsReporter ) ReportStep (data CliStepData ) {
110118 properties := analytics .NewProperties ().
111119 Set ("accountId" , r .accountId ).
112120 Set ("accountName" , r .accountName ).
113121 Set ("userName" , r .userName ).
114122 Set ("flowId" , r .flowId ).
115- Set ("description" , step .Description ).
116- Set ("status" , step .Status )
123+ Set ("flowType" , r .flowType ).
124+ Set ("description" , data .Description ).
125+ Set ("step" , data .Step ).
126+ Set ("status" , data .Status )
117127
118- if step .Err != nil {
119- properties = properties .Set ("error" , step .Err .Error ())
128+ if data .Err != nil {
129+ properties = properties .Set ("error" , data .Err .Error ())
120130 }
121131
122132 err := r .client .Enqueue (analytics.Track {
123133 UserId : r .userId ,
124- Event : string ( step . Event ) ,
134+ Event : cliEvent ,
125135 Properties : properties ,
126136 })
127137
0 commit comments