mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
[Maps] Add Layer types and settings UI counters (#136306)
* Layer views telemetry with ui counters * Add telemetry for layers when opening map
This commit is contained in:
parent
816264d5c4
commit
a0df571b2c
1 changed files with 33 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { METRIC_TYPE } from '@kbn/analytics';
|
||||||
import { i18n } from '@kbn/i18n';
|
import { i18n } from '@kbn/i18n';
|
||||||
import { EmbeddableStateTransfer } from '@kbn/embeddable-plugin/public';
|
import { EmbeddableStateTransfer } from '@kbn/embeddable-plugin/public';
|
||||||
import { OnSaveProps } from '@kbn/saved-objects-plugin/public';
|
import { OnSaveProps } from '@kbn/saved-objects-plugin/public';
|
||||||
|
@ -40,6 +41,7 @@ import {
|
||||||
getIsAllowByValueEmbeddables,
|
getIsAllowByValueEmbeddables,
|
||||||
getSavedObjectsTagging,
|
getSavedObjectsTagging,
|
||||||
getTimeFilter,
|
getTimeFilter,
|
||||||
|
getUsageCollection,
|
||||||
} from '../../../kibana_services';
|
} from '../../../kibana_services';
|
||||||
import { goToSpecifiedPath } from '../../../render_app';
|
import { goToSpecifiedPath } from '../../../render_app';
|
||||||
import { LayerDescriptor } from '../../../../common/descriptor_types';
|
import { LayerDescriptor } from '../../../../common/descriptor_types';
|
||||||
|
@ -50,6 +52,7 @@ import { createBasemapLayerDescriptor } from '../../../classes/layers/create_bas
|
||||||
import { whenLicenseInitialized } from '../../../licensed_features';
|
import { whenLicenseInitialized } from '../../../licensed_features';
|
||||||
import { SerializedMapState, SerializedUiState } from './types';
|
import { SerializedMapState, SerializedUiState } from './types';
|
||||||
import { setAutoOpenLayerWizardId } from '../../../actions/ui_actions';
|
import { setAutoOpenLayerWizardId } from '../../../actions/ui_actions';
|
||||||
|
import { LayerStatsCollector } from '../../../../common/telemetry';
|
||||||
|
|
||||||
function setMapSettingsFromEncodedState(settings: Partial<MapSettings>) {
|
function setMapSettingsFromEncodedState(settings: Partial<MapSettings>) {
|
||||||
const decodedCustomIcons = settings.customIcons
|
const decodedCustomIcons = settings.customIcons
|
||||||
|
@ -136,6 +139,8 @@ export class SavedMap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._reportUsage();
|
||||||
|
|
||||||
if (this._mapEmbeddableInput && this._mapEmbeddableInput.mapSettings !== undefined) {
|
if (this._mapEmbeddableInput && this._mapEmbeddableInput.mapSettings !== undefined) {
|
||||||
this._store.dispatch(setMapSettingsFromEncodedState(this._mapEmbeddableInput.mapSettings));
|
this._store.dispatch(setMapSettingsFromEncodedState(this._mapEmbeddableInput.mapSettings));
|
||||||
} else if (this._attributes?.mapStateJSON) {
|
} else if (this._attributes?.mapStateJSON) {
|
||||||
|
@ -270,6 +275,34 @@ export class SavedMap {
|
||||||
: this._attributes!.title;
|
: this._attributes!.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _reportUsage(): void {
|
||||||
|
const usageCollector = getUsageCollection();
|
||||||
|
if (!usageCollector || !this._attributes) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const layerStatsCollector = new LayerStatsCollector(this._attributes);
|
||||||
|
|
||||||
|
const uiCounterEvents = {
|
||||||
|
layer: layerStatsCollector.getLayerCounts(),
|
||||||
|
scaling: layerStatsCollector.getScalingCounts(),
|
||||||
|
resolution: layerStatsCollector.getResolutionCounts(),
|
||||||
|
join: layerStatsCollector.getJoinCounts(),
|
||||||
|
ems_basemap: layerStatsCollector.getBasemapCounts(),
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const [eventType, eventTypeMetrics] of Object.entries(uiCounterEvents)) {
|
||||||
|
for (const [eventName, count] of Object.entries(eventTypeMetrics)) {
|
||||||
|
usageCollector.reportUiCounter(
|
||||||
|
APP_ID,
|
||||||
|
METRIC_TYPE.LOADED,
|
||||||
|
`${eventType}_${eventName}`,
|
||||||
|
count
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setBreadcrumbs() {
|
setBreadcrumbs() {
|
||||||
if (!this._attributes) {
|
if (!this._attributes) {
|
||||||
throw new Error('Invalid usage, must await whenReady before calling hasUnsavedChanges');
|
throw new Error('Invalid usage, must await whenReady before calling hasUnsavedChanges');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue