mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Add reportInteraction into plugin search (#84283)
add reportInteraction into plugin search
This commit is contained in:
parent
336acaf0bf
commit
9de3d75bea
@ -3,6 +3,7 @@ import React from 'react';
|
||||
import Skeleton from 'react-loading-skeleton';
|
||||
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { locationService, reportInteraction } from '@grafana/runtime';
|
||||
import { Badge, Icon, Stack, useStyles2 } from '@grafana/ui';
|
||||
import { SkeletonComponent, attachSkeleton } from '@grafana/ui/src/unstable';
|
||||
|
||||
@ -23,8 +24,17 @@ function PluginListItemComponent({ plugin, pathName, displayMode = PluginListDis
|
||||
const styles = useStyles2(getStyles);
|
||||
const isList = displayMode === PluginListDisplayMode.List;
|
||||
|
||||
const reportUserClickInteraction = () => {
|
||||
if (locationService.getSearchObject()?.q) {
|
||||
reportInteraction('plugins_search_user_click', {});
|
||||
}
|
||||
};
|
||||
return (
|
||||
<a href={`${pathName}/${plugin.id}`} className={cx(styles.container, { [styles.list]: isList })}>
|
||||
<a
|
||||
href={`${pathName}/${plugin.id}`}
|
||||
className={cx(styles.container, { [styles.list]: isList })}
|
||||
onClick={reportUserClickInteraction}
|
||||
>
|
||||
<PluginLogo src={plugin.info.logos.small} className={styles.pluginLogo} height={LOGO_SIZE} alt="" />
|
||||
<h2 className={cx(styles.name, 'plugin-name')}>{plugin.name}</h2>
|
||||
<div className={cx(styles.content, 'plugin-content')}>
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
|
||||
import { PluginError, PluginType, unEscapeStringFromRegex } from '@grafana/data';
|
||||
import { reportInteraction } from '@grafana/runtime';
|
||||
|
||||
import { filterByKeyword } from '../helpers';
|
||||
import { RequestStatus, PluginCatalogStoreState } from '../types';
|
||||
@ -35,6 +36,9 @@ export const selectPlugins = (filters: PluginFilters) =>
|
||||
const keyword = filters.keyword ? unEscapeStringFromRegex(filters.keyword.toLowerCase()) : '';
|
||||
const filteredPluginIds = keyword !== '' ? filterByKeyword(plugins, keyword) : null;
|
||||
|
||||
if (keyword) {
|
||||
reportInteraction('plugins_search', { resultsCount: filteredPluginIds?.length });
|
||||
}
|
||||
return plugins.filter((plugin) => {
|
||||
if (keyword && filteredPluginIds == null) {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user