Skip to content

Commit 5abc16d

Browse files
authored
📮 emit cyclops install manager (#785)
* emit cyclops install manager * send only if populated
1 parent 8d4c8c4 commit 5abc16d

File tree

3 files changed

+30
-28
lines changed

3 files changed

+30
-28
lines changed

cyclops-ctrl/cmd/main/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func main() {
6868
telemetryClient, _ := telemetry.NewClient(
6969
getEnvBool("DISABLE_TELEMETRY"),
7070
os.Getenv("CYCLOPS_VERSION"),
71+
os.Getenv("INSTALL_MANAGER"),
7172
setupLog,
7273
)
7374
telemetryClient.InstanceStart()

cyclops-ctrl/internal/telemetry/client.go

+28-28
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ type logger interface {
2121
}
2222

2323
type EnqueueClient struct {
24-
client posthog.Client
25-
distinctID string
26-
version string
24+
client posthog.Client
25+
distinctID string
26+
version string
27+
installManager string
2728
}
2829

2930
type MockClient struct{}
3031

31-
func NewClient(disable bool, version string, logger logger) (Client, error) {
32+
func NewClient(disable bool, version, installManager string, logger logger) (Client, error) {
3233
if disable {
3334
logger.Info("telemetry disabled")
3435
return MockClient{}, nil
@@ -56,82 +57,81 @@ func NewClient(disable bool, version string, logger logger) (Client, error) {
5657
logger.Info("starting instance with UUID", "UUID", idStr)
5758

5859
return EnqueueClient{
59-
client: client,
60-
distinctID: idStr,
61-
version: version,
60+
client: client,
61+
distinctID: idStr,
62+
version: version,
63+
installManager: installManager,
6264
}, nil
6365
}
6466

6567
func (c EnqueueClient) InstanceStart() {
6668
_ = c.client.Enqueue(posthog.Capture{
6769
Event: "cyclops-instance-start",
6870
DistinctId: c.distinctID,
69-
Properties: map[string]interface{}{
70-
"version": c.version,
71-
},
71+
Properties: c.messageProps(),
7272
})
7373
}
7474

7575
func (c EnqueueClient) ModuleReconciliation() {
7676
_ = c.client.Enqueue(posthog.Capture{
7777
Event: "module-reconciliation",
7878
DistinctId: c.distinctID,
79-
Properties: map[string]interface{}{
80-
"version": c.version,
81-
},
79+
Properties: c.messageProps(),
8280
})
8381
}
8482

8583
func (c EnqueueClient) ModuleCreation() {
8684
_ = c.client.Enqueue(posthog.Capture{
8785
Event: "module-creation",
8886
DistinctId: c.distinctID,
89-
Properties: map[string]interface{}{
90-
"version": c.version,
91-
},
87+
Properties: c.messageProps(),
9288
})
9389
}
9490

9591
func (c EnqueueClient) ReleaseUpdate() {
9692
_ = c.client.Enqueue(posthog.Capture{
9793
Event: "helm-release-upgrade",
9894
DistinctId: c.distinctID,
99-
Properties: map[string]interface{}{
100-
"version": c.version,
101-
},
95+
Properties: c.messageProps(),
10296
})
10397
}
10498

10599
func (c EnqueueClient) ReleaseMigration() {
106100
_ = c.client.Enqueue(posthog.Capture{
107101
Event: "helm-release-migration",
108102
DistinctId: c.distinctID,
109-
Properties: map[string]interface{}{
110-
"version": c.version,
111-
},
103+
Properties: c.messageProps(),
112104
})
113105
}
114106

115107
func (c EnqueueClient) TemplateCreation() {
116108
_ = c.client.Enqueue(posthog.Capture{
117109
Event: "template-creation",
118110
DistinctId: c.distinctID,
119-
Properties: map[string]interface{}{
120-
"version": c.version,
121-
},
111+
Properties: c.messageProps(),
122112
})
123113
}
124114

125115
func (c EnqueueClient) TemplateEdit() {
126116
_ = c.client.Enqueue(posthog.Capture{
127117
Event: "template-edit",
128118
DistinctId: c.distinctID,
129-
Properties: map[string]interface{}{
130-
"version": c.version,
131-
},
119+
Properties: c.messageProps(),
132120
})
133121
}
134122

123+
func (c EnqueueClient) messageProps() map[string]interface{} {
124+
props := map[string]interface{}{
125+
"version": c.version,
126+
}
127+
128+
if props != nil && len(c.installManager) != 0 {
129+
props["install_manager"] = c.installManager
130+
}
131+
132+
return props
133+
}
134+
135135
// region mock client
136136

137137
func (c MockClient) InstanceStart() {

web/docs/usage_metrics/usage_metrics.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Each time one of the events above is triggered, Cyclops sends an HTTP request to
3030
`distinct_id` - generated for each Cyclops instance using [NewUUID](https://pkg.go.dev/github.com/google/uuid#NewUUID) from google/uuid package
3131
`event` - which event was triggered; see events above
3232
`properties.version` - version of your Cyclops instance
33+
`properties.install_manager` - emits if Cyclops is installed via other applications/marketplaces (Rancher, Civo marketplace, DigitalOcean marketplace...)
3334

3435
## Turn off
3536

0 commit comments

Comments
 (0)