@algolia/autocomplete-plugin-algolia-insights
Advanced tools
Comparing version 1.8.3 to 1.9.0
@@ -1,2 +0,2 @@ | ||
import { AutocompletePlugin } from '@algolia/autocomplete-js'; | ||
import { AutocompletePlugin } from '@algolia/autocomplete-shared'; | ||
import { InsightsClient, OnActiveParams, OnItemsChangeParams, OnSelectParams } from './types'; | ||
@@ -9,3 +9,3 @@ export declare type CreateAlgoliaInsightsPluginParams = { | ||
*/ | ||
insightsClient: InsightsClient; | ||
insightsClient?: InsightsClient; | ||
/** | ||
@@ -12,0 +12,0 @@ * Hook to send an Insights event when the items change. |
@@ -0,20 +1,14 @@ | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
import { createRef, debounce, isEqual, noop } from '@algolia/autocomplete-shared'; | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
import { createRef, debounce, isEqual, noop, safelyRunOnBrowser } from '@algolia/autocomplete-shared'; | ||
import { createClickedEvent } from './createClickedEvent'; | ||
@@ -25,7 +19,9 @@ import { createSearchInsightsApi } from './createSearchInsightsApi'; | ||
var VIEW_EVENT_DELAY = 400; | ||
var ALGOLIA_INSIGHTS_VERSION = '2.4.0'; | ||
var ALGOLIA_INSIGHTS_SRC = "https://cdn.jsdelivr.net/npm/search-insights@".concat(ALGOLIA_INSIGHTS_VERSION, "/dist/search-insights.min.js"); | ||
var sendViewedObjectIDs = debounce(function (_ref) { | ||
var onItemsChange = _ref.onItemsChange, | ||
items = _ref.items, | ||
insights = _ref.insights, | ||
state = _ref.state; | ||
items = _ref.items, | ||
insights = _ref.insights, | ||
state = _ref.state; | ||
onItemsChange({ | ||
@@ -45,20 +41,43 @@ insights: insights, | ||
var _getOptions = getOptions(options), | ||
insightsClient = _getOptions.insightsClient, | ||
onItemsChange = _getOptions.onItemsChange, | ||
onSelectEvent = _getOptions.onSelect, | ||
onActiveEvent = _getOptions.onActive; | ||
providedInsightsClient = _getOptions.insightsClient, | ||
onItemsChange = _getOptions.onItemsChange, | ||
onSelectEvent = _getOptions.onSelect, | ||
onActiveEvent = _getOptions.onActive; | ||
var insightsClient = providedInsightsClient; | ||
if (!providedInsightsClient) { | ||
safelyRunOnBrowser(function (_ref2) { | ||
var window = _ref2.window; | ||
var pointer = window.AlgoliaAnalyticsObject || 'aa'; | ||
if (typeof pointer === 'string') { | ||
insightsClient = window[pointer]; | ||
} | ||
if (!insightsClient) { | ||
window.AlgoliaAnalyticsObject = pointer; | ||
if (!window[pointer]) { | ||
window[pointer] = function () { | ||
if (!window[pointer].queue) { | ||
window[pointer].queue = []; | ||
} | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
window[pointer].queue.push(args); | ||
}; | ||
} | ||
window[pointer].version = ALGOLIA_INSIGHTS_VERSION; | ||
insightsClient = window[pointer]; | ||
loadInsights(window); | ||
} | ||
}); | ||
} | ||
var insights = createSearchInsightsApi(insightsClient); | ||
var previousItems = createRef([]); | ||
var debouncedOnStateChange = debounce(function (_ref2) { | ||
var state = _ref2.state; | ||
var debouncedOnStateChange = debounce(function (_ref3) { | ||
var state = _ref3.state; | ||
if (!state.isOpen) { | ||
return; | ||
} | ||
var items = state.collections.reduce(function (acc, current) { | ||
return [].concat(_toConsumableArray(acc), _toConsumableArray(current.items)); | ||
}, []).filter(isAlgoliaInsightsHit); | ||
if (!isEqual(previousItems.current.map(function (x) { | ||
@@ -70,3 +89,2 @@ return x.objectID; | ||
previousItems.current = items; | ||
if (items.length > 0) { | ||
@@ -84,6 +102,6 @@ sendViewedObjectIDs({ | ||
name: 'aa.algoliaInsightsPlugin', | ||
subscribe: function subscribe(_ref3) { | ||
var setContext = _ref3.setContext, | ||
onSelect = _ref3.onSelect, | ||
onActive = _ref3.onActive; | ||
subscribe: function subscribe(_ref4) { | ||
var setContext = _ref4.setContext, | ||
onSelect = _ref4.onSelect, | ||
onActive = _ref4.onActive; | ||
insightsClient('addAlgoliaAgent', 'insights-plugin'); | ||
@@ -98,11 +116,9 @@ setContext({ | ||
}); | ||
onSelect(function (_ref4) { | ||
var item = _ref4.item, | ||
state = _ref4.state, | ||
event = _ref4.event; | ||
onSelect(function (_ref5) { | ||
var item = _ref5.item, | ||
state = _ref5.state, | ||
event = _ref5.event; | ||
if (!isAlgoliaInsightsHit(item)) { | ||
return; | ||
} | ||
onSelectEvent({ | ||
@@ -121,11 +137,9 @@ state: state, | ||
}); | ||
onActive(function (_ref5) { | ||
var item = _ref5.item, | ||
state = _ref5.state, | ||
event = _ref5.event; | ||
onActive(function (_ref6) { | ||
var item = _ref6.item, | ||
state = _ref6.state, | ||
event = _ref6.event; | ||
if (!isAlgoliaInsightsHit(item)) { | ||
return; | ||
} | ||
onActiveEvent({ | ||
@@ -145,4 +159,4 @@ state: state, | ||
}, | ||
onStateChange: function onStateChange(_ref6) { | ||
var state = _ref6.state; | ||
onStateChange: function onStateChange(_ref7) { | ||
var state = _ref7.state; | ||
debouncedOnStateChange({ | ||
@@ -155,17 +169,40 @@ state: state | ||
} | ||
function getOptions(options) { | ||
return _objectSpread({ | ||
onItemsChange: function onItemsChange(_ref7) { | ||
var insights = _ref7.insights, | ||
insightsEvents = _ref7.insightsEvents; | ||
insights.viewedObjectIDs.apply(insights, _toConsumableArray(insightsEvents)); | ||
}, | ||
onSelect: function onSelect(_ref8) { | ||
onItemsChange: function onItemsChange(_ref8) { | ||
var insights = _ref8.insights, | ||
insightsEvents = _ref8.insightsEvents; | ||
insights.clickedObjectIDsAfterSearch.apply(insights, _toConsumableArray(insightsEvents)); | ||
insightsEvents = _ref8.insightsEvents; | ||
insights.viewedObjectIDs.apply(insights, _toConsumableArray(insightsEvents.map(function (event) { | ||
return _objectSpread(_objectSpread({}, event), {}, { | ||
algoliaSource: [].concat(_toConsumableArray(event.algoliaSource || []), ['autocomplete-internal']) | ||
}); | ||
}))); | ||
}, | ||
onSelect: function onSelect(_ref9) { | ||
var insights = _ref9.insights, | ||
insightsEvents = _ref9.insightsEvents; | ||
insights.clickedObjectIDsAfterSearch.apply(insights, _toConsumableArray(insightsEvents.map(function (event) { | ||
return _objectSpread(_objectSpread({}, event), {}, { | ||
algoliaSource: [].concat(_toConsumableArray(event.algoliaSource || []), ['autocomplete-internal']) | ||
}); | ||
}))); | ||
}, | ||
onActive: noop | ||
}, options); | ||
} | ||
function loadInsights(environment) { | ||
var errorMessage = "[Autocomplete]: Could not load search-insights.js. Please load it manually following https://alg.li/insights-autocomplete"; | ||
try { | ||
var script = environment.document.createElement('script'); | ||
script.async = true; | ||
script.src = ALGOLIA_INSIGHTS_SRC; | ||
script.onerror = function () { | ||
// eslint-disable-next-line no-console | ||
console.error(errorMessage); | ||
}; | ||
document.body.appendChild(script); | ||
} catch (cause) { | ||
// eslint-disable-next-line no-console | ||
console.error(errorMessage); | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { AlgoliaInsightsHit, ClickedObjectIDsAfterSearchParams } from './types'; | ||
import type { AlgoliaInsightsHit, ClickedObjectIDsAfterSearchParams, InsightsParamsWithItems } from './types'; | ||
declare type CreateClickedEventParams = { | ||
@@ -6,3 +6,5 @@ item: AlgoliaInsightsHit; | ||
}; | ||
export declare function createClickedEvent({ item, items, }: CreateClickedEventParams): Omit<ClickedObjectIDsAfterSearchParams, 'eventName'>; | ||
export declare function createClickedEvent({ item, items, }: CreateClickedEventParams): Omit<InsightsParamsWithItems<ClickedObjectIDsAfterSearchParams>, 'eventName'> & { | ||
algoliaSource?: string[]; | ||
}; | ||
export {}; |
export function createClickedEvent(_ref) { | ||
var item = _ref.item, | ||
items = _ref.items; | ||
items = _ref.items; | ||
return { | ||
index: item.__autocomplete_indexName, | ||
objectIDs: [item.objectID], | ||
items: [item], | ||
positions: [1 + items.findIndex(function (x) { | ||
return x.objectID === item.objectID; | ||
})], | ||
queryID: item.__autocomplete_queryID | ||
queryID: item.__autocomplete_queryID, | ||
algoliaSource: ['autocomplete'] | ||
}; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { ClickedFiltersParams, ClickedObjectIDsAfterSearchParams, ClickedObjectIDsParams, ConvertedFiltersParams, ConvertedObjectIDsAfterSearchParams, ConvertedObjectIDsParams, InsightsClient, ViewedFiltersParams, ViewedObjectIDsParams } from './types'; | ||
import { ClickedFiltersParams, ClickedObjectIDsAfterSearchParams, ClickedObjectIDsParams, ConvertedFiltersParams, ConvertedObjectIDsAfterSearchParams, ConvertedObjectIDsParams, InsightsClient, InsightsParamsWithItems, ViewedFiltersParams, ViewedObjectIDsParams } from './types'; | ||
export declare function createSearchInsightsApi(searchInsights: InsightsClient): { | ||
@@ -16,3 +16,3 @@ /** | ||
*/ | ||
clickedObjectIDsAfterSearch(...params: ClickedObjectIDsAfterSearchParams[]): void; | ||
clickedObjectIDsAfterSearch(...params: Array<InsightsParamsWithItems<ClickedObjectIDsAfterSearchParams>>): void; | ||
/** | ||
@@ -23,3 +23,3 @@ * Sends click events to capture clicked items. | ||
*/ | ||
clickedObjectIDs(...params: ClickedObjectIDsParams[]): void; | ||
clickedObjectIDs(...params: Array<InsightsParamsWithItems<ClickedObjectIDsParams>>): void; | ||
/** | ||
@@ -36,3 +36,3 @@ * Sends click events to capture the filters a user clicks on. | ||
*/ | ||
convertedObjectIDsAfterSearch(...params: ConvertedObjectIDsAfterSearchParams[]): void; | ||
convertedObjectIDsAfterSearch(...params: Array<InsightsParamsWithItems<ConvertedObjectIDsAfterSearchParams>>): void; | ||
/** | ||
@@ -43,3 +43,3 @@ * Sends conversion events to capture clicked items. | ||
*/ | ||
convertedObjectIDs(...params: ConvertedObjectIDsParams[]): void; | ||
convertedObjectIDs(...params: Array<InsightsParamsWithItems<ConvertedObjectIDsParams>>): void; | ||
/** | ||
@@ -56,3 +56,3 @@ * Sends conversion events to capture the filters a user uses when converting. | ||
*/ | ||
viewedObjectIDs(...params: ViewedObjectIDsParams[]): void; | ||
viewedObjectIDs(...params: Array<InsightsParamsWithItems<ViewedObjectIDsParams>>): void; | ||
/** | ||
@@ -59,0 +59,0 @@ * Sends view events to capture the filters a user uses when viewing. |
@@ -0,23 +1,21 @@ | ||
var _excluded = ["items"], | ||
_excluded2 = ["items"]; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
import { isModernInsightsClient } from './isModernInsightsClient'; | ||
function chunk(item) { | ||
var chunkSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20; | ||
var chunks = []; | ||
for (var i = 0; i < item.objectIDs.length; i += chunkSize) { | ||
@@ -28,7 +26,34 @@ chunks.push(_objectSpread(_objectSpread({}, item), {}, { | ||
} | ||
return chunks; | ||
} | ||
function mapToInsightsParamsApi(params) { | ||
return params.map(function (_ref) { | ||
var items = _ref.items, | ||
param = _objectWithoutProperties(_ref, _excluded); | ||
return _objectSpread(_objectSpread({}, param), {}, { | ||
objectIDs: (items === null || items === void 0 ? void 0 : items.map(function (_ref2) { | ||
var objectID = _ref2.objectID; | ||
return objectID; | ||
})) || param.objectIDs | ||
}); | ||
}); | ||
} | ||
export function createSearchInsightsApi(searchInsights) { | ||
var canSendHeaders = isModernInsightsClient(searchInsights); | ||
function sendToInsights(method, payloads, items) { | ||
if (canSendHeaders && typeof items !== 'undefined') { | ||
var _items$0$__autocomple = items[0].__autocomplete_algoliaCredentials, | ||
appId = _items$0$__autocomple.appId, | ||
apiKey = _items$0$__autocomple.apiKey; | ||
var headers = { | ||
'X-Algolia-Application-Id': appId, | ||
'X-Algolia-API-Key': apiKey | ||
}; | ||
searchInsights.apply(void 0, [method].concat(_toConsumableArray(payloads), [{ | ||
headers: headers | ||
}])); | ||
} else { | ||
searchInsights.apply(void 0, [method].concat(_toConsumableArray(payloads))); | ||
} | ||
} | ||
return { | ||
@@ -44,3 +69,2 @@ /** | ||
}, | ||
/** | ||
@@ -52,3 +76,2 @@ * Sets the user token to attach to events. | ||
}, | ||
/** | ||
@@ -63,8 +86,6 @@ * Sends click events to capture a query and its clicked items and positions. | ||
} | ||
if (params.length > 0) { | ||
searchInsights.apply(void 0, ['clickedObjectIDsAfterSearch'].concat(params)); | ||
sendToInsights('clickedObjectIDsAfterSearch', mapToInsightsParamsApi(params), params[0].items); | ||
} | ||
}, | ||
/** | ||
@@ -79,8 +100,6 @@ * Sends click events to capture clicked items. | ||
} | ||
if (params.length > 0) { | ||
searchInsights.apply(void 0, ['clickedObjectIDs'].concat(params)); | ||
sendToInsights('clickedObjectIDs', mapToInsightsParamsApi(params), params[0].items); | ||
} | ||
}, | ||
/** | ||
@@ -95,3 +114,2 @@ * Sends click events to capture the filters a user clicks on. | ||
} | ||
if (params.length > 0) { | ||
@@ -101,3 +119,2 @@ searchInsights.apply(void 0, ['clickedFilters'].concat(params)); | ||
}, | ||
/** | ||
@@ -112,8 +129,6 @@ * Sends conversion events to capture a query and its clicked items. | ||
} | ||
if (params.length > 0) { | ||
searchInsights.apply(void 0, ['convertedObjectIDsAfterSearch'].concat(params)); | ||
sendToInsights('convertedObjectIDsAfterSearch', mapToInsightsParamsApi(params), params[0].items); | ||
} | ||
}, | ||
/** | ||
@@ -128,8 +143,6 @@ * Sends conversion events to capture clicked items. | ||
} | ||
if (params.length > 0) { | ||
searchInsights.apply(void 0, ['convertedObjectIDs'].concat(params)); | ||
sendToInsights('convertedObjectIDs', mapToInsightsParamsApi(params), params[0].items); | ||
} | ||
}, | ||
/** | ||
@@ -144,3 +157,2 @@ * Sends conversion events to capture the filters a user uses when converting. | ||
} | ||
if (params.length > 0) { | ||
@@ -150,3 +162,2 @@ searchInsights.apply(void 0, ['convertedFilters'].concat(params)); | ||
}, | ||
/** | ||
@@ -161,12 +172,24 @@ * Sends view events to capture clicked items. | ||
} | ||
if (params.length > 0) { | ||
params.reduce(function (acc, param) { | ||
return [].concat(_toConsumableArray(acc), _toConsumableArray(chunk(param))); | ||
}, []).forEach(function (param) { | ||
return searchInsights('viewedObjectIDs', param); | ||
params.reduce(function (acc, _ref3) { | ||
var items = _ref3.items, | ||
param = _objectWithoutProperties(_ref3, _excluded2); | ||
return [].concat(_toConsumableArray(acc), _toConsumableArray(chunk(_objectSpread(_objectSpread({}, param), {}, { | ||
objectIDs: (items === null || items === void 0 ? void 0 : items.map(function (_ref4) { | ||
var objectID = _ref4.objectID; | ||
return objectID; | ||
})) || param.objectIDs | ||
})).map(function (payload) { | ||
return { | ||
items: items, | ||
payload: payload | ||
}; | ||
}))); | ||
}, []).forEach(function (_ref5) { | ||
var items = _ref5.items, | ||
payload = _ref5.payload; | ||
return sendToInsights('viewedObjectIDs', [payload], items); | ||
}); | ||
} | ||
}, | ||
/** | ||
@@ -181,3 +204,2 @@ * Sends view events to capture the filters a user uses when viewing. | ||
} | ||
if (params.length > 0) { | ||
@@ -184,0 +206,0 @@ searchInsights.apply(void 0, ['viewedFilters'].concat(params)); |
@@ -1,6 +0,6 @@ | ||
import { AlgoliaInsightsHit, ViewedObjectIDsParams } from './types'; | ||
import { AlgoliaInsightsHit, InsightsParamsWithItems, ViewedObjectIDsParams } from './types'; | ||
declare type CreateViewedEventsParams = { | ||
items: AlgoliaInsightsHit[]; | ||
}; | ||
export declare function createViewedEvents({ items, }: CreateViewedEventsParams): Array<Omit<ViewedObjectIDsParams, 'eventName'>>; | ||
export declare function createViewedEvents({ items, }: CreateViewedEventsParams): Array<Omit<InsightsParamsWithItems<ViewedObjectIDsParams>, 'eventName'>>; | ||
export {}; |
export function createViewedEvents(_ref) { | ||
var items = _ref.items; | ||
var objectIDsByIndexName = items.reduce(function (acc, current) { | ||
var itemsByIndexName = items.reduce(function (acc, current) { | ||
var _acc$current$__autoco; | ||
acc[current.__autocomplete_indexName] = ((_acc$current$__autoco = acc[current.__autocomplete_indexName]) !== null && _acc$current$__autoco !== void 0 ? _acc$current$__autoco : []).concat(current.objectID); | ||
acc[current.__autocomplete_indexName] = ((_acc$current$__autoco = acc[current.__autocomplete_indexName]) !== null && _acc$current$__autoco !== void 0 ? _acc$current$__autoco : []).concat(current); | ||
return acc; | ||
}, {}); | ||
return Object.keys(objectIDsByIndexName).map(function (indexName) { | ||
var objectIDs = objectIDsByIndexName[indexName]; | ||
return Object.keys(itemsByIndexName).map(function (indexName) { | ||
var items = itemsByIndexName[indexName]; | ||
return { | ||
index: indexName, | ||
objectIDs: objectIDs | ||
items: items, | ||
algoliaSource: ['autocomplete'] | ||
}; | ||
}); | ||
} |
@@ -1,2 +0,2 @@ | ||
export type { AutocompleteInsightsApi } from './types/AutocompleteInsightsApi'; | ||
export * from './types'; | ||
export * from './createAlgoliaInsightsPlugin'; |
@@ -1,2 +0,2 @@ | ||
export * from './createAlgoliaInsightsPlugin'; | ||
export {}; | ||
export * from './types'; | ||
export * from './createAlgoliaInsightsPlugin'; |
@@ -5,2 +5,6 @@ export declare type AlgoliaInsightsHit = { | ||
__autocomplete_queryID: string; | ||
__autocomplete_algoliaCredentials: { | ||
appId: string; | ||
apiKey: string; | ||
}; | ||
}; |
import { createSearchInsightsApi } from '../createSearchInsightsApi'; | ||
import type { AlgoliaInsightsHit } from './AlgoliaInsightsHit'; | ||
export declare type AutocompleteInsightsApi = ReturnType<typeof createSearchInsightsApi>; | ||
export declare type InsightsParamsWithItems<TParams extends { | ||
objectIDs: string[]; | ||
}> = Omit<TParams, 'objectIDs'> & { | ||
items: AlgoliaInsightsHit[]; | ||
/** | ||
* @deprecated use `items` instead | ||
*/ | ||
objectIDs?: string[]; | ||
}; | ||
export declare type ClickedObjectIDsAfterSearchParams = { | ||
@@ -4,0 +14,0 @@ eventName: string; |
@@ -1,7 +0,9 @@ | ||
import { AutocompleteState } from '@algolia/autocomplete-js'; | ||
import { ClickedObjectIDsAfterSearchParams, ViewedObjectIDsParams } from './AutocompleteInsightsApi'; | ||
import { AlgoliaInsightsHit, AutocompleteInsightsApi } from '.'; | ||
import type { AutocompleteState } from '@algolia/autocomplete-shared'; | ||
import type { ClickedObjectIDsAfterSearchParams, InsightsParamsWithItems, ViewedObjectIDsParams } from './AutocompleteInsightsApi'; | ||
import type { AlgoliaInsightsHit, AutocompleteInsightsApi } from '.'; | ||
export declare type OnSelectParams = { | ||
insights: AutocompleteInsightsApi; | ||
insightsEvents: ClickedObjectIDsAfterSearchParams[]; | ||
insightsEvents: Array<InsightsParamsWithItems<ClickedObjectIDsAfterSearchParams & { | ||
algoliaSource?: string[]; | ||
}>>; | ||
item: AlgoliaInsightsHit; | ||
@@ -14,4 +16,6 @@ state: AutocompleteState<any>; | ||
insights: AutocompleteInsightsApi; | ||
insightsEvents: ViewedObjectIDsParams[]; | ||
insightsEvents: Array<InsightsParamsWithItems<ViewedObjectIDsParams & { | ||
algoliaSource?: string[]; | ||
}>>; | ||
state: AutocompleteState<any>; | ||
}; |
@@ -1,1 +0,16 @@ | ||
export declare type InsightsClient = any; | ||
import type { InsightsMethodMap, InsightsClient as _InsightsClient } from 'search-insights'; | ||
export type { Init as InsightsInit, AddAlgoliaAgent as InsightsAddAlgoliaAgent, SetUserToken as InsightsSetUserToken, GetUserToken as InsightsGetUserToken, OnUserTokenChange as InsightsOnUserTokenChange, } from 'search-insights'; | ||
export declare type InsightsClientMethod = keyof InsightsMethodMap; | ||
export declare type InsightsClientPayload = { | ||
eventName: string; | ||
queryID: string; | ||
index: string; | ||
objectIDs: string[]; | ||
positions?: number[]; | ||
}; | ||
declare type QueueItemMap = Record<string, unknown>; | ||
declare type QueueItem = QueueItemMap[keyof QueueItemMap]; | ||
export declare type InsightsClient = _InsightsClient & { | ||
queue?: QueueItem[]; | ||
version?: string; | ||
}; |
@@ -1,2 +0,2 @@ | ||
/*! @algolia/autocomplete-plugin-algolia-insights 1.8.3 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */ | ||
/*! @algolia/autocomplete-plugin-algolia-insights 1.9.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */ | ||
(function (global, factory) { | ||
@@ -8,5 +8,31 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
function _iterableToArrayLimit(arr, i) { | ||
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; | ||
if (null != _i) { | ||
var _s, | ||
_e, | ||
_x, | ||
_r, | ||
_arr = [], | ||
_n = !0, | ||
_d = !1; | ||
try { | ||
if (_x = (_i = _i.call(arr)).next, 0 === i) { | ||
if (Object(_i) !== _i) return; | ||
_n = !1; | ||
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); | ||
} catch (err) { | ||
_d = !0, _e = err; | ||
} finally { | ||
try { | ||
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
} | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
@@ -18,6 +44,4 @@ var symbols = Object.getOwnPropertySymbols(object); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
@@ -32,7 +56,6 @@ for (var i = 1; i < arguments.length; i++) { | ||
} | ||
return target; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
key = _toPropertyKey(key); | ||
if (key in obj) { | ||
@@ -48,18 +71,46 @@ Object.defineProperty(obj, key, { | ||
} | ||
return obj; | ||
} | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
} | ||
return target; | ||
} | ||
function _objectWithoutProperties(source, excluded) { | ||
if (source == null) return {}; | ||
var target = _objectWithoutPropertiesLoose(source, excluded); | ||
var key, i; | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
key = sourceSymbolKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; | ||
target[key] = source[key]; | ||
} | ||
} | ||
return target; | ||
} | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) return _arrayLikeToArray(arr); | ||
} | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function _iterableToArray(iter) { | ||
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
@@ -73,14 +124,27 @@ if (!o) return; | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
function _toPrimitive(input, hint) { | ||
if (typeof input !== "object" || input === null) return input; | ||
var prim = input[Symbol.toPrimitive]; | ||
if (prim !== undefined) { | ||
var res = prim.call(input, hint || "default"); | ||
if (typeof res !== "object") return res; | ||
throw new TypeError("@@toPrimitive must return a primitive value."); | ||
} | ||
return (hint === "string" ? String : Number)(input); | ||
} | ||
function _toPropertyKey(arg) { | ||
var key = _toPrimitive(arg, "string"); | ||
return typeof key === "symbol" ? key : String(key); | ||
} | ||
@@ -99,7 +163,5 @@ function createRef(initialValue) { | ||
} | ||
if (timerId) { | ||
clearTimeout(timerId); | ||
} | ||
timerId = setTimeout(function () { | ||
@@ -114,3 +176,2 @@ return fn.apply(void 0, args); | ||
} | ||
function isEqual(first, second) { | ||
@@ -120,18 +181,13 @@ if (first === second) { | ||
} | ||
if (isPrimitive(first) || isPrimitive(second) || typeof first === 'function' || typeof second === 'function') { | ||
return first === second; | ||
} | ||
if (Object.keys(first).length !== Object.keys(second).length) { | ||
return false; | ||
} | ||
for (var _i = 0, _Object$keys = Object.keys(first); _i < _Object$keys.length; _i++) { | ||
var key = _Object$keys[_i]; | ||
if (!(key in second)) { | ||
return false; | ||
} | ||
if (!isEqual(first[key], second[key])) { | ||
@@ -141,3 +197,2 @@ return false; | ||
} | ||
return true; | ||
@@ -148,19 +203,51 @@ } | ||
/** | ||
* Safely runs code meant for browser environments only. | ||
*/ | ||
function safelyRunOnBrowser(callback) { | ||
if (typeof window !== 'undefined') { | ||
return callback({ | ||
window: window | ||
}); | ||
} | ||
return undefined; | ||
} | ||
function createClickedEvent(_ref) { | ||
var item = _ref.item, | ||
items = _ref.items; | ||
items = _ref.items; | ||
return { | ||
index: item.__autocomplete_indexName, | ||
objectIDs: [item.objectID], | ||
items: [item], | ||
positions: [1 + items.findIndex(function (x) { | ||
return x.objectID === item.objectID; | ||
})], | ||
queryID: item.__autocomplete_queryID | ||
queryID: item.__autocomplete_queryID, | ||
algoliaSource: ['autocomplete'] | ||
}; | ||
} | ||
/** | ||
* Determines if a given insights `client` supports the optional call to `init` | ||
* and the ability to set credentials via extra parameters when sending events. | ||
*/ | ||
function isModernInsightsClient(client) { | ||
var _split$map = (client.version || '').split('.').map(Number), | ||
_split$map2 = _slicedToArray(_split$map, 2), | ||
major = _split$map2[0], | ||
minor = _split$map2[1]; | ||
/* eslint-disable @typescript-eslint/camelcase */ | ||
var v3 = major >= 3; | ||
var v2_4 = major === 2 && minor >= 4; | ||
var v1_10 = major === 1 && minor >= 10; | ||
return v3 || v2_4 || v1_10; | ||
/* eslint-enable @typescript-eslint/camelcase */ | ||
} | ||
var _excluded = ["items"], | ||
_excluded2 = ["items"]; | ||
function chunk(item) { | ||
var chunkSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20; | ||
var chunks = []; | ||
for (var i = 0; i < item.objectIDs.length; i += chunkSize) { | ||
@@ -171,7 +258,34 @@ chunks.push(_objectSpread2(_objectSpread2({}, item), {}, { | ||
} | ||
return chunks; | ||
} | ||
function mapToInsightsParamsApi(params) { | ||
return params.map(function (_ref) { | ||
var items = _ref.items, | ||
param = _objectWithoutProperties(_ref, _excluded); | ||
return _objectSpread2(_objectSpread2({}, param), {}, { | ||
objectIDs: (items === null || items === void 0 ? void 0 : items.map(function (_ref2) { | ||
var objectID = _ref2.objectID; | ||
return objectID; | ||
})) || param.objectIDs | ||
}); | ||
}); | ||
} | ||
function createSearchInsightsApi(searchInsights) { | ||
var canSendHeaders = isModernInsightsClient(searchInsights); | ||
function sendToInsights(method, payloads, items) { | ||
if (canSendHeaders && typeof items !== 'undefined') { | ||
var _items$0$__autocomple = items[0].__autocomplete_algoliaCredentials, | ||
appId = _items$0$__autocomple.appId, | ||
apiKey = _items$0$__autocomple.apiKey; | ||
var headers = { | ||
'X-Algolia-Application-Id': appId, | ||
'X-Algolia-API-Key': apiKey | ||
}; | ||
searchInsights.apply(void 0, [method].concat(_toConsumableArray(payloads), [{ | ||
headers: headers | ||
}])); | ||
} else { | ||
searchInsights.apply(void 0, [method].concat(_toConsumableArray(payloads))); | ||
} | ||
} | ||
return { | ||
@@ -187,3 +301,2 @@ /** | ||
}, | ||
/** | ||
@@ -195,3 +308,2 @@ * Sets the user token to attach to events. | ||
}, | ||
/** | ||
@@ -206,8 +318,6 @@ * Sends click events to capture a query and its clicked items and positions. | ||
} | ||
if (params.length > 0) { | ||
searchInsights.apply(void 0, ['clickedObjectIDsAfterSearch'].concat(params)); | ||
sendToInsights('clickedObjectIDsAfterSearch', mapToInsightsParamsApi(params), params[0].items); | ||
} | ||
}, | ||
/** | ||
@@ -222,8 +332,6 @@ * Sends click events to capture clicked items. | ||
} | ||
if (params.length > 0) { | ||
searchInsights.apply(void 0, ['clickedObjectIDs'].concat(params)); | ||
sendToInsights('clickedObjectIDs', mapToInsightsParamsApi(params), params[0].items); | ||
} | ||
}, | ||
/** | ||
@@ -238,3 +346,2 @@ * Sends click events to capture the filters a user clicks on. | ||
} | ||
if (params.length > 0) { | ||
@@ -244,3 +351,2 @@ searchInsights.apply(void 0, ['clickedFilters'].concat(params)); | ||
}, | ||
/** | ||
@@ -255,8 +361,6 @@ * Sends conversion events to capture a query and its clicked items. | ||
} | ||
if (params.length > 0) { | ||
searchInsights.apply(void 0, ['convertedObjectIDsAfterSearch'].concat(params)); | ||
sendToInsights('convertedObjectIDsAfterSearch', mapToInsightsParamsApi(params), params[0].items); | ||
} | ||
}, | ||
/** | ||
@@ -271,8 +375,6 @@ * Sends conversion events to capture clicked items. | ||
} | ||
if (params.length > 0) { | ||
searchInsights.apply(void 0, ['convertedObjectIDs'].concat(params)); | ||
sendToInsights('convertedObjectIDs', mapToInsightsParamsApi(params), params[0].items); | ||
} | ||
}, | ||
/** | ||
@@ -287,3 +389,2 @@ * Sends conversion events to capture the filters a user uses when converting. | ||
} | ||
if (params.length > 0) { | ||
@@ -293,3 +394,2 @@ searchInsights.apply(void 0, ['convertedFilters'].concat(params)); | ||
}, | ||
/** | ||
@@ -304,12 +404,24 @@ * Sends view events to capture clicked items. | ||
} | ||
if (params.length > 0) { | ||
params.reduce(function (acc, param) { | ||
return [].concat(_toConsumableArray(acc), _toConsumableArray(chunk(param))); | ||
}, []).forEach(function (param) { | ||
return searchInsights('viewedObjectIDs', param); | ||
params.reduce(function (acc, _ref3) { | ||
var items = _ref3.items, | ||
param = _objectWithoutProperties(_ref3, _excluded2); | ||
return [].concat(_toConsumableArray(acc), _toConsumableArray(chunk(_objectSpread2(_objectSpread2({}, param), {}, { | ||
objectIDs: (items === null || items === void 0 ? void 0 : items.map(function (_ref4) { | ||
var objectID = _ref4.objectID; | ||
return objectID; | ||
})) || param.objectIDs | ||
})).map(function (payload) { | ||
return { | ||
items: items, | ||
payload: payload | ||
}; | ||
}))); | ||
}, []).forEach(function (_ref5) { | ||
var items = _ref5.items, | ||
payload = _ref5.payload; | ||
return sendToInsights('viewedObjectIDs', [payload], items); | ||
}); | ||
} | ||
}, | ||
/** | ||
@@ -324,3 +436,2 @@ * Sends view events to capture the filters a user uses when viewing. | ||
} | ||
if (params.length > 0) { | ||
@@ -335,13 +446,13 @@ searchInsights.apply(void 0, ['viewedFilters'].concat(params)); | ||
var items = _ref.items; | ||
var objectIDsByIndexName = items.reduce(function (acc, current) { | ||
var itemsByIndexName = items.reduce(function (acc, current) { | ||
var _acc$current$__autoco; | ||
acc[current.__autocomplete_indexName] = ((_acc$current$__autoco = acc[current.__autocomplete_indexName]) !== null && _acc$current$__autoco !== void 0 ? _acc$current$__autoco : []).concat(current.objectID); | ||
acc[current.__autocomplete_indexName] = ((_acc$current$__autoco = acc[current.__autocomplete_indexName]) !== null && _acc$current$__autoco !== void 0 ? _acc$current$__autoco : []).concat(current); | ||
return acc; | ||
}, {}); | ||
return Object.keys(objectIDsByIndexName).map(function (indexName) { | ||
var objectIDs = objectIDsByIndexName[indexName]; | ||
return Object.keys(itemsByIndexName).map(function (indexName) { | ||
var items = itemsByIndexName[indexName]; | ||
return { | ||
index: indexName, | ||
objectIDs: objectIDs | ||
items: items, | ||
algoliaSource: ['autocomplete'] | ||
}; | ||
@@ -356,7 +467,9 @@ }); | ||
var VIEW_EVENT_DELAY = 400; | ||
var ALGOLIA_INSIGHTS_VERSION = '2.4.0'; | ||
var ALGOLIA_INSIGHTS_SRC = "https://cdn.jsdelivr.net/npm/search-insights@".concat(ALGOLIA_INSIGHTS_VERSION, "/dist/search-insights.min.js"); | ||
var sendViewedObjectIDs = debounce(function (_ref) { | ||
var onItemsChange = _ref.onItemsChange, | ||
items = _ref.items, | ||
insights = _ref.insights, | ||
state = _ref.state; | ||
items = _ref.items, | ||
insights = _ref.insights, | ||
state = _ref.state; | ||
onItemsChange({ | ||
@@ -376,20 +489,43 @@ insights: insights, | ||
var _getOptions = getOptions(options), | ||
insightsClient = _getOptions.insightsClient, | ||
onItemsChange = _getOptions.onItemsChange, | ||
onSelectEvent = _getOptions.onSelect, | ||
onActiveEvent = _getOptions.onActive; | ||
providedInsightsClient = _getOptions.insightsClient, | ||
onItemsChange = _getOptions.onItemsChange, | ||
onSelectEvent = _getOptions.onSelect, | ||
onActiveEvent = _getOptions.onActive; | ||
var insightsClient = providedInsightsClient; | ||
if (!providedInsightsClient) { | ||
safelyRunOnBrowser(function (_ref2) { | ||
var window = _ref2.window; | ||
var pointer = window.AlgoliaAnalyticsObject || 'aa'; | ||
if (typeof pointer === 'string') { | ||
insightsClient = window[pointer]; | ||
} | ||
if (!insightsClient) { | ||
window.AlgoliaAnalyticsObject = pointer; | ||
if (!window[pointer]) { | ||
window[pointer] = function () { | ||
if (!window[pointer].queue) { | ||
window[pointer].queue = []; | ||
} | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
window[pointer].queue.push(args); | ||
}; | ||
} | ||
window[pointer].version = ALGOLIA_INSIGHTS_VERSION; | ||
insightsClient = window[pointer]; | ||
loadInsights(window); | ||
} | ||
}); | ||
} | ||
var insights = createSearchInsightsApi(insightsClient); | ||
var previousItems = createRef([]); | ||
var debouncedOnStateChange = debounce(function (_ref2) { | ||
var state = _ref2.state; | ||
var debouncedOnStateChange = debounce(function (_ref3) { | ||
var state = _ref3.state; | ||
if (!state.isOpen) { | ||
return; | ||
} | ||
var items = state.collections.reduce(function (acc, current) { | ||
return [].concat(_toConsumableArray(acc), _toConsumableArray(current.items)); | ||
}, []).filter(isAlgoliaInsightsHit); | ||
if (!isEqual(previousItems.current.map(function (x) { | ||
@@ -401,3 +537,2 @@ return x.objectID; | ||
previousItems.current = items; | ||
if (items.length > 0) { | ||
@@ -415,6 +550,6 @@ sendViewedObjectIDs({ | ||
name: 'aa.algoliaInsightsPlugin', | ||
subscribe: function subscribe(_ref3) { | ||
var setContext = _ref3.setContext, | ||
onSelect = _ref3.onSelect, | ||
onActive = _ref3.onActive; | ||
subscribe: function subscribe(_ref4) { | ||
var setContext = _ref4.setContext, | ||
onSelect = _ref4.onSelect, | ||
onActive = _ref4.onActive; | ||
insightsClient('addAlgoliaAgent', 'insights-plugin'); | ||
@@ -429,11 +564,9 @@ setContext({ | ||
}); | ||
onSelect(function (_ref4) { | ||
var item = _ref4.item, | ||
state = _ref4.state, | ||
event = _ref4.event; | ||
onSelect(function (_ref5) { | ||
var item = _ref5.item, | ||
state = _ref5.state, | ||
event = _ref5.event; | ||
if (!isAlgoliaInsightsHit(item)) { | ||
return; | ||
} | ||
onSelectEvent({ | ||
@@ -452,11 +585,9 @@ state: state, | ||
}); | ||
onActive(function (_ref5) { | ||
var item = _ref5.item, | ||
state = _ref5.state, | ||
event = _ref5.event; | ||
onActive(function (_ref6) { | ||
var item = _ref6.item, | ||
state = _ref6.state, | ||
event = _ref6.event; | ||
if (!isAlgoliaInsightsHit(item)) { | ||
return; | ||
} | ||
onActiveEvent({ | ||
@@ -476,4 +607,4 @@ state: state, | ||
}, | ||
onStateChange: function onStateChange(_ref6) { | ||
var state = _ref6.state; | ||
onStateChange: function onStateChange(_ref7) { | ||
var state = _ref7.state; | ||
debouncedOnStateChange({ | ||
@@ -486,18 +617,41 @@ state: state | ||
} | ||
function getOptions(options) { | ||
return _objectSpread2({ | ||
onItemsChange: function onItemsChange(_ref7) { | ||
var insights = _ref7.insights, | ||
insightsEvents = _ref7.insightsEvents; | ||
insights.viewedObjectIDs.apply(insights, _toConsumableArray(insightsEvents)); | ||
}, | ||
onSelect: function onSelect(_ref8) { | ||
onItemsChange: function onItemsChange(_ref8) { | ||
var insights = _ref8.insights, | ||
insightsEvents = _ref8.insightsEvents; | ||
insights.clickedObjectIDsAfterSearch.apply(insights, _toConsumableArray(insightsEvents)); | ||
insightsEvents = _ref8.insightsEvents; | ||
insights.viewedObjectIDs.apply(insights, _toConsumableArray(insightsEvents.map(function (event) { | ||
return _objectSpread2(_objectSpread2({}, event), {}, { | ||
algoliaSource: [].concat(_toConsumableArray(event.algoliaSource || []), ['autocomplete-internal']) | ||
}); | ||
}))); | ||
}, | ||
onSelect: function onSelect(_ref9) { | ||
var insights = _ref9.insights, | ||
insightsEvents = _ref9.insightsEvents; | ||
insights.clickedObjectIDsAfterSearch.apply(insights, _toConsumableArray(insightsEvents.map(function (event) { | ||
return _objectSpread2(_objectSpread2({}, event), {}, { | ||
algoliaSource: [].concat(_toConsumableArray(event.algoliaSource || []), ['autocomplete-internal']) | ||
}); | ||
}))); | ||
}, | ||
onActive: noop | ||
}, options); | ||
} | ||
function loadInsights(environment) { | ||
var errorMessage = "[Autocomplete]: Could not load search-insights.js. Please load it manually following https://alg.li/insights-autocomplete"; | ||
try { | ||
var script = environment.document.createElement('script'); | ||
script.async = true; | ||
script.src = ALGOLIA_INSIGHTS_SRC; | ||
script.onerror = function () { | ||
// eslint-disable-next-line no-console | ||
console.error(errorMessage); | ||
}; | ||
document.body.appendChild(script); | ||
} catch (cause) { | ||
// eslint-disable-next-line no-console | ||
console.error(errorMessage); | ||
} | ||
} | ||
@@ -504,0 +658,0 @@ exports.createAlgoliaInsightsPlugin = createAlgoliaInsightsPlugin; |
@@ -1,3 +0,3 @@ | ||
/*! @algolia/autocomplete-plugin-algolia-insights 1.8.3 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/autocomplete-plugin-algolia-insights"]={})}(this,(function(e){"use strict";function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function n(e){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?t(Object(i),!0).forEach((function(t){r(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function c(e,t){var n=void 0;return function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];n&&clearTimeout(n),n=setTimeout((function(){return e.apply(void 0,i)}),t)}}function a(e){return e!==Object(e)}function s(e,t){if(e===t)return!0;if(a(e)||a(t)||"function"==typeof e||"function"==typeof t)return e===t;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var n=0,r=Object.keys(e);n<r.length;n++){var i=r[n];if(!(i in t))return!1;if(!s(e[i],t[i]))return!1}return!0}var u=function(){};function l(e){var t=e.item,n=e.items;return{index:t.__autocomplete_indexName,objectIDs:[t.objectID],positions:[1+n.findIndex((function(e){return e.objectID===t.objectID}))],queryID:t.__autocomplete_queryID}}function f(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,r=[],i=0;i<e.objectIDs.length;i+=t)r.push(n(n({},e),{},{objectIDs:e.objectIDs.slice(i,i+t)}));return r}function p(e){var t=e.items.reduce((function(e,t){var n;return e[t.__autocomplete_indexName]=(null!==(n=e[t.__autocomplete_indexName])&&void 0!==n?n:[]).concat(t.objectID),e}),{});return Object.keys(t).map((function(e){return{index:e,objectIDs:t[e]}}))}function g(e){return e.objectID&&e.__autocomplete_indexName&&e.__autocomplete_queryID}var v=c((function(e){var t=e.onItemsChange,r=e.items,i=e.insights,o=e.state;t({insights:i,insightsEvents:p({items:r}).map((function(e){return n({eventName:"Items Viewed"},e)})),state:o})}),400);e.createAlgoliaInsightsPlugin=function(e){var t,r=function(e){return n({onItemsChange:function(e){var t=e.insights,n=e.insightsEvents;t.viewedObjectIDs.apply(t,i(n))},onSelect:function(e){var t=e.insights,n=e.insightsEvents;t.clickedObjectIDsAfterSearch.apply(t,i(n))},onActive:u},e)}(e),o=r.insightsClient,a=r.onItemsChange,p=r.onSelect,h=r.onActive,d=(t=o,{init:function(e,n){t("init",{appId:e,apiKey:n})},setUserToken:function(e){t("setUserToken",e)},clickedObjectIDsAfterSearch:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];n.length>0&&t.apply(void 0,["clickedObjectIDsAfterSearch"].concat(n))},clickedObjectIDs:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];n.length>0&&t.apply(void 0,["clickedObjectIDs"].concat(n))},clickedFilters:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];n.length>0&&t.apply(void 0,["clickedFilters"].concat(n))},convertedObjectIDsAfterSearch:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];n.length>0&&t.apply(void 0,["convertedObjectIDsAfterSearch"].concat(n))},convertedObjectIDs:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];n.length>0&&t.apply(void 0,["convertedObjectIDs"].concat(n))},convertedFilters:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];n.length>0&&t.apply(void 0,["convertedFilters"].concat(n))},viewedObjectIDs:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];n.length>0&&n.reduce((function(e,t){return[].concat(i(e),i(f(t)))}),[]).forEach((function(e){return t("viewedObjectIDs",e)}))},viewedFilters:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];n.length>0&&t.apply(void 0,["viewedFilters"].concat(n))}}),b={current:[]},m=c((function(e){var t=e.state;if(t.isOpen){var n=t.collections.reduce((function(e,t){return[].concat(i(e),i(t.items))}),[]).filter(g);s(b.current.map((function(e){return e.objectID})),n.map((function(e){return e.objectID})))||(b.current=n,n.length>0&&v({onItemsChange:a,items:n,insights:d,state:t}))}}),0);return{name:"aa.algoliaInsightsPlugin",subscribe:function(e){var t=e.setContext,r=e.onSelect,i=e.onActive;o("addAlgoliaAgent","insights-plugin"),t({algoliaInsightsPlugin:{__algoliaSearchParameters:{clickAnalytics:!0},insights:d}}),r((function(e){var t=e.item,r=e.state,i=e.event;g(t)&&p({state:r,event:i,insights:d,item:t,insightsEvents:[n({eventName:"Item Selected"},l({item:t,items:b.current}))]})})),i((function(e){var t=e.item,r=e.state,i=e.event;g(t)&&h({state:r,event:i,insights:d,item:t,insightsEvents:[n({eventName:"Item Active"},l({item:t,items:b.current}))]})}))},onStateChange:function(e){var t=e.state;m({state:t})},__autocomplete_pluginOptions:e}},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
/*! @algolia/autocomplete-plugin-algolia-insights 1.9.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/autocomplete-plugin-algolia-insights"]={})}(this,(function(e){"use strict";function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function n(e){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?t(Object(i),!0).forEach((function(t){r(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function r(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,c,a=[],u=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(a.push(r.value),a.length!==t);u=!0);}catch(e){l=!0,i=e}finally{try{if(!u&&null!=n.return&&(c=n.return(),Object(c)!==c))return}finally{if(l)throw i}}return a}}(e,t)||a(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||a(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function l(e,t){var n=void 0;return function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];n&&clearTimeout(n),n=setTimeout((function(){return e.apply(void 0,i)}),t)}}function s(e){return e!==Object(e)}function f(e,t){if(e===t)return!0;if(s(e)||s(t)||"function"==typeof e||"function"==typeof t)return e===t;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var n=0,r=Object.keys(e);n<r.length;n++){var i=r[n];if(!(i in t))return!1;if(!f(e[i],t[i]))return!1}return!0}var p=function(){};function m(e){var t=e.item,n=e.items;return{index:t.__autocomplete_indexName,items:[t],positions:[1+n.findIndex((function(e){return e.objectID===t.objectID}))],queryID:t.__autocomplete_queryID,algoliaSource:["autocomplete"]}}var v=["items"],g=["items"];function d(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,r=[],i=0;i<e.objectIDs.length;i+=t)r.push(n(n({},e),{},{objectIDs:e.objectIDs.slice(i,i+t)}));return r}function y(e){return e.map((function(e){var t=e.items,r=i(e,v);return n(n({},r),{},{objectIDs:(null==t?void 0:t.map((function(e){return e.objectID})))||r.objectIDs})}))}function h(e){var t,r,a,u=(t=o((e.version||"").split(".").map(Number),2),r=t[0],a=t[1],r>=3||2===r&&a>=4||1===r&&a>=10);function l(t,n,r){if(u&&void 0!==r){var i=r[0].__autocomplete_algoliaCredentials,o={"X-Algolia-Application-Id":i.appId,"X-Algolia-API-Key":i.apiKey};e.apply(void 0,[t].concat(c(n),[{headers:o}]))}else e.apply(void 0,[t].concat(c(n)))}return{init:function(t,n){e("init",{appId:t,apiKey:n})},setUserToken:function(t){e("setUserToken",t)},clickedObjectIDsAfterSearch:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];t.length>0&&l("clickedObjectIDsAfterSearch",y(t),t[0].items)},clickedObjectIDs:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];t.length>0&&l("clickedObjectIDs",y(t),t[0].items)},clickedFilters:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.length>0&&e.apply(void 0,["clickedFilters"].concat(n))},convertedObjectIDsAfterSearch:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];t.length>0&&l("convertedObjectIDsAfterSearch",y(t),t[0].items)},convertedObjectIDs:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];t.length>0&&l("convertedObjectIDs",y(t),t[0].items)},convertedFilters:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.length>0&&e.apply(void 0,["convertedFilters"].concat(n))},viewedObjectIDs:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t.length>0&&t.reduce((function(e,t){var r=t.items,o=i(t,g);return[].concat(c(e),c(d(n(n({},o),{},{objectIDs:(null==r?void 0:r.map((function(e){return e.objectID})))||o.objectIDs})).map((function(e){return{items:r,payload:e}}))))}),[]).forEach((function(e){var t=e.items;return l("viewedObjectIDs",[e.payload],t)}))},viewedFilters:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.length>0&&e.apply(void 0,["viewedFilters"].concat(n))}}}function b(e){var t=e.items.reduce((function(e,t){var n;return e[t.__autocomplete_indexName]=(null!==(n=e[t.__autocomplete_indexName])&&void 0!==n?n:[]).concat(t),e}),{});return Object.keys(t).map((function(e){return{index:e,items:t[e],algoliaSource:["autocomplete"]}}))}function j(e){return e.objectID&&e.__autocomplete_indexName&&e.__autocomplete_queryID}var O="2.4.0",I="https://cdn.jsdelivr.net/npm/search-insights@".concat(O,"/dist/search-insights.min.js"),w=l((function(e){var t=e.onItemsChange,r=e.items,i=e.insights,o=e.state;t({insights:i,insightsEvents:b({items:r}).map((function(e){return n({eventName:"Items Viewed"},e)})),state:o})}),400);e.createAlgoliaInsightsPlugin=function(e){var t=function(e){return n({onItemsChange:function(e){var t=e.insights,r=e.insightsEvents;t.viewedObjectIDs.apply(t,c(r.map((function(e){return n(n({},e),{},{algoliaSource:[].concat(c(e.algoliaSource||[]),["autocomplete-internal"])})}))))},onSelect:function(e){var t=e.insights,r=e.insightsEvents;t.clickedObjectIDsAfterSearch.apply(t,c(r.map((function(e){return n(n({},e),{},{algoliaSource:[].concat(c(e.algoliaSource||[]),["autocomplete-internal"])})}))))},onActive:p},e)}(e),r=t.insightsClient,i=t.onItemsChange,o=t.onSelect,a=t.onActive,u=r;r||function(e){if("undefined"!=typeof window)e({window:window})}((function(e){var t=e.window,n=t.AlgoliaAnalyticsObject||"aa";"string"==typeof n&&(u=t[n]),u||(t.AlgoliaAnalyticsObject=n,t[n]||(t[n]=function(){t[n].queue||(t[n].queue=[]);for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];t[n].queue.push(r)}),t[n].version=O,u=t[n],function(e){var t="[Autocomplete]: Could not load search-insights.js. Please load it manually following https://alg.li/insights-autocomplete";try{var n=e.document.createElement("script");n.async=!0,n.src=I,n.onerror=function(){console.error(t)},document.body.appendChild(n)}catch(e){console.error(t)}}(t))}));var s=h(u),v={current:[]},g=l((function(e){var t=e.state;if(t.isOpen){var n=t.collections.reduce((function(e,t){return[].concat(c(e),c(t.items))}),[]).filter(j);f(v.current.map((function(e){return e.objectID})),n.map((function(e){return e.objectID})))||(v.current=n,n.length>0&&w({onItemsChange:i,items:n,insights:s,state:t}))}}),0);return{name:"aa.algoliaInsightsPlugin",subscribe:function(e){var t=e.setContext,r=e.onSelect,i=e.onActive;u("addAlgoliaAgent","insights-plugin"),t({algoliaInsightsPlugin:{__algoliaSearchParameters:{clickAnalytics:!0},insights:s}}),r((function(e){var t=e.item,r=e.state,i=e.event;j(t)&&o({state:r,event:i,insights:s,item:t,insightsEvents:[n({eventName:"Item Selected"},m({item:t,items:v.current}))]})})),i((function(e){var t=e.item,r=e.state,i=e.event;j(t)&&a({state:r,event:i,insights:s,item:t,insightsEvents:[n({eventName:"Item Active"},m({item:t,items:v.current}))]})}))},onStateChange:function(e){var t=e.state;g({state:t})},__autocomplete_pluginOptions:e}},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.production.js.map |
{ | ||
"name": "@algolia/autocomplete-plugin-algolia-insights", | ||
"description": "A plugin to add Algolia Insights to Algolia Autocomplete.", | ||
"version": "1.8.3", | ||
"version": "1.9.0", | ||
"license": "MIT", | ||
@@ -34,8 +34,4 @@ "homepage": "https://github.com/algolia/autocomplete", | ||
"dependencies": { | ||
"@algolia/autocomplete-js": "1.8.3", | ||
"@algolia/autocomplete-shared": "1.8.3" | ||
"@algolia/autocomplete-shared": "1.9.0" | ||
}, | ||
"devDependencies": { | ||
"@algolia/autocomplete-core": "1.8.3" | ||
}, | ||
"peerDependencies": { | ||
@@ -42,0 +38,0 @@ "search-insights": ">= 1 < 3" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
133261
2
0
31
1349
0
+ Added@algolia/autocomplete-shared@1.9.0(transitive)
- Removed@algolia/autocomplete-js@1.8.3
- Removed@algolia/autocomplete-core@1.8.3(transitive)
- Removed@algolia/autocomplete-js@1.8.3(transitive)
- Removed@algolia/autocomplete-preset-algolia@1.8.3(transitive)
- Removed@algolia/autocomplete-shared@1.8.3(transitive)
- Removedhtm@3.1.1(transitive)
- Removedpreact@10.25.0(transitive)