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

(TFECO-7524) chore: add Stacks Terraform version to telemetry #1828

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions .changes/unreleased/INTERNAL-20240913-111349.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: INTERNAL
body: Add Stacks Terraform version to telemetry
time: 2024-09-13T11:13:49.570195+02:00
custom:
Issue: "1828"
Repository: terraform-ls
17 changes: 17 additions & 0 deletions internal/features/stacks/stacks_feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,20 @@ func (f *StacksFeature) Diagnostics(path string) diagnostics.Diagnostics {

return diags
}

func (f *StacksFeature) Telemetry(path string) map[string]interface{} {
properties := make(map[string]interface{})

record, err := f.store.StackRecordByPath(path)
if err != nil {
return properties
}

properties["stacks"] = true

if record.RequiredTerraformVersion != nil {
properties["stacksTfVersion"] = record.RequiredTerraformVersion.String()
}

return properties
}
4 changes: 4 additions & 0 deletions internal/langserver/handlers/hooks_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ func sendModuleTelemetry(features *Features, telemetrySender telemetry.Sender) n
// We assume there are no conflicting property keys
properties := features.Modules.Telemetry(path)
rootTelemetry := features.RootModules.Telemetry(path)
stacksTelemetry := features.Stacks.Telemetry(path)
for property, value := range rootTelemetry {
properties[property] = value
}
for property, value := range stacksTelemetry {
properties[property] = value
}

telemetrySender.SendEvent(ctx, "moduleData", properties)

Expand Down