@@ -31,17 +31,19 @@ type (
31
31
}
32
32
33
33
CliStepData struct {
34
- Event CliEventType
34
+ Step CliStep
35
35
Status CliStepStatus
36
36
Description string
37
37
Err error
38
38
}
39
39
40
- CliEventType string
40
+ CliStep string
41
41
CliStepStatus string
42
+ FlowType string
42
43
43
44
segmentAnalyticsReporter struct {
44
45
client analytics.Client
46
+ flowType FlowType
45
47
flowId string
46
48
userId string
47
49
userName string
@@ -53,41 +55,46 @@ type (
53
55
)
54
56
55
57
const (
58
+ cliEvent string = "cli-runtime-operations"
59
+
56
60
// 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"
70
74
71
75
// 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"
76
80
77
81
// General
78
- SIGNAL_TERMINATION CliEventType = "signal-termination"
82
+ SIGNAL_TERMINATION CliStep = "signal-termination"
79
83
80
84
SUCCESS CliStepStatus = "SUCCESS"
81
85
FAILURE CliStepStatus = "FAILURE"
82
86
CANCELED CliStepStatus = "CANCELED"
87
+
88
+ InstallFlow FlowType = "installation"
89
+ UninstallFlow FlowType = "uninstallation"
83
90
)
84
91
85
92
// G returns the global reporter
86
93
func G () AnalyticsReporter {
87
94
return ar
88
95
}
89
96
90
- func Init (user * codefresh.User ) {
97
+ func Init (user * codefresh.User , flow FlowType ) {
91
98
writeKey := store .Get ().SegmentWriteKey
92
99
if writeKey == "" {
93
100
log .G ().Debug ("No segment write key was provided. Using the noop reporter." )
@@ -99,29 +106,32 @@ func Init(user *codefresh.User) {
99
106
ar = & segmentAnalyticsReporter {
100
107
client : analytics .New (writeKey ),
101
108
flowId : uuid .New ().String (),
109
+ flowType : flow ,
102
110
userId : user .ID ,
103
111
userName : user .Name ,
104
112
accountId : account .ID ,
105
113
accountName : account .Name ,
106
114
}
107
115
}
108
116
109
- func (r * segmentAnalyticsReporter ) ReportStep (step CliStepData ) {
117
+ func (r * segmentAnalyticsReporter ) ReportStep (data CliStepData ) {
110
118
properties := analytics .NewProperties ().
111
119
Set ("accountId" , r .accountId ).
112
120
Set ("accountName" , r .accountName ).
113
121
Set ("userName" , r .userName ).
114
122
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 )
117
127
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 ())
120
130
}
121
131
122
132
err := r .client .Enqueue (analytics.Track {
123
133
UserId : r .userId ,
124
- Event : string ( step . Event ) ,
134
+ Event : cliEvent ,
125
135
Properties : properties ,
126
136
})
127
137
0 commit comments