@constructor-io/constructorio-ui-autocomplete 1.20.8 → 1.21.0
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/dist/constructorio-ui-autocomplete-bundled.js +12 -12
- package/lib/cjs/hooks/useCioAutocomplete.js +2 -2
- package/lib/cjs/hooks/useDownShift.js +2 -1
- package/lib/cjs/utils.js +23 -1
- package/lib/cjs/version.js +1 -1
- package/lib/mjs/hooks/useCioAutocomplete.js +3 -3
- package/lib/mjs/hooks/useDownShift.js +2 -1
- package/lib/mjs/utils.js +19 -0
- package/lib/mjs/version.js +1 -1
- package/lib/types/utils.d.ts +2 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -118,7 +118,7 @@ const useCioAutocomplete = (options) => {
|
|
|
118
118
|
onSubmit({ query });
|
|
119
119
|
}
|
|
120
120
|
try {
|
|
121
|
-
|
|
121
|
+
(0, utils_1.trackSearchSubmit)(cioClient, query, { originalQuery: query });
|
|
122
122
|
}
|
|
123
123
|
catch (error) {
|
|
124
124
|
// eslint-disable-next-line no-console
|
|
@@ -133,7 +133,7 @@ const useCioAutocomplete = (options) => {
|
|
|
133
133
|
onSubmit({ query });
|
|
134
134
|
}
|
|
135
135
|
try {
|
|
136
|
-
|
|
136
|
+
(0, utils_1.trackSearchSubmit)(cioClient, query, { originalQuery: query });
|
|
137
137
|
}
|
|
138
138
|
catch (error) {
|
|
139
139
|
// eslint-disable-next-line no-console
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const downshift_1 = require("downshift");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
4
5
|
let idCounter = 0;
|
|
5
6
|
const useDownShift = ({ setQuery, items, onSubmit, cioClient, previousQuery = '' }) => (0, downshift_1.useCombobox)({
|
|
6
7
|
id: `cio-autocomplete-${idCounter++}`,
|
|
@@ -15,7 +16,7 @@ const useDownShift = ({ setQuery, items, onSubmit, cioClient, previousQuery = ''
|
|
|
15
16
|
try {
|
|
16
17
|
if ((selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.section) === 'Search Suggestions') {
|
|
17
18
|
setQuery(selectedItem.value || '');
|
|
18
|
-
|
|
19
|
+
(0, utils_1.trackSearchSubmit)(cioClient, selectedItem.value, {
|
|
19
20
|
originalQuery: previousQuery,
|
|
20
21
|
});
|
|
21
22
|
}
|
package/lib/cjs/utils.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.translate = exports.getItemsForActiveSections = exports.trackRecommendationView = exports.escapeRegExp = exports.getActiveSectionsWithData = exports.getCioClient = exports.disableStoryActions = exports.stringifyWithDefaults = exports.functionStrings = exports.getStoryParams = exports.sleep = exports.clearConstructorRequests = exports.isTrackingRequestSent = exports.toKebabCase = exports.camelToStartCase = exports.getItemPosition = exports.getFeatures = void 0;
|
|
3
|
+
exports.logger = exports.trackSearchSubmit = exports.translate = exports.getItemsForActiveSections = exports.trackRecommendationView = exports.escapeRegExp = exports.getActiveSectionsWithData = exports.getCioClient = exports.disableStoryActions = exports.stringifyWithDefaults = exports.functionStrings = exports.getStoryParams = exports.sleep = exports.clearConstructorRequests = exports.isTrackingRequestSent = exports.toKebabCase = exports.camelToStartCase = exports.getItemPosition = exports.getFeatures = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const constructorio_client_javascript_1 = tslib_1.__importDefault(require("@constructor-io/constructorio-client-javascript"));
|
|
6
|
+
// eslint-disable-next-line import/no-cycle
|
|
7
|
+
const beaconUtils_1 = require("./beaconUtils");
|
|
6
8
|
const typeGuards_1 = require("./typeGuards");
|
|
7
9
|
const version_1 = tslib_1.__importDefault(require("./version"));
|
|
8
10
|
function getFeatures(request) {
|
|
@@ -210,3 +212,23 @@ const translate = (word, translations) => {
|
|
|
210
212
|
return localTranslations[word] || word;
|
|
211
213
|
};
|
|
212
214
|
exports.translate = translate;
|
|
215
|
+
const trackSearchSubmit = (cioClient, term, autocompleteData = {}) => {
|
|
216
|
+
cioClient === null || cioClient === void 0 ? void 0 : cioClient.tracker.trackSearchSubmit(term, autocompleteData);
|
|
217
|
+
(0, beaconUtils_1.storageSetItem)(beaconUtils_1.CONSTANTS.SEARCH_TERM_STORAGE_KEY, term);
|
|
218
|
+
(0, beaconUtils_1.storeRecentSearch)(term, {});
|
|
219
|
+
(0, beaconUtils_1.storeRecentAction)(beaconUtils_1.CONSTANTS.SEARCH_SUBMIT);
|
|
220
|
+
};
|
|
221
|
+
exports.trackSearchSubmit = trackSearchSubmit;
|
|
222
|
+
const logger = (error) => {
|
|
223
|
+
var _a;
|
|
224
|
+
try {
|
|
225
|
+
if (typeof process !== 'undefined' && ((_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.LOGGER)) {
|
|
226
|
+
// eslint-disable-next-line no-console
|
|
227
|
+
console.log(error);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
catch (e) {
|
|
231
|
+
// process variable is not available and logger should not be active
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
exports.logger = logger;
|
package/lib/cjs/version.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useMemo, useState } from 'react';
|
|
|
3
3
|
import useCioClient from './useCioClient';
|
|
4
4
|
import useDownShift from './useDownShift';
|
|
5
5
|
import usePrevious from './usePrevious';
|
|
6
|
-
import { getItemPosition, getItemsForActiveSections, getFeatures, trackRecommendationView, toKebabCase, } from '../utils';
|
|
6
|
+
import { getItemPosition, getItemsForActiveSections, getFeatures, trackRecommendationView, toKebabCase, trackSearchSubmit, } from '../utils';
|
|
7
7
|
import useConsoleErrors from './useConsoleErrors';
|
|
8
8
|
import useSections from './useSections';
|
|
9
9
|
import useRecommendationsObserver from './useRecommendationsObserver';
|
|
@@ -127,7 +127,7 @@ const useCioAutocomplete = (options) => {
|
|
|
127
127
|
onSubmit({ query });
|
|
128
128
|
}
|
|
129
129
|
try {
|
|
130
|
-
|
|
130
|
+
trackSearchSubmit(cioClient, query, { originalQuery: query });
|
|
131
131
|
}
|
|
132
132
|
catch (error) {
|
|
133
133
|
// eslint-disable-next-line no-console
|
|
@@ -143,7 +143,7 @@ const useCioAutocomplete = (options) => {
|
|
|
143
143
|
onSubmit({ query });
|
|
144
144
|
}
|
|
145
145
|
try {
|
|
146
|
-
|
|
146
|
+
trackSearchSubmit(cioClient, query, { originalQuery: query });
|
|
147
147
|
}
|
|
148
148
|
catch (error) {
|
|
149
149
|
// eslint-disable-next-line no-console
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCombobox } from 'downshift';
|
|
2
|
+
import { trackSearchSubmit } from '../utils';
|
|
2
3
|
let idCounter = 0;
|
|
3
4
|
const useDownShift = ({ setQuery, items, onSubmit, cioClient, previousQuery = '' }) => useCombobox({
|
|
4
5
|
id: `cio-autocomplete-${idCounter++}`,
|
|
@@ -12,7 +13,7 @@ const useDownShift = ({ setQuery, items, onSubmit, cioClient, previousQuery = ''
|
|
|
12
13
|
try {
|
|
13
14
|
if (selectedItem?.section === 'Search Suggestions') {
|
|
14
15
|
setQuery(selectedItem.value || '');
|
|
15
|
-
|
|
16
|
+
trackSearchSubmit(cioClient, selectedItem.value, {
|
|
16
17
|
originalQuery: previousQuery,
|
|
17
18
|
});
|
|
18
19
|
}
|
package/lib/mjs/utils.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';
|
|
2
|
+
// eslint-disable-next-line import/no-cycle
|
|
3
|
+
import { storageSetItem, storeRecentSearch, storeRecentAction, CONSTANTS } from './beaconUtils';
|
|
2
4
|
import { isRecommendationsSection } from './typeGuards';
|
|
3
5
|
import version from './version';
|
|
4
6
|
export function getFeatures(request) {
|
|
@@ -191,3 +193,20 @@ export const translate = (word, translations) => {
|
|
|
191
193
|
return translations[word];
|
|
192
194
|
return localTranslations[word] || word;
|
|
193
195
|
};
|
|
196
|
+
export const trackSearchSubmit = (cioClient, term, autocompleteData = {}) => {
|
|
197
|
+
cioClient?.tracker.trackSearchSubmit(term, autocompleteData);
|
|
198
|
+
storageSetItem(CONSTANTS.SEARCH_TERM_STORAGE_KEY, term);
|
|
199
|
+
storeRecentSearch(term, {});
|
|
200
|
+
storeRecentAction(CONSTANTS.SEARCH_SUBMIT);
|
|
201
|
+
};
|
|
202
|
+
export const logger = (error) => {
|
|
203
|
+
try {
|
|
204
|
+
if (typeof process !== 'undefined' && process?.env?.LOGGER) {
|
|
205
|
+
// eslint-disable-next-line no-console
|
|
206
|
+
console.log(error);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
// process variable is not available and logger should not be active
|
|
211
|
+
}
|
|
212
|
+
};
|
package/lib/mjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.
|
|
1
|
+
export default '1.21.0';
|
package/lib/types/utils.d.ts
CHANGED
|
@@ -41,4 +41,6 @@ export declare const escapeRegExp: (string: string) => string;
|
|
|
41
41
|
export declare const trackRecommendationView: (target: HTMLElement, activeSectionsWithData: Section[], cioClient: Nullable<ConstructorIOClient>) => void;
|
|
42
42
|
export declare const getItemsForActiveSections: (activeSectionsWithData: Section[]) => Item[];
|
|
43
43
|
export declare const translate: (word: string, translations?: Translations) => any;
|
|
44
|
+
export declare const trackSearchSubmit: (cioClient: any, term: any, autocompleteData?: {}) => void;
|
|
45
|
+
export declare const logger: (error: any) => void;
|
|
44
46
|
export {};
|
package/lib/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.
|
|
1
|
+
declare const _default: "1.21.0";
|
|
2
2
|
export default _default;
|
package/package.json
CHANGED