Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@algolia/autocomplete-plugin-algolia-insights

Package Overview
Dependencies
Maintainers
84
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/autocomplete-plugin-algolia-insights - npm Package Compare versions

Comparing version 1.11.1 to 1.12.0

4

dist/esm/createAlgoliaInsightsPlugin.d.ts

@@ -36,3 +36,7 @@ import { AutocompletePlugin } from '@algolia/autocomplete-shared';

onActive?(params: OnActiveParams): void;
/**
* @internal
*/
__autocomplete_clickAnalytics?: boolean;
};
export declare function createAlgoliaInsightsPlugin(options: CreateAlgoliaInsightsPluginParams): AutocompletePlugin<any, undefined>;

26

dist/esm/createAlgoliaInsightsPlugin.js

@@ -43,3 +43,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); }

onSelectEvent = _getOptions.onSelect,
onActiveEvent = _getOptions.onActive;
onActiveEvent = _getOptions.onActive,
__autocomplete_clickAnalytics = _getOptions.__autocomplete_clickAnalytics;
var insightsClient = providedInsightsClient;

@@ -107,5 +108,5 @@ if (!providedInsightsClient) {

algoliaInsightsPlugin: {
__algoliaSearchParameters: _objectSpread({
__algoliaSearchParameters: _objectSpread(_objectSpread({}, __autocomplete_clickAnalytics ? {
clickAnalytics: true
}, userToken ? {
} : {}), userToken ? {
userToken: userToken

@@ -175,2 +176,8 @@ } : {}),

}
function getAlgoliaSources() {
var _context$algoliaInsig;
var algoliaSourceBase = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var context = arguments.length > 1 ? arguments[1] : undefined;
return [].concat(_toConsumableArray(algoliaSourceBase), ['autocomplete-internal'], _toConsumableArray((_context$algoliaInsig = context.algoliaInsightsPlugin) !== null && _context$algoliaInsig !== void 0 && _context$algoliaInsig.__automaticInsights ? ['autocomplete-automatic'] : []));
}
function getOptions(options) {

@@ -180,6 +187,7 @@ return _objectSpread({

var insights = _ref8.insights,
insightsEvents = _ref8.insightsEvents;
insightsEvents = _ref8.insightsEvents,
state = _ref8.state;
insights.viewedObjectIDs.apply(insights, _toConsumableArray(insightsEvents.map(function (event) {
return _objectSpread(_objectSpread({}, event), {}, {
algoliaSource: [].concat(_toConsumableArray(event.algoliaSource || []), ['autocomplete-internal'])
algoliaSource: getAlgoliaSources(event.algoliaSource, state.context)
});

@@ -190,10 +198,12 @@ })));

var insights = _ref9.insights,
insightsEvents = _ref9.insightsEvents;
insightsEvents = _ref9.insightsEvents,
state = _ref9.state;
insights.clickedObjectIDsAfterSearch.apply(insights, _toConsumableArray(insightsEvents.map(function (event) {
return _objectSpread(_objectSpread({}, event), {}, {
algoliaSource: [].concat(_toConsumableArray(event.algoliaSource || []), ['autocomplete-internal'])
algoliaSource: getAlgoliaSources(event.algoliaSource, state.context)
});
})));
},
onActive: noop
onActive: noop,
__autocomplete_clickAnalytics: true
}, options);

@@ -200,0 +210,0 @@ }

@@ -1,2 +0,2 @@

import { ClickedFiltersParams, ClickedObjectIDsAfterSearchParams, ClickedObjectIDsParams, ConvertedFiltersParams, ConvertedObjectIDsAfterSearchParams, ConvertedObjectIDsParams, InsightsClient, InsightsParamsWithItems, ViewedFiltersParams, ViewedObjectIDsParams } from './types';
import { ClickedFiltersParams, ClickedObjectIDsAfterSearchParams, ClickedObjectIDsParams, ConvertedFiltersParams, ConvertedObjectIDsAfterSearchParams, ConvertedObjectIDsParams, InsightsClient, WithArbitraryParams, InsightsParamsWithItems, ViewedFiltersParams, ViewedObjectIDsParams } from './types';
export declare function createSearchInsightsApi(searchInsights: InsightsClient): {

@@ -16,3 +16,3 @@ /**

*/
clickedObjectIDsAfterSearch(...params: Array<InsightsParamsWithItems<ClickedObjectIDsAfterSearchParams>>): void;
clickedObjectIDsAfterSearch(...params: Array<WithArbitraryParams<InsightsParamsWithItems<ClickedObjectIDsAfterSearchParams>>>): void;
/**

@@ -23,3 +23,3 @@ * Sends click events to capture clicked items.

*/
clickedObjectIDs(...params: Array<InsightsParamsWithItems<ClickedObjectIDsParams>>): void;
clickedObjectIDs(...params: Array<WithArbitraryParams<InsightsParamsWithItems<ClickedObjectIDsParams>>>): void;
/**

@@ -30,3 +30,3 @@ * Sends click events to capture the filters a user clicks on.

*/
clickedFilters(...params: ClickedFiltersParams[]): void;
clickedFilters(...params: Array<WithArbitraryParams<ClickedFiltersParams>>): void;
/**

@@ -37,3 +37,3 @@ * Sends conversion events to capture a query and its clicked items.

*/
convertedObjectIDsAfterSearch(...params: Array<InsightsParamsWithItems<ConvertedObjectIDsAfterSearchParams>>): void;
convertedObjectIDsAfterSearch(...params: Array<WithArbitraryParams<InsightsParamsWithItems<ConvertedObjectIDsAfterSearchParams>>>): void;
/**

@@ -44,3 +44,3 @@ * Sends conversion events to capture clicked items.

*/
convertedObjectIDs(...params: Array<InsightsParamsWithItems<ConvertedObjectIDsParams>>): void;
convertedObjectIDs(...params: Array<WithArbitraryParams<InsightsParamsWithItems<ConvertedObjectIDsParams>>>): void;
/**

@@ -51,3 +51,3 @@ * Sends conversion events to capture the filters a user uses when converting.

*/
convertedFilters(...params: ConvertedFiltersParams[]): void;
convertedFilters(...params: Array<WithArbitraryParams<ConvertedFiltersParams>>): void;
/**

@@ -58,3 +58,3 @@ * Sends view events to capture clicked items.

*/
viewedObjectIDs(...params: Array<InsightsParamsWithItems<ViewedObjectIDsParams>>): void;
viewedObjectIDs(...params: Array<WithArbitraryParams<InsightsParamsWithItems<ViewedObjectIDsParams>>>): void;
/**

@@ -65,3 +65,3 @@ * Sends view events to capture the filters a user uses when viewing.

*/
viewedFilters(...params: ViewedFiltersParams[]): void;
viewedFilters(...params: Array<WithArbitraryParams<ViewedFiltersParams>>): void;
};
import { createSearchInsightsApi } from '../createSearchInsightsApi';
import type { AlgoliaInsightsHit } from './AlgoliaInsightsHit';
export declare type AutocompleteInsightsApi = ReturnType<typeof createSearchInsightsApi>;
export declare type WithArbitraryParams<TParams extends Record<string, unknown>> = Record<string, unknown> & TParams;
export declare type InsightsParamsWithItems<TParams extends {

@@ -5,0 +6,0 @@ objectIDs: string[];

@@ -1,2 +0,2 @@

/*! @algolia/autocomplete-plugin-algolia-insights 1.11.1 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */
/*! @algolia/autocomplete-plugin-algolia-insights 1.12.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */
(function (global, factory) {

@@ -468,3 +468,4 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

onSelectEvent = _getOptions.onSelect,
onActiveEvent = _getOptions.onActive;
onActiveEvent = _getOptions.onActive,
__autocomplete_clickAnalytics = _getOptions.__autocomplete_clickAnalytics;
var insightsClient = providedInsightsClient;

@@ -532,5 +533,5 @@ if (!providedInsightsClient) {

algoliaInsightsPlugin: {
__algoliaSearchParameters: _objectSpread2({
__algoliaSearchParameters: _objectSpread2(_objectSpread2({}, __autocomplete_clickAnalytics ? {
clickAnalytics: true
}, userToken ? {
} : {}), userToken ? {
userToken: userToken

@@ -600,2 +601,8 @@ } : {}),

}
function getAlgoliaSources() {
var _context$algoliaInsig;
var algoliaSourceBase = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var context = arguments.length > 1 ? arguments[1] : undefined;
return [].concat(_toConsumableArray(algoliaSourceBase), ['autocomplete-internal'], _toConsumableArray((_context$algoliaInsig = context.algoliaInsightsPlugin) !== null && _context$algoliaInsig !== void 0 && _context$algoliaInsig.__automaticInsights ? ['autocomplete-automatic'] : []));
}
function getOptions(options) {

@@ -605,6 +612,7 @@ return _objectSpread2({

var insights = _ref8.insights,
insightsEvents = _ref8.insightsEvents;
insightsEvents = _ref8.insightsEvents,
state = _ref8.state;
insights.viewedObjectIDs.apply(insights, _toConsumableArray(insightsEvents.map(function (event) {
return _objectSpread2(_objectSpread2({}, event), {}, {
algoliaSource: [].concat(_toConsumableArray(event.algoliaSource || []), ['autocomplete-internal'])
algoliaSource: getAlgoliaSources(event.algoliaSource, state.context)
});

@@ -615,10 +623,12 @@ })));

var insights = _ref9.insights,
insightsEvents = _ref9.insightsEvents;
insightsEvents = _ref9.insightsEvents,
state = _ref9.state;
insights.clickedObjectIDsAfterSearch.apply(insights, _toConsumableArray(insightsEvents.map(function (event) {
return _objectSpread2(_objectSpread2({}, event), {}, {
algoliaSource: [].concat(_toConsumableArray(event.algoliaSource || []), ['autocomplete-internal'])
algoliaSource: getAlgoliaSources(event.algoliaSource, state.context)
});
})));
},
onActive: noop
onActive: noop,
__autocomplete_clickAnalytics: true
}, options);

@@ -625,0 +635,0 @@ }

@@ -1,3 +0,3 @@

/*! @algolia/autocomplete-plugin-algolia-insights 1.11.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){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 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 I="2.6.0",O="https://cdn.jsdelivr.net/npm/search-insights@".concat(I,"/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=I,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=O,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;function c(e){t({algoliaInsightsPlugin:{__algoliaSearchParameters:n({clickAnalytics:!0},e?{userToken:e}:{}),insights:s}})}u("addAlgoliaAgent","insights-plugin"),c(),u("onUserTokenChange",c),u("getUserToken",null,(function(e,t){c(t)})),r((function(e){var t=e.item,r=e.state,i=e.event,c=e.source;j(t)&&o({state:r,event:i,insights:s,item:t,insightsEvents:[n({eventName:"Item Selected"},m({item:t,items:c.getItems().filter(j)}))]})})),i((function(e){var t=e.item,r=e.source,i=e.state,o=e.event;j(t)&&a({state:i,event:o,insights:s,item:t,insightsEvents:[n({eventName:"Item Active"},m({item:t,items:r.getItems().filter(j)}))]})}))},onStateChange:function(e){var t=e.state;g({state:t})},__autocomplete_pluginOptions:e}},Object.defineProperty(e,"__esModule",{value:!0})}));
/*! @algolia/autocomplete-plugin-algolia-insights 1.12.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.6.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"]:[]))}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.onItemsChange,o=t.onSelect,a=t.onActive,u=t.__autocomplete_clickAnalytics,s=r;r||function(e){if("undefined"!=typeof window)e({window:window})}((function(e){var t=e.window,n=t.AlgoliaAnalyticsObject||"aa";"string"==typeof n&&(s=t[n]),s||(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,s=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))}));var g=h(s),v={current:[]},d=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&&A({onItemsChange:i,items:n,insights:g,state:t}))}}),0);return{name:"aa.algoliaInsightsPlugin",subscribe:function(e){var t=e.setContext,r=e.onSelect,i=e.onActive;function c(e){t({algoliaInsightsPlugin:{__algoliaSearchParameters:n(n({},u?{clickAnalytics:!0}:{}),e?{userToken:e}:{}),insights:g}})}s("addAlgoliaAgent","insights-plugin"),c(),s("onUserTokenChange",c),s("getUserToken",null,(function(e,t){c(t)})),r((function(e){var t=e.item,r=e.state,i=e.event,c=e.source;j(t)&&o({state:r,event:i,insights:g,item:t,insightsEvents:[n({eventName:"Item Selected"},m({item:t,items:c.getItems().filter(j)}))]})})),i((function(e){var t=e.item,r=e.source,i=e.state,o=e.event;j(t)&&a({state:i,event:o,insights:g,item:t,insightsEvents:[n({eventName:"Item Active"},m({item:t,items:r.getItems().filter(j)}))]})}))},onStateChange:function(e){var t=e.state;d({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.11.1",
"version": "1.12.0",
"license": "MIT",

@@ -34,3 +34,3 @@ "homepage": "https://github.com/algolia/autocomplete",

"dependencies": {
"@algolia/autocomplete-shared": "1.11.1"
"@algolia/autocomplete-shared": "1.12.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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc