Search analytics event refactored

This commit is contained in:
svetlagasheva 2021-03-09 20:33:38 +02:00
parent 2797b68436
commit b8ea217730

View file

@ -16,13 +16,14 @@ const useSearch = (queryParams) => {
function emitSearchEvent() {
timerId = null;
const state = core.transport.getState('search');
const query = state.selected.extra.find((extra) => extra[0] === 'search')[1];
if (query !== null) {
const responses_count = state.catalogs.filter((catalog) => catalog.content.type === 'Ready').length;
if (state.selected !== null) {
const [, query] = state.selected.extra.find(([name]) => name === 'search');
const responses = state.catalogs.filter((catalog) => catalog.content.type === 'Ready');
core.transport.analytics({
event: 'Search',
args: {
query, responses_count
query,
responsesCount: responses.length
}
});
}