elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.64k stars 8.23k forks source link

[Telemetry] Use internal repository instead of SO Client #147864

Open afharo opened 1 year ago

afharo commented 1 year ago
    nit: Potential improvement: Probably using the repository is good enough (no need to instantiate the client).

_Originally posted by @afharo in https://github.com/elastic/kibana/pull/147631#discussion_r1049898673_

It feels like we are only creating the client to make TS happy. We should change the types of the helpers to expect SavedObjectsClientContract instead of SavedObjectsClient and we can use the repository then :)

Relevant lines of code: https://github.com/elastic/kibana/blob/0b87e90c1889c8318c3a08b401e063318d5f0585/src/plugins/telemetry/server/fetcher.ts#L90-L92

The idea is that we can use the SO repository straight away:

- this.internalRepository = new SavedObjectsClient( 
-   savedObjects.createInternalRepository([TELEMETRY_SAVED_OBJECT_TYPE]) 
- ); 
+ this.internalRepository = savedObjects.createInternalRepository([TELEMETRY_SAVED_OBJECT_TYPE]);
elasticmachine commented 1 year ago

Pinging @elastic/kibana-core (Team:Core)