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

@algolia/client-insights

Package Overview
Dependencies
Maintainers
3
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/client-insights - npm Package Compare versions

Comparing version 5.8.1 to 5.9.0

9

dist/browser.d.ts

@@ -577,8 +577,9 @@ import * as _algolia_client_common from '@algolia/client-common';

declare const apiClientVersion = "5.8.1";
declare const apiClientVersion = "5.9.0";
declare const REGIONS: readonly ["de", "us"];
type Region = (typeof REGIONS)[number];
declare function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & {
type RegionOptions = {
region?: Region;
}): {
};
declare function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & RegionOptions): {
transporter: _algolia_client_common.Transporter;

@@ -672,2 +673,2 @@ /**

export { type AddToCartEvent, type AddedToCartObjectIDs, type AddedToCartObjectIDsAfterSearch, type ClickEvent, type ClickedFilters, type ClickedObjectIDs, type ClickedObjectIDsAfterSearch, type ConversionEvent, type ConvertedFilters, type ConvertedObjectIDs, type ConvertedObjectIDsAfterSearch, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type DeleteUserTokenProps, type Discount, type ErrorBase, type EventsItems, type EventsResponse, type InsightsClient, type InsightsEvents, type ObjectData, type ObjectDataAfterSearch, type Price, type PurchaseEvent, type PurchasedObjectIDs, type PurchasedObjectIDsAfterSearch, type Region, type Value, type ViewEvent, type ViewedFilters, type ViewedObjectIDs, apiClientVersion, insightsClient };
export { type AddToCartEvent, type AddedToCartObjectIDs, type AddedToCartObjectIDsAfterSearch, type ClickEvent, type ClickedFilters, type ClickedObjectIDs, type ClickedObjectIDsAfterSearch, type ConversionEvent, type ConvertedFilters, type ConvertedObjectIDs, type ConvertedObjectIDsAfterSearch, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type DeleteUserTokenProps, type Discount, type ErrorBase, type EventsItems, type EventsResponse, type InsightsClient, type InsightsEvents, type ObjectData, type ObjectDataAfterSearch, type Price, type PurchaseEvent, type PurchasedObjectIDs, type PurchasedObjectIDsAfterSearch, type Region, type RegionOptions, type Value, type ViewEvent, type ViewedFilters, type ViewedObjectIDs, apiClientVersion, insightsClient };

@@ -15,3 +15,3 @@ // builds/browser.ts

import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.8.1";
var apiClientVersion = "5.9.0";
var REGIONS = ["de", "us"];

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

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

function W(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>t.setRequestHeader(a,e.headers[a]));let n=(a,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0})},a),l=n(e.connectTimeout,"Connection timeout"),h;t.onreadystatechange=()=>{t.readyState>t.OPENED&&h===void 0&&(clearTimeout(l),h=n(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(l),clearTimeout(h),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(l),clearTimeout(h),o({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}function j(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function n(){return JSON.parse(t().getItem(o)||"{}")}function l(a){t().setItem(o,JSON.stringify(a))}function h(){let a=r.timeToLive?r.timeToLive*1e3:null,s=n(),i=Object.fromEntries(Object.entries(s).filter(([,p])=>p.timestamp!==void 0));if(l(i),!a)return;let m=Object.fromEntries(Object.entries(i).filter(([,p])=>{let E=new Date().getTime();return!(p.timestamp+a<E)}));l(m)}return{get(a,s,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(h(),n()[JSON.stringify(a)])).then(m=>Promise.all([m?m.value:s(),m!==void 0])).then(([m,p])=>Promise.all([m,p||i.miss(m)])).then(([m])=>m)},set(a,s){return Promise.resolve().then(()=>{let i=n();return i[JSON.stringify(a)]={timestamp:new Date().getTime(),value:s},t().setItem(o,JSON.stringify(i)),s})},delete(a){return Promise.resolve().then(()=>{let s=n();delete s[JSON.stringify(a)],t().setItem(o,JSON.stringify(s))})},clear(){return Promise.resolve().then(()=>{t().removeItem(o)})}}}function ee(){return{get(r,e,o={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,o.miss(n)])).then(([n])=>n)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function R(r){let e=[...r.caches],o=e.shift();return o===void 0?ee():{get(t,n,l={miss:()=>Promise.resolve()}){return o.get(t,n,l).catch(()=>R({caches:e}).get(t,n,l))},set(t,n){return o.set(t,n).catch(()=>R({caches:e}).set(t,n))},delete(t){return o.delete(t).catch(()=>R({caches:e}).delete(t))},clear(){return o.clear().catch(()=>R({caches:e}).clear())}}}function q(r={serializable:!0}){let e={};return{get(o,t,n={miss:()=>Promise.resolve()}){let l=JSON.stringify(o);if(l in e)return Promise.resolve(r.serializable?JSON.parse(e[l]):e[l]);let h=t();return h.then(a=>n.miss(a)).then(()=>h)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var J=1e3,M=2e3,z=3e4;function re(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function Q(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function F({algoliaAgents:r,client:e,version:o}){let t=re(o).add({segment:e,version:o});return r.forEach(n=>t.add(n)),t}function G(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var H=2*60*1e3;function $(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>H}function n(){return e==="timed out"&&Date.now()-o<=H}return{...r,status:e,lastUpdate:o,isUp:t,isTimedOut:n}}var B=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}},X=class extends B{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e}},te=class extends X{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",r,"RetryError")}},_=class extends X{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e}},oe=class extends B{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},se=class extends _{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o}};function ne(r,e,o){let t=ae(o),n=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(n+=`?${t}`),n}function ae(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function ie(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function ce(r,e,o){let t={Accept:"application/json",...r,...e,...o},n={};return Object.keys(t).forEach(l=>{let h=t[l];n[l.toLowerCase()]=h}),n}function ue(r){try{return JSON.parse(r.content)}catch(e){throw new oe(e.message,r)}}function le({content:r,status:e},o){try{let t=JSON.parse(r);return"error"in t?new se(t.message,e,t.error,o):new _(t.message,e,o)}catch{}return new _(r,e,o)}function me({isTimedOut:r,status:e}){return!r&&~~e===0}function de({isTimedOut:r,status:e}){return r||me({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function he({status:r}){return~~(r/100)===2}function pe(r){return r.map(e=>K(e))}function K(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function V({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:n,algoliaAgent:l,timeouts:h,requester:a,requestsCache:s,responsesCache:i}){async function m(c){let u=await Promise.all(c.map(d=>e.get(d,()=>Promise.resolve($(d))))),g=u.filter(d=>d.isUp()),P=u.filter(d=>d.isTimedOut()),w=[...g,...P];return{hosts:w.length>0?w:c,getTimeout(d,T){return(P.length===0&&d===0?1:P.length+3+d)*T}}}async function p(c,u,g=!0){let P=[],w=ie(c,u),y=ce(o,c.headers,u.headers),d=c.method==="GET"?{...c.data,...u.data}:{},T={...n,...c.queryParameters,...d};if(l.value&&(T["x-algolia-agent"]=l.value),u&&u.queryParameters)for(let f of Object.keys(u.queryParameters))!u.queryParameters[f]||Object.prototype.toString.call(u.queryParameters[f])==="[object Object]"?T[f]=u.queryParameters[f]:T[f]=u.queryParameters[f].toString();let x=0,D=async(f,S)=>{let O=f.pop();if(O===void 0)throw new te(pe(P));let C={...h,...u.timeouts},k={data:w,headers:y,method:c.method,url:ne(O,c.path,T),connectTimeout:S(x,C.connect),responseTimeout:S(x,g?C.read:C.write)},U=b=>{let L={request:k,response:b,host:O,triesLeft:f.length};return P.push(L),L},v=await a.send(k);if(de(v)){let b=U(v);return v.isTimedOut&&x++,t.info("Retryable failure",K(b)),await e.set(O,$(O,v.isTimedOut?"timed out":"down")),D(f,S)}if(he(v))return ue(v);throw U(v),le(v,P)},Z=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),I=await m(Z);return D([...I.hosts].reverse(),I.getTimeout)}function E(c,u={}){let g=c.useReadTransporter||c.method==="GET";if(!g)return p(c,u,g);let P=()=>p(c,u);if((u.cacheable||c.cacheable)!==!0)return P();let y={request:c,requestOptions:u,transporter:{queryParameters:n,headers:o}};return i.get(y,()=>s.get(y,()=>s.set(y,P()).then(d=>Promise.all([s.delete(y),d]),d=>Promise.all([s.delete(y),Promise.reject(d)])).then(([d,T])=>T)),{miss:d=>i.set(y,d)})}return{hostsCache:e,requester:a,timeouts:h,logger:t,algoliaAgent:l,baseHeaders:o,baseQueryParameters:n,hosts:r,request:E,requestsCache:s,responsesCache:i}}var A="5.8.1",N=["de","us"];function fe(r){return[{url:r?"insights.{region}.algolia.io".replace("{region}",r):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function Y({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:n,...l}){let h=Q(r,e,o),a=V({hosts:fe(n),...l,algoliaAgent:F({algoliaAgents:t,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...h.headers(),...l.baseHeaders},baseQueryParameters:{...h.queryParameters(),...l.baseQueryParameters}});return{transporter:a,appId:r,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(s,i){a.algoliaAgent.add({segment:s,version:i})},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=s:a.baseQueryParameters["x-algolia-api-key"]=s},customDelete({path:s,parameters:i},m){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let u={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return a.request(u,m)},customGet({path:s,parameters:i},m){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let u={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return a.request(u,m)},customPost({path:s,parameters:i,body:m},p){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:m||{}};return a.request(g,p)},customPut({path:s,parameters:i,body:m},p){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:m||{}};return a.request(g,p)},deleteUserToken({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let c={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(c,i)},pushEvents(s,i){if(!s)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!s.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");let c={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:s};return a.request(c,i)}}}function nr(r,e,o,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(o&&(typeof o!="string"||!N.includes(o)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return Y({appId:r,apiKey:e,region:o,timeouts:{connect:J,read:M,write:z},logger:G(),requester:W(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:q(),requestsCache:q({serializable:!1}),hostsCache:R({caches:[j({key:`${A}-${r}`}),q()]}),...t})}export{A as apiClientVersion,nr as insightsClient};
function W(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>t.setRequestHeader(a,e.headers[a]));let n=(a,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0})},a),l=n(e.connectTimeout,"Connection timeout"),h;t.onreadystatechange=()=>{t.readyState>t.OPENED&&h===void 0&&(clearTimeout(l),h=n(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(l),clearTimeout(h),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(l),clearTimeout(h),o({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}function j(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function n(){return JSON.parse(t().getItem(o)||"{}")}function l(a){t().setItem(o,JSON.stringify(a))}function h(){let a=r.timeToLive?r.timeToLive*1e3:null,s=n(),i=Object.fromEntries(Object.entries(s).filter(([,p])=>p.timestamp!==void 0));if(l(i),!a)return;let m=Object.fromEntries(Object.entries(i).filter(([,p])=>{let E=new Date().getTime();return!(p.timestamp+a<E)}));l(m)}return{get(a,s,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(h(),n()[JSON.stringify(a)])).then(m=>Promise.all([m?m.value:s(),m!==void 0])).then(([m,p])=>Promise.all([m,p||i.miss(m)])).then(([m])=>m)},set(a,s){return Promise.resolve().then(()=>{let i=n();return i[JSON.stringify(a)]={timestamp:new Date().getTime(),value:s},t().setItem(o,JSON.stringify(i)),s})},delete(a){return Promise.resolve().then(()=>{let s=n();delete s[JSON.stringify(a)],t().setItem(o,JSON.stringify(s))})},clear(){return Promise.resolve().then(()=>{t().removeItem(o)})}}}function ee(){return{get(r,e,o={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,o.miss(n)])).then(([n])=>n)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function R(r){let e=[...r.caches],o=e.shift();return o===void 0?ee():{get(t,n,l={miss:()=>Promise.resolve()}){return o.get(t,n,l).catch(()=>R({caches:e}).get(t,n,l))},set(t,n){return o.set(t,n).catch(()=>R({caches:e}).set(t,n))},delete(t){return o.delete(t).catch(()=>R({caches:e}).delete(t))},clear(){return o.clear().catch(()=>R({caches:e}).clear())}}}function q(r={serializable:!0}){let e={};return{get(o,t,n={miss:()=>Promise.resolve()}){let l=JSON.stringify(o);if(l in e)return Promise.resolve(r.serializable?JSON.parse(e[l]):e[l]);let h=t();return h.then(a=>n.miss(a)).then(()=>h)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var J=1e3,M=2e3,z=3e4;function re(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function Q(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function F({algoliaAgents:r,client:e,version:o}){let t=re(o).add({segment:e,version:o});return r.forEach(n=>t.add(n)),t}function G(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var H=2*60*1e3;function $(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>H}function n(){return e==="timed out"&&Date.now()-o<=H}return{...r,status:e,lastUpdate:o,isUp:t,isTimedOut:n}}var B=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}},X=class extends B{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e}},te=class extends X{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",r,"RetryError")}},_=class extends X{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e}},oe=class extends B{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},se=class extends _{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o}};function ne(r,e,o){let t=ae(o),n=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(n+=`?${t}`),n}function ae(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function ie(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function ce(r,e,o){let t={Accept:"application/json",...r,...e,...o},n={};return Object.keys(t).forEach(l=>{let h=t[l];n[l.toLowerCase()]=h}),n}function ue(r){try{return JSON.parse(r.content)}catch(e){throw new oe(e.message,r)}}function le({content:r,status:e},o){try{let t=JSON.parse(r);return"error"in t?new se(t.message,e,t.error,o):new _(t.message,e,o)}catch{}return new _(r,e,o)}function me({isTimedOut:r,status:e}){return!r&&~~e===0}function de({isTimedOut:r,status:e}){return r||me({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function he({status:r}){return~~(r/100)===2}function pe(r){return r.map(e=>K(e))}function K(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function V({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:n,algoliaAgent:l,timeouts:h,requester:a,requestsCache:s,responsesCache:i}){async function m(c){let u=await Promise.all(c.map(d=>e.get(d,()=>Promise.resolve($(d))))),g=u.filter(d=>d.isUp()),P=u.filter(d=>d.isTimedOut()),w=[...g,...P];return{hosts:w.length>0?w:c,getTimeout(d,T){return(P.length===0&&d===0?1:P.length+3+d)*T}}}async function p(c,u,g=!0){let P=[],w=ie(c,u),y=ce(o,c.headers,u.headers),d=c.method==="GET"?{...c.data,...u.data}:{},T={...n,...c.queryParameters,...d};if(l.value&&(T["x-algolia-agent"]=l.value),u&&u.queryParameters)for(let f of Object.keys(u.queryParameters))!u.queryParameters[f]||Object.prototype.toString.call(u.queryParameters[f])==="[object Object]"?T[f]=u.queryParameters[f]:T[f]=u.queryParameters[f].toString();let x=0,D=async(f,S)=>{let O=f.pop();if(O===void 0)throw new te(pe(P));let C={...h,...u.timeouts},k={data:w,headers:y,method:c.method,url:ne(O,c.path,T),connectTimeout:S(x,C.connect),responseTimeout:S(x,g?C.read:C.write)},U=b=>{let L={request:k,response:b,host:O,triesLeft:f.length};return P.push(L),L},v=await a.send(k);if(de(v)){let b=U(v);return v.isTimedOut&&x++,t.info("Retryable failure",K(b)),await e.set(O,$(O,v.isTimedOut?"timed out":"down")),D(f,S)}if(he(v))return ue(v);throw U(v),le(v,P)},Z=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),I=await m(Z);return D([...I.hosts].reverse(),I.getTimeout)}function E(c,u={}){let g=c.useReadTransporter||c.method==="GET";if(!g)return p(c,u,g);let P=()=>p(c,u);if((u.cacheable||c.cacheable)!==!0)return P();let y={request:c,requestOptions:u,transporter:{queryParameters:n,headers:o}};return i.get(y,()=>s.get(y,()=>s.set(y,P()).then(d=>Promise.all([s.delete(y),d]),d=>Promise.all([s.delete(y),Promise.reject(d)])).then(([d,T])=>T)),{miss:d=>i.set(y,d)})}return{hostsCache:e,requester:a,timeouts:h,logger:t,algoliaAgent:l,baseHeaders:o,baseQueryParameters:n,hosts:r,request:E,requestsCache:s,responsesCache:i}}var A="5.9.0",N=["de","us"];function fe(r){return[{url:r?"insights.{region}.algolia.io".replace("{region}",r):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function Y({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:n,...l}){let h=Q(r,e,o),a=V({hosts:fe(n),...l,algoliaAgent:F({algoliaAgents:t,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...h.headers(),...l.baseHeaders},baseQueryParameters:{...h.queryParameters(),...l.baseQueryParameters}});return{transporter:a,appId:r,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(s,i){a.algoliaAgent.add({segment:s,version:i})},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=s:a.baseQueryParameters["x-algolia-api-key"]=s},customDelete({path:s,parameters:i},m){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let u={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return a.request(u,m)},customGet({path:s,parameters:i},m){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let u={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return a.request(u,m)},customPost({path:s,parameters:i,body:m},p){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:m||{}};return a.request(g,p)},customPut({path:s,parameters:i,body:m},p){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:m||{}};return a.request(g,p)},deleteUserToken({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let c={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(c,i)},pushEvents(s,i){if(!s)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!s.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");let c={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:s};return a.request(c,i)}}}function nr(r,e,o,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(o&&(typeof o!="string"||!N.includes(o)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return Y({appId:r,apiKey:e,region:o,timeouts:{connect:J,read:M,write:z},logger:G(),requester:W(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:q(),requestsCache:q({serializable:!1}),hostsCache:R({caches:[j({key:`${A}-${r}`}),q()]}),...t})}export{A as apiClientVersion,nr as insightsClient};
//# sourceMappingURL=browser.min.js.map

@@ -7,3 +7,3 @@ (function (global, factory) {

function W(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>t.setRequestHeader(a,e.headers[a]));let n=(a,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0});},a),l=n(e.connectTimeout,"Connection timeout"),h;t.onreadystatechange=()=>{t.readyState>t.OPENED&&h===void 0&&(clearTimeout(l),h=n(e.responseTimeout,"Socket timeout"));},t.onerror=()=>{t.status===0&&(clearTimeout(l),clearTimeout(h),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}));},t.onload=()=>{clearTimeout(l),clearTimeout(h),o({content:t.responseText,status:t.status,isTimedOut:!1});},t.send(e.data);})}return {send:r}}function j(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function n(){return JSON.parse(t().getItem(o)||"{}")}function l(a){t().setItem(o,JSON.stringify(a));}function h(){let a=r.timeToLive?r.timeToLive*1e3:null,s=n(),i=Object.fromEntries(Object.entries(s).filter(([,p])=>p.timestamp!==void 0));if(l(i),!a)return;let m=Object.fromEntries(Object.entries(i).filter(([,p])=>{let E=new Date().getTime();return !(p.timestamp+a<E)}));l(m);}return {get(a,s,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(h(),n()[JSON.stringify(a)])).then(m=>Promise.all([m?m.value:s(),m!==void 0])).then(([m,p])=>Promise.all([m,p||i.miss(m)])).then(([m])=>m)},set(a,s){return Promise.resolve().then(()=>{let i=n();return i[JSON.stringify(a)]={timestamp:new Date().getTime(),value:s},t().setItem(o,JSON.stringify(i)),s})},delete(a){return Promise.resolve().then(()=>{let s=n();delete s[JSON.stringify(a)],t().setItem(o,JSON.stringify(s));})},clear(){return Promise.resolve().then(()=>{t().removeItem(o);})}}}function ee(){return {get(r,e,o={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,o.miss(n)])).then(([n])=>n)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function R(r){let e=[...r.caches],o=e.shift();return o===void 0?ee():{get(t,n,l={miss:()=>Promise.resolve()}){return o.get(t,n,l).catch(()=>R({caches:e}).get(t,n,l))},set(t,n){return o.set(t,n).catch(()=>R({caches:e}).set(t,n))},delete(t){return o.delete(t).catch(()=>R({caches:e}).delete(t))},clear(){return o.clear().catch(()=>R({caches:e}).clear())}}}function q(r={serializable:!0}){let e={};return {get(o,t,n={miss:()=>Promise.resolve()}){let l=JSON.stringify(o);if(l in e)return Promise.resolve(r.serializable?JSON.parse(e[l]):e[l]);let h=t();return h.then(a=>n.miss(a)).then(()=>h)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var J=1e3,M=2e3,z=3e4;function re(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function Q(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return {headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function F({algoliaAgents:r,client:e,version:o}){let t=re(o).add({segment:e,version:o});return r.forEach(n=>t.add(n)),t}function G(){return {debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var H=2*60*1e3;function $(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>H}function n(){return e==="timed out"&&Date.now()-o<=H}return {...r,status:e,lastUpdate:o,isUp:t,isTimedOut:n}}var B=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e);}},X=class extends B{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e;}},te=class extends X{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",r,"RetryError");}},_=class extends X{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e;}},oe=class extends B{response;constructor(r,e){super(r,"DeserializationError"),this.response=e;}},se=class extends _{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o;}};function ne(r,e,o){let t=ae(o),n=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(n+=`?${t}`),n}function ae(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function ie(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function ce(r,e,o){let t={Accept:"application/json",...r,...e,...o},n={};return Object.keys(t).forEach(l=>{let h=t[l];n[l.toLowerCase()]=h;}),n}function ue(r){try{return JSON.parse(r.content)}catch(e){throw new oe(e.message,r)}}function le({content:r,status:e},o){try{let t=JSON.parse(r);return "error"in t?new se(t.message,e,t.error,o):new _(t.message,e,o)}catch{}return new _(r,e,o)}function me({isTimedOut:r,status:e}){return !r&&~~e===0}function de({isTimedOut:r,status:e}){return r||me({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function he({status:r}){return ~~(r/100)===2}function pe(r){return r.map(e=>K(e))}function K(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function V({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:n,algoliaAgent:l,timeouts:h,requester:a,requestsCache:s,responsesCache:i}){async function m(c){let u=await Promise.all(c.map(d=>e.get(d,()=>Promise.resolve($(d))))),g=u.filter(d=>d.isUp()),P=u.filter(d=>d.isTimedOut()),w=[...g,...P];return {hosts:w.length>0?w:c,getTimeout(d,T){return (P.length===0&&d===0?1:P.length+3+d)*T}}}async function p(c,u,g=!0){let P=[],w=ie(c,u),y=ce(o,c.headers,u.headers),d=c.method==="GET"?{...c.data,...u.data}:{},T={...n,...c.queryParameters,...d};if(l.value&&(T["x-algolia-agent"]=l.value),u&&u.queryParameters)for(let f of Object.keys(u.queryParameters))!u.queryParameters[f]||Object.prototype.toString.call(u.queryParameters[f])==="[object Object]"?T[f]=u.queryParameters[f]:T[f]=u.queryParameters[f].toString();let x=0,D=async(f,S)=>{let O=f.pop();if(O===void 0)throw new te(pe(P));let C={...h,...u.timeouts},k={data:w,headers:y,method:c.method,url:ne(O,c.path,T),connectTimeout:S(x,C.connect),responseTimeout:S(x,g?C.read:C.write)},U=b=>{let L={request:k,response:b,host:O,triesLeft:f.length};return P.push(L),L},v=await a.send(k);if(de(v)){let b=U(v);return v.isTimedOut&&x++,t.info("Retryable failure",K(b)),await e.set(O,$(O,v.isTimedOut?"timed out":"down")),D(f,S)}if(he(v))return ue(v);throw U(v),le(v,P)},Z=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),I=await m(Z);return D([...I.hosts].reverse(),I.getTimeout)}function E(c,u={}){let g=c.useReadTransporter||c.method==="GET";if(!g)return p(c,u,g);let P=()=>p(c,u);if((u.cacheable||c.cacheable)!==!0)return P();let y={request:c,requestOptions:u,transporter:{queryParameters:n,headers:o}};return i.get(y,()=>s.get(y,()=>s.set(y,P()).then(d=>Promise.all([s.delete(y),d]),d=>Promise.all([s.delete(y),Promise.reject(d)])).then(([d,T])=>T)),{miss:d=>i.set(y,d)})}return {hostsCache:e,requester:a,timeouts:h,logger:t,algoliaAgent:l,baseHeaders:o,baseQueryParameters:n,hosts:r,request:E,requestsCache:s,responsesCache:i}}var A="5.8.1",N=["de","us"];function fe(r){return [{url:r?"insights.{region}.algolia.io".replace("{region}",r):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function Y({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:n,...l}){let h=Q(r,e,o),a=V({hosts:fe(n),...l,algoliaAgent:F({algoliaAgents:t,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...h.headers(),...l.baseHeaders},baseQueryParameters:{...h.queryParameters(),...l.baseQueryParameters}});return {transporter:a,appId:r,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(s,i){a.algoliaAgent.add({segment:s,version:i});},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=s:a.baseQueryParameters["x-algolia-api-key"]=s;},customDelete({path:s,parameters:i},m){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let u={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return a.request(u,m)},customGet({path:s,parameters:i},m){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let u={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return a.request(u,m)},customPost({path:s,parameters:i,body:m},p){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:m||{}};return a.request(g,p)},customPut({path:s,parameters:i,body:m},p){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:m||{}};return a.request(g,p)},deleteUserToken({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let c={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(c,i)},pushEvents(s,i){if(!s)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!s.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");let c={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:s};return a.request(c,i)}}}function nr(r,e,o,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(o&&(typeof o!="string"||!N.includes(o)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return Y({appId:r,apiKey:e,region:o,timeouts:{connect:J,read:M,write:z},logger:G(),requester:W(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:q(),requestsCache:q({serializable:!1}),hostsCache:R({caches:[j({key:`${A}-${r}`}),q()]}),...t})}
function W(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>t.setRequestHeader(a,e.headers[a]));let n=(a,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0});},a),l=n(e.connectTimeout,"Connection timeout"),h;t.onreadystatechange=()=>{t.readyState>t.OPENED&&h===void 0&&(clearTimeout(l),h=n(e.responseTimeout,"Socket timeout"));},t.onerror=()=>{t.status===0&&(clearTimeout(l),clearTimeout(h),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}));},t.onload=()=>{clearTimeout(l),clearTimeout(h),o({content:t.responseText,status:t.status,isTimedOut:!1});},t.send(e.data);})}return {send:r}}function j(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function n(){return JSON.parse(t().getItem(o)||"{}")}function l(a){t().setItem(o,JSON.stringify(a));}function h(){let a=r.timeToLive?r.timeToLive*1e3:null,s=n(),i=Object.fromEntries(Object.entries(s).filter(([,p])=>p.timestamp!==void 0));if(l(i),!a)return;let m=Object.fromEntries(Object.entries(i).filter(([,p])=>{let E=new Date().getTime();return !(p.timestamp+a<E)}));l(m);}return {get(a,s,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(h(),n()[JSON.stringify(a)])).then(m=>Promise.all([m?m.value:s(),m!==void 0])).then(([m,p])=>Promise.all([m,p||i.miss(m)])).then(([m])=>m)},set(a,s){return Promise.resolve().then(()=>{let i=n();return i[JSON.stringify(a)]={timestamp:new Date().getTime(),value:s},t().setItem(o,JSON.stringify(i)),s})},delete(a){return Promise.resolve().then(()=>{let s=n();delete s[JSON.stringify(a)],t().setItem(o,JSON.stringify(s));})},clear(){return Promise.resolve().then(()=>{t().removeItem(o);})}}}function ee(){return {get(r,e,o={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,o.miss(n)])).then(([n])=>n)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function R(r){let e=[...r.caches],o=e.shift();return o===void 0?ee():{get(t,n,l={miss:()=>Promise.resolve()}){return o.get(t,n,l).catch(()=>R({caches:e}).get(t,n,l))},set(t,n){return o.set(t,n).catch(()=>R({caches:e}).set(t,n))},delete(t){return o.delete(t).catch(()=>R({caches:e}).delete(t))},clear(){return o.clear().catch(()=>R({caches:e}).clear())}}}function q(r={serializable:!0}){let e={};return {get(o,t,n={miss:()=>Promise.resolve()}){let l=JSON.stringify(o);if(l in e)return Promise.resolve(r.serializable?JSON.parse(e[l]):e[l]);let h=t();return h.then(a=>n.miss(a)).then(()=>h)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var J=1e3,M=2e3,z=3e4;function re(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function Q(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return {headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function F({algoliaAgents:r,client:e,version:o}){let t=re(o).add({segment:e,version:o});return r.forEach(n=>t.add(n)),t}function G(){return {debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var H=2*60*1e3;function $(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>H}function n(){return e==="timed out"&&Date.now()-o<=H}return {...r,status:e,lastUpdate:o,isUp:t,isTimedOut:n}}var B=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e);}},X=class extends B{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e;}},te=class extends X{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",r,"RetryError");}},_=class extends X{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e;}},oe=class extends B{response;constructor(r,e){super(r,"DeserializationError"),this.response=e;}},se=class extends _{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o;}};function ne(r,e,o){let t=ae(o),n=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(n+=`?${t}`),n}function ae(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function ie(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function ce(r,e,o){let t={Accept:"application/json",...r,...e,...o},n={};return Object.keys(t).forEach(l=>{let h=t[l];n[l.toLowerCase()]=h;}),n}function ue(r){try{return JSON.parse(r.content)}catch(e){throw new oe(e.message,r)}}function le({content:r,status:e},o){try{let t=JSON.parse(r);return "error"in t?new se(t.message,e,t.error,o):new _(t.message,e,o)}catch{}return new _(r,e,o)}function me({isTimedOut:r,status:e}){return !r&&~~e===0}function de({isTimedOut:r,status:e}){return r||me({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function he({status:r}){return ~~(r/100)===2}function pe(r){return r.map(e=>K(e))}function K(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function V({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:n,algoliaAgent:l,timeouts:h,requester:a,requestsCache:s,responsesCache:i}){async function m(c){let u=await Promise.all(c.map(d=>e.get(d,()=>Promise.resolve($(d))))),g=u.filter(d=>d.isUp()),P=u.filter(d=>d.isTimedOut()),w=[...g,...P];return {hosts:w.length>0?w:c,getTimeout(d,T){return (P.length===0&&d===0?1:P.length+3+d)*T}}}async function p(c,u,g=!0){let P=[],w=ie(c,u),y=ce(o,c.headers,u.headers),d=c.method==="GET"?{...c.data,...u.data}:{},T={...n,...c.queryParameters,...d};if(l.value&&(T["x-algolia-agent"]=l.value),u&&u.queryParameters)for(let f of Object.keys(u.queryParameters))!u.queryParameters[f]||Object.prototype.toString.call(u.queryParameters[f])==="[object Object]"?T[f]=u.queryParameters[f]:T[f]=u.queryParameters[f].toString();let x=0,D=async(f,S)=>{let O=f.pop();if(O===void 0)throw new te(pe(P));let C={...h,...u.timeouts},k={data:w,headers:y,method:c.method,url:ne(O,c.path,T),connectTimeout:S(x,C.connect),responseTimeout:S(x,g?C.read:C.write)},U=b=>{let L={request:k,response:b,host:O,triesLeft:f.length};return P.push(L),L},v=await a.send(k);if(de(v)){let b=U(v);return v.isTimedOut&&x++,t.info("Retryable failure",K(b)),await e.set(O,$(O,v.isTimedOut?"timed out":"down")),D(f,S)}if(he(v))return ue(v);throw U(v),le(v,P)},Z=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),I=await m(Z);return D([...I.hosts].reverse(),I.getTimeout)}function E(c,u={}){let g=c.useReadTransporter||c.method==="GET";if(!g)return p(c,u,g);let P=()=>p(c,u);if((u.cacheable||c.cacheable)!==!0)return P();let y={request:c,requestOptions:u,transporter:{queryParameters:n,headers:o}};return i.get(y,()=>s.get(y,()=>s.set(y,P()).then(d=>Promise.all([s.delete(y),d]),d=>Promise.all([s.delete(y),Promise.reject(d)])).then(([d,T])=>T)),{miss:d=>i.set(y,d)})}return {hostsCache:e,requester:a,timeouts:h,logger:t,algoliaAgent:l,baseHeaders:o,baseQueryParameters:n,hosts:r,request:E,requestsCache:s,responsesCache:i}}var A="5.9.0",N=["de","us"];function fe(r){return [{url:r?"insights.{region}.algolia.io".replace("{region}",r):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function Y({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:n,...l}){let h=Q(r,e,o),a=V({hosts:fe(n),...l,algoliaAgent:F({algoliaAgents:t,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...h.headers(),...l.baseHeaders},baseQueryParameters:{...h.queryParameters(),...l.baseQueryParameters}});return {transporter:a,appId:r,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(s,i){a.algoliaAgent.add({segment:s,version:i});},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=s:a.baseQueryParameters["x-algolia-api-key"]=s;},customDelete({path:s,parameters:i},m){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let u={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return a.request(u,m)},customGet({path:s,parameters:i},m){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let u={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return a.request(u,m)},customPost({path:s,parameters:i,body:m},p){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:m||{}};return a.request(g,p)},customPut({path:s,parameters:i,body:m},p){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:m||{}};return a.request(g,p)},deleteUserToken({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let c={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(c,i)},pushEvents(s,i){if(!s)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!s.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");let c={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:s};return a.request(c,i)}}}function nr(r,e,o,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(o&&(typeof o!="string"||!N.includes(o)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return Y({appId:r,apiKey:e,region:o,timeouts:{connect:J,read:M,write:z},logger:G(),requester:W(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:q(),requestsCache:q({serializable:!1}),hostsCache:R({caches:[j({key:`${A}-${r}`}),q()]}),...t})}

@@ -10,0 +10,0 @@ exports.apiClientVersion = A;

@@ -14,3 +14,3 @@ // builds/fetch.ts

import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.8.1";
var apiClientVersion = "5.9.0";
var REGIONS = ["de", "us"];

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

@@ -14,3 +14,3 @@ // builds/node.ts

import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.8.1";
var apiClientVersion = "5.9.0";
var REGIONS = ["de", "us"];

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

@@ -577,8 +577,9 @@ import * as _algolia_client_common from '@algolia/client-common';

declare const apiClientVersion = "5.8.1";
declare const apiClientVersion = "5.9.0";
declare const REGIONS: readonly ["de", "us"];
type Region = (typeof REGIONS)[number];
declare function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & {
type RegionOptions = {
region?: Region;
}): {
};
declare function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & RegionOptions): {
transporter: _algolia_client_common.Transporter;

@@ -673,2 +674,2 @@ /**

export { type AddToCartEvent, type AddedToCartObjectIDs, type AddedToCartObjectIDsAfterSearch, type ClickEvent, type ClickedFilters, type ClickedObjectIDs, type ClickedObjectIDsAfterSearch, type ConversionEvent, type ConvertedFilters, type ConvertedObjectIDs, type ConvertedObjectIDsAfterSearch, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type DeleteUserTokenProps, type Discount, type ErrorBase, type EventsItems, type EventsResponse, type InsightsClient, type InsightsEvents, type ObjectData, type ObjectDataAfterSearch, type Price, type PurchaseEvent, type PurchasedObjectIDs, type PurchasedObjectIDsAfterSearch, type Region, type Value, type ViewEvent, type ViewedFilters, type ViewedObjectIDs, apiClientVersion, insightsClient };
export { type AddToCartEvent, type AddedToCartObjectIDs, type AddedToCartObjectIDsAfterSearch, type ClickEvent, type ClickedFilters, type ClickedObjectIDs, type ClickedObjectIDsAfterSearch, type ConversionEvent, type ConvertedFilters, type ConvertedObjectIDs, type ConvertedObjectIDsAfterSearch, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type DeleteUserTokenProps, type Discount, type ErrorBase, type EventsItems, type EventsResponse, type InsightsClient, type InsightsEvents, type ObjectData, type ObjectDataAfterSearch, type Price, type PurchaseEvent, type PurchasedObjectIDs, type PurchasedObjectIDsAfterSearch, type Region, type RegionOptions, type Value, type ViewEvent, type ViewedFilters, type ViewedObjectIDs, apiClientVersion, insightsClient };

@@ -577,8 +577,9 @@ import * as _algolia_client_common from '@algolia/client-common';

declare const apiClientVersion = "5.8.1";
declare const apiClientVersion = "5.9.0";
declare const REGIONS: readonly ["de", "us"];
type Region = (typeof REGIONS)[number];
declare function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & {
type RegionOptions = {
region?: Region;
}): {
};
declare function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & RegionOptions): {
transporter: _algolia_client_common.Transporter;

@@ -673,2 +674,2 @@ /**

export { type AddToCartEvent, type AddedToCartObjectIDs, type AddedToCartObjectIDsAfterSearch, type ClickEvent, type ClickedFilters, type ClickedObjectIDs, type ClickedObjectIDsAfterSearch, type ConversionEvent, type ConvertedFilters, type ConvertedObjectIDs, type ConvertedObjectIDsAfterSearch, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type DeleteUserTokenProps, type Discount, type ErrorBase, type EventsItems, type EventsResponse, type InsightsClient, type InsightsEvents, type ObjectData, type ObjectDataAfterSearch, type Price, type PurchaseEvent, type PurchasedObjectIDs, type PurchasedObjectIDsAfterSearch, type Region, type Value, type ViewEvent, type ViewedFilters, type ViewedObjectIDs, apiClientVersion, insightsClient };
export { type AddToCartEvent, type AddedToCartObjectIDs, type AddedToCartObjectIDsAfterSearch, type ClickEvent, type ClickedFilters, type ClickedObjectIDs, type ClickedObjectIDsAfterSearch, type ConversionEvent, type ConvertedFilters, type ConvertedObjectIDs, type ConvertedObjectIDsAfterSearch, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type DeleteUserTokenProps, type Discount, type ErrorBase, type EventsItems, type EventsResponse, type InsightsClient, type InsightsEvents, type ObjectData, type ObjectDataAfterSearch, type Price, type PurchaseEvent, type PurchasedObjectIDs, type PurchasedObjectIDsAfterSearch, type Region, type RegionOptions, type Value, type ViewEvent, type ViewedFilters, type ViewedObjectIDs, apiClientVersion, insightsClient };
// src/insightsClient.ts
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.8.1";
var apiClientVersion = "5.9.0";
var REGIONS = ["de", "us"];

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

{
"version": "5.8.1",
"version": "5.9.0",
"repository": {

@@ -52,14 +52,14 @@ "type": "git",

"dependencies": {
"@algolia/client-common": "5.8.1",
"@algolia/requester-browser-xhr": "5.8.1",
"@algolia/requester-fetch": "5.8.1",
"@algolia/requester-node-http": "5.8.1"
"@algolia/client-common": "5.9.0",
"@algolia/requester-browser-xhr": "5.9.0",
"@algolia/requester-fetch": "5.9.0",
"@algolia/requester-node-http": "5.9.0"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.4",
"@types/node": "22.7.4",
"@types/node": "22.7.5",
"publint": "0.2.11",
"rollup": "4.24.0",
"tsup": "8.3.0",
"typescript": "5.6.2"
"typescript": "5.6.3"
},

@@ -66,0 +66,0 @@ "engines": {

@@ -35,2 +35,5 @@ <p align="center">

> [!TIP]
> This API client is already a dependency of [the algoliasearch client](https://www.npmjs.com/package/algoliasearch), you don't need to manually install `@algolia/client-insights` if you already have `algoliasearch` installed.
To get started, you first need to install @algolia/client-insights (or any other available API client package).

@@ -42,7 +45,7 @@ All of our clients comes with type definition, and are available for both browser and node environments.

```bash
yarn add @algolia/client-insights@5.8.1
yarn add @algolia/client-insights@5.9.0
# or
npm install @algolia/client-insights@5.8.1
npm install @algolia/client-insights@5.9.0
# or
pnpm add @algolia/client-insights@5.8.1
pnpm add @algolia/client-insights@5.9.0
```

@@ -55,3 +58,3 @@

```html
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-insights@5.8.1/dist/builds/browser.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-insights@5.9.0/dist/builds/browser.umd.js"></script>
```

@@ -58,0 +61,0 @@

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 not supported yet

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 not supported yet

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 not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc