LocalCDN-Firefox-Chrome-Brave/resources/search-insights/2.6.0/search-insights.min.jsm

2 lines
8.3 KiB
JavaScript

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).AlgoliaAnalytics={})}(this,function(e){"use strict";function n(){"function"!=typeof Object.assign&&(Object.assign=function(e,n){var t=arguments;if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(e),o=1;o<arguments.length;o++){var r=t[o];if(null!=r)for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])}return i})}function t(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)n.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(t[i[o]]=e[i[o]])}return t}function i(e){return e.reduce(function(e,n){var t=e.events,i=e.additionalParams;return"index"in n?{additionalParams:i,events:t.concat([n])}:{events:t,additionalParams:n}},{events:[],additionalParams:void 0})}var o=function(){try{return Boolean(navigator.cookieEnabled)}catch(e){return!1}},r=function(){try{return Boolean(navigator.sendBeacon)}catch(e){return!1}},s=function(){try{return Boolean(XMLHttpRequest)}catch(e){return!1}},a=function(e){return void 0===e},u=function(e){return"number"==typeof e},c=function(e){return"function"==typeof e};function l(e){return function(n,i){var o,r,s,u=this;if(!this._userHasOptedOut){if(!(!a(this._apiKey)&&!a(this._appId)||(null===(o=i)||void 0===o?void 0:o.headers["X-Algolia-Application-Id"])&&(null===(r=i)||void 0===r?void 0:r.headers["X-Algolia-API-Key"])))throw new Error("Before calling any methods on the analytics, you first need to call the 'init' function with appId and apiKey parameters or provide custom credentials in additional parameters.");!this._userToken&&this._anonymousUserToken&&this.setAnonymousUserToken(!0);var c=n.map(function(e){var n,i,o=e.filters,r=t(e,["filters"]),s=Object.assign(Object.assign({},r),{userToken:(i=null===(n=e)||void 0===n?void 0:n.userToken,null!==i&&void 0!==i?i:u._userToken)});return a(o)||(s.filters=o.map(encodeURIComponent)),s});return function(e,n,t,i,o,r,s){void 0===s&&(s={});var a=Object.assign({"X-Algolia-Application-Id":n,"X-Algolia-API-Key":t,"X-Algolia-Agent":encodeURIComponent(i.join("; "))},s),u=Object.keys(a).map(function(e){return e+"="+a[e]}).join("&");return e(o+"/1/events?"+u,{events:r})}(e,this._appId,this._apiKey,this._ua,this._endpointOrigin,c,null===(s=i)||void 0===s?void 0:s.headers)}}}var h="2.6.0",d=["insights-js ("+h+")","insights-js-browser-umd ("+h+")"];var f=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var n=16*Math.random()|0;return("x"===e?n:3&n|8).toString(16)})},v="_ALGOLIA",p=2592e6,g=function(e,n,t){var i=new Date;i.setTime(i.getTime()+t);var o="expires="+i.toUTCString();document.cookie=e+"="+n+";"+o+";path=/"},y=function(e){for(var n=e+"=",t=document.cookie.split(";"),i=0;i<t.length;i++){for(var o=t[i];" "===o.charAt(0);)o=o.substring(1);if(0===o.indexOf(n))return o.substring(n.length,o.length)}return""};n();var b,k,O,m,_=["de","us"];function x(e){var n,i;if(void 0===e&&(e={}),!a(e.region)&&-1===_.indexOf(e.region))throw new Error("optional region is incorrect, please provide either one of: "+_.join(", ")+".");if(!(a(e.cookieDuration)||u(e.cookieDuration)&&isFinite(e.cookieDuration)&&Math.floor(e.cookieDuration)===e.cookieDuration))throw new Error("optional cookieDuration is incorrect, expected an integer.");!function(e,n,i){var o=n.partial,r=t(n,["partial"]);o||Object.assign(e,i);Object.assign(e,Object.keys(r).reduce(function(e,n){var t;return Object.assign(Object.assign({},e),((t={})["_"+n]=r[n],t))},{}))}(this,e,{_userHasOptedOut:!!e.userHasOptedOut,_region:e.region,_host:e.host,_anonymousUserToken:(n=e.anonymousUserToken,null===n||void 0===n||n),_useCookie:(i=e.useCookie,null!==i&&void 0!==i&&i),_cookieDuration:e.cookieDuration||6*p}),this._endpointOrigin=this._host||(this._region?"https://insights."+this._region+".algolia.io":"https://insights.algolia.io"),this._ua=[].concat(d),e.userToken?this.setUserToken(e.userToken):this._userToken||this._userHasOptedOut||!this._useCookie||this.setAnonymousUserToken()}function T(e,n){return n.map(function(n){return Object.assign({eventType:e},n)})}Object.keys||(Object.keys=(b=Object.prototype.hasOwnProperty,k=!{toString:null}.propertyIsEnumerable("toString"),m=(O=["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 n,t,i=[];for(n in e)b.call(e,n)&&i.push(n);if(k)for(t=0;t<m;t++)b.call(e,O[t])&&i.push(O[t]);return i})),n();var j=function(e){var n=e.requestFn;this._endpointOrigin="https://insights.algolia.io",this._anonymousUserToken=!0,this._userHasOptedOut=!1,this._useCookie=!1,this._cookieDuration=6*p,this._ua=[],this.version=h,this.sendEvents=l(n).bind(this),this.init=x.bind(this),this.addAlgoliaAgent=function(e){-1===this._ua.indexOf(e)&&this._ua.push(e)}.bind(this),this.setUserToken=function(e){this._userToken=e,c(this._onUserTokenChangeCallback)&&this._onUserTokenChangeCallback(this._userToken)}.bind(this),this.setAnonymousUserToken=function(e){if(void 0===e&&(e=!1),e)this.setUserToken("anonymous-"+f());else if(o()){var n=y(v);n&&""!==n&&0===n.indexOf("anonymous-")?this.setUserToken(n):(this.setUserToken("anonymous-"+f()),g(v,this._userToken,this._cookieDuration))}}.bind(this),this.getUserToken=function(e,n){return c(n)&&n(null,this._userToken),this._userToken}.bind(this),this.onUserTokenChange=function(e,n){this._onUserTokenChangeCallback=e,n&&n.immediate&&c(this._onUserTokenChangeCallback)&&this._onUserTokenChangeCallback(this._userToken)}.bind(this),this.clickedObjectIDsAfterSearch=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var t=i(e),o=t.events,r=t.additionalParams;return this.sendEvents(T("click",o),r)}.bind(this),this.clickedObjectIDs=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var t=i(e),o=t.events,r=t.additionalParams;return this.sendEvents(T("click",o),r)}.bind(this),this.clickedFilters=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var t=i(e),o=t.events,r=t.additionalParams;return this.sendEvents(T("click",o),r)}.bind(this),this.convertedObjectIDsAfterSearch=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var t=i(e),o=t.events,r=t.additionalParams;return this.sendEvents(T("conversion",o),r)}.bind(this),this.convertedObjectIDs=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var t=i(e),o=t.events,r=t.additionalParams;return this.sendEvents(T("conversion",o),r)}.bind(this),this.convertedFilters=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var t=i(e),o=t.events,r=t.additionalParams;return this.sendEvents(T("conversion",o),r)}.bind(this),this.viewedObjectIDs=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var t=i(e),o=t.events,r=t.additionalParams;return this.sendEvents(T("view",o),r)}.bind(this),this.viewedFilters=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var t=i(e),o=t.events,r=t.additionalParams;return this.sendEvents(T("view",o),r)}.bind(this),this.getVersion=function(e){c(e)&&e(this.version)}.bind(this)},w=function(e,n){var t=JSON.stringify(n);if(!navigator.sendBeacon(e,t))return A(e,n)},A=function(e,n){var t=JSON.stringify(n),i=new XMLHttpRequest;i.open("POST",e),i.setRequestHeader("Content-Type","application/json"),i.setRequestHeader("Content-Length",""+t.length),i.send(t)};function P(e){var n,t=e.AlgoliaAnalyticsObject;if(t){var i=(n=this,function(e){for(var t=[],i=arguments.length-1;i-- >0;)t[i]=arguments[i+1];e&&c(n[e])?n[e].apply(n,t):console.warn("The method `"+e+"` doesn't exist.")}),o=e[t];o.queue=o.queue||[];var r=o.queue;r.forEach(function(e){var n=[].slice.call(e),t=n[0],o=n.slice(1);i.apply(void 0,[t].concat(o))}),r.push=function(e){var n=[].slice.call(e),t=n[0],o=n.slice(1);i.apply(void 0,[t].concat(o))}}}function C(e){var n=new j({requestFn:e});return"object"==typeof window&&P.call(n,window),n.version=h,n}var U=C(function(){if(r())return w;if(s())return A;throw new Error("Could not find a supported HTTP request client in this environment.")}());e.createInsightsClient=C,e.default=U,Object.defineProperty(e,"__esModule",{value:!0})});