ublo-lib 1.47.91 → 1.47.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/common/components/search-bar/hooks/use-search.d.ts.map +1 -1
- package/es/common/components/search-bar/hooks/use-search.js +7 -1
- package/es/common/components/search-bar/search-bar.js +26 -5
- package/es/esf/components/instant-search/instant-search.js +1 -1
- package/es/lbm/components/instant-search/hooks/use-search.d.ts.map +1 -1
- package/es/lbm/components/instant-search/hooks/use-search.js +8 -1
- package/es/lbm/components/instant-search/instant-search.d.ts.map +1 -1
- package/es/lbm/components/instant-search/instant-search.js +19 -2
- package/es/lbm/components/instant-search/results.d.ts +1 -1
- package/es/lbm/components/instant-search/results.d.ts.map +1 -1
- package/es/lbm/components/instant-search/results.js +1 -1
- package/es/market-place/components/instant-search/hooks/use-search.d.ts.map +1 -1
- package/es/market-place/components/instant-search/hooks/use-search.js +8 -1
- package/es/market-place/components/instant-search/instant-search.d.ts.map +1 -1
- package/es/market-place/components/instant-search/instant-search.js +16 -1
- package/es/market-place/components/instant-search/results.d.ts +1 -1
- package/es/market-place/components/instant-search/results.d.ts.map +1 -1
- package/es/market-place/components/instant-search/results.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-search.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/search-bar/hooks/use-search.js"],"names":[],"mappings":"AAGA;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"use-search.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/search-bar/hooks/use-search.js"],"names":[],"mappings":"AAGA;;;;;;;;;;EAYC"}
|
|
@@ -2,6 +2,12 @@ import useDebouncedSearch from "./use-debounced-search";
|
|
|
2
2
|
import { fetchResults } from "../utils/fetcher";
|
|
3
3
|
export default function useSearch({ ubloApi, site, lang, seo, exclude }) {
|
|
4
4
|
return useDebouncedSearch(async (query) => {
|
|
5
|
-
return fetchResults(ubloApi, site, lang, query, seo, exclude)
|
|
5
|
+
return fetchResults(ubloApi, site, lang, query, seo, exclude).then((res) => {
|
|
6
|
+
sendEvent("basic", "search", {
|
|
7
|
+
query: query,
|
|
8
|
+
match_count: res?.result?.length,
|
|
9
|
+
});
|
|
10
|
+
return res;
|
|
11
|
+
});
|
|
6
12
|
});
|
|
7
13
|
}
|
|
@@ -11,6 +11,7 @@ import * as Plausible from "../../../future/components/plausible";
|
|
|
11
11
|
import useSearch from "./hooks/use-search";
|
|
12
12
|
import * as KeyboardKeys from "./utils/keyboard-keys";
|
|
13
13
|
import { message } from "./messages";
|
|
14
|
+
import { sendEvent } from "../../../future/components/event-analytics/instant-search";
|
|
14
15
|
const { publicRuntimeConfig } = getConfig();
|
|
15
16
|
const { ubloApi, site } = publicRuntimeConfig;
|
|
16
17
|
const SearchBar = ({ lang, resultFormatter, backdrop, OverrideIcons = {}, messages, seo, exclude, autofocus, additionalResults = [], }) => {
|
|
@@ -30,7 +31,18 @@ const SearchBar = ({ lang, resultFormatter, backdrop, OverrideIcons = {}, messag
|
|
|
30
31
|
LoadIcon: LoaderIcon,
|
|
31
32
|
};
|
|
32
33
|
const Icons = Object.assign({}, DefaultIcons, OverrideIcons);
|
|
33
|
-
const close = () => {
|
|
34
|
+
const close = (skipEvent = false) => {
|
|
35
|
+
if (!skipEvent) {
|
|
36
|
+
if (text?.length > 2) {
|
|
37
|
+
sendEvent("basic", "fail", {
|
|
38
|
+
query: text,
|
|
39
|
+
match_count: search?.result?.length,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
sendEvent("basic", "cancel");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
34
46
|
setText("");
|
|
35
47
|
if (document.activeElement) {
|
|
36
48
|
document.activeElement.blur();
|
|
@@ -89,8 +101,11 @@ const SearchBar = ({ lang, resultFormatter, backdrop, OverrideIcons = {}, messag
|
|
|
89
101
|
});
|
|
90
102
|
}
|
|
91
103
|
};
|
|
92
|
-
const focusInput = () => {
|
|
93
|
-
|
|
104
|
+
const focusInput = (focus = true) => {
|
|
105
|
+
sendEvent("basic", "load");
|
|
106
|
+
if (focus) {
|
|
107
|
+
input.current.focus();
|
|
108
|
+
}
|
|
94
109
|
};
|
|
95
110
|
const handleKeyPresses = React.useCallback((e) => {
|
|
96
111
|
const allowedKeys = ["k"];
|
|
@@ -128,7 +143,7 @@ const SearchBar = ({ lang, resultFormatter, backdrop, OverrideIcons = {}, messag
|
|
|
128
143
|
"search-bar--opened": results.length > 0,
|
|
129
144
|
"search-bar--loading": search?.loading,
|
|
130
145
|
});
|
|
131
|
-
return (_jsxs("div", { className: classes, children: [backdrop && _jsx("div", { className: "search-bar__backdrop", onClick: close }), _jsxs("div", { className: "search-bar__input-container", children: [_jsx("input", { ref: input, type: "text", value: text, onChange: updateSearch, onKeyDown: handleKeyDown, className: "search-bar__input", placeholder: message(ubloLang, "what-are-you-looking-for", messages), onBlur: handleBlur }), _jsx(Icon, { className: "search-bar__icon" }), _jsxs("div", { ref: resultsContainer, className: "search-bar__results", children: [results?.map((result, i) => {
|
|
146
|
+
return (_jsxs("div", { className: classes, onFocus: focusInput, children: [backdrop && _jsx("div", { className: "search-bar__backdrop", onClick: close }), _jsxs("div", { className: "search-bar__input-container", children: [_jsx("input", { ref: input, type: "text", value: text, onChange: updateSearch, onKeyDown: handleKeyDown, className: "search-bar__input", placeholder: message(ubloLang, "what-are-you-looking-for", messages), onBlur: handleBlur }), _jsx(Icon, { className: "search-bar__icon" }), _jsxs("div", { ref: resultsContainer, className: "search-bar__results", children: [results?.map((result, i) => {
|
|
132
147
|
const { name, title, page, path } = result;
|
|
133
148
|
const externalLink = page === undefined;
|
|
134
149
|
const Tag = externalLink ? "a" : Link;
|
|
@@ -145,12 +160,18 @@ const SearchBar = ({ lang, resultFormatter, backdrop, OverrideIcons = {}, messag
|
|
|
145
160
|
title: resultLabel,
|
|
146
161
|
};
|
|
147
162
|
const sendPlausibleGoal = () => {
|
|
163
|
+
sendEvent("basic", "success", {
|
|
164
|
+
query: text,
|
|
165
|
+
match_count: search?.result?.length,
|
|
166
|
+
path,
|
|
167
|
+
kind: "pages",
|
|
168
|
+
});
|
|
148
169
|
Plausible.sendGoal("Search", {
|
|
149
170
|
"Terms - Destination": `${text} - ${path}`,
|
|
150
171
|
});
|
|
151
172
|
};
|
|
152
173
|
const onClick = () => {
|
|
153
|
-
close();
|
|
174
|
+
close(false);
|
|
154
175
|
sendPlausibleGoal();
|
|
155
176
|
};
|
|
156
177
|
const props = externalLink ? anchorProps : linkProps;
|
|
@@ -34,7 +34,7 @@ export default function InstantSearch({ lang, suggestions, className, ubloContex
|
|
|
34
34
|
Plausible.sendGoal(event, {
|
|
35
35
|
Terms: text,
|
|
36
36
|
});
|
|
37
|
-
sendEvent("esf",
|
|
37
|
+
sendEvent("esf", "fail", {
|
|
38
38
|
query: text,
|
|
39
39
|
match_count: search?.result?.hits?.length,
|
|
40
40
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-search.d.ts","sourceRoot":"","sources":["../../../../../src/lbm/components/instant-search/hooks/use-search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-search.d.ts","sourceRoot":"","sources":["../../../../../src/lbm/components/instant-search/hooks/use-search.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB;;;;;;EAiB1E"}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import getConfig from "next/config";
|
|
2
2
|
import useDebouncedSearch from "./use-debounced-search";
|
|
3
3
|
import * as API from "../services/api";
|
|
4
|
+
import { sendEvent } from "../../../../future/components/event-analytics/instant-search";
|
|
4
5
|
const { publicRuntimeConfig } = getConfig();
|
|
5
6
|
const { site } = publicRuntimeConfig;
|
|
6
7
|
export default function useSearch(lang, options = {}) {
|
|
7
8
|
return useDebouncedSearch(async (query, facet) => {
|
|
8
|
-
return API.fetchResults(site, lang, query, facet, options.queryBy, options.queryByWeights)
|
|
9
|
+
return API.fetchResults(site, lang, query, facet, options.queryBy, options.queryByWeights).then((res) => {
|
|
10
|
+
sendEvent("lbm", "search", {
|
|
11
|
+
query: query,
|
|
12
|
+
match_count: res?.result?.hits?.length,
|
|
13
|
+
});
|
|
14
|
+
return res;
|
|
15
|
+
});
|
|
9
16
|
});
|
|
10
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instant-search.d.ts","sourceRoot":"","sources":["../../../../src/lbm/components/instant-search/instant-search.tsx"],"names":[],"mappings":"AAOA,OAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"instant-search.d.ts","sourceRoot":"","sources":["../../../../src/lbm/components/instant-search/instant-search.tsx"],"names":[],"mappings":"AAOA,OAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMnE,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC;QAC1C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,WAAW,CAAC,EAAE;QACZ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;QACd,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;KACf,CAAC;IACF,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,IAAI,EACJ,WAAW,EACX,SAAS,EACT,OAAY,GACb,EAAE,KAAK,2CAkHP"}
|
|
@@ -9,6 +9,7 @@ import Results from "./results";
|
|
|
9
9
|
import useSearch from "./hooks/use-search";
|
|
10
10
|
import * as Plausible from "../../../future/components/plausible";
|
|
11
11
|
import css from "./instant-search.module.css";
|
|
12
|
+
import { sendEvent } from "../../../future/components/event-analytics/instant-search";
|
|
12
13
|
export default function InstantSearch({ lang, suggestions, className, options = {}, }) {
|
|
13
14
|
const [opened, setOpened] = React.useState(false);
|
|
14
15
|
const { text, setText, facet, setFacet, search } = useSearch(lang, options);
|
|
@@ -16,21 +17,37 @@ export default function InstantSearch({ lang, suggestions, className, options =
|
|
|
16
17
|
const openSearch = () => {
|
|
17
18
|
setOpened(true);
|
|
18
19
|
document.body.style.setProperty("overflow", "hidden");
|
|
20
|
+
sendEvent("lbm", "load");
|
|
19
21
|
};
|
|
20
22
|
const closeSearch = (skipEvent) => {
|
|
21
23
|
setOpened(false);
|
|
22
24
|
setText("");
|
|
23
25
|
document.body.style.removeProperty("overflow");
|
|
24
26
|
if (!skipEvent) {
|
|
25
|
-
const event = search?.result?.length === 0
|
|
27
|
+
const event = search?.result?.hits?.length === 0
|
|
28
|
+
? "Search failed"
|
|
29
|
+
: "Search canceled";
|
|
26
30
|
if (text.length > 0) {
|
|
27
31
|
Plausible.sendGoal(event, {
|
|
28
32
|
Terms: text,
|
|
29
33
|
});
|
|
34
|
+
sendEvent("lbm", "fail", {
|
|
35
|
+
query: text,
|
|
36
|
+
match_count: search?.result?.hits?.length,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
sendEvent("lbm", "cancel");
|
|
30
41
|
}
|
|
31
42
|
}
|
|
32
43
|
};
|
|
33
|
-
const sendPlausibleGoal = (path) => () => {
|
|
44
|
+
const sendPlausibleGoal = (type) => (path) => () => {
|
|
45
|
+
sendEvent("lbm", "success", {
|
|
46
|
+
query: text,
|
|
47
|
+
match_count: search?.result?.hits?.length,
|
|
48
|
+
path,
|
|
49
|
+
kind: type,
|
|
50
|
+
});
|
|
34
51
|
Plausible.sendGoal("Search", {
|
|
35
52
|
"Terms - Destination": `${text} - ${path}`,
|
|
36
53
|
});
|
|
@@ -68,7 +68,7 @@ type Props = {
|
|
|
68
68
|
facet: number;
|
|
69
69
|
setFacet: (facet: number) => void;
|
|
70
70
|
results: SiteResults;
|
|
71
|
-
sendPlausibleGoal: (path: string) => () => void;
|
|
71
|
+
sendPlausibleGoal: (type: string) => (path: string) => () => void;
|
|
72
72
|
loading: boolean;
|
|
73
73
|
};
|
|
74
74
|
export default function Results({ lang, text, facet, setFacet, results, loading, sendPlausibleGoal, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../../../src/lbm/components/instant-search/results.tsx"],"names":[],"mappings":"AAWA,KAAK,QAAQ,GAAG;IACd,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EACA,MAAM,GACN,SAAS,GACT,aAAa,GACb,KAAK,GACL,UAAU,GACV,QAAQ,GACR,aAAa,GACb,SAAS,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,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AC;IAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IAEd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,OAAO,EAAE,WAAW,CAAC;IAErB,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../../../src/lbm/components/instant-search/results.tsx"],"names":[],"mappings":"AAWA,KAAK,QAAQ,GAAG;IACd,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EACA,MAAM,GACN,SAAS,GACT,aAAa,GACb,KAAK,GACL,UAAU,GACV,QAAQ,GACR,aAAa,GACb,SAAS,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,I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F,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IAEd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,OAAO,EAAE,WAAW,CAAC;IAErB,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,IAAI,CAAC;IAClE,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAC9B,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,OAAO,EACP,OAAO,EACP,iBAAiB,GAClB,EAAE,KAAK,2CAwHP"}
|
|
@@ -41,5 +41,5 @@ export default function Results({ lang, text, facet, setFacet, results, loading,
|
|
|
41
41
|
const { page: pages, product: products, information, faq: faqs, widget: widgets, document: documents, "msem-widget": msemWidgets, lodging: lodgings, } = sortedHits;
|
|
42
42
|
const isOtherResultsEmpty = !(pages.length || information.length);
|
|
43
43
|
const countLabel = message(lang, "results");
|
|
44
|
-
return (_jsx("div", { className: css.results, children: (loading || text.length > 0) && (_jsxs("div", { className: css.inner, children: [_jsxs("div", { ref: ref, className: css.left, children: [_jsxs("div", { className: css.facet, children: [countLabel, " ", _jsx(FacetSwitch, { lang: lang, facet: facet, setFacet: setFacet })] }), _jsx(Links, { linksTitle: message(lang, "pages"), icon: "File", links: pages, loading: loading, sendPlausibleGoal: sendPlausibleGoal }), _jsx(Links, { linksTitle: message(lang, "documents"), icon: "FileText", links: documents, loading: loading, sendPlausibleGoal: sendPlausibleGoal }), _jsx(Links, { linksTitle: message(lang, "information"), icon: "Info", links: information, loading: loading, sendPlausibleGoal: sendPlausibleGoal }), _jsx(OTLinks, { products: googleSearch.result, loading: googleSearch.loading, sendPlausibleGoal: sendPlausibleGoal, faqsMaximized: faqsMaximized })] }), _jsxs("div", { className: css.right, children: [_jsx(Widgets, { lang: lang, widgets: [...widgets, ...msemWidgets, ...lodgings], loading: loading, sendPlausibleGoal: sendPlausibleGoal, faqsMaximized: faqsMaximized }), _jsx(Products, { lang: lang, products: products, loading: loading, sendPlausibleGoal: sendPlausibleGoal, otherResultsRef: ref, isOtherResultsEmpty: isOtherResultsEmpty, faqsMaximized: faqsMaximized }), _jsx(Faqs, { lang: lang, faqs: faqs, loading: loading, sendPlausibleGoal: sendPlausibleGoal, maximized: faqsMaximized, setMaximized: setFaqsMaximized })] })] })) }));
|
|
44
|
+
return (_jsx("div", { className: css.results, children: (loading || text.length > 0) && (_jsxs("div", { className: css.inner, children: [_jsxs("div", { ref: ref, className: css.left, children: [_jsxs("div", { className: css.facet, children: [countLabel, " ", _jsx(FacetSwitch, { lang: lang, facet: facet, setFacet: setFacet })] }), _jsx(Links, { linksTitle: message(lang, "pages"), icon: "File", links: pages, loading: loading, sendPlausibleGoal: sendPlausibleGoal("pages") }), _jsx(Links, { linksTitle: message(lang, "documents"), icon: "FileText", links: documents, loading: loading, sendPlausibleGoal: sendPlausibleGoal("documents") }), _jsx(Links, { linksTitle: message(lang, "information"), icon: "Info", links: information, loading: loading, sendPlausibleGoal: sendPlausibleGoal("information") }), _jsx(OTLinks, { products: googleSearch.result, loading: googleSearch.loading, sendPlausibleGoal: sendPlausibleGoal("ot-link"), faqsMaximized: faqsMaximized })] }), _jsxs("div", { className: css.right, children: [_jsx(Widgets, { lang: lang, widgets: [...widgets, ...msemWidgets, ...lodgings], loading: loading, sendPlausibleGoal: sendPlausibleGoal("widget"), faqsMaximized: faqsMaximized }), _jsx(Products, { lang: lang, products: products, loading: loading, sendPlausibleGoal: sendPlausibleGoal("product"), otherResultsRef: ref, isOtherResultsEmpty: isOtherResultsEmpty, faqsMaximized: faqsMaximized }), _jsx(Faqs, { lang: lang, faqs: faqs, loading: loading, sendPlausibleGoal: sendPlausibleGoal("faq"), maximized: faqsMaximized, setMaximized: setFaqsMaximized })] })] })) }));
|
|
45
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-search.d.ts","sourceRoot":"","sources":["../../../../../src/market-place/components/instant-search/hooks/use-search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-search.d.ts","sourceRoot":"","sources":["../../../../../src/market-place/components/instant-search/hooks/use-search.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB;;;;EAgB1E"}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import getConfig from "next/config";
|
|
2
2
|
import useDebouncedSearch from "./use-debounced-search";
|
|
3
3
|
import * as API from "../services/api";
|
|
4
|
+
import { sendEvent } from "../../../../future/components/event-analytics/instant-search";
|
|
4
5
|
const { publicRuntimeConfig } = getConfig();
|
|
5
6
|
const { site } = publicRuntimeConfig;
|
|
6
7
|
export default function useSearch(lang, options = {}) {
|
|
7
8
|
return useDebouncedSearch(async (query) => {
|
|
8
|
-
return API.fetchResults(site, lang, query, options.queryBy, options.queryByWeights)
|
|
9
|
+
return API.fetchResults(site, lang, query, options.queryBy, options.queryByWeights).then((res) => {
|
|
10
|
+
sendEvent("market-place", "search", {
|
|
11
|
+
query: query,
|
|
12
|
+
match_count: res?.result?.hits?.length,
|
|
13
|
+
});
|
|
14
|
+
return res;
|
|
15
|
+
});
|
|
9
16
|
});
|
|
10
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instant-search.d.ts","sourceRoot":"","sources":["../../../../src/market-place/components/instant-search/instant-search.tsx"],"names":[],"mappings":"AAOA,OAAkB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"instant-search.d.ts","sourceRoot":"","sources":["../../../../src/market-place/components/instant-search/instant-search.tsx"],"names":[],"mappings":"AAOA,OAAkB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAM9D,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE;QACZ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;QACd,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;KACf,CAAC;IACF,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,IAAI,EACJ,WAAW,EACX,SAAS,EACT,OAAY,EACZ,UAAU,GACX,EAAE,KAAK,2CAgHP"}
|
|
@@ -10,12 +10,14 @@ import useSearch from "./hooks/use-search";
|
|
|
10
10
|
import * as Plausible from "../../../future/components/plausible";
|
|
11
11
|
import message from "./services/messages";
|
|
12
12
|
import css from "./instant-search.module.css";
|
|
13
|
+
import { sendEvent } from "../../../future/components/event-analytics/instant-search";
|
|
13
14
|
export default function InstantSearch({ lang, suggestions, className, options = {}, weekNumber, }) {
|
|
14
15
|
const [opened, setOpened] = React.useState(false);
|
|
15
16
|
const { text, setText, search } = useSearch(lang, options);
|
|
16
17
|
const classes = classNames(css.search, className);
|
|
17
18
|
const openSearch = () => {
|
|
18
19
|
setOpened(true);
|
|
20
|
+
sendEvent("market-place", "load");
|
|
19
21
|
};
|
|
20
22
|
const closeSearch = (skipEvent) => {
|
|
21
23
|
setOpened(false);
|
|
@@ -29,10 +31,23 @@ export default function InstantSearch({ lang, suggestions, className, options =
|
|
|
29
31
|
Plausible.sendGoal(event, {
|
|
30
32
|
Terms: text,
|
|
31
33
|
});
|
|
34
|
+
sendEvent("market-place", "fail", {
|
|
35
|
+
query: text,
|
|
36
|
+
match_count: search?.result?.hits?.length,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
sendEvent("market-place", "cancel");
|
|
32
41
|
}
|
|
33
42
|
}
|
|
34
43
|
};
|
|
35
|
-
const sendPlausibleGoal = (path) => () => {
|
|
44
|
+
const sendPlausibleGoal = (type) => (path) => () => {
|
|
45
|
+
sendEvent("market-place", "success", {
|
|
46
|
+
query: text,
|
|
47
|
+
match_count: search?.result?.hits?.length,
|
|
48
|
+
path,
|
|
49
|
+
kind: type,
|
|
50
|
+
});
|
|
36
51
|
Plausible.sendGoal("Search", {
|
|
37
52
|
"Terms - Destination": `${text} - ${path}`,
|
|
38
53
|
});
|
|
@@ -12,7 +12,7 @@ type Props = {
|
|
|
12
12
|
search_time_ms?: number;
|
|
13
13
|
};
|
|
14
14
|
weekNumber: number | null;
|
|
15
|
-
sendPlausibleGoal: (path: string) => () => void;
|
|
15
|
+
sendPlausibleGoal: (type: string) => (path: string) => () => void;
|
|
16
16
|
loading: boolean;
|
|
17
17
|
};
|
|
18
18
|
export default function Results({ lang, text, results, weekNumber, loading, sendPlausibleGoal, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../../../src/market-place/components/instant-search/results.tsx"],"names":[],"mappings":"AAQA,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QACP,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,cAAc,CAAC,EAAE,aAAa,CAAC;QAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../../../src/market-place/components/instant-search/results.tsx"],"names":[],"mappings":"AAQA,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QACP,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,cAAc,CAAC,EAAE,aAAa,CAAC;QAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,IAAI,CAAC;IAClE,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAC9B,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,UAAU,EACV,OAAO,EACP,iBAAiB,GAClB,EAAE,KAAK,2CAsGP"}
|
|
@@ -40,5 +40,5 @@ export default function Results({ lang, text, results, weekNumber, loading, send
|
|
|
40
40
|
filteredFaqs.length ||
|
|
41
41
|
information.length);
|
|
42
42
|
const allProducts = [...products, ...pages, ...lodgings];
|
|
43
|
-
return (_jsx("div", { className: css.results, children: (loading || text.length > 0) && (_jsxs("div", { className: css.inner, children: [_jsxs("div", { ref: ref, className: css.left, children: [_jsx(Links, { linksTitle: message(lang, "faqs"), icon: "Question", links: filteredFaqs, loading: loading, sendPlausibleGoal: sendPlausibleGoal }), _jsx(OTLinks, { links: googleSearch.result, loading: googleSearch.loading, sendPlausibleGoal: sendPlausibleGoal }), _jsx(Links, { linksTitle: message(lang, "information"), icon: "Info", links: information, loading: loading, sendPlausibleGoal: sendPlausibleGoal, pageTitleAsTitle: true })] }), _jsx("div", { className: css.right, children: _jsx(Products, { lang: lang, products: allProducts, weekNumber: weekNumber, loading: loading, sendPlausibleGoal: sendPlausibleGoal, otherResultsRef: ref, isOtherResultsEmpty: isOtherResultsEmpty }) })] })) }));
|
|
43
|
+
return (_jsx("div", { className: css.results, children: (loading || text.length > 0) && (_jsxs("div", { className: css.inner, children: [_jsxs("div", { ref: ref, className: css.left, children: [_jsx(Links, { linksTitle: message(lang, "faqs"), icon: "Question", links: filteredFaqs, loading: loading, sendPlausibleGoal: sendPlausibleGoal("faq") }), _jsx(OTLinks, { links: googleSearch.result, loading: googleSearch.loading, sendPlausibleGoal: sendPlausibleGoal("ot-link") }), _jsx(Links, { linksTitle: message(lang, "information"), icon: "Info", links: information, loading: loading, sendPlausibleGoal: sendPlausibleGoal("information"), pageTitleAsTitle: true })] }), _jsx("div", { className: css.right, children: _jsx(Products, { lang: lang, products: allProducts, weekNumber: weekNumber, loading: loading, sendPlausibleGoal: sendPlausibleGoal("product"), otherResultsRef: ref, isOtherResultsEmpty: isOtherResultsEmpty }) })] })) }));
|
|
44
44
|
}
|