@algolia/autocomplete-plugin-algolia-insights
Advanced tools
Comparing version 1.4.1 to 1.5.0
@@ -37,2 +37,2 @@ import { AutocompletePlugin } from '@algolia/autocomplete-js'; | ||
}; | ||
export declare function createAlgoliaInsightsPlugin({ insightsClient, onItemsChange, onSelect: onSelectEvent, onActive: onActiveEvent, }: CreateAlgoliaInsightsPluginParams): AutocompletePlugin<any, undefined>; | ||
export declare function createAlgoliaInsightsPlugin(options: CreateAlgoliaInsightsPluginParams): AutocompletePlugin<any, undefined>; |
@@ -7,3 +7,3 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||
@@ -14,3 +14,3 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } | ||
@@ -21,3 +21,3 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
import { createRef, debounce, isEqual } from '@algolia/autocomplete-shared'; | ||
import { createRef, debounce, isEqual, noop } from '@algolia/autocomplete-shared'; | ||
import { createClickedEvent } from './createClickedEvent'; | ||
@@ -45,22 +45,13 @@ import { createSearchInsightsApi } from './createSearchInsightsApi'; | ||
}, VIEW_EVENT_DELAY); | ||
export function createAlgoliaInsightsPlugin(_ref2) { | ||
var insightsClient = _ref2.insightsClient, | ||
_ref2$onItemsChange = _ref2.onItemsChange, | ||
onItemsChange = _ref2$onItemsChange === void 0 ? function (_ref3) { | ||
var insights = _ref3.insights, | ||
insightsEvents = _ref3.insightsEvents; | ||
insights.viewedObjectIDs.apply(insights, _toConsumableArray(insightsEvents)); | ||
} : _ref2$onItemsChange, | ||
_ref2$onSelect = _ref2.onSelect, | ||
onSelectEvent = _ref2$onSelect === void 0 ? function (_ref4) { | ||
var insights = _ref4.insights, | ||
insightsEvents = _ref4.insightsEvents; | ||
insights.clickedObjectIDsAfterSearch.apply(insights, _toConsumableArray(insightsEvents)); | ||
} : _ref2$onSelect, | ||
_ref2$onActive = _ref2.onActive, | ||
onActiveEvent = _ref2$onActive === void 0 ? function () {} : _ref2$onActive; | ||
export function createAlgoliaInsightsPlugin(options) { | ||
var _getOptions = getOptions(options), | ||
insightsClient = _getOptions.insightsClient, | ||
onItemsChange = _getOptions.onItemsChange, | ||
onSelectEvent = _getOptions.onSelect, | ||
onActiveEvent = _getOptions.onActive; | ||
var insights = createSearchInsightsApi(insightsClient); | ||
var previousItems = createRef([]); | ||
var debouncedOnStateChange = debounce(function (_ref5) { | ||
var state = _ref5.state; | ||
var debouncedOnStateChange = debounce(function (_ref2) { | ||
var state = _ref2.state; | ||
@@ -93,6 +84,7 @@ if (!state.isOpen) { | ||
return { | ||
subscribe: function subscribe(_ref6) { | ||
var setContext = _ref6.setContext, | ||
onSelect = _ref6.onSelect, | ||
onActive = _ref6.onActive; | ||
name: 'aa.algoliaInsightsPlugin', | ||
subscribe: function subscribe(_ref3) { | ||
var setContext = _ref3.setContext, | ||
onSelect = _ref3.onSelect, | ||
onActive = _ref3.onActive; | ||
setContext({ | ||
@@ -103,6 +95,6 @@ algoliaInsightsPlugin: { | ||
}); | ||
onSelect(function (_ref7) { | ||
var item = _ref7.item, | ||
state = _ref7.state, | ||
event = _ref7.event; | ||
onSelect(function (_ref4) { | ||
var item = _ref4.item, | ||
state = _ref4.state, | ||
event = _ref4.event; | ||
@@ -126,6 +118,6 @@ if (!isAlgoliaInsightsHit(item)) { | ||
}); | ||
onActive(function (_ref8) { | ||
var item = _ref8.item, | ||
state = _ref8.state, | ||
event = _ref8.event; | ||
onActive(function (_ref5) { | ||
var item = _ref5.item, | ||
state = _ref5.state, | ||
event = _ref5.event; | ||
@@ -150,9 +142,26 @@ if (!isAlgoliaInsightsHit(item)) { | ||
}, | ||
onStateChange: function onStateChange(_ref9) { | ||
var state = _ref9.state; | ||
onStateChange: function onStateChange(_ref6) { | ||
var state = _ref6.state; | ||
debouncedOnStateChange({ | ||
state: state | ||
}); | ||
} | ||
}, | ||
__autocomplete_pluginOptions: options | ||
}; | ||
} | ||
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) { | ||
var insights = _ref8.insights, | ||
insightsEvents = _ref8.insightsEvents; | ||
insights.clickedObjectIDsAfterSearch.apply(insights, _toConsumableArray(insightsEvents)); | ||
}, | ||
onActive: noop | ||
}, options); | ||
} |
@@ -1,1 +0,2 @@ | ||
export * from './createAlgoliaInsightsPlugin'; | ||
export * from './createAlgoliaInsightsPlugin'; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
/*! @algolia/autocomplete-plugin-algolia-insights 1.4.1 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */ | ||
/*! @algolia/autocomplete-plugin-algolia-insights 1.5.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */ | ||
(function (global, factory) { | ||
@@ -8,17 +8,2 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
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 ownKeys(object, enumerableOnly) { | ||
@@ -29,5 +14,9 @@ var keys = Object.keys(object); | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
if (enumerableOnly) symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); | ||
if (enumerableOnly) { | ||
symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); | ||
} | ||
keys.push.apply(keys, symbols); | ||
@@ -59,2 +48,17 @@ } | ||
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 _toConsumableArray(arr) { | ||
@@ -69,3 +73,3 @@ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
function _iterableToArray(iter) { | ||
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); | ||
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); | ||
} | ||
@@ -149,2 +153,4 @@ | ||
var noop = function noop() {}; | ||
function createClickedEvent(_ref) { | ||
@@ -343,22 +349,13 @@ var item = _ref.item, | ||
}, VIEW_EVENT_DELAY); | ||
function createAlgoliaInsightsPlugin(_ref2) { | ||
var insightsClient = _ref2.insightsClient, | ||
_ref2$onItemsChange = _ref2.onItemsChange, | ||
onItemsChange = _ref2$onItemsChange === void 0 ? function (_ref3) { | ||
var insights = _ref3.insights, | ||
insightsEvents = _ref3.insightsEvents; | ||
insights.viewedObjectIDs.apply(insights, _toConsumableArray(insightsEvents)); | ||
} : _ref2$onItemsChange, | ||
_ref2$onSelect = _ref2.onSelect, | ||
onSelectEvent = _ref2$onSelect === void 0 ? function (_ref4) { | ||
var insights = _ref4.insights, | ||
insightsEvents = _ref4.insightsEvents; | ||
insights.clickedObjectIDsAfterSearch.apply(insights, _toConsumableArray(insightsEvents)); | ||
} : _ref2$onSelect, | ||
_ref2$onActive = _ref2.onActive, | ||
onActiveEvent = _ref2$onActive === void 0 ? function () {} : _ref2$onActive; | ||
function createAlgoliaInsightsPlugin(options) { | ||
var _getOptions = getOptions(options), | ||
insightsClient = _getOptions.insightsClient, | ||
onItemsChange = _getOptions.onItemsChange, | ||
onSelectEvent = _getOptions.onSelect, | ||
onActiveEvent = _getOptions.onActive; | ||
var insights = createSearchInsightsApi(insightsClient); | ||
var previousItems = createRef([]); | ||
var debouncedOnStateChange = debounce(function (_ref5) { | ||
var state = _ref5.state; | ||
var debouncedOnStateChange = debounce(function (_ref2) { | ||
var state = _ref2.state; | ||
@@ -391,6 +388,7 @@ if (!state.isOpen) { | ||
return { | ||
subscribe: function subscribe(_ref6) { | ||
var setContext = _ref6.setContext, | ||
onSelect = _ref6.onSelect, | ||
onActive = _ref6.onActive; | ||
name: 'aa.algoliaInsightsPlugin', | ||
subscribe: function subscribe(_ref3) { | ||
var setContext = _ref3.setContext, | ||
onSelect = _ref3.onSelect, | ||
onActive = _ref3.onActive; | ||
setContext({ | ||
@@ -401,6 +399,6 @@ algoliaInsightsPlugin: { | ||
}); | ||
onSelect(function (_ref7) { | ||
var item = _ref7.item, | ||
state = _ref7.state, | ||
event = _ref7.event; | ||
onSelect(function (_ref4) { | ||
var item = _ref4.item, | ||
state = _ref4.state, | ||
event = _ref4.event; | ||
@@ -424,6 +422,6 @@ if (!isAlgoliaInsightsHit(item)) { | ||
}); | ||
onActive(function (_ref8) { | ||
var item = _ref8.item, | ||
state = _ref8.state, | ||
event = _ref8.event; | ||
onActive(function (_ref5) { | ||
var item = _ref5.item, | ||
state = _ref5.state, | ||
event = _ref5.event; | ||
@@ -448,11 +446,28 @@ if (!isAlgoliaInsightsHit(item)) { | ||
}, | ||
onStateChange: function onStateChange(_ref9) { | ||
var state = _ref9.state; | ||
onStateChange: function onStateChange(_ref6) { | ||
var state = _ref6.state; | ||
debouncedOnStateChange({ | ||
state: state | ||
}); | ||
} | ||
}, | ||
__autocomplete_pluginOptions: options | ||
}; | ||
} | ||
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) { | ||
var insights = _ref8.insights, | ||
insightsEvents = _ref8.insightsEvents; | ||
insights.clickedObjectIDsAfterSearch.apply(insights, _toConsumableArray(insightsEvents)); | ||
}, | ||
onActive: noop | ||
}, options); | ||
} | ||
exports.createAlgoliaInsightsPlugin = createAlgoliaInsightsPlugin; | ||
@@ -459,0 +474,0 @@ |
@@ -1,3 +0,3 @@ | ||
/*! @algolia/autocomplete-plugin-algolia-insights 1.4.1 | 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,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(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 r(e){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?n(Object(i),!0).forEach((function(n){t(e,n,i[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):n(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function i(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))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}function u(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){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 l(e){return e.objectID&&e.__autocomplete_indexName&&e.__autocomplete_queryID}var v=c((function(e){var t=e.onItemsChange,n=e.items,i=e.insights,o=e.state;t({insights:i,insightsEvents:f({items:n}).map((function(e){return r({eventName:"Items Viewed"},e)})),state:o})}),400);e.createAlgoliaInsightsPlugin=function(e){var t,n=e.insightsClient,o=e.onItemsChange,a=void 0===o?function(e){var t=e.insights,n=e.insightsEvents;t.viewedObjectIDs.apply(t,i(n))}:o,f=e.onSelect,p=void 0===f?function(e){var t=e.insights,n=e.insightsEvents;t.clickedObjectIDsAfterSearch.apply(t,i(n))}:f,d=e.onActive,g=void 0===d?function(){}:d,y=(t=n,{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&&t.apply(void 0,["viewedObjectIDs"].concat(n))},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:[]},h=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(l);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:y,state:t}))}}),0);return{subscribe:function(e){var t=e.setContext,n=e.onSelect,i=e.onActive;t({algoliaInsightsPlugin:{insights:y}}),n((function(e){var t=e.item,n=e.state,i=e.event;l(t)&&p({state:n,event:i,insights:y,item:t,insightsEvents:[r({eventName:"Item Selected"},u({item:t,items:b.current}))]})})),i((function(e){var t=e.item,n=e.state,i=e.event;l(t)&&g({state:n,event:i,insights:y,item:t,insightsEvents:[r({eventName:"Item Active"},u({item:t,items:b.current}))]})}))},onStateChange:function(e){var t=e.state;h({state:t})}}},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
/*! @algolia/autocomplete-plugin-algolia-insights 1.5.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 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){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 p(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:f({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,f=r.onSelect,g=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&&t.apply(void 0,["viewedObjectIDs"].concat(n))},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))}}),h={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(p);s(h.current.map((function(e){return e.objectID})),n.map((function(e){return e.objectID})))||(h.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;t({algoliaInsightsPlugin:{insights:d}}),r((function(e){var t=e.item,r=e.state,i=e.event;p(t)&&f({state:r,event:i,insights:d,item:t,insightsEvents:[n({eventName:"Item Selected"},l({item:t,items:h.current}))]})})),i((function(e){var t=e.item,r=e.state,i=e.event;p(t)&&g({state:r,event:i,insights:d,item:t,insightsEvents:[n({eventName:"Item Active"},l({item:t,items:h.current}))]})}))},onStateChange:function(e){var t=e.state;m({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.4.1", | ||
"version": "1.5.0", | ||
"license": "MIT", | ||
@@ -34,7 +34,7 @@ "homepage": "https://github.com/algolia/autocomplete", | ||
"dependencies": { | ||
"@algolia/autocomplete-js": "1.4.1", | ||
"@algolia/autocomplete-shared": "1.4.1" | ||
"@algolia/autocomplete-js": "1.5.0", | ||
"@algolia/autocomplete-shared": "1.5.0" | ||
}, | ||
"devDependencies": { | ||
"@algolia/autocomplete-core": "1.4.1" | ||
"@algolia/autocomplete-core": "1.5.0" | ||
}, | ||
@@ -41,0 +41,0 @@ "peerDependencies": { |
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
80581
29
912
+ Added@algolia/autocomplete-core@1.5.0(transitive)
+ Added@algolia/autocomplete-js@1.5.0(transitive)
+ Added@algolia/autocomplete-preset-algolia@1.5.0(transitive)
+ Added@algolia/autocomplete-shared@1.5.0(transitive)
- Removed@algolia/autocomplete-core@1.4.1(transitive)
- Removed@algolia/autocomplete-js@1.4.1(transitive)
- Removed@algolia/autocomplete-preset-algolia@1.4.1(transitive)
- Removed@algolia/autocomplete-shared@1.4.1(transitive)