@algolia/autocomplete-plugin-algolia-insights
Advanced tools
Comparing version 1.14.0 to 1.15.0
@@ -130,2 +130,4 @@ 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); } | ||
setInsightsContext(); | ||
// Handles user token changes | ||
insightsClient('onUserTokenChange', setInsightsContext); | ||
@@ -135,2 +137,18 @@ insightsClient('getUserToken', null, function (_error, userToken) { | ||
}); | ||
// Handles authenticated user token changes | ||
insightsClient('onAuthenticatedUserTokenChange', function (authenticatedUserToken) { | ||
if (authenticatedUserToken) { | ||
setInsightsContext(authenticatedUserToken); | ||
} else { | ||
insightsClient('getUserToken', null, function (_error, userToken) { | ||
return setInsightsContext(userToken); | ||
}); | ||
} | ||
}); | ||
insightsClient('getAuthenticatedUserToken', null, function (_error, authenticatedUserToken) { | ||
if (authenticatedUserToken) { | ||
setInsightsContext(authenticatedUserToken); | ||
} | ||
}); | ||
onSelect(function (_ref5) { | ||
@@ -137,0 +155,0 @@ var item = _ref5.item, |
@@ -8,2 +8,9 @@ import { ClickedFiltersParams, ClickedObjectIDsAfterSearchParams, ClickedObjectIDsParams, ConvertedFiltersParams, ConvertedObjectIDsAfterSearchParams, ConvertedObjectIDsParams, InsightsClient, WithArbitraryParams, InsightsParamsWithItems, ViewedFiltersParams, ViewedObjectIDsParams } from './types'; | ||
/** | ||
* Sets the authenticated user token to attach to events. | ||
* Unsets the authenticated token by passing `undefined`. | ||
* | ||
* @link https://www.algolia.com/doc/api-reference/api-methods/set-authenticated-user-token/ | ||
*/ | ||
setAuthenticatedUserToken(authenticatedUserToken: string | undefined): void; | ||
/** | ||
* Sets the user token to attach to events. | ||
@@ -10,0 +17,0 @@ */ |
@@ -69,2 +69,11 @@ var _excluded = ["items"], | ||
/** | ||
* Sets the authenticated user token to attach to events. | ||
* Unsets the authenticated token by passing `undefined`. | ||
* | ||
* @link https://www.algolia.com/doc/api-reference/api-methods/set-authenticated-user-token/ | ||
*/ | ||
setAuthenticatedUserToken: function setAuthenticatedUserToken(authenticatedUserToken) { | ||
searchInsights('setAuthenticatedUserToken', authenticatedUserToken); | ||
}, | ||
/** | ||
* Sets the user token to attach to events. | ||
@@ -71,0 +80,0 @@ */ |
import type { InsightsMethodMap as _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 type { Init as InsightsInit, AddAlgoliaAgent as InsightsAddAlgoliaAgent, SetUserToken as InsightsSetUserToken, GetUserToken as InsightsGetUserToken, OnUserTokenChange as InsightsOnUserTokenChange, InsightsEvent, } from 'search-insights'; | ||
export declare type InsightsMethodMap = _InsightsMethodMap; | ||
@@ -4,0 +4,0 @@ export declare type InsightsClientMethod = keyof InsightsMethodMap; |
@@ -1,2 +0,2 @@ | ||
/*! @algolia/autocomplete-plugin-algolia-insights 1.14.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */ | ||
/*! @algolia/autocomplete-plugin-algolia-insights 1.15.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */ | ||
(function (global, factory) { | ||
@@ -292,2 +292,11 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
/** | ||
* Sets the authenticated user token to attach to events. | ||
* Unsets the authenticated token by passing `undefined`. | ||
* | ||
* @link https://www.algolia.com/doc/api-reference/api-methods/set-authenticated-user-token/ | ||
*/ | ||
setAuthenticatedUserToken: function setAuthenticatedUserToken(authenticatedUserToken) { | ||
searchInsights('setAuthenticatedUserToken', authenticatedUserToken); | ||
}, | ||
/** | ||
* Sets the user token to attach to events. | ||
@@ -556,2 +565,4 @@ */ | ||
setInsightsContext(); | ||
// Handles user token changes | ||
insightsClient('onUserTokenChange', setInsightsContext); | ||
@@ -561,2 +572,18 @@ insightsClient('getUserToken', null, function (_error, userToken) { | ||
}); | ||
// Handles authenticated user token changes | ||
insightsClient('onAuthenticatedUserTokenChange', function (authenticatedUserToken) { | ||
if (authenticatedUserToken) { | ||
setInsightsContext(authenticatedUserToken); | ||
} else { | ||
insightsClient('getUserToken', null, function (_error, userToken) { | ||
return setInsightsContext(userToken); | ||
}); | ||
} | ||
}); | ||
insightsClient('getAuthenticatedUserToken', null, function (_error, authenticatedUserToken) { | ||
if (authenticatedUserToken) { | ||
setInsightsContext(authenticatedUserToken); | ||
} | ||
}); | ||
onSelect(function (_ref5) { | ||
@@ -563,0 +590,0 @@ var item = _ref5.item, |
@@ -1,3 +0,3 @@ | ||
/*! @algolia/autocomplete-plugin-algolia-insights 1.14.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,r=void 0===n?[]:n;return{index:t.__autocomplete_indexName,items:[t],positions:[1+r.findIndex((function(e){return e.objectID===t.objectID}))],queryID:t.__autocomplete_queryID,algoliaSource:["autocomplete"]}}var g=["items"],v=["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,g);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,v);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 I="2.13.0",O="https://cdn.jsdelivr.net/npm/search-insights@".concat(I,"/dist/search-insights.min.js"),A=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);function w(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0;return[].concat(c(t),["autocomplete-internal"],c(null!==(e=n.algoliaInsightsPlugin)&&void 0!==e&&e.__automaticInsights?["autocomplete-automatic"]:[]))}function _(e){return"number"==typeof e?e.toString():e}e.createAlgoliaInsightsPlugin=function(e){var t=function(e){return n({onItemsChange:function(e){var t=e.insights,r=e.insightsEvents,i=e.state;t.viewedObjectIDs.apply(t,c(r.map((function(e){return n(n({},e),{},{algoliaSource:w(e.algoliaSource,i.context)})}))))},onSelect:function(e){var t=e.insights,r=e.insightsEvents,i=e.state;t.clickedObjectIDsAfterSearch.apply(t,c(r.map((function(e){return n(n({},e),{},{algoliaSource:w(e.algoliaSource,i.context)})}))))},onActive:p,__autocomplete_clickAnalytics:!0},e)}(e),r=t.insightsClient,i=t.insightsInitParams,o=t.onItemsChange,a=t.onSelect,u=t.onActive,s=t.__autocomplete_clickAnalytics,g=r;if(r||function(e){if("undefined"!=typeof window)e({window:window})}((function(e){var t=e.window,n=t.AlgoliaAnalyticsObject||"aa";"string"==typeof n&&(g=t[n]),g||(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=I,g=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=O,n.onerror=function(){console.error(t)},document.body.appendChild(n)}catch(e){console.error(t)}}(t))})),!g)return{};i&&g("init",n({partial:!0},i));var v=h(g),d={current:[]},y=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(d.current.map((function(e){return e.objectID})),n.map((function(e){return e.objectID})))||(d.current=n,n.length>0&&A({onItemsChange:o,items:n,insights:v,state:t}))}}),0);return{name:"aa.algoliaInsightsPlugin",subscribe:function(e){var t=e.setContext,r=e.onSelect,i=e.onActive;function o(e){t({algoliaInsightsPlugin:{__algoliaSearchParameters:n(n({},s?{clickAnalytics:!0}:{}),e?{userToken:_(e)}:{}),insights:v}})}g("addAlgoliaAgent","insights-plugin"),o(),g("onUserTokenChange",o),g("getUserToken",null,(function(e,t){o(t)})),r((function(e){var t=e.item,r=e.state,i=e.event,o=e.source;j(t)&&a({state:r,event:i,insights:v,item:t,insightsEvents:[n({eventName:"Item Selected"},m({item:t,items:o.getItems().filter(j)}))]})})),i((function(e){var t=e.item,r=e.source,i=e.state,o=e.event;j(t)&&u({state:i,event:o,insights:v,item:t,insightsEvents:[n({eventName:"Item Active"},m({item:t,items:r.getItems().filter(j)}))]})}))},onStateChange:function(e){var t=e.state;y({state:t})},__autocomplete_pluginOptions:e}},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
/*! @algolia/autocomplete-plugin-algolia-insights 1.15.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 g(e){var t=e.item,n=e.items,r=void 0===n?[]:n;return{index:t.__autocomplete_indexName,items:[t],positions:[1+r.findIndex((function(e){return e.objectID===t.objectID}))],queryID:t.__autocomplete_queryID,algoliaSource:["autocomplete"]}}var m=["items"],v=["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 h(e){return e.map((function(e){var t=e.items,r=i(e,m);return n(n({},r),{},{objectIDs:(null==t?void 0:t.map((function(e){return e.objectID})))||r.objectIDs})}))}function y(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})},setAuthenticatedUserToken:function(t){e("setAuthenticatedUserToken",t)},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",h(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",h(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",h(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",h(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,v);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 I="2.13.0",O="https://cdn.jsdelivr.net/npm/search-insights@".concat(I,"/dist/search-insights.min.js"),A=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);function w(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0;return[].concat(c(t),["autocomplete-internal"],c(null!==(e=n.algoliaInsightsPlugin)&&void 0!==e&&e.__automaticInsights?["autocomplete-automatic"]:[]))}function _(e){return"number"==typeof e?e.toString():e}e.createAlgoliaInsightsPlugin=function(e){var t=function(e){return n({onItemsChange:function(e){var t=e.insights,r=e.insightsEvents,i=e.state;t.viewedObjectIDs.apply(t,c(r.map((function(e){return n(n({},e),{},{algoliaSource:w(e.algoliaSource,i.context)})}))))},onSelect:function(e){var t=e.insights,r=e.insightsEvents,i=e.state;t.clickedObjectIDsAfterSearch.apply(t,c(r.map((function(e){return n(n({},e),{},{algoliaSource:w(e.algoliaSource,i.context)})}))))},onActive:p,__autocomplete_clickAnalytics:!0},e)}(e),r=t.insightsClient,i=t.insightsInitParams,o=t.onItemsChange,a=t.onSelect,u=t.onActive,s=t.__autocomplete_clickAnalytics,m=r;if(r||function(e){if("undefined"!=typeof window)e({window:window})}((function(e){var t=e.window,n=t.AlgoliaAnalyticsObject||"aa";"string"==typeof n&&(m=t[n]),m||(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=I,m=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=O,n.onerror=function(){console.error(t)},document.body.appendChild(n)}catch(e){console.error(t)}}(t))})),!m)return{};i&&m("init",n({partial:!0},i));var v=y(m),d={current:[]},h=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(d.current.map((function(e){return e.objectID})),n.map((function(e){return e.objectID})))||(d.current=n,n.length>0&&A({onItemsChange:o,items:n,insights:v,state:t}))}}),0);return{name:"aa.algoliaInsightsPlugin",subscribe:function(e){var t=e.setContext,r=e.onSelect,i=e.onActive;function o(e){t({algoliaInsightsPlugin:{__algoliaSearchParameters:n(n({},s?{clickAnalytics:!0}:{}),e?{userToken:_(e)}:{}),insights:v}})}m("addAlgoliaAgent","insights-plugin"),o(),m("onUserTokenChange",o),m("getUserToken",null,(function(e,t){o(t)})),m("onAuthenticatedUserTokenChange",(function(e){e?o(e):m("getUserToken",null,(function(e,t){return o(t)}))})),m("getAuthenticatedUserToken",null,(function(e,t){t&&o(t)})),r((function(e){var t=e.item,r=e.state,i=e.event,o=e.source;j(t)&&a({state:r,event:i,insights:v,item:t,insightsEvents:[n({eventName:"Item Selected"},g({item:t,items:o.getItems().filter(j)}))]})})),i((function(e){var t=e.item,r=e.source,i=e.state,o=e.event;j(t)&&u({state:i,event:o,insights:v,item:t,insightsEvents:[n({eventName:"Item Active"},g({item:t,items:r.getItems().filter(j)}))]})}))},onStateChange:function(e){var t=e.state;h({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.14.0", | ||
"version": "1.15.0", | ||
"license": "MIT", | ||
@@ -34,3 +34,3 @@ "homepage": "https://github.com/algolia/autocomplete", | ||
"dependencies": { | ||
"@algolia/autocomplete-shared": "1.14.0" | ||
"@algolia/autocomplete-shared": "1.15.0" | ||
}, | ||
@@ -37,0 +37,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
153505
1504
+ Added@algolia/autocomplete-shared@1.15.0(transitive)
- Removed@algolia/autocomplete-shared@1.14.0(transitive)