Socket
Socket
Sign inDemoInstall

@algolia/client-analytics

Package Overview
Dependencies
Maintainers
3
Versions
220
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/client-analytics - npm Package Compare versions

Comparing version 5.0.0-alpha.12 to 5.0.0-alpha.13

2

dist/builds/browser.d.ts
import type { ClientOptions } from '@algolia/client-common';
import type { AnalyticsClient, Region } from '../src/analyticsClient';
export { apiClientVersion, AnalyticsClient } from '../src/analyticsClient';
export { apiClientVersion, AnalyticsClient, Region, } from '../src/analyticsClient';
export * from '../model';
export declare function analyticsClient(appId: string, apiKey: string, region?: Region, options?: ClientOptions): AnalyticsClient;
//# sourceMappingURL=browser.d.ts.map
import type { ClientOptions } from '@algolia/client-common';
import type { AnalyticsClient, Region } from '../src/analyticsClient';
export { apiClientVersion, AnalyticsClient } from '../src/analyticsClient';
export { apiClientVersion, AnalyticsClient, Region, } from '../src/analyticsClient';
export * from '../model';
export declare function analyticsClient(appId: string, apiKey: string, region?: Region, options?: ClientOptions): AnalyticsClient;
//# sourceMappingURL=node.d.ts.map

@@ -9,3 +9,3 @@ 'use strict';

// This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
const apiClientVersion = '5.0.0-alpha.12';
const apiClientVersion = '5.0.0-alpha.13';
const REGIONS = ['de', 'us'];

@@ -12,0 +12,0 @@ function getDefaultHosts(region) {

@@ -5,3 +5,3 @@ import { createAuth, createTransporter, getAlgoliaAgent, DEFAULT_CONNECT_TIMEOUT_NODE, DEFAULT_READ_TIMEOUT_NODE, DEFAULT_WRITE_TIMEOUT_NODE, createNullCache, createMemoryCache } from '@algolia/client-common';

// This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
const apiClientVersion = '5.0.0-alpha.12';
const apiClientVersion = '5.0.0-alpha.13';
const REGIONS = ['de', 'us'];

@@ -8,0 +8,0 @@ function getDefaultHosts(region) {

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

/*! client-analytics.umd.js | 5.0.0-alpha.12 | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */
!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/client-analytics"]={})}(this,(function(e){"use strict";function t(e){let t;const r=`algolia-client-js-${e.key}`;function i(){return void 0===t&&(t=e.localStorage||window.localStorage),t}function o(){return JSON.parse(i().getItem(r)||"{}")}return{get:(e,t,r={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>{const r=JSON.stringify(e),i=o()[r];return Promise.all([i||t(),void 0!==i])})).then((([e,t])=>Promise.all([e,t||r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{const s=o();return s[JSON.stringify(e)]=t,i().setItem(r,JSON.stringify(s)),t})),delete:e=>Promise.resolve().then((()=>{const t=o();delete t[JSON.stringify(e)],i().setItem(r,JSON.stringify(t))})),clear:()=>Promise.resolve().then((()=>{i().removeItem(r)}))}}function r(e){const t=[...e.caches],i=t.shift();return void 0===i?{get:(e,t,r={miss:()=>Promise.resolve()})=>t().then((e=>Promise.all([e,r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve(t),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,o,s={miss:()=>Promise.resolve()})=>i.get(e,o,s).catch((()=>r({caches:t}).get(e,o,s))),set:(e,o)=>i.set(e,o).catch((()=>r({caches:t}).set(e,o))),delete:e=>i.delete(e).catch((()=>r({caches:t}).delete(e))),clear:()=>i.clear().catch((()=>r({caches:t}).clear()))}}function i(e={serializable:!0}){let t={};return{get(r,i,o={miss:()=>Promise.resolve()}){const s=JSON.stringify(r);if(s in t)return Promise.resolve(e.serializable?JSON.parse(t[s]):t[s]);const a=i();return a.then((e=>o.miss(e))).then((()=>a))},set:(r,i)=>(t[JSON.stringify(r)]=e.serializable?JSON.stringify(i):i,Promise.resolve(i)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}const o=12e4;function s(e,t="up"){const r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>o},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=o}}}function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class n extends Error{constructor(e,t){super(e),a(this,"name","AlgoliaError"),t&&(this.name=t)}}class d extends n{constructor(e,t,r){super(e,r),a(this,"stackTrace",void 0),this.stackTrace=t}}class c extends d{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.",e,"RetryError")}}class u extends d{constructor(e,t,r){super(e,r,"ApiError"),a(this,"status",void 0),this.status=t}}class l extends n{constructor(e,t){super(e,"DeserializationError"),a(this,"response",void 0),this.response=t}}function g(e,t,r){const i=function(e){const t=e=>"[object Object]"===Object.prototype.toString.call(e)||"[object Array]"===Object.prototype.toString.call(e);return Object.keys(e).map((r=>`${r}=${t(e[r])?JSON.stringify(e[r]):e[r]}`)).join("&")}(r);let o=`${e.protocol}://${e.url}/${"/"===t.charAt(0)?t.substr(1):t}`;return i.length&&(o+=`?${i}`),o}function h(e){const t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function m({hosts:e,hostsCache:t,baseHeaders:r,baseQueryParameters:i,algoliaAgent:o,timeouts:a,requester:n,requestsCache:d,responsesCache:m}){async function p(d,m,p=!0){const f=[],v=function(e,t){if("GET"===e.method||void 0===e.data&&void 0===t.data)return;const r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}(d,m),S=function(e,t,r){const i={Accept:"application/json",...e,...t,...r},o={};return Object.keys(i).forEach((e=>{const t=i[e];o[e.toLowerCase()]=t})),o}(r,d.headers,m.headers),y="GET"===d.method?{...d.data,...m.data}:{},w={"x-algolia-agent":o.value,...i,...d.queryParameters,...y};if(m&&m.queryParameters)for(const e of Object.keys(m.queryParameters))m.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(m.queryParameters[e])?w[e]=m.queryParameters[e].toString():w[e]=m.queryParameters[e];let P=0;const q=async(e,r)=>{const i=e.pop();if(void 0===i)throw new c(function(e){return e.map((e=>h(e)))}(f));let o=m.timeout;void 0===o&&(o=p?a.read:a.write);const y={data:v,headers:S,method:d.method,url:g(i,d.path,w),connectTimeout:r(P,a.connect),responseTimeout:r(P,o)},D=t=>{const r={request:y,response:t,host:i,triesLeft:e.length};return f.push(r),r},T=await n.send(y);if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&0==~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(T)){const o=D(T);return T.isTimedOut&&P++,console.log("Retryable failure",h(o)),await t.set(i,s(i,T.isTimedOut?"timed out":"down")),q(e,r)}if(function({status:e}){return 2==~~(e/100)}(T))return function(e){try{return JSON.parse(e.content)}catch(t){throw new l(t.message,e)}}(T);throw D(T),function({content:e,status:t},r){let i=e;try{i=JSON.parse(e).message}catch(e){}return new u(i,t,r)}(T,f)},D=e.filter((e=>"readWrite"===e.accept||(p?"read"===e.accept:"write"===e.accept))),T=await async function(e){const r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(s(e))))))),i=r.filter((e=>e.isUp())),o=r.filter((e=>e.isTimedOut())),a=[...i,...o];return{hosts:a.length>0?a:e,getTimeout:(e,t)=>(0===o.length&&0===e?1:o.length+3+e)*t}}(D);return q([...T.hosts].reverse(),T.getTimeout)}return{hostsCache:t,requester:n,timeouts:a,algoliaAgent:o,baseHeaders:r,baseQueryParameters:i,hosts:e,request:function(e,t={}){const o=e.useReadTransporter||"GET"===e.method;if(!o)return p(e,t,o);const s=()=>p(e,t);if(!0!==(t.cacheable||e.cacheable))return s();const a={request:e,requestOptions:t,transporter:{queryParameters:i,headers:r}};return m.get(a,(()=>d.get(a,(()=>d.set(a,s()).then((e=>Promise.all([d.delete(a),e])),(e=>Promise.all([d.delete(a),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>m.set(a,e)})},requestsCache:d,responsesCache:m}}function p({algoliaAgents:e,client:t,version:r}){const i=function(e){const t={value:`Algolia for JavaScript (${e})`,add(e){const r=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===t.value.indexOf(r)&&(t.value=`${t.value}${r}`),t}};return t}(r).add({segment:t,version:r});return e.forEach((e=>i.add(e))),i}const f="5.0.0-alpha.12",v=["de","us"];e.analyticsClient=function(e,o,s,a){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!o||"string"!=typeof o)throw new Error("`apiKey` is missing.");if(s&&("string"!=typeof s||!v.includes(s)))throw new Error(`\`region\` must be one of the following: ${v.join(", ")}`);return function({appId:e,apiKey:t,authMode:r,algoliaAgents:i,region:o,...s}){const a=function(e,t,r="WithinHeaders"){const i={"x-algolia-api-key":t,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===r?i:{},queryParameters:()=>"WithinQueryParameters"===r?i:{}}}(e,t,r),n=m({hosts:(d=o,[{url:d?"analytics.{region}.algolia.com".replace("{region}",d):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]),...s,algoliaAgent:p({algoliaAgents:i,client:"Analytics",version:f}),baseHeaders:{"content-type":"text/plain",...a.headers(),...s.baseHeaders},baseQueryParameters:{...a.queryParameters(),...s.baseQueryParameters}});var d;return{transporter:n,appId:e,clearCache:()=>Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then((()=>{})),get _ua(){return n.algoliaAgent.value},addAlgoliaAgent(e,t){n.algoliaAgent.add({segment:e,version:t})},del({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `del`.");const i={method:"DELETE",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return n.request(i,r)},get({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `get`.");const i={method:"GET",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return n.request(i,r)},getAverageClickPosition({index:e,startDate:t,endDate:r,tags:i},o){if(!e)throw new Error("Parameter `index` is required when calling `getAverageClickPosition`.");const s={};void 0!==e&&(s.index=e.toString()),void 0!==t&&(s.startDate=t.toString()),void 0!==r&&(s.endDate=r.toString()),void 0!==i&&(s.tags=i.toString());const a={method:"GET",path:"/2/clicks/averageClickPosition",queryParameters:s,headers:{}};return n.request(a,o)},getClickPositions({index:e,startDate:t,endDate:r,tags:i},o){if(!e)throw new Error("Parameter `index` is required when calling `getClickPositions`.");const s={};void 0!==e&&(s.index=e.toString()),void 0!==t&&(s.startDate=t.toString()),void 0!==r&&(s.endDate=r.toString()),void 0!==i&&(s.tags=i.toString());const a={method:"GET",path:"/2/clicks/positions",queryParameters:s,headers:{}};return n.request(a,o)},getClickThroughRate({index:e,startDate:t,endDate:r,tags:i},o){if(!e)throw new Error("Parameter `index` is required when calling `getClickThroughRate`.");const s={};void 0!==e&&(s.index=e.toString()),void 0!==t&&(s.startDate=t.toString()),void 0!==r&&(s.endDate=r.toString()),void 0!==i&&(s.tags=i.toString());const a={method:"GET",path:"/2/clicks/clickThroughRate",queryParameters:s,headers:{}};return n.request(a,o)},getConversationRate({index:e,startDate:t,endDate:r,tags:i},o){if(!e)throw new Error("Parameter `index` is required when calling `getConversationRate`.");const s={};void 0!==e&&(s.index=e.toString()),void 0!==t&&(s.startDate=t.toString()),void 0!==r&&(s.endDate=r.toString()),void 0!==i&&(s.tags=i.toString());const a={method:"GET",path:"/2/conversions/conversionRate",queryParameters:s,headers:{}};return n.request(a,o)},getNoClickRate({index:e,startDate:t,endDate:r,tags:i},o){if(!e)throw new Error("Parameter `index` is required when calling `getNoClickRate`.");const s={};void 0!==e&&(s.index=e.toString()),void 0!==t&&(s.startDate=t.toString()),void 0!==r&&(s.endDate=r.toString()),void 0!==i&&(s.tags=i.toString());const a={method:"GET",path:"/2/searches/noClickRate",queryParameters:s,headers:{}};return n.request(a,o)},getNoResultsRate({index:e,startDate:t,endDate:r,tags:i},o){if(!e)throw new Error("Parameter `index` is required when calling `getNoResultsRate`.");const s={};void 0!==e&&(s.index=e.toString()),void 0!==t&&(s.startDate=t.toString()),void 0!==r&&(s.endDate=r.toString()),void 0!==i&&(s.tags=i.toString());const a={method:"GET",path:"/2/searches/noResultRate",queryParameters:s,headers:{}};return n.request(a,o)},getSearchesCount({index:e,startDate:t,endDate:r,tags:i},o){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesCount`.");const s={};void 0!==e&&(s.index=e.toString()),void 0!==t&&(s.startDate=t.toString()),void 0!==r&&(s.endDate=r.toString()),void 0!==i&&(s.tags=i.toString());const a={method:"GET",path:"/2/searches/count",queryParameters:s,headers:{}};return n.request(a,o)},getSearchesNoClicks({index:e,startDate:t,endDate:r,limit:i,offset:o,tags:s},a){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesNoClicks`.");const d={};void 0!==e&&(d.index=e.toString()),void 0!==t&&(d.startDate=t.toString()),void 0!==r&&(d.endDate=r.toString()),void 0!==i&&(d.limit=i.toString()),void 0!==o&&(d.offset=o.toString()),void 0!==s&&(d.tags=s.toString());const c={method:"GET",path:"/2/searches/noClicks",queryParameters:d,headers:{}};return n.request(c,a)},getSearchesNoResults({index:e,startDate:t,endDate:r,limit:i,offset:o,tags:s},a){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesNoResults`.");const d={};void 0!==e&&(d.index=e.toString()),void 0!==t&&(d.startDate=t.toString()),void 0!==r&&(d.endDate=r.toString()),void 0!==i&&(d.limit=i.toString()),void 0!==o&&(d.offset=o.toString()),void 0!==s&&(d.tags=s.toString());const c={method:"GET",path:"/2/searches/noResults",queryParameters:d,headers:{}};return n.request(c,a)},getStatus({index:e},t){if(!e)throw new Error("Parameter `index` is required when calling `getStatus`.");const r={};void 0!==e&&(r.index=e.toString());const i={method:"GET",path:"/2/status",queryParameters:r,headers:{}};return n.request(i,t)},getTopCountries({index:e,startDate:t,endDate:r,limit:i,offset:o,tags:s},a){if(!e)throw new Error("Parameter `index` is required when calling `getTopCountries`.");const d={};void 0!==e&&(d.index=e.toString()),void 0!==t&&(d.startDate=t.toString()),void 0!==r&&(d.endDate=r.toString()),void 0!==i&&(d.limit=i.toString()),void 0!==o&&(d.offset=o.toString()),void 0!==s&&(d.tags=s.toString());const c={method:"GET",path:"/2/countries",queryParameters:d,headers:{}};return n.request(c,a)},getTopFilterAttributes({index:e,search:t,startDate:r,endDate:i,limit:o,offset:s,tags:a},d){if(!e)throw new Error("Parameter `index` is required when calling `getTopFilterAttributes`.");const c={};void 0!==e&&(c.index=e.toString()),void 0!==t&&(c.search=t.toString()),void 0!==r&&(c.startDate=r.toString()),void 0!==i&&(c.endDate=i.toString()),void 0!==o&&(c.limit=o.toString()),void 0!==s&&(c.offset=s.toString()),void 0!==a&&(c.tags=a.toString());const u={method:"GET",path:"/2/filters",queryParameters:c,headers:{}};return n.request(u,d)},getTopFilterForAttribute({attribute:e,index:t,search:r,startDate:i,endDate:o,limit:s,offset:a,tags:d},c){if(!e)throw new Error("Parameter `attribute` is required when calling `getTopFilterForAttribute`.");if(!t)throw new Error("Parameter `index` is required when calling `getTopFilterForAttribute`.");const u="/2/filters/{attribute}".replace("{attribute}",encodeURIComponent(e)),l={};void 0!==t&&(l.index=t.toString()),void 0!==r&&(l.search=r.toString()),void 0!==i&&(l.startDate=i.toString()),void 0!==o&&(l.endDate=o.toString()),void 0!==s&&(l.limit=s.toString()),void 0!==a&&(l.offset=a.toString()),void 0!==d&&(l.tags=d.toString());const g={method:"GET",path:u,queryParameters:l,headers:{}};return n.request(g,c)},getTopFiltersNoResults({index:e,search:t,startDate:r,endDate:i,limit:o,offset:s,tags:a},d){if(!e)throw new Error("Parameter `index` is required when calling `getTopFiltersNoResults`.");const c={};void 0!==e&&(c.index=e.toString()),void 0!==t&&(c.search=t.toString()),void 0!==r&&(c.startDate=r.toString()),void 0!==i&&(c.endDate=i.toString()),void 0!==o&&(c.limit=o.toString()),void 0!==s&&(c.offset=s.toString()),void 0!==a&&(c.tags=a.toString());const u={method:"GET",path:"/2/filters/noResults",queryParameters:c,headers:{}};return n.request(u,d)},getTopHits({index:e,search:t,clickAnalytics:r,startDate:i,endDate:o,limit:s,offset:a,tags:d},c){if(!e)throw new Error("Parameter `index` is required when calling `getTopHits`.");const u={};void 0!==e&&(u.index=e.toString()),void 0!==t&&(u.search=t.toString()),void 0!==r&&(u.clickAnalytics=r.toString()),void 0!==i&&(u.startDate=i.toString()),void 0!==o&&(u.endDate=o.toString()),void 0!==s&&(u.limit=s.toString()),void 0!==a&&(u.offset=a.toString()),void 0!==d&&(u.tags=d.toString());const l={method:"GET",path:"/2/hits",queryParameters:u,headers:{}};return n.request(l,c)},getTopSearches({index:e,clickAnalytics:t,startDate:r,endDate:i,orderBy:o,direction:s,limit:a,offset:d,tags:c},u){if(!e)throw new Error("Parameter `index` is required when calling `getTopSearches`.");const l={};void 0!==e&&(l.index=e.toString()),void 0!==t&&(l.clickAnalytics=t.toString()),void 0!==r&&(l.startDate=r.toString()),void 0!==i&&(l.endDate=i.toString()),void 0!==o&&(l.orderBy=o.toString()),void 0!==s&&(l.direction=s.toString()),void 0!==a&&(l.limit=a.toString()),void 0!==d&&(l.offset=d.toString()),void 0!==c&&(l.tags=c.toString());const g={method:"GET",path:"/2/searches",queryParameters:l,headers:{}};return n.request(g,u)},getUsersCount({index:e,startDate:t,endDate:r,tags:i},o){if(!e)throw new Error("Parameter `index` is required when calling `getUsersCount`.");const s={};void 0!==e&&(s.index=e.toString()),void 0!==t&&(s.startDate=t.toString()),void 0!==r&&(s.endDate=r.toString()),void 0!==i&&(s.tags=i.toString());const a={method:"GET",path:"/2/users/count",queryParameters:s,headers:{}};return n.request(a,o)},post({path:e,parameters:t,body:r},i){if(!e)throw new Error("Parameter `path` is required when calling `post`.");const o={method:"POST",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return n.request(o,i)},put({path:e,parameters:t,body:r},i){if(!e)throw new Error("Parameter `path` is required when calling `put`.");const o={method:"PUT",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return n.request(o,i)}}}({appId:e,apiKey:o,region:s,timeouts:{connect:1e3,read:2e3,write:3e4},requester:{send:function(e){return new Promise((t=>{const r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((t=>r.setRequestHeader(t,e.headers[t])));const i=(e,i)=>setTimeout((()=>{r.abort(),t({status:0,content:i,isTimedOut:!0})}),e),o=i(e.connectTimeout,"Connection timeout");let s;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===s&&(clearTimeout(o),s=i(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(o),clearTimeout(s),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(o),clearTimeout(s),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:i(),requestsCache:i({serializable:!1}),hostsCache:r({caches:[t({key:`5.0.0-alpha.12-${e}`}),i()]}),...a})},e.apiClientVersion=f}));
/*! client-analytics.umd.js | 5.0.0-alpha.13 | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */
!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/client-analytics"]={})}(this,(function(e){"use strict";function t(e){let t;const r=`algolia-client-js-${e.key}`;function i(){return void 0===t&&(t=e.localStorage||window.localStorage),t}function o(){return JSON.parse(i().getItem(r)||"{}")}return{get:(e,t,r={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>{const r=JSON.stringify(e),i=o()[r];return Promise.all([i||t(),void 0!==i])})).then((([e,t])=>Promise.all([e,t||r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{const s=o();return s[JSON.stringify(e)]=t,i().setItem(r,JSON.stringify(s)),t})),delete:e=>Promise.resolve().then((()=>{const t=o();delete t[JSON.stringify(e)],i().setItem(r,JSON.stringify(t))})),clear:()=>Promise.resolve().then((()=>{i().removeItem(r)}))}}function r(e){const t=[...e.caches],i=t.shift();return void 0===i?{get:(e,t,r={miss:()=>Promise.resolve()})=>t().then((e=>Promise.all([e,r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve(t),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,o,s={miss:()=>Promise.resolve()})=>i.get(e,o,s).catch((()=>r({caches:t}).get(e,o,s))),set:(e,o)=>i.set(e,o).catch((()=>r({caches:t}).set(e,o))),delete:e=>i.delete(e).catch((()=>r({caches:t}).delete(e))),clear:()=>i.clear().catch((()=>r({caches:t}).clear()))}}function i(e={serializable:!0}){let t={};return{get(r,i,o={miss:()=>Promise.resolve()}){const s=JSON.stringify(r);if(s in t)return Promise.resolve(e.serializable?JSON.parse(t[s]):t[s]);const a=i();return a.then((e=>o.miss(e))).then((()=>a))},set:(r,i)=>(t[JSON.stringify(r)]=e.serializable?JSON.stringify(i):i,Promise.resolve(i)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}const o=12e4;function s(e,t="up"){const r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>o},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=o}}}function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class n extends Error{constructor(e,t){super(e),a(this,"name","AlgoliaError"),t&&(this.name=t)}}class d extends n{constructor(e,t,r){super(e,r),a(this,"stackTrace",void 0),this.stackTrace=t}}class c extends d{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.",e,"RetryError")}}class u extends d{constructor(e,t,r){super(e,r,"ApiError"),a(this,"status",void 0),this.status=t}}class l extends n{constructor(e,t){super(e,"DeserializationError"),a(this,"response",void 0),this.response=t}}function g(e,t,r){const i=function(e){const t=e=>"[object Object]"===Object.prototype.toString.call(e)||"[object Array]"===Object.prototype.toString.call(e);return Object.keys(e).map((r=>`${r}=${t(e[r])?JSON.stringify(e[r]):e[r]}`)).join("&")}(r);let o=`${e.protocol}://${e.url}/${"/"===t.charAt(0)?t.substr(1):t}`;return i.length&&(o+=`?${i}`),o}function h(e){const t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function m({hosts:e,hostsCache:t,baseHeaders:r,baseQueryParameters:i,algoliaAgent:o,timeouts:a,requester:n,requestsCache:d,responsesCache:m}){async function p(d,m,p=!0){const f=[],v=function(e,t){if("GET"===e.method||void 0===e.data&&void 0===t.data)return;const r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}(d,m),S=function(e,t,r){const i={Accept:"application/json",...e,...t,...r},o={};return Object.keys(i).forEach((e=>{const t=i[e];o[e.toLowerCase()]=t})),o}(r,d.headers,m.headers),y="GET"===d.method?{...d.data,...m.data}:{},w={"x-algolia-agent":o.value,...i,...d.queryParameters,...y};if(m&&m.queryParameters)for(const e of Object.keys(m.queryParameters))m.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(m.queryParameters[e])?w[e]=m.queryParameters[e].toString():w[e]=m.queryParameters[e];let P=0;const q=async(e,r)=>{const i=e.pop();if(void 0===i)throw new c(function(e){return e.map((e=>h(e)))}(f));let o=m.timeout;void 0===o&&(o=p?a.read:a.write);const y={data:v,headers:S,method:d.method,url:g(i,d.path,w),connectTimeout:r(P,a.connect),responseTimeout:r(P,o)},D=t=>{const r={request:y,response:t,host:i,triesLeft:e.length};return f.push(r),r},T=await n.send(y);if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&0==~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(T)){const o=D(T);return T.isTimedOut&&P++,console.log("Retryable failure",h(o)),await t.set(i,s(i,T.isTimedOut?"timed out":"down")),q(e,r)}if(function({status:e}){return 2==~~(e/100)}(T))return function(e){try{return JSON.parse(e.content)}catch(t){throw new l(t.message,e)}}(T);throw D(T),function({content:e,status:t},r){let i=e;try{i=JSON.parse(e).message}catch(e){}return new u(i,t,r)}(T,f)},D=e.filter((e=>"readWrite"===e.accept||(p?"read"===e.accept:"write"===e.accept))),T=await async function(e){const r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(s(e))))))),i=r.filter((e=>e.isUp())),o=r.filter((e=>e.isTimedOut())),a=[...i,...o];return{hosts:a.length>0?a:e,getTimeout:(e,t)=>(0===o.length&&0===e?1:o.length+3+e)*t}}(D);return q([...T.hosts].reverse(),T.getTimeout)}return{hostsCache:t,requester:n,timeouts:a,algoliaAgent:o,baseHeaders:r,baseQueryParameters:i,hosts:e,request:function(e,t={}){const o=e.useReadTransporter||"GET"===e.method;if(!o)return p(e,t,o);const s=()=>p(e,t);if(!0!==(t.cacheable||e.cacheable))return s();const a={request:e,requestOptions:t,transporter:{queryParameters:i,headers:r}};return m.get(a,(()=>d.get(a,(()=>d.set(a,s()).then((e=>Promise.all([d.delete(a),e])),(e=>Promise.all([d.delete(a),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>m.set(a,e)})},requestsCache:d,responsesCache:m}}function p({algoliaAgents:e,client:t,version:r}){const i=function(e){const t={value:`Algolia for JavaScript (${e})`,add(e){const r=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===t.value.indexOf(r)&&(t.value=`${t.value}${r}`),t}};return t}(r).add({segment:t,version:r});return e.forEach((e=>i.add(e))),i}const f="5.0.0-alpha.13",v=["de","us"];e.analyticsClient=function(e,o,s,a){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!o||"string"!=typeof o)throw new Error("`apiKey` is missing.");if(s&&("string"!=typeof s||!v.includes(s)))throw new Error(`\`region\` must be one of the following: ${v.join(", ")}`);return function({appId:e,apiKey:t,authMode:r,algoliaAgents:i,region:o,...s}){const a=function(e,t,r="WithinHeaders"){const i={"x-algolia-api-key":t,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===r?i:{},queryParameters:()=>"WithinQueryParameters"===r?i:{}}}(e,t,r),n=m({hosts:(d=o,[{url:d?"analytics.{region}.algolia.com".replace("{region}",d):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]),...s,algoliaAgent:p({algoliaAgents:i,client:"Analytics",version:f}),baseHeaders:{"content-type":"text/plain",...a.headers(),...s.baseHeaders},baseQueryParameters:{...a.queryParameters(),...s.baseQueryParameters}});var d;return{transporter:n,appId:e,clearCache:()=>Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then((()=>{})),get _ua(){return n.algoliaAgent.value},addAlgoliaAgent(e,t){n.algoliaAgent.add({segment:e,version:t})},del({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `del`.");const i={method:"DELETE",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return n.request(i,r)},get({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `get`.");const i={method:"GET",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return n.request(i,r)},getAverageClickPosition({index:e,startDate:t,endDate:r,tags:i},o){if(!e)throw new Error("Parameter `index` is required when calling `getAverageClickPosition`.");const s={};void 0!==e&&(s.index=e.toString()),void 0!==t&&(s.startDate=t.toString()),void 0!==r&&(s.endDate=r.toString()),void 0!==i&&(s.tags=i.toString());const a={method:"GET",path:"/2/clicks/averageClickPosition",queryParameters:s,headers:{}};return n.request(a,o)},getClickPositions({index:e,startDate:t,endDate:r,tags:i},o){if(!e)throw new Error("Parameter `index` is required when calling `getClickPositions`.");const s={};void 0!==e&&(s.index=e.toString()),void 0!==t&&(s.startDate=t.toString()),void 0!==r&&(s.endDate=r.toString()),void 0!==i&&(s.tags=i.toString());const a={method:"GET",path:"/2/clicks/positions",queryParameters:s,headers:{}};return n.request(a,o)},getClickThroughRate({index:e,startDate:t,endDate:r,tags:i},o){if(!e)throw new Error("Parameter `index` is required when calling `getClickThroughRate`.");const s={};void 0!==e&&(s.index=e.toString()),void 0!==t&&(s.startDate=t.toString()),void 0!==r&&(s.endDate=r.toString()),void 0!==i&&(s.tags=i.toString());const a={method:"GET",path:"/2/clicks/clickThroughRate",queryParameters:s,headers:{}};return n.request(a,o)},getConversationRate({index:e,startDate:t,endDate:r,tags:i},o){if(!e)throw new Error("Parameter `index` is required when calling `getConversationRate`.");const s={};void 0!==e&&(s.index=e.toString()),void 0!==t&&(s.startDate=t.toString()),void 0!==r&&(s.endDate=r.toString()),void 0!==i&&(s.tags=i.toString());const a={method:"GET",path:"/2/conversions/conversionRate",queryParameters:s,headers:{}};return n.request(a,o)},getNoClickRate({index:e,startDate:t,endDate:r,tags:i},o){if(!e)throw new Error("Parameter `index` is required when calling `getNoClickRate`.");const s={};void 0!==e&&(s.index=e.toString()),void 0!==t&&(s.startDate=t.toString()),void 0!==r&&(s.endDate=r.toString()),void 0!==i&&(s.tags=i.toString());const a={method:"GET",path:"/2/searches/noClickRate",queryParameters:s,headers:{}};return n.request(a,o)},getNoResultsRate({index:e,startDate:t,endDate:r,tags:i},o){if(!e)throw new Error("Parameter `index` is required when calling `getNoResultsRate`.");const s={};void 0!==e&&(s.index=e.toString()),void 0!==t&&(s.startDate=t.toString()),void 0!==r&&(s.endDate=r.toString()),void 0!==i&&(s.tags=i.toString());const a={method:"GET",path:"/2/searches/noResultRate",queryParameters:s,headers:{}};return n.request(a,o)},getSearchesCount({index:e,startDate:t,endDate:r,tags:i},o){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesCount`.");const s={};void 0!==e&&(s.index=e.toString()),void 0!==t&&(s.startDate=t.toString()),void 0!==r&&(s.endDate=r.toString()),void 0!==i&&(s.tags=i.toString());const a={method:"GET",path:"/2/searches/count",queryParameters:s,headers:{}};return n.request(a,o)},getSearchesNoClicks({index:e,startDate:t,endDate:r,limit:i,offset:o,tags:s},a){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesNoClicks`.");const d={};void 0!==e&&(d.index=e.toString()),void 0!==t&&(d.startDate=t.toString()),void 0!==r&&(d.endDate=r.toString()),void 0!==i&&(d.limit=i.toString()),void 0!==o&&(d.offset=o.toString()),void 0!==s&&(d.tags=s.toString());const c={method:"GET",path:"/2/searches/noClicks",queryParameters:d,headers:{}};return n.request(c,a)},getSearchesNoResults({index:e,startDate:t,endDate:r,limit:i,offset:o,tags:s},a){if(!e)throw new Error("Parameter `index` is required when calling `getSearchesNoResults`.");const d={};void 0!==e&&(d.index=e.toString()),void 0!==t&&(d.startDate=t.toString()),void 0!==r&&(d.endDate=r.toString()),void 0!==i&&(d.limit=i.toString()),void 0!==o&&(d.offset=o.toString()),void 0!==s&&(d.tags=s.toString());const c={method:"GET",path:"/2/searches/noResults",queryParameters:d,headers:{}};return n.request(c,a)},getStatus({index:e},t){if(!e)throw new Error("Parameter `index` is required when calling `getStatus`.");const r={};void 0!==e&&(r.index=e.toString());const i={method:"GET",path:"/2/status",queryParameters:r,headers:{}};return n.request(i,t)},getTopCountries({index:e,startDate:t,endDate:r,limit:i,offset:o,tags:s},a){if(!e)throw new Error("Parameter `index` is required when calling `getTopCountries`.");const d={};void 0!==e&&(d.index=e.toString()),void 0!==t&&(d.startDate=t.toString()),void 0!==r&&(d.endDate=r.toString()),void 0!==i&&(d.limit=i.toString()),void 0!==o&&(d.offset=o.toString()),void 0!==s&&(d.tags=s.toString());const c={method:"GET",path:"/2/countries",queryParameters:d,headers:{}};return n.request(c,a)},getTopFilterAttributes({index:e,search:t,startDate:r,endDate:i,limit:o,offset:s,tags:a},d){if(!e)throw new Error("Parameter `index` is required when calling `getTopFilterAttributes`.");const c={};void 0!==e&&(c.index=e.toString()),void 0!==t&&(c.search=t.toString()),void 0!==r&&(c.startDate=r.toString()),void 0!==i&&(c.endDate=i.toString()),void 0!==o&&(c.limit=o.toString()),void 0!==s&&(c.offset=s.toString()),void 0!==a&&(c.tags=a.toString());const u={method:"GET",path:"/2/filters",queryParameters:c,headers:{}};return n.request(u,d)},getTopFilterForAttribute({attribute:e,index:t,search:r,startDate:i,endDate:o,limit:s,offset:a,tags:d},c){if(!e)throw new Error("Parameter `attribute` is required when calling `getTopFilterForAttribute`.");if(!t)throw new Error("Parameter `index` is required when calling `getTopFilterForAttribute`.");const u="/2/filters/{attribute}".replace("{attribute}",encodeURIComponent(e)),l={};void 0!==t&&(l.index=t.toString()),void 0!==r&&(l.search=r.toString()),void 0!==i&&(l.startDate=i.toString()),void 0!==o&&(l.endDate=o.toString()),void 0!==s&&(l.limit=s.toString()),void 0!==a&&(l.offset=a.toString()),void 0!==d&&(l.tags=d.toString());const g={method:"GET",path:u,queryParameters:l,headers:{}};return n.request(g,c)},getTopFiltersNoResults({index:e,search:t,startDate:r,endDate:i,limit:o,offset:s,tags:a},d){if(!e)throw new Error("Parameter `index` is required when calling `getTopFiltersNoResults`.");const c={};void 0!==e&&(c.index=e.toString()),void 0!==t&&(c.search=t.toString()),void 0!==r&&(c.startDate=r.toString()),void 0!==i&&(c.endDate=i.toString()),void 0!==o&&(c.limit=o.toString()),void 0!==s&&(c.offset=s.toString()),void 0!==a&&(c.tags=a.toString());const u={method:"GET",path:"/2/filters/noResults",queryParameters:c,headers:{}};return n.request(u,d)},getTopHits({index:e,search:t,clickAnalytics:r,startDate:i,endDate:o,limit:s,offset:a,tags:d},c){if(!e)throw new Error("Parameter `index` is required when calling `getTopHits`.");const u={};void 0!==e&&(u.index=e.toString()),void 0!==t&&(u.search=t.toString()),void 0!==r&&(u.clickAnalytics=r.toString()),void 0!==i&&(u.startDate=i.toString()),void 0!==o&&(u.endDate=o.toString()),void 0!==s&&(u.limit=s.toString()),void 0!==a&&(u.offset=a.toString()),void 0!==d&&(u.tags=d.toString());const l={method:"GET",path:"/2/hits",queryParameters:u,headers:{}};return n.request(l,c)},getTopSearches({index:e,clickAnalytics:t,startDate:r,endDate:i,orderBy:o,direction:s,limit:a,offset:d,tags:c},u){if(!e)throw new Error("Parameter `index` is required when calling `getTopSearches`.");const l={};void 0!==e&&(l.index=e.toString()),void 0!==t&&(l.clickAnalytics=t.toString()),void 0!==r&&(l.startDate=r.toString()),void 0!==i&&(l.endDate=i.toString()),void 0!==o&&(l.orderBy=o.toString()),void 0!==s&&(l.direction=s.toString()),void 0!==a&&(l.limit=a.toString()),void 0!==d&&(l.offset=d.toString()),void 0!==c&&(l.tags=c.toString());const g={method:"GET",path:"/2/searches",queryParameters:l,headers:{}};return n.request(g,u)},getUsersCount({index:e,startDate:t,endDate:r,tags:i},o){if(!e)throw new Error("Parameter `index` is required when calling `getUsersCount`.");const s={};void 0!==e&&(s.index=e.toString()),void 0!==t&&(s.startDate=t.toString()),void 0!==r&&(s.endDate=r.toString()),void 0!==i&&(s.tags=i.toString());const a={method:"GET",path:"/2/users/count",queryParameters:s,headers:{}};return n.request(a,o)},post({path:e,parameters:t,body:r},i){if(!e)throw new Error("Parameter `path` is required when calling `post`.");const o={method:"POST",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return n.request(o,i)},put({path:e,parameters:t,body:r},i){if(!e)throw new Error("Parameter `path` is required when calling `put`.");const o={method:"PUT",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return n.request(o,i)}}}({appId:e,apiKey:o,region:s,timeouts:{connect:1e3,read:2e3,write:3e4},requester:{send:function(e){return new Promise((t=>{const r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((t=>r.setRequestHeader(t,e.headers[t])));const i=(e,i)=>setTimeout((()=>{r.abort(),t({status:0,content:i,isTimedOut:!0})}),e),o=i(e.connectTimeout,"Connection timeout");let s;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===s&&(clearTimeout(o),s=i(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(o),clearTimeout(s),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(o),clearTimeout(s),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:i(),requestsCache:i({serializable:!1}),hostsCache:r({caches:[t({key:`5.0.0-alpha.13-${e}`}),i()]}),...a})},e.apiClientVersion=f}));

@@ -20,3 +20,3 @@ import type { CreateClientOptions, RequestOptions } from '@algolia/client-common';

import type { GetUsersCountResponse } from '../model/getUsersCountResponse';
export declare const apiClientVersion = "5.0.0-alpha.12";
export declare const apiClientVersion = "5.0.0-alpha.13";
export declare const REGIONS: readonly ["de", "us"];

@@ -23,0 +23,0 @@ export declare type Region = typeof REGIONS[number];

{
"name": "@algolia/client-analytics",
"version": "5.0.0-alpha.12",
"version": "5.0.0-alpha.13",
"description": "JavaScript client for client-analytics",

@@ -41,5 +41,5 @@ "repository": "algolia/algoliasearch-client-javascript",

"dependencies": {
"@algolia/client-common": "5.0.0-alpha.12",
"@algolia/requester-browser-xhr": "5.0.0-alpha.12",
"@algolia/requester-node-http": "5.0.0-alpha.12"
"@algolia/client-common": "5.0.0-alpha.13",
"@algolia/requester-browser-xhr": "5.0.0-alpha.13",
"@algolia/requester-node-http": "5.0.0-alpha.13"
},

@@ -46,0 +46,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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