[Infrastructure UI] Track host cloud provider on table entry click (#150685)

## 📓 Summary

Closes #150681 

The tracked event when clicking an entry from the Hosts table was not
applying correctly the default `unknow` string for the `cloud_provider`
parameter.
Now it defaults to it in case the value is not passed or is null.

## 🧪 Testing
- Navigate to the Hosts view
- Open the console dev tools
- Click on a host name from the table and navigate to the host detail.
- Verify the following error does not appear in the log
```
Uncaught Error: Failed to validate payload coming from "Event Type 'Host Entry Clicked'":
[cloud_provider]: {"expected":"string","actual":"object","value":null}
```

Co-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani@elastic.co>
This commit is contained in:
Marco Antonio Ghiani 2023-02-09 19:19:10 +01:00 committed by GitHub
parent 1f03570126
commit 26eddec708
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,11 +22,11 @@ export class TelemetryClient implements ITelemetryClient {
public reportHostEntryClicked = ({
hostname,
cloud_provider: cloudProvider = 'unknown',
cloud_provider: cloudProvider,
}: HostEntryClickedParams) => {
this.analytics.reportEvent(InfraTelemetryEventTypes.HOSTS_ENTRY_CLICKED, {
hostname,
cloud_provider: cloudProvider,
cloud_provider: cloudProvider ?? 'unknown',
});
};