Skip to content

Commit

Permalink
Merge pull request #829 from navikt/log-search-string-when-added
Browse files Browse the repository at this point in the history
Logger search string når man legger det inn i combobox
  • Loading branch information
otenav authored Oct 11, 2024
2 parents 5bbe2a3 + 33e0948 commit 581664c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app/(sok)/_components/searchBox/SearchCombobox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import useQuery from "@/app/(sok)/_components/QueryProvider";
import { QueryNames } from "@/app/(sok)/_utils/QueryNames";
import { findLabelForFilter, getSearchBoxOptions } from "@/app/(sok)/_components/searchBox/buildSearchBoxOptions";
import logAmplitudeEvent, { logFilterChanged } from "@/app/_common/monitoring/amplitude";
import { logSearchString } from "@/app/_common/monitoring/search-logging";

function SearchCombobox({ aggregations, locations }) {
const [showComboboxList, setShowComboboxList] = useState(undefined);
Expand Down Expand Up @@ -33,6 +34,7 @@ function SearchCombobox({ aggregations, locations }) {
const handleFreeTextSearchOption = (value, isSelected) => {
if (isSelected) {
query.append(QueryNames.SEARCH_STRING, value);
logSearchString(value);
logAmplitudeEvent("Text searched", { searchTerm: "Add" });
} else {
query.remove(QueryNames.SEARCH_STRING, value);
Expand Down
4 changes: 4 additions & 0 deletions src/app/_common/monitoring/search-logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export async function logSearch(rating, rawSearchParams) {
loggerWithoutCallId.info(`[rating search params] ${JSON.stringify(metadata)}`);
}

export async function logSearchString(searchString) {
loggerWithoutCallId.info(`[search string] ${searchString}`);
}

export async function logTextSearch(rawSearchParams) {
const searchParams = removeUnknownSearchParams(rawSearchParams);

Expand Down

0 comments on commit 581664c

Please sign in to comment.