Embeddable telemetry and reference extraction/injection#74352
Embeddable telemetry and reference extraction/injection#74352ppisljar merged 32 commits intoelastic:masterfrom
Conversation
|
Pinging @elastic/kibana-app-arch (Team:AppArch) |
412dfc9 to
28b78c7
Compare
28b78c7 to
9192a0a
Compare
There was a problem hiding this comment.
Just picked around during our meeting ( when you presented it )
Will try to play and understand a bit later.
We have this one place where we do migration for dashboard drilldown:
https://github.com/elastic/kibana/blob/master/x-pack/plugins/embeddable_enhanced/public/embeddables/embeddable_action_storage.ts#L122
Should we try to refactor it to use new approach in this pr?
src/plugins/embeddable/public/lib/embeddables/default_embeddable_factory_provider.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/ui_actions_enhanced/public/drilldowns/drilldown_definition.ts
Outdated
Show resolved
Hide resolved
src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts
Outdated
Show resolved
Hide resolved
|
Can you add tests for migrating base, extended and enhanced state? |
There was a problem hiding this comment.
input.id != type - this won't work.
I think the migrate function will have to ask for type, separate from input.
|
This is generally inline with my thinking. Few things though:
Example: migrate(state: unknown, version: number) {
if (version === 1 && isValid1State(state)) {
return state;
} else if (version === 0 && isValid0State(state)) {
return migrateBarChart0(state);
} else {
throw new Error("Invalid state");
}
}
}
|
9192a0a to
3408f1d
Compare
7f06f38 to
60cf0b1
Compare
|
@elasticmachine merge upstream |
There was a problem hiding this comment.
// disable can be also remove?
There was a problem hiding this comment.
I think also worth disabling this rule for ui_actions_enhanced_examples
be0a8dd to
43438c3
Compare
flash1293
left a comment
There was a problem hiding this comment.
Left a few more comments. Especially the ones about ts-ignore and the way telemetry works should be addressed before merging this
| >, | ||
| TSavedObjectAttributes extends SavedObjectAttributes = SavedObjectAttributes | ||
| > { | ||
| // @ts-ignore |
There was a problem hiding this comment.
This is worrying in such a basic type - can we avoid it to make sure we don't introduce actually wrong types here in the future?
| return { | ||
| telemetry: this.telemetry, | ||
| extract: this.extract, | ||
| inject: this.inject, |
There was a problem hiding this comment.
We can probably live without it for now, but as Tim mentioned once we have migrations on that level we also need to add them on the server as well and migrate everything before fetching telemetry
There was a problem hiding this comment.
adding migrations is the next step for this which will be done in a followup
|
|
||
| telemetryBaseEmbeddableInput(state, telemetryData); | ||
| if (factory) { | ||
| factory.telemetry(state, telemetryData); |
There was a problem hiding this comment.
This implementation seems strange to me - telemetry returns an updated telemetryData object, but we are simply discarding and probably assume the passed in object will be mutated.
I really don't like relying on object reference here and mutation the object passed into the function. This is not how reduce is typically implemented - can we make telemetry return a new object with added information instead of mutating the existing one? This can lead to hard to catch bugs.
| id: 'dynamicActions', | ||
| telemetry: (state: SerializableState, telemetry: Record<string, any>) => { | ||
| (state as DynamicActionsState).events.forEach((event: SerializedEvent) => { | ||
| if (uiActionsEnhanced.getActionFactory(event.action.factoryId)) { |
There was a problem hiding this comment.
nit: Can be shortened to
uiActionsEnhanced.getActionFactory(event.action.factoryId)?.telemetry(event, telemetry);There was a problem hiding this comment.
that might assign void to telemetryData
| ): EnhancementRegistryDefinition => { | ||
| return { | ||
| id: 'dynamicActions', | ||
| telemetry: (state: SerializableState, telemetryData: Record<string, any>) => { |
There was a problem hiding this comment.
No strong opinion, just interested - why did you keep the telemetry API on the client even if it's not used?
There was a problem hiding this comment.
so we can keep the same persistable state definition type on both sides
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
page load bundle size
distributable file count
History
To update your PR or re-run it, just comment with: |
Summary
adds
.telemetry.extractand.injectfunctions to embeddable service, which can take in any embeddable input and perform associated action on it.embeddable service exposes
.telemetry.injectand.extractfunction which then:same set of function was also added to dynamic actions registry:
As we need this functionality on the server as well and embeddable plugin and uiActionEnhanced plugins didn't have server contract until now, that was added as well, together with all the mentioned registried and functions.
note that telemetry/extract/inject functions were not added for any embeddable and should be done as a followup. most of them also have nested state dependency tree (for example visualize embeddable will need to check visualizations registry (which will need to provide all above functions, as well as every visualization registered), and some visualizations will need to go further like getting search source functions, which in turn shall get filter, query and timerange functions.
Checklist
Delete any items that are not applicable to this PR.
For maintainers