Skip to content

Commit

Permalink
Log correct exclusion analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
dmbrooke committed Aug 18, 2023
1 parent f29b359 commit 8226d67
Showing 1 changed file with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
logFacetClearAll,
logFacetDeselect,
logFacetSelect,
logFacetExclude,
} from '../../features/facets/facet-set/facet-set-analytics-actions';
import {logSearchboxSubmit} from '../../features/query/query-analytics-actions';
import {SearchParameters} from '../../features/search-parameters/search-parameter-actions';
Expand Down Expand Up @@ -117,10 +118,16 @@ function logFacetAnalyticsAction(
const addedIds = newIds.filter((id) => !previousIds.includes(id));
if (addedIds.length) {
const facetId = addedIds[0];
return logFacetSelect({
facetId,
facetValue: newFacets[facetId][0],
});
const facetValue = newFacets[facetId][0];
return facetValue === 'selected'
? logFacetSelect({
facetId,
facetValue: facetValue,
})
: logFacetExclude({
facetId,
facetValue: facetValue,
});
}

const facetIdWithDifferentValues = newIds.find((key) =>
Expand All @@ -140,10 +147,15 @@ function logFacetAnalyticsAction(
);

if (addedValues.length) {
return logFacetSelect({
facetId: facetIdWithDifferentValues,
facetValue: addedValues[0],
});
return addedValues[0] === 'selected'
? logFacetSelect({
facetId: facetIdWithDifferentValues,
facetValue: addedValues[0],
})
: logFacetExclude({
facetId: facetIdWithDifferentValues,
facetValue: addedValues[0],
});
}

const removedValues = previousValues.filter(
Expand Down

0 comments on commit 8226d67

Please sign in to comment.