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

search-insights

Package Overview
Dependencies
Maintainers
8
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

search-insights - npm Package Compare versions

Comparing version 1.8.0 to 1.9.0

dist/_createInsightsClient.d.ts

9

CHANGELOG.md

@@ -0,1 +1,10 @@

# [1.9.0](https://github.com/algolia/search-insights.js/compare/v1.8.0...v1.9.0) (2023-02-16)
### Features
* **api:** expose window.AlgoliaAnalyticsObject if not yet set ([#391](https://github.com/algolia/search-insights.js/issues/391)) ([59c479c](https://github.com/algolia/search-insights.js/commit/59c479cf1f70736fb96a2e271b6390777be45855))
# [1.8.0](https://github.com/algolia/search-insights.js/compare/v1.7.2...v1.8.0) (2021-04-28)

@@ -2,0 +11,0 @@

2

dist/entry-browser-cjs.d.ts
import { getRequesterForBrowser } from "./utils/getRequesterForBrowser";
import { getRequesterForNode } from "./utils/getRequesterForNode";
import { RequestFnType } from "./utils/request";
export { getRequesterForBrowser, getRequesterForNode };
export * from "./types";
export declare function createInsightsClient(requestFn: RequestFnType): import("./types").InsightsClient;
declare const _default: import("./types").InsightsClient;
export default _default;
import { getRequesterForBrowser } from "./utils/getRequesterForBrowser";
import { getRequesterForNode } from "./utils/getRequesterForNode";
import { RequestFnType } from "./utils/request";
export { getRequesterForBrowser, getRequesterForNode };
export * from "./types";
export declare function createInsightsClient(requestFn: RequestFnType): import("./types").InsightsClient;
declare const _default: import("./types").InsightsClient;
export default _default;

@@ -15,6 +15,6 @@ import { InsightsEventType, InsightsEvent } from "./_sendEvent";

};
declare type AlgoliaAnalyticsObject = Queue | AnalyticsFunction;
export declare type AlgoliaAnalyticsObject = Queue | AnalyticsFunction;
declare global {
interface Window {
AlgoliaAnalyticsObject: AlgoliaAnalyticsObject;
AlgoliaAnalyticsObject?: string;
}

@@ -21,0 +21,0 @@ }

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

"use strict";function objectAssignPolyfill(){"function"!=typeof Object.assign&&(Object.assign=function(e,t){var r=arguments;if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e),o=1;o<arguments.length;o++){var i=r[o];if(null!=i)for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])}return n})}function objectKeysPolyfill(){var e,t,r,n;Object.keys||(Object.keys=(e=Object.prototype.hasOwnProperty,t=!{toString:null}.propertyIsEnumerable("toString"),n=(r=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"]).length,function(o){if("function"!=typeof o&&("object"!=typeof o||null===o))throw new TypeError("Object.keys called on non-object");var i,s,a=[];for(i in o)e.call(o,i)&&a.push(i);if(t)for(s=0;s<n;s++)e.call(o,r[s])&&a.push(r[s]);return a}))}Object.defineProperty(exports,"__esModule",{value:!0});var supportsCookies=function(){try{return Boolean(navigator.cookieEnabled)}catch(e){return!1}},supportsSendBeacon=function(){try{return Boolean(navigator.sendBeacon)}catch(e){return!1}},supportsXMLHttpRequest=function(){try{return Boolean(XMLHttpRequest)}catch(e){return!1}},supportsNodeHttpModule=function(){try{var e=require("http").request,t=require("https").request;return Boolean(e)&&Boolean(t)}catch(e){return!1}},isUndefined=function(e){return void 0===e},isString=function(e){return"string"==typeof e},isNumber=function(e){return"number"==typeof e},isFunction=function(e){return"function"==typeof e};function makeSendEvent(e){return function(t,r){if(!this._userHasOptedOut){if(!this._hasCredentials)throw new Error("Before calling any methods on the analytics, you first need to call the 'init' function with appId and apiKey parameters");if(""===r.userToken||""===this._userToken)throw new Error("`userToken` cannot be an empty string.");var n=r.userToken||this._userToken;if(isUndefined(n))throw new Error("Before calling any methods on the analytics, you first need to call 'setUserToken' function or include 'userToken' in the event payload.");if(!isString(r.index))throw new TypeError("expected required parameter `index` to be a string");if(!isString(r.eventName))throw new TypeError("expected required parameter `eventName` to be a string");if(!isUndefined(r.userToken)&&!isString(r.userToken))throw new TypeError("expected optional parameter `userToken` to be a string");var o={eventType:t,eventName:r.eventName,userToken:n,index:r.index};if(!isUndefined(r.timestamp)){if(!isNumber(r.timestamp))throw new TypeError("expected optional parameter `timestamp` to be a number");o.timestamp=r.timestamp}if(!isUndefined(r.queryID)){if(!isString(r.queryID))throw new TypeError("expected optional parameter `queryID` to be a string");o.queryID=r.queryID}if(!isUndefined(r.objectIDs)){if(!Array.isArray(r.objectIDs))throw new TypeError("expected optional parameter `objectIDs` to be an array");o.objectIDs=r.objectIDs}if(!isUndefined(r.positions)){if(!Array.isArray(r.positions))throw new TypeError("expected optional parameter `positions` to be an array");if(isUndefined(r.objectIDs))throw new Error("cannot use `positions` without providing `objectIDs`");if(r.objectIDs.length!==r.positions.length)throw new Error("objectIDs and positions need to be of the same size");o.positions=r.positions}if(!isUndefined(r.filters)){if(!isUndefined(r.objectIDs))throw new Error("cannot use `objectIDs` and `filters` for the same event");if(!Array.isArray(r.filters))throw new TypeError("expected optional parameter `filters` to be an array");o.filters=r.filters}if(isUndefined(r.objectIDs)&&isUndefined(r.filters))throw new Error("expected either `objectIDs` or `filters` to be provided");return bulkSendEvent(e,this._appId,this._apiKey,this._uaURIEncoded,this._endpointOrigin,[o])}}}function bulkSendEvent(e,t,r,n,o,i){return e(o+"/1/events?X-Algolia-Application-Id="+t+"&X-Algolia-API-Key="+r+"&X-Algolia-Agent="+n,{events:i})}var version="1.8.0",DEFAULT_ALGOLIA_AGENT="insights-js ("+version+")";function addAlgoliaAgent(e){-1===this._ua.indexOf("; "+e)&&(this._ua+="; "+e,this._uaURIEncoded=encodeURIComponent(this._ua))}var SUPPORTED_REGIONS=["de","us"],MONTH=2592e6;function init(e){var t;if(!e)throw new Error("Init function should be called with an object argument containing your apiKey and appId");if(isUndefined(e.apiKey)||!isString(e.apiKey))throw new Error("apiKey is missing, please provide it so we can authenticate the application");if(isUndefined(e.appId)||!isString(e.appId))throw new Error("appId is missing, please provide it, so we can properly attribute data to your application");if(!isUndefined(e.region)&&-1===SUPPORTED_REGIONS.indexOf(e.region))throw new Error("optional region is incorrect, please provide either one of: "+SUPPORTED_REGIONS.join(", ")+".");if(!(isUndefined(e.cookieDuration)||isNumber(e.cookieDuration)&&isFinite(e.cookieDuration)&&Math.floor(e.cookieDuration)===e.cookieDuration))throw new Error("optional cookieDuration is incorrect, expected an integer.");this._apiKey=e.apiKey,this._appId=e.appId,this._userHasOptedOut=!!e.userHasOptedOut,this._region=e.region,this._endpointOrigin=e.region?"https://insights."+e.region+".algolia.io":"https://insights.algolia.io",this._useCookie=null===(t=e.useCookie)||void 0===t||t,this._cookieDuration=e.cookieDuration?e.cookieDuration:6*MONTH,this._hasCredentials=!0,this._ua=DEFAULT_ALGOLIA_AGENT,this._uaURIEncoded=encodeURIComponent(DEFAULT_ALGOLIA_AGENT),e.userToken?this.setUserToken(e.userToken):this._userToken||this._userHasOptedOut||!this._useCookie||this.setAnonymousUserToken()}function get(e,t){t(this[e])}function initSearch(e){if(!this._hasCredentials)throw new Error("Before calling any methods on the analytics, you first need to call the 'init' function with appId and apiKey parameters");if(!e)throw new Error("initSearch function requires an argument with getQueryID and hitsContainer arguments");if(!e.getQueryID||"function"!=typeof e.getQueryID)throw new Error("getQueryID must be a function that returns the queryID of the last search operation");this.getQueryID=e.getQueryID}function getVersion(e){isFunction(e)&&e(this.version)}function clickedObjectIDsAfterSearch(e){if(!e)throw new Error("No params were sent to clickedObjectIDsAfterSearch function, please provide `queryID`, `objectIDs` and `positions` to be reported");if(!e.queryID)throw new Error("required queryID parameter was not sent, click event can not be properly sent without");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, click event can not be properly sent without");if(!e.positions)throw new Error("required positions parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}function clickedObjectIDs(e){if(!e)throw new Error("No params were sent to clickedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required `objectIDs` parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}function clickedFilters(e){if(!e)throw new Error("No params were sent to clickedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required `filters` parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}function convertedObjectIDsAfterSearch(e){if(!e)throw new Error("No params were sent to convertedObjectIDsAfterSearch function, please provide `queryID` and `objectIDs` to be reported");if(!e.queryID)throw new Error("required queryID parameter was not sent, conversion event can not be properly sent without");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}function convertedObjectIDs(e){if(!e)throw new Error("No params were sent to convertedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}function convertedFilters(e){if(!e)throw new Error("No params were sent to convertedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required filters parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}function viewedObjectIDs(e){if(!e)throw new Error("No params were sent to viewedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, view event can not be properly sent without");this.sendEvent("view",e)}function viewedFilters(e){if(!e)throw new Error("No params were sent to viewedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required filters parameter was not sent, view event can not be properly sent without");this.sendEvent("view",e)}var createUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},COOKIE_KEY="_ALGOLIA",setCookie=function(e,t,r){var n=new Date;n.setTime(n.getTime()+r);var o="expires="+n.toUTCString();document.cookie=e+"="+t+";"+o+";path=/"},getCookie=function(e){for(var t=e+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var o=r[n];" "===o.charAt(0);)o=o.substring(1);if(0===o.indexOf(t))return o.substring(t.length,o.length)}return""};function setAnonymousUserToken(){if(supportsCookies()){var e=getCookie(COOKIE_KEY);e&&""!==e&&0===e.indexOf("anonymous-")?this.setUserToken(e):(this.setUserToken("anonymous-"+createUUID()),setCookie(COOKIE_KEY,this._userToken,this._cookieDuration))}}function setUserToken(e){this._userToken=e,isFunction(this._onUserTokenChangeCallback)&&this._onUserTokenChangeCallback(this._userToken)}function getUserToken(e,t){return isFunction(t)&&t(null,this._userToken),this._userToken}function onUserTokenChange(e,t){this._onUserTokenChangeCallback=e,t&&t.immediate&&isFunction(this._onUserTokenChangeCallback)&&this._onUserTokenChangeCallback(this._userToken)}objectKeysPolyfill(),objectAssignPolyfill();var AlgoliaAnalytics=function(e){var t=e.requestFn;this._ua="",this._uaURIEncoded="",this.version=version,this._hasCredentials=!1,this.sendEvent=makeSendEvent(t).bind(this),this.init=init.bind(this),this.initSearch=initSearch.bind(this),this.addAlgoliaAgent=addAlgoliaAgent.bind(this),this.setUserToken=setUserToken.bind(this),this.setAnonymousUserToken=setAnonymousUserToken.bind(this),this.getUserToken=getUserToken.bind(this),this.onUserTokenChange=onUserTokenChange.bind(this),this.clickedObjectIDsAfterSearch=clickedObjectIDsAfterSearch.bind(this),this.clickedObjectIDs=clickedObjectIDs.bind(this),this.clickedFilters=clickedFilters.bind(this),this.convertedObjectIDsAfterSearch=convertedObjectIDsAfterSearch.bind(this),this.convertedObjectIDs=convertedObjectIDs.bind(this),this.convertedFilters=convertedFilters.bind(this),this.viewedObjectIDs=viewedObjectIDs.bind(this),this.viewedFilters=viewedFilters.bind(this),this._get=get.bind(this),this.getVersion=getVersion.bind(this)};function getFunctionalInterface(e){return function(t){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];t&&isFunction(e[t])?e[t].apply(e,r):console.warn("The method `"+t+"` doesn't exist.")}}var requestWithSendBeacon=function(e,t){var r=JSON.stringify(t);navigator.sendBeacon(e,r)},requestWithXMLHttpRequest=function(e,t){var r=JSON.stringify(t),n=new XMLHttpRequest;n.open("POST",e),n.send(r)},requestWithNodeHttpModule=function(e,t){var r=JSON.stringify(t),n=require("url").parse(e),o={protocol:n.protocol,host:n.host,path:n.path,method:"POST",headers:{"Content-Type":"application/json","Content-Length":r.length}},i=(0,(0===e.indexOf("https://")?require("https"):require("http")).request)(o);i.on("error",function(e){console.error(e)}),i.write(r),i.end()};function getRequesterForBrowser(){if(supportsSendBeacon())return requestWithSendBeacon;if(supportsXMLHttpRequest())return requestWithXMLHttpRequest;throw new Error("Could not find a supported HTTP request client in this environment.")}function getRequesterForNode(){if(supportsNodeHttpModule())return requestWithNodeHttpModule;throw new Error("Could not find a supported HTTP request client in this environment.")}function createInsightsClient(e){return getFunctionalInterface(new AlgoliaAnalytics({requestFn:e}))}var entryBrowserCjs=createInsightsClient(getRequesterForBrowser());exports.createInsightsClient=createInsightsClient,exports.default=entryBrowserCjs,exports.getRequesterForBrowser=getRequesterForBrowser,exports.getRequesterForNode=getRequesterForNode;
"use strict";function objectAssignPolyfill(){"function"!=typeof Object.assign&&(Object.assign=function(e,t){var r=arguments;if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e),o=1;o<arguments.length;o++){var i=r[o];if(null!=i)for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])}return n})}function objectKeysPolyfill(){var e,t,r,n;Object.keys||(Object.keys=(e=Object.prototype.hasOwnProperty,t=!{toString:null}.propertyIsEnumerable("toString"),n=(r=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"]).length,function(o){if("function"!=typeof o&&("object"!=typeof o||null===o))throw new TypeError("Object.keys called on non-object");var i,s,a=[];for(i in o)e.call(o,i)&&a.push(i);if(t)for(s=0;s<n;s++)e.call(o,r[s])&&a.push(r[s]);return a}))}Object.defineProperty(exports,"__esModule",{value:!0});var supportsCookies=function(){try{return Boolean(navigator.cookieEnabled)}catch(e){return!1}},supportsSendBeacon=function(){try{return Boolean(navigator.sendBeacon)}catch(e){return!1}},supportsXMLHttpRequest=function(){try{return Boolean(XMLHttpRequest)}catch(e){return!1}},supportsNodeHttpModule=function(){try{var e=require("http").request,t=require("https").request;return Boolean(e)&&Boolean(t)}catch(e){return!1}},isUndefined=function(e){return void 0===e},isString=function(e){return"string"==typeof e},isNumber=function(e){return"number"==typeof e},isFunction=function(e){return"function"==typeof e};function makeSendEvent(e){return function(t,r){if(!this._userHasOptedOut){if(!this._hasCredentials)throw new Error("Before calling any methods on the analytics, you first need to call the 'init' function with appId and apiKey parameters");if(""===r.userToken||""===this._userToken)throw new Error("`userToken` cannot be an empty string.");var n=r.userToken||this._userToken;if(isUndefined(n))throw new Error("Before calling any methods on the analytics, you first need to call 'setUserToken' function or include 'userToken' in the event payload.");if(!isString(r.index))throw new TypeError("expected required parameter `index` to be a string");if(!isString(r.eventName))throw new TypeError("expected required parameter `eventName` to be a string");if(!isUndefined(r.userToken)&&!isString(r.userToken))throw new TypeError("expected optional parameter `userToken` to be a string");var o={eventType:t,eventName:r.eventName,userToken:n,index:r.index};if(!isUndefined(r.timestamp)){if(!isNumber(r.timestamp))throw new TypeError("expected optional parameter `timestamp` to be a number");o.timestamp=r.timestamp}if(!isUndefined(r.queryID)){if(!isString(r.queryID))throw new TypeError("expected optional parameter `queryID` to be a string");o.queryID=r.queryID}if(!isUndefined(r.objectIDs)){if(!Array.isArray(r.objectIDs))throw new TypeError("expected optional parameter `objectIDs` to be an array");o.objectIDs=r.objectIDs}if(!isUndefined(r.positions)){if(!Array.isArray(r.positions))throw new TypeError("expected optional parameter `positions` to be an array");if(isUndefined(r.objectIDs))throw new Error("cannot use `positions` without providing `objectIDs`");if(r.objectIDs.length!==r.positions.length)throw new Error("objectIDs and positions need to be of the same size");o.positions=r.positions}if(!isUndefined(r.filters)){if(!isUndefined(r.objectIDs))throw new Error("cannot use `objectIDs` and `filters` for the same event");if(!Array.isArray(r.filters))throw new TypeError("expected optional parameter `filters` to be an array");o.filters=r.filters}if(isUndefined(r.objectIDs)&&isUndefined(r.filters))throw new Error("expected either `objectIDs` or `filters` to be provided");return bulkSendEvent(e,this._appId,this._apiKey,this._uaURIEncoded,this._endpointOrigin,[o])}}}function bulkSendEvent(e,t,r,n,o,i){return e(o+"/1/events?X-Algolia-Application-Id="+t+"&X-Algolia-API-Key="+r+"&X-Algolia-Agent="+n,{events:i})}var version="1.9.0",DEFAULT_ALGOLIA_AGENT="insights-js ("+version+")";function addAlgoliaAgent(e){-1===this._ua.indexOf("; "+e)&&(this._ua+="; "+e,this._uaURIEncoded=encodeURIComponent(this._ua))}var SUPPORTED_REGIONS=["de","us"],MONTH=2592e6;function init(e){var t;if(!e)throw new Error("Init function should be called with an object argument containing your apiKey and appId");if(isUndefined(e.apiKey)||!isString(e.apiKey))throw new Error("apiKey is missing, please provide it so we can authenticate the application");if(isUndefined(e.appId)||!isString(e.appId))throw new Error("appId is missing, please provide it, so we can properly attribute data to your application");if(!isUndefined(e.region)&&-1===SUPPORTED_REGIONS.indexOf(e.region))throw new Error("optional region is incorrect, please provide either one of: "+SUPPORTED_REGIONS.join(", ")+".");if(!(isUndefined(e.cookieDuration)||isNumber(e.cookieDuration)&&isFinite(e.cookieDuration)&&Math.floor(e.cookieDuration)===e.cookieDuration))throw new Error("optional cookieDuration is incorrect, expected an integer.");this._apiKey=e.apiKey,this._appId=e.appId,this._userHasOptedOut=!!e.userHasOptedOut,this._region=e.region,this._endpointOrigin=e.region?"https://insights."+e.region+".algolia.io":"https://insights.algolia.io",this._useCookie=null===(t=e.useCookie)||void 0===t||t,this._cookieDuration=e.cookieDuration?e.cookieDuration:6*MONTH,this._hasCredentials=!0,this._ua=DEFAULT_ALGOLIA_AGENT,this._uaURIEncoded=encodeURIComponent(DEFAULT_ALGOLIA_AGENT),e.userToken?this.setUserToken(e.userToken):this._userToken||this._userHasOptedOut||!this._useCookie||this.setAnonymousUserToken()}function get(e,t){t(this[e])}function initSearch(e){if(!this._hasCredentials)throw new Error("Before calling any methods on the analytics, you first need to call the 'init' function with appId and apiKey parameters");if(!e)throw new Error("initSearch function requires an argument with getQueryID and hitsContainer arguments");if(!e.getQueryID||"function"!=typeof e.getQueryID)throw new Error("getQueryID must be a function that returns the queryID of the last search operation");this.getQueryID=e.getQueryID}function getVersion(e){isFunction(e)&&e(this.version)}function clickedObjectIDsAfterSearch(e){if(!e)throw new Error("No params were sent to clickedObjectIDsAfterSearch function, please provide `queryID`, `objectIDs` and `positions` to be reported");if(!e.queryID)throw new Error("required queryID parameter was not sent, click event can not be properly sent without");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, click event can not be properly sent without");if(!e.positions)throw new Error("required positions parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}function clickedObjectIDs(e){if(!e)throw new Error("No params were sent to clickedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required `objectIDs` parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}function clickedFilters(e){if(!e)throw new Error("No params were sent to clickedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required `filters` parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}function convertedObjectIDsAfterSearch(e){if(!e)throw new Error("No params were sent to convertedObjectIDsAfterSearch function, please provide `queryID` and `objectIDs` to be reported");if(!e.queryID)throw new Error("required queryID parameter was not sent, conversion event can not be properly sent without");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}function convertedObjectIDs(e){if(!e)throw new Error("No params were sent to convertedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}function convertedFilters(e){if(!e)throw new Error("No params were sent to convertedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required filters parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}function viewedObjectIDs(e){if(!e)throw new Error("No params were sent to viewedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, view event can not be properly sent without");this.sendEvent("view",e)}function viewedFilters(e){if(!e)throw new Error("No params were sent to viewedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required filters parameter was not sent, view event can not be properly sent without");this.sendEvent("view",e)}var createUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},COOKIE_KEY="_ALGOLIA",setCookie=function(e,t,r){var n=new Date;n.setTime(n.getTime()+r);var o="expires="+n.toUTCString();document.cookie=e+"="+t+";"+o+";path=/"},getCookie=function(e){for(var t=e+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var o=r[n];" "===o.charAt(0);)o=o.substring(1);if(0===o.indexOf(t))return o.substring(t.length,o.length)}return""};function setAnonymousUserToken(){if(supportsCookies()){var e=getCookie(COOKIE_KEY);e&&""!==e&&0===e.indexOf("anonymous-")?this.setUserToken(e):(this.setUserToken("anonymous-"+createUUID()),setCookie(COOKIE_KEY,this._userToken,this._cookieDuration))}}function setUserToken(e){this._userToken=e,isFunction(this._onUserTokenChangeCallback)&&this._onUserTokenChangeCallback(this._userToken)}function getUserToken(e,t){return isFunction(t)&&t(null,this._userToken),this._userToken}function onUserTokenChange(e,t){this._onUserTokenChangeCallback=e,t&&t.immediate&&isFunction(this._onUserTokenChangeCallback)&&this._onUserTokenChangeCallback(this._userToken)}objectKeysPolyfill(),objectAssignPolyfill();var AlgoliaAnalytics=function(e){var t=e.requestFn;this._ua="",this._uaURIEncoded="",this.version=version,this._hasCredentials=!1,this.sendEvent=makeSendEvent(t).bind(this),this.init=init.bind(this),this.initSearch=initSearch.bind(this),this.addAlgoliaAgent=addAlgoliaAgent.bind(this),this.setUserToken=setUserToken.bind(this),this.setAnonymousUserToken=setAnonymousUserToken.bind(this),this.getUserToken=getUserToken.bind(this),this.onUserTokenChange=onUserTokenChange.bind(this),this.clickedObjectIDsAfterSearch=clickedObjectIDsAfterSearch.bind(this),this.clickedObjectIDs=clickedObjectIDs.bind(this),this.clickedFilters=clickedFilters.bind(this),this.convertedObjectIDsAfterSearch=convertedObjectIDsAfterSearch.bind(this),this.convertedObjectIDs=convertedObjectIDs.bind(this),this.convertedFilters=convertedFilters.bind(this),this.viewedObjectIDs=viewedObjectIDs.bind(this),this.viewedFilters=viewedFilters.bind(this),this._get=get.bind(this),this.getVersion=getVersion.bind(this)};function getFunctionalInterface(e){return function(t){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];t&&isFunction(e[t])?e[t].apply(e,r):console.warn("The method `"+t+"` doesn't exist.")}}function createInsightsClient(e){var t=getFunctionalInterface(new AlgoliaAnalytics({requestFn:e}));if("object"==typeof window&&!window.AlgoliaAnalyticsObject){var r;do{r=createUUID()}while(void 0!==window[r]);window.AlgoliaAnalyticsObject=r,window[window.AlgoliaAnalyticsObject]=t}return t}var requestWithSendBeacon=function(e,t){var r=JSON.stringify(t);navigator.sendBeacon(e,r)},requestWithXMLHttpRequest=function(e,t){var r=JSON.stringify(t),n=new XMLHttpRequest;n.open("POST",e),n.send(r)},requestWithNodeHttpModule=function(e,t){var r=JSON.stringify(t),n=require("url").parse(e),o={protocol:n.protocol,host:n.host,path:n.path,method:"POST",headers:{"Content-Type":"application/json","Content-Length":r.length}},i=(0,(0===e.indexOf("https://")?require("https"):require("http")).request)(o);i.on("error",function(e){console.error(e)}),i.write(r),i.end()};function getRequesterForBrowser(){if(supportsSendBeacon())return requestWithSendBeacon;if(supportsXMLHttpRequest())return requestWithXMLHttpRequest;throw new Error("Could not find a supported HTTP request client in this environment.")}function getRequesterForNode(){if(supportsNodeHttpModule())return requestWithNodeHttpModule;throw new Error("Could not find a supported HTTP request client in this environment.")}var entryBrowserCjs=createInsightsClient(getRequesterForBrowser());exports.default=entryBrowserCjs,exports.getRequesterForBrowser=getRequesterForBrowser,exports.getRequesterForNode=getRequesterForNode;

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

"use strict";function objectAssignPolyfill(){"function"!=typeof Object.assign&&(Object.assign=function(e,t){var r=arguments;if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e),o=1;o<arguments.length;o++){var i=r[o];if(null!=i)for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])}return n})}function objectKeysPolyfill(){var e,t,r,n;Object.keys||(Object.keys=(e=Object.prototype.hasOwnProperty,t=!{toString:null}.propertyIsEnumerable("toString"),n=(r=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"]).length,function(o){if("function"!=typeof o&&("object"!=typeof o||null===o))throw new TypeError("Object.keys called on non-object");var i,s,a=[];for(i in o)e.call(o,i)&&a.push(i);if(t)for(s=0;s<n;s++)e.call(o,r[s])&&a.push(r[s]);return a}))}Object.defineProperty(exports,"__esModule",{value:!0});var supportsCookies=function(){try{return Boolean(navigator.cookieEnabled)}catch(e){return!1}},supportsSendBeacon=function(){try{return Boolean(navigator.sendBeacon)}catch(e){return!1}},supportsXMLHttpRequest=function(){try{return Boolean(XMLHttpRequest)}catch(e){return!1}},supportsNodeHttpModule=function(){try{var e=require("http").request,t=require("https").request;return Boolean(e)&&Boolean(t)}catch(e){return!1}},isUndefined=function(e){return void 0===e},isString=function(e){return"string"==typeof e},isNumber=function(e){return"number"==typeof e},isFunction=function(e){return"function"==typeof e};function makeSendEvent(e){return function(t,r){if(!this._userHasOptedOut){if(!this._hasCredentials)throw new Error("Before calling any methods on the analytics, you first need to call the 'init' function with appId and apiKey parameters");if(""===r.userToken||""===this._userToken)throw new Error("`userToken` cannot be an empty string.");var n=r.userToken||this._userToken;if(isUndefined(n))throw new Error("Before calling any methods on the analytics, you first need to call 'setUserToken' function or include 'userToken' in the event payload.");if(!isString(r.index))throw new TypeError("expected required parameter `index` to be a string");if(!isString(r.eventName))throw new TypeError("expected required parameter `eventName` to be a string");if(!isUndefined(r.userToken)&&!isString(r.userToken))throw new TypeError("expected optional parameter `userToken` to be a string");var o={eventType:t,eventName:r.eventName,userToken:n,index:r.index};if(!isUndefined(r.timestamp)){if(!isNumber(r.timestamp))throw new TypeError("expected optional parameter `timestamp` to be a number");o.timestamp=r.timestamp}if(!isUndefined(r.queryID)){if(!isString(r.queryID))throw new TypeError("expected optional parameter `queryID` to be a string");o.queryID=r.queryID}if(!isUndefined(r.objectIDs)){if(!Array.isArray(r.objectIDs))throw new TypeError("expected optional parameter `objectIDs` to be an array");o.objectIDs=r.objectIDs}if(!isUndefined(r.positions)){if(!Array.isArray(r.positions))throw new TypeError("expected optional parameter `positions` to be an array");if(isUndefined(r.objectIDs))throw new Error("cannot use `positions` without providing `objectIDs`");if(r.objectIDs.length!==r.positions.length)throw new Error("objectIDs and positions need to be of the same size");o.positions=r.positions}if(!isUndefined(r.filters)){if(!isUndefined(r.objectIDs))throw new Error("cannot use `objectIDs` and `filters` for the same event");if(!Array.isArray(r.filters))throw new TypeError("expected optional parameter `filters` to be an array");o.filters=r.filters}if(isUndefined(r.objectIDs)&&isUndefined(r.filters))throw new Error("expected either `objectIDs` or `filters` to be provided");return bulkSendEvent(e,this._appId,this._apiKey,this._uaURIEncoded,this._endpointOrigin,[o])}}}function bulkSendEvent(e,t,r,n,o,i){return e(o+"/1/events?X-Algolia-Application-Id="+t+"&X-Algolia-API-Key="+r+"&X-Algolia-Agent="+n,{events:i})}var version="1.8.0",DEFAULT_ALGOLIA_AGENT="insights-js ("+version+")";function addAlgoliaAgent(e){-1===this._ua.indexOf("; "+e)&&(this._ua+="; "+e,this._uaURIEncoded=encodeURIComponent(this._ua))}var SUPPORTED_REGIONS=["de","us"],MONTH=2592e6;function init(e){var t;if(!e)throw new Error("Init function should be called with an object argument containing your apiKey and appId");if(isUndefined(e.apiKey)||!isString(e.apiKey))throw new Error("apiKey is missing, please provide it so we can authenticate the application");if(isUndefined(e.appId)||!isString(e.appId))throw new Error("appId is missing, please provide it, so we can properly attribute data to your application");if(!isUndefined(e.region)&&-1===SUPPORTED_REGIONS.indexOf(e.region))throw new Error("optional region is incorrect, please provide either one of: "+SUPPORTED_REGIONS.join(", ")+".");if(!(isUndefined(e.cookieDuration)||isNumber(e.cookieDuration)&&isFinite(e.cookieDuration)&&Math.floor(e.cookieDuration)===e.cookieDuration))throw new Error("optional cookieDuration is incorrect, expected an integer.");this._apiKey=e.apiKey,this._appId=e.appId,this._userHasOptedOut=!!e.userHasOptedOut,this._region=e.region,this._endpointOrigin=e.region?"https://insights."+e.region+".algolia.io":"https://insights.algolia.io",this._useCookie=null===(t=e.useCookie)||void 0===t||t,this._cookieDuration=e.cookieDuration?e.cookieDuration:6*MONTH,this._hasCredentials=!0,this._ua=DEFAULT_ALGOLIA_AGENT,this._uaURIEncoded=encodeURIComponent(DEFAULT_ALGOLIA_AGENT),e.userToken?this.setUserToken(e.userToken):this._userToken||this._userHasOptedOut||!this._useCookie||this.setAnonymousUserToken()}function get(e,t){t(this[e])}function initSearch(e){if(!this._hasCredentials)throw new Error("Before calling any methods on the analytics, you first need to call the 'init' function with appId and apiKey parameters");if(!e)throw new Error("initSearch function requires an argument with getQueryID and hitsContainer arguments");if(!e.getQueryID||"function"!=typeof e.getQueryID)throw new Error("getQueryID must be a function that returns the queryID of the last search operation");this.getQueryID=e.getQueryID}function getVersion(e){isFunction(e)&&e(this.version)}function clickedObjectIDsAfterSearch(e){if(!e)throw new Error("No params were sent to clickedObjectIDsAfterSearch function, please provide `queryID`, `objectIDs` and `positions` to be reported");if(!e.queryID)throw new Error("required queryID parameter was not sent, click event can not be properly sent without");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, click event can not be properly sent without");if(!e.positions)throw new Error("required positions parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}function clickedObjectIDs(e){if(!e)throw new Error("No params were sent to clickedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required `objectIDs` parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}function clickedFilters(e){if(!e)throw new Error("No params were sent to clickedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required `filters` parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}function convertedObjectIDsAfterSearch(e){if(!e)throw new Error("No params were sent to convertedObjectIDsAfterSearch function, please provide `queryID` and `objectIDs` to be reported");if(!e.queryID)throw new Error("required queryID parameter was not sent, conversion event can not be properly sent without");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}function convertedObjectIDs(e){if(!e)throw new Error("No params were sent to convertedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}function convertedFilters(e){if(!e)throw new Error("No params were sent to convertedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required filters parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}function viewedObjectIDs(e){if(!e)throw new Error("No params were sent to viewedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, view event can not be properly sent without");this.sendEvent("view",e)}function viewedFilters(e){if(!e)throw new Error("No params were sent to viewedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required filters parameter was not sent, view event can not be properly sent without");this.sendEvent("view",e)}var createUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},COOKIE_KEY="_ALGOLIA",setCookie=function(e,t,r){var n=new Date;n.setTime(n.getTime()+r);var o="expires="+n.toUTCString();document.cookie=e+"="+t+";"+o+";path=/"},getCookie=function(e){for(var t=e+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var o=r[n];" "===o.charAt(0);)o=o.substring(1);if(0===o.indexOf(t))return o.substring(t.length,o.length)}return""};function setAnonymousUserToken(){if(supportsCookies()){var e=getCookie(COOKIE_KEY);e&&""!==e&&0===e.indexOf("anonymous-")?this.setUserToken(e):(this.setUserToken("anonymous-"+createUUID()),setCookie(COOKIE_KEY,this._userToken,this._cookieDuration))}}function setUserToken(e){this._userToken=e,isFunction(this._onUserTokenChangeCallback)&&this._onUserTokenChangeCallback(this._userToken)}function getUserToken(e,t){return isFunction(t)&&t(null,this._userToken),this._userToken}function onUserTokenChange(e,t){this._onUserTokenChangeCallback=e,t&&t.immediate&&isFunction(this._onUserTokenChangeCallback)&&this._onUserTokenChangeCallback(this._userToken)}objectKeysPolyfill(),objectAssignPolyfill();var AlgoliaAnalytics=function(e){var t=e.requestFn;this._ua="",this._uaURIEncoded="",this.version=version,this._hasCredentials=!1,this.sendEvent=makeSendEvent(t).bind(this),this.init=init.bind(this),this.initSearch=initSearch.bind(this),this.addAlgoliaAgent=addAlgoliaAgent.bind(this),this.setUserToken=setUserToken.bind(this),this.setAnonymousUserToken=setAnonymousUserToken.bind(this),this.getUserToken=getUserToken.bind(this),this.onUserTokenChange=onUserTokenChange.bind(this),this.clickedObjectIDsAfterSearch=clickedObjectIDsAfterSearch.bind(this),this.clickedObjectIDs=clickedObjectIDs.bind(this),this.clickedFilters=clickedFilters.bind(this),this.convertedObjectIDsAfterSearch=convertedObjectIDsAfterSearch.bind(this),this.convertedObjectIDs=convertedObjectIDs.bind(this),this.convertedFilters=convertedFilters.bind(this),this.viewedObjectIDs=viewedObjectIDs.bind(this),this.viewedFilters=viewedFilters.bind(this),this._get=get.bind(this),this.getVersion=getVersion.bind(this)};function getFunctionalInterface(e){return function(t){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];t&&isFunction(e[t])?e[t].apply(e,r):console.warn("The method `"+t+"` doesn't exist.")}}var requestWithSendBeacon=function(e,t){var r=JSON.stringify(t);navigator.sendBeacon(e,r)},requestWithXMLHttpRequest=function(e,t){var r=JSON.stringify(t),n=new XMLHttpRequest;n.open("POST",e),n.send(r)},requestWithNodeHttpModule=function(e,t){var r=JSON.stringify(t),n=require("url").parse(e),o={protocol:n.protocol,host:n.host,path:n.path,method:"POST",headers:{"Content-Type":"application/json","Content-Length":r.length}},i=(0,(0===e.indexOf("https://")?require("https"):require("http")).request)(o);i.on("error",function(e){console.error(e)}),i.write(r),i.end()};function getRequesterForBrowser(){if(supportsSendBeacon())return requestWithSendBeacon;if(supportsXMLHttpRequest())return requestWithXMLHttpRequest;throw new Error("Could not find a supported HTTP request client in this environment.")}function getRequesterForNode(){if(supportsNodeHttpModule())return requestWithNodeHttpModule;throw new Error("Could not find a supported HTTP request client in this environment.")}function createInsightsClient(e){return getFunctionalInterface(new AlgoliaAnalytics({requestFn:e}))}var entryNodeCjs=createInsightsClient(getRequesterForNode());exports.createInsightsClient=createInsightsClient,exports.default=entryNodeCjs,exports.getRequesterForBrowser=getRequesterForBrowser,exports.getRequesterForNode=getRequesterForNode;
"use strict";function objectAssignPolyfill(){"function"!=typeof Object.assign&&(Object.assign=function(e,t){var n=arguments;if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(e),o=1;o<arguments.length;o++){var i=n[o];if(null!=i)for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(r[s]=i[s])}return r})}function objectKeysPolyfill(){var e,t,n,r;Object.keys||(Object.keys=(e=Object.prototype.hasOwnProperty,t=!{toString:null}.propertyIsEnumerable("toString"),r=(n=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"]).length,function(o){if("function"!=typeof o&&("object"!=typeof o||null===o))throw new TypeError("Object.keys called on non-object");var i,s,a=[];for(i in o)e.call(o,i)&&a.push(i);if(t)for(s=0;s<r;s++)e.call(o,n[s])&&a.push(n[s]);return a}))}Object.defineProperty(exports,"__esModule",{value:!0});var supportsCookies=function(){try{return Boolean(navigator.cookieEnabled)}catch(e){return!1}},supportsSendBeacon=function(){try{return Boolean(navigator.sendBeacon)}catch(e){return!1}},supportsXMLHttpRequest=function(){try{return Boolean(XMLHttpRequest)}catch(e){return!1}},supportsNodeHttpModule=function(){try{var e=require("http").request,t=require("https").request;return Boolean(e)&&Boolean(t)}catch(e){return!1}},isUndefined=function(e){return void 0===e},isString=function(e){return"string"==typeof e},isNumber=function(e){return"number"==typeof e},isFunction=function(e){return"function"==typeof e};function makeSendEvent(e){return function(t,n){if(!this._userHasOptedOut){if(!this._hasCredentials)throw new Error("Before calling any methods on the analytics, you first need to call the 'init' function with appId and apiKey parameters");if(""===n.userToken||""===this._userToken)throw new Error("`userToken` cannot be an empty string.");var r=n.userToken||this._userToken;if(isUndefined(r))throw new Error("Before calling any methods on the analytics, you first need to call 'setUserToken' function or include 'userToken' in the event payload.");if(!isString(n.index))throw new TypeError("expected required parameter `index` to be a string");if(!isString(n.eventName))throw new TypeError("expected required parameter `eventName` to be a string");if(!isUndefined(n.userToken)&&!isString(n.userToken))throw new TypeError("expected optional parameter `userToken` to be a string");var o={eventType:t,eventName:n.eventName,userToken:r,index:n.index};if(!isUndefined(n.timestamp)){if(!isNumber(n.timestamp))throw new TypeError("expected optional parameter `timestamp` to be a number");o.timestamp=n.timestamp}if(!isUndefined(n.queryID)){if(!isString(n.queryID))throw new TypeError("expected optional parameter `queryID` to be a string");o.queryID=n.queryID}if(!isUndefined(n.objectIDs)){if(!Array.isArray(n.objectIDs))throw new TypeError("expected optional parameter `objectIDs` to be an array");o.objectIDs=n.objectIDs}if(!isUndefined(n.positions)){if(!Array.isArray(n.positions))throw new TypeError("expected optional parameter `positions` to be an array");if(isUndefined(n.objectIDs))throw new Error("cannot use `positions` without providing `objectIDs`");if(n.objectIDs.length!==n.positions.length)throw new Error("objectIDs and positions need to be of the same size");o.positions=n.positions}if(!isUndefined(n.filters)){if(!isUndefined(n.objectIDs))throw new Error("cannot use `objectIDs` and `filters` for the same event");if(!Array.isArray(n.filters))throw new TypeError("expected optional parameter `filters` to be an array");o.filters=n.filters}if(isUndefined(n.objectIDs)&&isUndefined(n.filters))throw new Error("expected either `objectIDs` or `filters` to be provided");return bulkSendEvent(e,this._appId,this._apiKey,this._uaURIEncoded,this._endpointOrigin,[o])}}}function bulkSendEvent(e,t,n,r,o,i){return e(o+"/1/events?X-Algolia-Application-Id="+t+"&X-Algolia-API-Key="+n+"&X-Algolia-Agent="+r,{events:i})}var version="1.9.0",DEFAULT_ALGOLIA_AGENT="insights-js ("+version+")";function addAlgoliaAgent(e){-1===this._ua.indexOf("; "+e)&&(this._ua+="; "+e,this._uaURIEncoded=encodeURIComponent(this._ua))}var SUPPORTED_REGIONS=["de","us"],MONTH=2592e6;function init(e){var t;if(!e)throw new Error("Init function should be called with an object argument containing your apiKey and appId");if(isUndefined(e.apiKey)||!isString(e.apiKey))throw new Error("apiKey is missing, please provide it so we can authenticate the application");if(isUndefined(e.appId)||!isString(e.appId))throw new Error("appId is missing, please provide it, so we can properly attribute data to your application");if(!isUndefined(e.region)&&-1===SUPPORTED_REGIONS.indexOf(e.region))throw new Error("optional region is incorrect, please provide either one of: "+SUPPORTED_REGIONS.join(", ")+".");if(!(isUndefined(e.cookieDuration)||isNumber(e.cookieDuration)&&isFinite(e.cookieDuration)&&Math.floor(e.cookieDuration)===e.cookieDuration))throw new Error("optional cookieDuration is incorrect, expected an integer.");this._apiKey=e.apiKey,this._appId=e.appId,this._userHasOptedOut=!!e.userHasOptedOut,this._region=e.region,this._endpointOrigin=e.region?"https://insights."+e.region+".algolia.io":"https://insights.algolia.io",this._useCookie=null===(t=e.useCookie)||void 0===t||t,this._cookieDuration=e.cookieDuration?e.cookieDuration:6*MONTH,this._hasCredentials=!0,this._ua=DEFAULT_ALGOLIA_AGENT,this._uaURIEncoded=encodeURIComponent(DEFAULT_ALGOLIA_AGENT),e.userToken?this.setUserToken(e.userToken):this._userToken||this._userHasOptedOut||!this._useCookie||this.setAnonymousUserToken()}function get(e,t){t(this[e])}function initSearch(e){if(!this._hasCredentials)throw new Error("Before calling any methods on the analytics, you first need to call the 'init' function with appId and apiKey parameters");if(!e)throw new Error("initSearch function requires an argument with getQueryID and hitsContainer arguments");if(!e.getQueryID||"function"!=typeof e.getQueryID)throw new Error("getQueryID must be a function that returns the queryID of the last search operation");this.getQueryID=e.getQueryID}function getVersion(e){isFunction(e)&&e(this.version)}function clickedObjectIDsAfterSearch(e){if(!e)throw new Error("No params were sent to clickedObjectIDsAfterSearch function, please provide `queryID`, `objectIDs` and `positions` to be reported");if(!e.queryID)throw new Error("required queryID parameter was not sent, click event can not be properly sent without");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, click event can not be properly sent without");if(!e.positions)throw new Error("required positions parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}function clickedObjectIDs(e){if(!e)throw new Error("No params were sent to clickedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required `objectIDs` parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}function clickedFilters(e){if(!e)throw new Error("No params were sent to clickedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required `filters` parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}function convertedObjectIDsAfterSearch(e){if(!e)throw new Error("No params were sent to convertedObjectIDsAfterSearch function, please provide `queryID` and `objectIDs` to be reported");if(!e.queryID)throw new Error("required queryID parameter was not sent, conversion event can not be properly sent without");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}function convertedObjectIDs(e){if(!e)throw new Error("No params were sent to convertedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}function convertedFilters(e){if(!e)throw new Error("No params were sent to convertedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required filters parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}function viewedObjectIDs(e){if(!e)throw new Error("No params were sent to viewedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, view event can not be properly sent without");this.sendEvent("view",e)}function viewedFilters(e){if(!e)throw new Error("No params were sent to viewedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required filters parameter was not sent, view event can not be properly sent without");this.sendEvent("view",e)}var createUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},COOKIE_KEY="_ALGOLIA",setCookie=function(e,t,n){var r=new Date;r.setTime(r.getTime()+n);var o="expires="+r.toUTCString();document.cookie=e+"="+t+";"+o+";path=/"},getCookie=function(e){for(var t=e+"=",n=document.cookie.split(";"),r=0;r<n.length;r++){for(var o=n[r];" "===o.charAt(0);)o=o.substring(1);if(0===o.indexOf(t))return o.substring(t.length,o.length)}return""};function setAnonymousUserToken(){if(supportsCookies()){var e=getCookie(COOKIE_KEY);e&&""!==e&&0===e.indexOf("anonymous-")?this.setUserToken(e):(this.setUserToken("anonymous-"+createUUID()),setCookie(COOKIE_KEY,this._userToken,this._cookieDuration))}}function setUserToken(e){this._userToken=e,isFunction(this._onUserTokenChangeCallback)&&this._onUserTokenChangeCallback(this._userToken)}function getUserToken(e,t){return isFunction(t)&&t(null,this._userToken),this._userToken}function onUserTokenChange(e,t){this._onUserTokenChangeCallback=e,t&&t.immediate&&isFunction(this._onUserTokenChangeCallback)&&this._onUserTokenChangeCallback(this._userToken)}objectKeysPolyfill(),objectAssignPolyfill();var AlgoliaAnalytics=function(e){var t=e.requestFn;this._ua="",this._uaURIEncoded="",this.version=version,this._hasCredentials=!1,this.sendEvent=makeSendEvent(t).bind(this),this.init=init.bind(this),this.initSearch=initSearch.bind(this),this.addAlgoliaAgent=addAlgoliaAgent.bind(this),this.setUserToken=setUserToken.bind(this),this.setAnonymousUserToken=setAnonymousUserToken.bind(this),this.getUserToken=getUserToken.bind(this),this.onUserTokenChange=onUserTokenChange.bind(this),this.clickedObjectIDsAfterSearch=clickedObjectIDsAfterSearch.bind(this),this.clickedObjectIDs=clickedObjectIDs.bind(this),this.clickedFilters=clickedFilters.bind(this),this.convertedObjectIDsAfterSearch=convertedObjectIDsAfterSearch.bind(this),this.convertedObjectIDs=convertedObjectIDs.bind(this),this.convertedFilters=convertedFilters.bind(this),this.viewedObjectIDs=viewedObjectIDs.bind(this),this.viewedFilters=viewedFilters.bind(this),this._get=get.bind(this),this.getVersion=getVersion.bind(this)};function getFunctionalInterface(e){return function(t){for(var n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];t&&isFunction(e[t])?e[t].apply(e,n):console.warn("The method `"+t+"` doesn't exist.")}}function createInsightsClient(e){var t=getFunctionalInterface(new AlgoliaAnalytics({requestFn:e}));if("object"==typeof window&&!window.AlgoliaAnalyticsObject){var n;do{n=createUUID()}while(void 0!==window[n]);window.AlgoliaAnalyticsObject=n,window[window.AlgoliaAnalyticsObject]=t}return t}var requestWithSendBeacon=function(e,t){var n=JSON.stringify(t);navigator.sendBeacon(e,n)},requestWithXMLHttpRequest=function(e,t){var n=JSON.stringify(t),r=new XMLHttpRequest;r.open("POST",e),r.send(n)},requestWithNodeHttpModule=function(e,t){var n=JSON.stringify(t),r=require("url").parse(e),o={protocol:r.protocol,host:r.host,path:r.path,method:"POST",headers:{"Content-Type":"application/json","Content-Length":n.length}},i=(0,(0===e.indexOf("https://")?require("https"):require("http")).request)(o);i.on("error",function(e){console.error(e)}),i.write(n),i.end()};function getRequesterForBrowser(){if(supportsSendBeacon())return requestWithSendBeacon;if(supportsXMLHttpRequest())return requestWithXMLHttpRequest;throw new Error("Could not find a supported HTTP request client in this environment.")}function getRequesterForNode(){if(supportsNodeHttpModule())return requestWithNodeHttpModule;throw new Error("Could not find a supported HTTP request client in this environment.")}var entryNodeCjs=createInsightsClient(getRequesterForNode());exports.default=entryNodeCjs,exports.getRequesterForBrowser=getRequesterForBrowser,exports.getRequesterForNode=getRequesterForNode;

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).AlgoliaAnalytics={})}(this,function(e){"use strict";var t=function(){try{return Boolean(navigator.cookieEnabled)}catch(e){return!1}},r=function(){try{return Boolean(navigator.sendBeacon)}catch(e){return!1}},n=function(){try{return Boolean(XMLHttpRequest)}catch(e){return!1}},o=function(e){return void 0===e},i=function(e){return"string"==typeof e},s=function(e){return"number"==typeof e},a=function(e){return"function"==typeof e};var c="insights-js (1.8.0)";var u=["de","us"],h=2592e6;var p,f,l,d,w=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},b="_ALGOLIA",y=function(e,t,r){var n=new Date;n.setTime(n.getTime()+r);var o="expires="+n.toUTCString();document.cookie=e+"="+t+";"+o+";path=/"},v=function(e){for(var t=e+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var o=r[n];" "===o.charAt(0);)o=o.substring(1);if(0===o.indexOf(t))return o.substring(t.length,o.length)}return""};Object.keys||(Object.keys=(p=Object.prototype.hasOwnProperty,f=!{toString:null}.propertyIsEnumerable("toString"),d=(l=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"]).length,function(e){if("function"!=typeof e&&("object"!=typeof e||null===e))throw new TypeError("Object.keys called on non-object");var t,r,n=[];for(t in e)p.call(e,t)&&n.push(t);if(f)for(r=0;r<d;r++)p.call(e,l[r])&&n.push(l[r]);return n})),"function"!=typeof Object.assign&&(Object.assign=function(e,t){var r=arguments;if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e),o=1;o<arguments.length;o++){var i=r[o];if(null!=i)for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])}return n});var g=function(e){var r=e.requestFn;this._ua="",this._uaURIEncoded="",this.version="1.8.0",this._hasCredentials=!1,this.sendEvent=function(e){return function(t,r){if(!this._userHasOptedOut){if(!this._hasCredentials)throw new Error("Before calling any methods on the analytics, you first need to call the 'init' function with appId and apiKey parameters");if(""===r.userToken||""===this._userToken)throw new Error("`userToken` cannot be an empty string.");var n=r.userToken||this._userToken;if(o(n))throw new Error("Before calling any methods on the analytics, you first need to call 'setUserToken' function or include 'userToken' in the event payload.");if(!i(r.index))throw new TypeError("expected required parameter `index` to be a string");if(!i(r.eventName))throw new TypeError("expected required parameter `eventName` to be a string");if(!o(r.userToken)&&!i(r.userToken))throw new TypeError("expected optional parameter `userToken` to be a string");var a={eventType:t,eventName:r.eventName,userToken:n,index:r.index};if(!o(r.timestamp)){if(!s(r.timestamp))throw new TypeError("expected optional parameter `timestamp` to be a number");a.timestamp=r.timestamp}if(!o(r.queryID)){if(!i(r.queryID))throw new TypeError("expected optional parameter `queryID` to be a string");a.queryID=r.queryID}if(!o(r.objectIDs)){if(!Array.isArray(r.objectIDs))throw new TypeError("expected optional parameter `objectIDs` to be an array");a.objectIDs=r.objectIDs}if(!o(r.positions)){if(!Array.isArray(r.positions))throw new TypeError("expected optional parameter `positions` to be an array");if(o(r.objectIDs))throw new Error("cannot use `positions` without providing `objectIDs`");if(r.objectIDs.length!==r.positions.length)throw new Error("objectIDs and positions need to be of the same size");a.positions=r.positions}if(!o(r.filters)){if(!o(r.objectIDs))throw new Error("cannot use `objectIDs` and `filters` for the same event");if(!Array.isArray(r.filters))throw new TypeError("expected optional parameter `filters` to be an array");a.filters=r.filters}if(o(r.objectIDs)&&o(r.filters))throw new Error("expected either `objectIDs` or `filters` to be provided");return function(e,t,r,n,o,i){return e(o+"/1/events?X-Algolia-Application-Id="+t+"&X-Algolia-API-Key="+r+"&X-Algolia-Agent="+n,{events:i})}(e,this._appId,this._apiKey,this._uaURIEncoded,this._endpointOrigin,[a])}}}(r).bind(this),this.init=function(e){var t;if(!e)throw new Error("Init function should be called with an object argument containing your apiKey and appId");if(o(e.apiKey)||!i(e.apiKey))throw new Error("apiKey is missing, please provide it so we can authenticate the application");if(o(e.appId)||!i(e.appId))throw new Error("appId is missing, please provide it, so we can properly attribute data to your application");if(!o(e.region)&&-1===u.indexOf(e.region))throw new Error("optional region is incorrect, please provide either one of: "+u.join(", ")+".");if(!(o(e.cookieDuration)||s(e.cookieDuration)&&isFinite(e.cookieDuration)&&Math.floor(e.cookieDuration)===e.cookieDuration))throw new Error("optional cookieDuration is incorrect, expected an integer.");this._apiKey=e.apiKey,this._appId=e.appId,this._userHasOptedOut=!!e.userHasOptedOut,this._region=e.region,this._endpointOrigin=e.region?"https://insights."+e.region+".algolia.io":"https://insights.algolia.io",this._useCookie=null===(t=e.useCookie)||void 0===t||t,this._cookieDuration=e.cookieDuration?e.cookieDuration:6*h,this._hasCredentials=!0,this._ua=c,this._uaURIEncoded=encodeURIComponent(c),e.userToken?this.setUserToken(e.userToken):this._userToken||this._userHasOptedOut||!this._useCookie||this.setAnonymousUserToken()}.bind(this),this.initSearch=function(e){if(!this._hasCredentials)throw new Error("Before calling any methods on the analytics, you first need to call the 'init' function with appId and apiKey parameters");if(!e)throw new Error("initSearch function requires an argument with getQueryID and hitsContainer arguments");if(!e.getQueryID||"function"!=typeof e.getQueryID)throw new Error("getQueryID must be a function that returns the queryID of the last search operation");this.getQueryID=e.getQueryID}.bind(this),this.addAlgoliaAgent=function(e){-1===this._ua.indexOf("; "+e)&&(this._ua+="; "+e,this._uaURIEncoded=encodeURIComponent(this._ua))}.bind(this),this.setUserToken=function(e){this._userToken=e,a(this._onUserTokenChangeCallback)&&this._onUserTokenChangeCallback(this._userToken)}.bind(this),this.setAnonymousUserToken=function(){if(t()){var e=v(b);e&&""!==e&&0===e.indexOf("anonymous-")?this.setUserToken(e):(this.setUserToken("anonymous-"+w()),y(b,this._userToken,this._cookieDuration))}}.bind(this),this.getUserToken=function(e,t){return a(t)&&t(null,this._userToken),this._userToken}.bind(this),this.onUserTokenChange=function(e,t){this._onUserTokenChangeCallback=e,t&&t.immediate&&a(this._onUserTokenChangeCallback)&&this._onUserTokenChangeCallback(this._userToken)}.bind(this),this.clickedObjectIDsAfterSearch=function(e){if(!e)throw new Error("No params were sent to clickedObjectIDsAfterSearch function, please provide `queryID`, `objectIDs` and `positions` to be reported");if(!e.queryID)throw new Error("required queryID parameter was not sent, click event can not be properly sent without");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, click event can not be properly sent without");if(!e.positions)throw new Error("required positions parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}.bind(this),this.clickedObjectIDs=function(e){if(!e)throw new Error("No params were sent to clickedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required `objectIDs` parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}.bind(this),this.clickedFilters=function(e){if(!e)throw new Error("No params were sent to clickedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required `filters` parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}.bind(this),this.convertedObjectIDsAfterSearch=function(e){if(!e)throw new Error("No params were sent to convertedObjectIDsAfterSearch function, please provide `queryID` and `objectIDs` to be reported");if(!e.queryID)throw new Error("required queryID parameter was not sent, conversion event can not be properly sent without");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}.bind(this),this.convertedObjectIDs=function(e){if(!e)throw new Error("No params were sent to convertedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}.bind(this),this.convertedFilters=function(e){if(!e)throw new Error("No params were sent to convertedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required filters parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}.bind(this),this.viewedObjectIDs=function(e){if(!e)throw new Error("No params were sent to viewedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, view event can not be properly sent without");this.sendEvent("view",e)}.bind(this),this.viewedFilters=function(e){if(!e)throw new Error("No params were sent to viewedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required filters parameter was not sent, view event can not be properly sent without");this.sendEvent("view",e)}.bind(this),this._get=function(e,t){t(this[e])}.bind(this),this.getVersion=function(e){a(e)&&e(this.version)}.bind(this)},I=function(e,t){var r=JSON.stringify(t);navigator.sendBeacon(e,r)},m=function(e,t){var r=JSON.stringify(t),n=new XMLHttpRequest;n.open("POST",e),n.send(r)};function k(e){var t,r=e.AlgoliaAnalyticsObject;if(r){var n=(t=this,function(e){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];e&&a(t[e])?t[e].apply(t,r):console.warn("The method `"+e+"` doesn't exist.")}),o=e[r];o.queue=o.queue||[];var i=o.queue;i.forEach(function(e){var t=[].slice.call(e),r=t[0],o=t.slice(1);n.apply(void 0,[r].concat(o))}),i.push=function(e){var t=[].slice.call(e),r=t[0],o=t.slice(1);n.apply(void 0,[r].concat(o))}}}function D(e){var t=new g({requestFn:e});return"undefined"!=typeof window&&k.call(t,window),t}var E=D(function(){if(r())return I;if(n())return m;throw new Error("Could not find a supported HTTP request client in this environment.")}());e.createInsightsClient=D,e.default=E,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).AlgoliaAnalytics={})}(this,function(e){"use strict";var t=function(){try{return Boolean(navigator.cookieEnabled)}catch(e){return!1}},r=function(){try{return Boolean(navigator.sendBeacon)}catch(e){return!1}},n=function(){try{return Boolean(XMLHttpRequest)}catch(e){return!1}},o=function(e){return void 0===e},i=function(e){return"string"==typeof e},s=function(e){return"number"==typeof e},a=function(e){return"function"==typeof e};var c="insights-js (1.9.0)";var u=["de","us"],h=2592e6;var p,f,l,d,w=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},b="_ALGOLIA",y=function(e,t,r){var n=new Date;n.setTime(n.getTime()+r);var o="expires="+n.toUTCString();document.cookie=e+"="+t+";"+o+";path=/"},v=function(e){for(var t=e+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var o=r[n];" "===o.charAt(0);)o=o.substring(1);if(0===o.indexOf(t))return o.substring(t.length,o.length)}return""};Object.keys||(Object.keys=(p=Object.prototype.hasOwnProperty,f=!{toString:null}.propertyIsEnumerable("toString"),d=(l=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"]).length,function(e){if("function"!=typeof e&&("object"!=typeof e||null===e))throw new TypeError("Object.keys called on non-object");var t,r,n=[];for(t in e)p.call(e,t)&&n.push(t);if(f)for(r=0;r<d;r++)p.call(e,l[r])&&n.push(l[r]);return n})),"function"!=typeof Object.assign&&(Object.assign=function(e,t){var r=arguments;if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e),o=1;o<arguments.length;o++){var i=r[o];if(null!=i)for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])}return n});var g=function(e){var r=e.requestFn;this._ua="",this._uaURIEncoded="",this.version="1.9.0",this._hasCredentials=!1,this.sendEvent=function(e){return function(t,r){if(!this._userHasOptedOut){if(!this._hasCredentials)throw new Error("Before calling any methods on the analytics, you first need to call the 'init' function with appId and apiKey parameters");if(""===r.userToken||""===this._userToken)throw new Error("`userToken` cannot be an empty string.");var n=r.userToken||this._userToken;if(o(n))throw new Error("Before calling any methods on the analytics, you first need to call 'setUserToken' function or include 'userToken' in the event payload.");if(!i(r.index))throw new TypeError("expected required parameter `index` to be a string");if(!i(r.eventName))throw new TypeError("expected required parameter `eventName` to be a string");if(!o(r.userToken)&&!i(r.userToken))throw new TypeError("expected optional parameter `userToken` to be a string");var a={eventType:t,eventName:r.eventName,userToken:n,index:r.index};if(!o(r.timestamp)){if(!s(r.timestamp))throw new TypeError("expected optional parameter `timestamp` to be a number");a.timestamp=r.timestamp}if(!o(r.queryID)){if(!i(r.queryID))throw new TypeError("expected optional parameter `queryID` to be a string");a.queryID=r.queryID}if(!o(r.objectIDs)){if(!Array.isArray(r.objectIDs))throw new TypeError("expected optional parameter `objectIDs` to be an array");a.objectIDs=r.objectIDs}if(!o(r.positions)){if(!Array.isArray(r.positions))throw new TypeError("expected optional parameter `positions` to be an array");if(o(r.objectIDs))throw new Error("cannot use `positions` without providing `objectIDs`");if(r.objectIDs.length!==r.positions.length)throw new Error("objectIDs and positions need to be of the same size");a.positions=r.positions}if(!o(r.filters)){if(!o(r.objectIDs))throw new Error("cannot use `objectIDs` and `filters` for the same event");if(!Array.isArray(r.filters))throw new TypeError("expected optional parameter `filters` to be an array");a.filters=r.filters}if(o(r.objectIDs)&&o(r.filters))throw new Error("expected either `objectIDs` or `filters` to be provided");return function(e,t,r,n,o,i){return e(o+"/1/events?X-Algolia-Application-Id="+t+"&X-Algolia-API-Key="+r+"&X-Algolia-Agent="+n,{events:i})}(e,this._appId,this._apiKey,this._uaURIEncoded,this._endpointOrigin,[a])}}}(r).bind(this),this.init=function(e){var t;if(!e)throw new Error("Init function should be called with an object argument containing your apiKey and appId");if(o(e.apiKey)||!i(e.apiKey))throw new Error("apiKey is missing, please provide it so we can authenticate the application");if(o(e.appId)||!i(e.appId))throw new Error("appId is missing, please provide it, so we can properly attribute data to your application");if(!o(e.region)&&-1===u.indexOf(e.region))throw new Error("optional region is incorrect, please provide either one of: "+u.join(", ")+".");if(!(o(e.cookieDuration)||s(e.cookieDuration)&&isFinite(e.cookieDuration)&&Math.floor(e.cookieDuration)===e.cookieDuration))throw new Error("optional cookieDuration is incorrect, expected an integer.");this._apiKey=e.apiKey,this._appId=e.appId,this._userHasOptedOut=!!e.userHasOptedOut,this._region=e.region,this._endpointOrigin=e.region?"https://insights."+e.region+".algolia.io":"https://insights.algolia.io",this._useCookie=null===(t=e.useCookie)||void 0===t||t,this._cookieDuration=e.cookieDuration?e.cookieDuration:6*h,this._hasCredentials=!0,this._ua=c,this._uaURIEncoded=encodeURIComponent(c),e.userToken?this.setUserToken(e.userToken):this._userToken||this._userHasOptedOut||!this._useCookie||this.setAnonymousUserToken()}.bind(this),this.initSearch=function(e){if(!this._hasCredentials)throw new Error("Before calling any methods on the analytics, you first need to call the 'init' function with appId and apiKey parameters");if(!e)throw new Error("initSearch function requires an argument with getQueryID and hitsContainer arguments");if(!e.getQueryID||"function"!=typeof e.getQueryID)throw new Error("getQueryID must be a function that returns the queryID of the last search operation");this.getQueryID=e.getQueryID}.bind(this),this.addAlgoliaAgent=function(e){-1===this._ua.indexOf("; "+e)&&(this._ua+="; "+e,this._uaURIEncoded=encodeURIComponent(this._ua))}.bind(this),this.setUserToken=function(e){this._userToken=e,a(this._onUserTokenChangeCallback)&&this._onUserTokenChangeCallback(this._userToken)}.bind(this),this.setAnonymousUserToken=function(){if(t()){var e=v(b);e&&""!==e&&0===e.indexOf("anonymous-")?this.setUserToken(e):(this.setUserToken("anonymous-"+w()),y(b,this._userToken,this._cookieDuration))}}.bind(this),this.getUserToken=function(e,t){return a(t)&&t(null,this._userToken),this._userToken}.bind(this),this.onUserTokenChange=function(e,t){this._onUserTokenChangeCallback=e,t&&t.immediate&&a(this._onUserTokenChangeCallback)&&this._onUserTokenChangeCallback(this._userToken)}.bind(this),this.clickedObjectIDsAfterSearch=function(e){if(!e)throw new Error("No params were sent to clickedObjectIDsAfterSearch function, please provide `queryID`, `objectIDs` and `positions` to be reported");if(!e.queryID)throw new Error("required queryID parameter was not sent, click event can not be properly sent without");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, click event can not be properly sent without");if(!e.positions)throw new Error("required positions parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}.bind(this),this.clickedObjectIDs=function(e){if(!e)throw new Error("No params were sent to clickedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required `objectIDs` parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}.bind(this),this.clickedFilters=function(e){if(!e)throw new Error("No params were sent to clickedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required `filters` parameter was not sent, click event can not be properly sent without");this.sendEvent("click",e)}.bind(this),this.convertedObjectIDsAfterSearch=function(e){if(!e)throw new Error("No params were sent to convertedObjectIDsAfterSearch function, please provide `queryID` and `objectIDs` to be reported");if(!e.queryID)throw new Error("required queryID parameter was not sent, conversion event can not be properly sent without");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}.bind(this),this.convertedObjectIDs=function(e){if(!e)throw new Error("No params were sent to convertedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}.bind(this),this.convertedFilters=function(e){if(!e)throw new Error("No params were sent to convertedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required filters parameter was not sent, conversion event can not be properly sent without");this.sendEvent("conversion",e)}.bind(this),this.viewedObjectIDs=function(e){if(!e)throw new Error("No params were sent to viewedObjectIDs function, please provide `objectIDs` to be reported");if(!e.objectIDs)throw new Error("required objectIDs parameter was not sent, view event can not be properly sent without");this.sendEvent("view",e)}.bind(this),this.viewedFilters=function(e){if(!e)throw new Error("No params were sent to viewedFilters function, please provide `filters` to be reported");if(!e.filters)throw new Error("required filters parameter was not sent, view event can not be properly sent without");this.sendEvent("view",e)}.bind(this),this._get=function(e,t){t(this[e])}.bind(this),this.getVersion=function(e){a(e)&&e(this.version)}.bind(this)},I=function(e,t){var r=JSON.stringify(t);navigator.sendBeacon(e,r)},m=function(e,t){var r=JSON.stringify(t),n=new XMLHttpRequest;n.open("POST",e),n.send(r)};function k(e){var t,r=e.AlgoliaAnalyticsObject;if(r){var n=(t=this,function(e){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];e&&a(t[e])?t[e].apply(t,r):console.warn("The method `"+e+"` doesn't exist.")}),o=e[r];o.queue=o.queue||[];var i=o.queue;i.forEach(function(e){var t=[].slice.call(e),r=t[0],o=t.slice(1);n.apply(void 0,[r].concat(o))}),i.push=function(e){var t=[].slice.call(e),r=t[0],o=t.slice(1);n.apply(void 0,[r].concat(o))}}}function D(e){var t=new g({requestFn:e});return"object"==typeof window&&k.call(t,window),t}var E=D(function(){if(r())return I;if(n())return m;throw new Error("Could not find a supported HTTP request client in this environment.")}());e.createInsightsClient=D,e.default=E,Object.defineProperty(e,"__esModule",{value:!0})});

@@ -1,6 +0,4 @@

import AlgoliaAnalytics from "./insights";
import { getFunctionalInterface } from "./_getFunctionalInterface";
import { createInsightsClient } from "./_createInsightsClient";
import { getRequesterForBrowser } from "./utils/getRequesterForBrowser";
import { getRequesterForNode } from "./utils/getRequesterForNode";
import { RequestFnType } from "./utils/request";

@@ -10,6 +8,2 @@ export { getRequesterForBrowser, getRequesterForNode };

export function createInsightsClient(requestFn: RequestFnType) {
return getFunctionalInterface(new AlgoliaAnalytics({ requestFn }));
}
export default createInsightsClient(getRequesterForBrowser());

@@ -1,6 +0,4 @@

import AlgoliaAnalytics from "./insights";
import { getFunctionalInterface } from "./_getFunctionalInterface";
import { createInsightsClient } from "./_createInsightsClient";
import { getRequesterForBrowser } from "./utils/getRequesterForBrowser";
import { getRequesterForNode } from "./utils/getRequesterForNode";
import { RequestFnType } from "./utils/request";

@@ -10,6 +8,2 @@ export { getRequesterForBrowser, getRequesterForNode };

export function createInsightsClient(requestFn: RequestFnType) {
return getFunctionalInterface(new AlgoliaAnalytics({ requestFn }));
}
export default createInsightsClient(getRequesterForNode());

@@ -8,3 +8,3 @@ import AlgoliaAnalytics from "./insights";

const instance = new AlgoliaAnalytics({ requestFn });
if (typeof window !== "undefined") {
if (typeof window === 'object') {
// Process queue upon script execution

@@ -11,0 +11,0 @@ processQueue.call(instance, window);

@@ -55,7 +55,7 @@ import objectAssignPolyfill from "./polyfills/objectAssign";

type AlgoliaAnalyticsObject = Queue | AnalyticsFunction;
export type AlgoliaAnalyticsObject = Queue | AnalyticsFunction;
declare global {
interface Window {
AlgoliaAnalyticsObject: AlgoliaAnalyticsObject;
AlgoliaAnalyticsObject?: string;
}

@@ -62,0 +62,0 @@ }

{
"name": "search-insights",
"description": "Library for reporting click, conversion and view metrics using the Algolia Insights API",
"version": "1.8.0",
"version": "1.9.0",
"jsdelivr": "dist/search-insights.min.js",

@@ -6,0 +6,0 @@ "main": "index-node.cjs.js",

@@ -40,3 +40,3 @@ # Search Insights

<script>
var ALGOLIA_INSIGHTS_SRC = "https://cdn.jsdelivr.net/npm/search-insights@1.8.0";
var ALGOLIA_INSIGHTS_SRC = "https://cdn.jsdelivr.net/npm/search-insights@1.9.0";

@@ -43,0 +43,0 @@ !function(e,a,t,n,s,i,c){e.AlgoliaAnalyticsObject=s,e[s]=e[s]||function(){

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