mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Maps] Track map embeddable usage with ui counters (#140994)
* Track map embeddable usage with ui counters * Change subscription to pipe(first()) The rxjs .toPromise() method is deprecated and the lastValueFrom function is the suggested replacement. * review feedback
This commit is contained in:
parent
2722123220
commit
333548e8a5
2 changed files with 12 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { first } from 'rxjs/operators';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { EmbeddableFactoryDefinition, IContainer } from '@kbn/embeddable-plugin/public';
|
||||
import { MAP_SAVED_OBJECT_TYPE, APP_ICON } from '../../common/constants';
|
||||
|
@ -12,6 +13,7 @@ import { getMapEmbeddableDisplayName } from '../../common/i18n_getters';
|
|||
import { extract, inject } from '../../common/embeddable';
|
||||
import { MapByReferenceInput, MapEmbeddableInput } from './types';
|
||||
import { lazyLoadMapModules } from '../lazy_load_bundle';
|
||||
import { getApplication, getUsageCollection } from '../kibana_services';
|
||||
|
||||
export class MapEmbeddableFactory implements EmbeddableFactoryDefinition {
|
||||
type = MAP_SAVED_OBJECT_TYPE;
|
||||
|
@ -50,6 +52,15 @@ export class MapEmbeddableFactory implements EmbeddableFactoryDefinition {
|
|||
|
||||
create = async (input: MapEmbeddableInput, parent?: IContainer) => {
|
||||
const { MapEmbeddable } = await lazyLoadMapModules();
|
||||
const usageCollection = getUsageCollection();
|
||||
if (usageCollection) {
|
||||
// currentAppId$ is a BehaviorSubject exposed as an observable so subscription gets last value upon subscribe
|
||||
getApplication()
|
||||
.currentAppId$.pipe(first())
|
||||
.subscribe((appId) => {
|
||||
if (appId) usageCollection.reportUiCounter('map', 'loaded', `open_maps_vis_${appId}`);
|
||||
});
|
||||
}
|
||||
return new MapEmbeddable(
|
||||
{
|
||||
editable: await this.isEditable(),
|
||||
|
|
|
@ -66,6 +66,7 @@ export const getPresentationUtilContext = () => pluginsStart.presentationUtil.Co
|
|||
export const getSecurityService = () => pluginsStart.security;
|
||||
export const getSpacesApi = () => pluginsStart.spaces;
|
||||
export const getTheme = () => coreStart.theme;
|
||||
export const getApplication = () => coreStart.application;
|
||||
export const getUsageCollection = () => pluginsStart.usageCollection;
|
||||
export const isScreenshotMode = () => {
|
||||
return pluginsStart.screenshotMode ? pluginsStart.screenshotMode.isScreenshotMode() : false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue