@algolia/client-insights
Advanced tools
@@ -210,3 +210,3 @@ import * as _algolia_client_common from '@algolia/client-common'; | ||
| /** | ||
| * Click event after an Algolia request. Use this event to track when users click items in the search results. If you\'re building your category pages with Algolia, you\'ll also use this event. | ||
| * Click event after an Algolia request. Use this event to track when users click items in the search results. If you\'re building your category pages with Algolia, you\'ll also use this event. | ||
| */ | ||
@@ -578,3 +578,3 @@ type ClickedObjectIDsAfterSearch = { | ||
| declare const apiClientVersion = "5.47.0"; | ||
| declare const apiClientVersion = "5.48.0"; | ||
| declare const REGIONS: readonly ["de", "us"]; | ||
@@ -581,0 +581,0 @@ type Region = (typeof REGIONS)[number]; |
| // builds/browser.ts | ||
| import { createXhrRequester } from "@algolia/requester-browser-xhr"; | ||
| import { | ||
@@ -9,6 +8,7 @@ createBrowserLocalStorageCache, | ||
| } from "@algolia/client-common"; | ||
| import { createXhrRequester } from "@algolia/requester-browser-xhr"; | ||
| // src/insightsClient.ts | ||
| import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
| var apiClientVersion = "5.47.0"; | ||
| var apiClientVersion = "5.48.0"; | ||
| var REGIONS = ["de", "us"]; | ||
@@ -15,0 +15,0 @@ function getDefaultHosts(region) { |
@@ -1,2 +0,2 @@ | ||
| function H(){function r(e){return new Promise(s=>{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,o)=>setTimeout(()=>{t.abort(),s({status:0,content:o,isTimedOut:!0})},a),u=n(e.connectTimeout,"Connection timeout"),p;t.onreadystatechange=()=>{t.readyState>t.OPENED&&p===void 0&&(clearTimeout(u),p=n(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(u),clearTimeout(p),s({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(u),clearTimeout(p),s({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}function W(r){let e,s=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function n(){return JSON.parse(t().getItem(s)||"{}")}function u(a){t().setItem(s,JSON.stringify(a))}function p(){let a=r.timeToLive?r.timeToLive*1e3:null,o=n(),i=Object.fromEntries(Object.entries(o).filter(([,h])=>h.timestamp!==void 0));if(u(i),!a)return;let l=Object.fromEntries(Object.entries(i).filter(([,h])=>{let P=new Date().getTime();return!(h.timestamp+a<P)}));u(l)}return{get(a,o,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),n()[JSON.stringify(a)])).then(l=>Promise.all([l?l.value:o(),l!==void 0])).then(([l,h])=>Promise.all([l,h||i.miss(l)])).then(([l])=>l)},set(a,o){return Promise.resolve().then(()=>{let i=n();return i[JSON.stringify(a)]={timestamp:new Date().getTime(),value:o},t().setItem(s,JSON.stringify(i)),o})},delete(a){return Promise.resolve().then(()=>{let o=n();delete o[JSON.stringify(a)],t().setItem(s,JSON.stringify(o))})},clear(){return Promise.resolve().then(()=>{t().removeItem(s)})}}}function V(){return{get(r,e,s={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,s.miss(n)])).then(([n])=>n)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function x(r){let e=[...r.caches],s=e.shift();return s===void 0?V():{get(t,n,u={miss:()=>Promise.resolve()}){return s.get(t,n,u).catch(()=>x({caches:e}).get(t,n,u))},set(t,n){return s.set(t,n).catch(()=>x({caches:e}).set(t,n))},delete(t){return s.delete(t).catch(()=>x({caches:e}).delete(t))},clear(){return s.clear().catch(()=>x({caches:e}).clear())}}}function q(r={serializable:!0}){let e={};return{get(s,t,n={miss:()=>Promise.resolve()}){let u=JSON.stringify(s);if(u in e)return Promise.resolve(r.serializable?JSON.parse(e[u]):e[u]);let p=t();return p.then(a=>n.miss(a)).then(()=>p)},set(s,t){return e[JSON.stringify(s)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}function Y(r){let e={value:`Algolia for JavaScript (${r})`,add(s){let t=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function J(r,e,s="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return s==="WithinHeaders"?t:{}},queryParameters(){return s==="WithinQueryParameters"?t:{}}}}function z({algoliaAgents:r,client:e,version:s}){let t=Y(s).add({segment:e,version:s});return r.forEach(n=>t.add(n)),t}function M(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var $=120*1e3;function j(r,e="up"){let s=Date.now();function t(){return e==="up"||Date.now()-s>$}function n(){return e==="timed out"&&Date.now()-s<=$}return{...r,status:e,lastUpdate:s,isUp:t,isTimedOut:n}}var Q=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}};var G=class extends Q{stackTrace;constructor(r,e,s){super(r,s),this.stackTrace=e}},Z=class extends G{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please visit our help center https://alg.li/support-unreachable-hosts or reach out to the Algolia Support team: https://alg.li/support",r,"RetryError")}},I=class extends G{status;constructor(r,e,s,t="ApiError"){super(r,s,t),this.status=e}},ee=class extends Q{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},re=class extends I{error;constructor(r,e,s,t){super(r,e,t,"DetailedApiError"),this.error=s}};function te(r,e,s){let t=se(s),n=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(n+=`?${t}`),n}function se(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 oe(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let s=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(s)}function ne(r,e,s){let t={Accept:"application/json",...r,...e,...s},n={};return Object.keys(t).forEach(u=>{let p=t[u];n[u.toLowerCase()]=p}),n}function ae(r){try{return JSON.parse(r.content)}catch(e){throw new ee(e.message,r)}}function ie({content:r,status:e},s){try{let t=JSON.parse(r);return"error"in t?new re(t.message,e,t.error,s):new I(t.message,e,s)}catch{}return new I(r,e,s)}function ce({isTimedOut:r,status:e}){return!r&&~~e===0}function ue({isTimedOut:r,status:e}){return r||ce({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:r}){return~~(r/100)===2}function me(r){return r.map(e=>F(e))}function F(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 B({hosts:r,hostsCache:e,baseHeaders:s,logger:t,baseQueryParameters:n,algoliaAgent:u,timeouts:p,requester:a,requestsCache:o,responsesCache:i}){async function l(c){let m=await Promise.all(c.map(d=>e.get(d,()=>Promise.resolve(j(d))))),g=m.filter(d=>d.isUp()),y=m.filter(d=>d.isTimedOut()),w=[...g,...y];return{hosts:w.length>0?w:c,getTimeout(d,v){return(y.length===0&&d===0?1:y.length+3+d)*v}}}async function h(c,m,g){let y=[],w=oe(c,m),E=ne(s,c.headers,m.headers),d=c.method==="GET"?{...c.data,...m.data}:{},v={...n,...c.queryParameters,...d};if(u.value&&(v["x-algolia-agent"]=u.value),m&&m.queryParameters)for(let f of Object.keys(m.queryParameters))!m.queryParameters[f]||Object.prototype.toString.call(m.queryParameters[f])==="[object Object]"?v[f]=m.queryParameters[f]:v[f]=m.queryParameters[f].toString();let O=0,D=async(f,S)=>{let R=f.pop();if(R===void 0)throw new Z(me(y));let b={...p,...m.timeouts},_={data:w,headers:E,method:c.method,url:te(R,c.path,v),connectTimeout:S(O,b.connect),responseTimeout:S(O,g?b.read:b.write)},U=C=>{let L={request:_,response:C,host:R,triesLeft:f.length};return y.push(L),L},T=await a.send(_);if(ue(T)){let C=U(T);return T.isTimedOut&&O++,t.info("Retryable failure",F(C)),await e.set(R,j(R,T.isTimedOut?"timed out":"down")),D(f,S)}if(le(T))return ae(T);throw U(T),ie(T,y)},K=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),k=await l(K);return D([...k.hosts].reverse(),k.getTimeout)}function P(c,m={}){let g=()=>h(c,m,y),y=c.useReadTransporter||c.method==="GET";if((m.cacheable||c.cacheable)!==!0)return g();let E={request:c,requestOptions:m,transporter:{queryParameters:n,headers:s}};return i.get(E,()=>o.get(E,()=>o.set(E,g()).then(d=>Promise.all([o.delete(E),d]),d=>Promise.all([o.delete(E),Promise.reject(d)])).then(([d,v])=>v)),{miss:d=>i.set(E,d)})}return{hostsCache:e,requester:a,timeouts:p,logger:t,algoliaAgent:u,baseHeaders:s,baseQueryParameters:n,hosts:r,request:P,requestsCache:o,responsesCache:i}}var A="5.47.0",N=["de","us"];function de(r){return[{url:r?"insights.{region}.algolia.io".replace("{region}",r):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function X({appId:r,apiKey:e,authMode:s,algoliaAgents:t,region:n,...u}){let p=J(r,e,s),a=B({hosts:de(n),...u,algoliaAgent:z({algoliaAgents:t,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...p.headers(),...u.baseHeaders},baseQueryParameters:{...p.queryParameters(),...u.baseQueryParameters}});return{transporter:a,appId:r,apiKey:e,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(o,i){a.algoliaAgent.add({segment:o,version:i})},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=o:a.baseQueryParameters["x-algolia-api-key"]=o},customDelete({path:o,parameters:i},l){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let m={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(m,l)},customGet({path:o,parameters:i},l){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let m={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(m,l)},customPost({path:o,parameters:i,body:l},h){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:l||{}};return a.request(g,h)},customPut({path:o,parameters:i,body:l},h){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:l||{}};return a.request(g,h)},deleteUserToken({userToken:o},i){if(!o)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let c={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,i)},pushEvents(o,i){if(!o)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!o.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");let c={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:o};return a.request(c,i)}}}function er(r,e,s,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!N.includes(s)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return X({appId:r,apiKey:e,region:s,timeouts:{connect:1e3,read:2e3,write:3e4},logger:M(),requester:H(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:q(),requestsCache:q({serializable:!1}),hostsCache:x({caches:[W({key:`${A}-${r}`}),q()]}),...t})}export{A as apiClientVersion,er as insightsClient}; | ||
| function j(r){let e,s=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function n(){return JSON.parse(t().getItem(s)||"{}")}function u(a){t().setItem(s,JSON.stringify(a))}function p(){let a=r.timeToLive?r.timeToLive*1e3:null,o=n(),i=Object.fromEntries(Object.entries(o).filter(([,h])=>h.timestamp!==void 0));if(u(i),!a)return;let l=Object.fromEntries(Object.entries(i).filter(([,h])=>{let P=new Date().getTime();return!(h.timestamp+a<P)}));u(l)}return{get(a,o,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),n()[JSON.stringify(a)])).then(l=>Promise.all([l?l.value:o(),l!==void 0])).then(([l,h])=>Promise.all([l,h||i.miss(l)])).then(([l])=>l)},set(a,o){return Promise.resolve().then(()=>{let i=n();return i[JSON.stringify(a)]={timestamp:new Date().getTime(),value:o},t().setItem(s,JSON.stringify(i)),o})},delete(a){return Promise.resolve().then(()=>{let o=n();delete o[JSON.stringify(a)],t().setItem(s,JSON.stringify(o))})},clear(){return Promise.resolve().then(()=>{t().removeItem(s)})}}}function V(){return{get(r,e,s={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,s.miss(n)])).then(([n])=>n)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function x(r){let e=[...r.caches],s=e.shift();return s===void 0?V():{get(t,n,u={miss:()=>Promise.resolve()}){return s.get(t,n,u).catch(()=>x({caches:e}).get(t,n,u))},set(t,n){return s.set(t,n).catch(()=>x({caches:e}).set(t,n))},delete(t){return s.delete(t).catch(()=>x({caches:e}).delete(t))},clear(){return s.clear().catch(()=>x({caches:e}).clear())}}}function q(r={serializable:!0}){let e={};return{get(s,t,n={miss:()=>Promise.resolve()}){let u=JSON.stringify(s);if(u in e)return Promise.resolve(r.serializable?JSON.parse(e[u]):e[u]);let p=t();return p.then(a=>n.miss(a)).then(()=>p)},set(s,t){return e[JSON.stringify(s)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}function Y(r){let e={value:`Algolia for JavaScript (${r})`,add(s){let t=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function W(r,e,s="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return s==="WithinHeaders"?t:{}},queryParameters(){return s==="WithinQueryParameters"?t:{}}}}function J({algoliaAgents:r,client:e,version:s}){let t=Y(s).add({segment:e,version:s});return r.forEach(n=>t.add(n)),t}function z(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var H=120*1e3;function $(r,e="up"){let s=Date.now();function t(){return e==="up"||Date.now()-s>H}function n(){return e==="timed out"&&Date.now()-s<=H}return{...r,status:e,lastUpdate:s,isUp:t,isTimedOut:n}}var M=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}};var Q=class extends M{stackTrace;constructor(r,e,s){super(r,s),this.stackTrace=e}},Z=class extends Q{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please visit our help center https://alg.li/support-unreachable-hosts or reach out to the Algolia Support team: https://alg.li/support",r,"RetryError")}},I=class extends Q{status;constructor(r,e,s,t="ApiError"){super(r,s,t),this.status=e}},ee=class extends M{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},re=class extends I{error;constructor(r,e,s,t){super(r,e,t,"DetailedApiError"),this.error=s}};function te(r,e,s){let t=se(s),n=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(n+=`?${t}`),n}function se(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 oe(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let s=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(s)}function ne(r,e,s){let t={Accept:"application/json",...r,...e,...s},n={};return Object.keys(t).forEach(u=>{let p=t[u];n[u.toLowerCase()]=p}),n}function ae(r){try{return JSON.parse(r.content)}catch(e){throw new ee(e.message,r)}}function ie({content:r,status:e},s){try{let t=JSON.parse(r);return"error"in t?new re(t.message,e,t.error,s):new I(t.message,e,s)}catch{}return new I(r,e,s)}function ce({isTimedOut:r,status:e}){return!r&&~~e===0}function ue({isTimedOut:r,status:e}){return r||ce({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:r}){return~~(r/100)===2}function me(r){return r.map(e=>G(e))}function G(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 F({hosts:r,hostsCache:e,baseHeaders:s,logger:t,baseQueryParameters:n,algoliaAgent:u,timeouts:p,requester:a,requestsCache:o,responsesCache:i}){async function l(c){let m=await Promise.all(c.map(d=>e.get(d,()=>Promise.resolve($(d))))),g=m.filter(d=>d.isUp()),y=m.filter(d=>d.isTimedOut()),w=[...g,...y];return{hosts:w.length>0?w:c,getTimeout(d,v){return(y.length===0&&d===0?1:y.length+3+d)*v}}}async function h(c,m,g){let y=[],w=oe(c,m),E=ne(s,c.headers,m.headers),d=c.method==="GET"?{...c.data,...m.data}:{},v={...n,...c.queryParameters,...d};if(u.value&&(v["x-algolia-agent"]=u.value),m&&m.queryParameters)for(let f of Object.keys(m.queryParameters))!m.queryParameters[f]||Object.prototype.toString.call(m.queryParameters[f])==="[object Object]"?v[f]=m.queryParameters[f]:v[f]=m.queryParameters[f].toString();let O=0,D=async(f,S)=>{let R=f.pop();if(R===void 0)throw new Z(me(y));let b={...p,...m.timeouts},_={data:w,headers:E,method:c.method,url:te(R,c.path,v),connectTimeout:S(O,b.connect),responseTimeout:S(O,g?b.read:b.write)},U=C=>{let L={request:_,response:C,host:R,triesLeft:f.length};return y.push(L),L},T=await a.send(_);if(ue(T)){let C=U(T);return T.isTimedOut&&O++,t.info("Retryable failure",G(C)),await e.set(R,$(R,T.isTimedOut?"timed out":"down")),D(f,S)}if(le(T))return ae(T);throw U(T),ie(T,y)},K=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),k=await l(K);return D([...k.hosts].reverse(),k.getTimeout)}function P(c,m={}){let g=()=>h(c,m,y),y=c.useReadTransporter||c.method==="GET";if((m.cacheable||c.cacheable)!==!0)return g();let E={request:c,requestOptions:m,transporter:{queryParameters:n,headers:s}};return i.get(E,()=>o.get(E,()=>o.set(E,g()).then(d=>Promise.all([o.delete(E),d]),d=>Promise.all([o.delete(E),Promise.reject(d)])).then(([d,v])=>v)),{miss:d=>i.set(E,d)})}return{hostsCache:e,requester:a,timeouts:p,logger:t,algoliaAgent:u,baseHeaders:s,baseQueryParameters:n,hosts:r,request:P,requestsCache:o,responsesCache:i}}function B(){function r(e){return new Promise(s=>{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,o)=>setTimeout(()=>{t.abort(),s({status:0,content:o,isTimedOut:!0})},a),u=n(e.connectTimeout,"Connection timeout"),p;t.onreadystatechange=()=>{t.readyState>t.OPENED&&p===void 0&&(clearTimeout(u),p=n(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(u),clearTimeout(p),s({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(u),clearTimeout(p),s({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}var A="5.48.0",N=["de","us"];function de(r){return[{url:r?"insights.{region}.algolia.io".replace("{region}",r):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function X({appId:r,apiKey:e,authMode:s,algoliaAgents:t,region:n,...u}){let p=W(r,e,s),a=F({hosts:de(n),...u,algoliaAgent:J({algoliaAgents:t,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...p.headers(),...u.baseHeaders},baseQueryParameters:{...p.queryParameters(),...u.baseQueryParameters}});return{transporter:a,appId:r,apiKey:e,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(o,i){a.algoliaAgent.add({segment:o,version:i})},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=o:a.baseQueryParameters["x-algolia-api-key"]=o},customDelete({path:o,parameters:i},l){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let m={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(m,l)},customGet({path:o,parameters:i},l){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let m={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(m,l)},customPost({path:o,parameters:i,body:l},h){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:l||{}};return a.request(g,h)},customPut({path:o,parameters:i,body:l},h){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:l||{}};return a.request(g,h)},deleteUserToken({userToken:o},i){if(!o)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let c={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,i)},pushEvents(o,i){if(!o)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!o.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");let c={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:o};return a.request(c,i)}}}function er(r,e,s,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!N.includes(s)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return X({appId:r,apiKey:e,region:s,timeouts:{connect:1e3,read:2e3,write:3e4},logger:z(),requester:B(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:q(),requestsCache:q({serializable:!1}),hostsCache:x({caches:[j({key:`${A}-${r}`}),q()]}),...t})}export{A as apiClientVersion,er as insightsClient}; | ||
| //# sourceMappingURL=browser.min.js.map |
@@ -7,3 +7,3 @@ (function (global, factory) { | ||
| function H(){function r(e){return new Promise(s=>{let t=new XMLHttpRequest;t.open(e.method,e.url,true),Object.keys(e.headers).forEach(a=>t.setRequestHeader(a,e.headers[a]));let n=(a,o)=>setTimeout(()=>{t.abort(),s({status:0,content:o,isTimedOut:true});},a),u=n(e.connectTimeout,"Connection timeout"),p;t.onreadystatechange=()=>{t.readyState>t.OPENED&&p===void 0&&(clearTimeout(u),p=n(e.responseTimeout,"Socket timeout"));},t.onerror=()=>{t.status===0&&(clearTimeout(u),clearTimeout(p),s({content:t.responseText||"Network request failed",status:t.status,isTimedOut:false}));},t.onload=()=>{clearTimeout(u),clearTimeout(p),s({content:t.responseText,status:t.status,isTimedOut:false});},t.send(e.data);})}return {send:r}}function W(r){let e,s=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function n(){return JSON.parse(t().getItem(s)||"{}")}function u(a){t().setItem(s,JSON.stringify(a));}function p(){let a=r.timeToLive?r.timeToLive*1e3:null,o=n(),i=Object.fromEntries(Object.entries(o).filter(([,h])=>h.timestamp!==void 0));if(u(i),!a)return;let l=Object.fromEntries(Object.entries(i).filter(([,h])=>{let P=new Date().getTime();return !(h.timestamp+a<P)}));u(l);}return {get(a,o,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),n()[JSON.stringify(a)])).then(l=>Promise.all([l?l.value:o(),l!==void 0])).then(([l,h])=>Promise.all([l,h||i.miss(l)])).then(([l])=>l)},set(a,o){return Promise.resolve().then(()=>{let i=n();return i[JSON.stringify(a)]={timestamp:new Date().getTime(),value:o},t().setItem(s,JSON.stringify(i)),o})},delete(a){return Promise.resolve().then(()=>{let o=n();delete o[JSON.stringify(a)],t().setItem(s,JSON.stringify(o));})},clear(){return Promise.resolve().then(()=>{t().removeItem(s);})}}}function V(){return {get(r,e,s={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,s.miss(n)])).then(([n])=>n)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function x(r){let e=[...r.caches],s=e.shift();return s===void 0?V():{get(t,n,u={miss:()=>Promise.resolve()}){return s.get(t,n,u).catch(()=>x({caches:e}).get(t,n,u))},set(t,n){return s.set(t,n).catch(()=>x({caches:e}).set(t,n))},delete(t){return s.delete(t).catch(()=>x({caches:e}).delete(t))},clear(){return s.clear().catch(()=>x({caches:e}).clear())}}}function q(r={serializable:true}){let e={};return {get(s,t,n={miss:()=>Promise.resolve()}){let u=JSON.stringify(s);if(u in e)return Promise.resolve(r.serializable?JSON.parse(e[u]):e[u]);let p=t();return p.then(a=>n.miss(a)).then(()=>p)},set(s,t){return e[JSON.stringify(s)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}function Y(r){let e={value:`Algolia for JavaScript (${r})`,add(s){let t=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function J(r,e,s="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return {headers(){return s==="WithinHeaders"?t:{}},queryParameters(){return s==="WithinQueryParameters"?t:{}}}}function z({algoliaAgents:r,client:e,version:s}){let t=Y(s).add({segment:e,version:s});return r.forEach(n=>t.add(n)),t}function M(){return {debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var $=120*1e3;function j(r,e="up"){let s=Date.now();function t(){return e==="up"||Date.now()-s>$}function n(){return e==="timed out"&&Date.now()-s<=$}return {...r,status:e,lastUpdate:s,isUp:t,isTimedOut:n}}var Q=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e);}};var G=class extends Q{stackTrace;constructor(r,e,s){super(r,s),this.stackTrace=e;}},Z=class extends G{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please visit our help center https://alg.li/support-unreachable-hosts or reach out to the Algolia Support team: https://alg.li/support",r,"RetryError");}},I=class extends G{status;constructor(r,e,s,t="ApiError"){super(r,s,t),this.status=e;}},ee=class extends Q{response;constructor(r,e){super(r,"DeserializationError"),this.response=e;}},re=class extends I{error;constructor(r,e,s,t){super(r,e,t,"DetailedApiError"),this.error=s;}};function te(r,e,s){let t=se(s),n=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(n+=`?${t}`),n}function se(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 oe(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let s=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(s)}function ne(r,e,s){let t={Accept:"application/json",...r,...e,...s},n={};return Object.keys(t).forEach(u=>{let p=t[u];n[u.toLowerCase()]=p;}),n}function ae(r){try{return JSON.parse(r.content)}catch(e){throw new ee(e.message,r)}}function ie({content:r,status:e},s){try{let t=JSON.parse(r);return "error"in t?new re(t.message,e,t.error,s):new I(t.message,e,s)}catch{}return new I(r,e,s)}function ce({isTimedOut:r,status:e}){return !r&&~~e===0}function ue({isTimedOut:r,status:e}){return r||ce({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:r}){return ~~(r/100)===2}function me(r){return r.map(e=>F(e))}function F(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 B({hosts:r,hostsCache:e,baseHeaders:s,logger:t,baseQueryParameters:n,algoliaAgent:u,timeouts:p,requester:a,requestsCache:o,responsesCache:i}){async function l(c){let m=await Promise.all(c.map(d=>e.get(d,()=>Promise.resolve(j(d))))),g=m.filter(d=>d.isUp()),y=m.filter(d=>d.isTimedOut()),w=[...g,...y];return {hosts:w.length>0?w:c,getTimeout(d,v){return (y.length===0&&d===0?1:y.length+3+d)*v}}}async function h(c,m,g){let y=[],w=oe(c,m),E=ne(s,c.headers,m.headers),d=c.method==="GET"?{...c.data,...m.data}:{},v={...n,...c.queryParameters,...d};if(u.value&&(v["x-algolia-agent"]=u.value),m&&m.queryParameters)for(let f of Object.keys(m.queryParameters))!m.queryParameters[f]||Object.prototype.toString.call(m.queryParameters[f])==="[object Object]"?v[f]=m.queryParameters[f]:v[f]=m.queryParameters[f].toString();let O=0,D=async(f,S)=>{let R=f.pop();if(R===void 0)throw new Z(me(y));let b={...p,...m.timeouts},_={data:w,headers:E,method:c.method,url:te(R,c.path,v),connectTimeout:S(O,b.connect),responseTimeout:S(O,g?b.read:b.write)},U=C=>{let L={request:_,response:C,host:R,triesLeft:f.length};return y.push(L),L},T=await a.send(_);if(ue(T)){let C=U(T);return T.isTimedOut&&O++,t.info("Retryable failure",F(C)),await e.set(R,j(R,T.isTimedOut?"timed out":"down")),D(f,S)}if(le(T))return ae(T);throw U(T),ie(T,y)},K=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),k=await l(K);return D([...k.hosts].reverse(),k.getTimeout)}function P(c,m={}){let g=()=>h(c,m,y),y=c.useReadTransporter||c.method==="GET";if((m.cacheable||c.cacheable)!==true)return g();let E={request:c,requestOptions:m,transporter:{queryParameters:n,headers:s}};return i.get(E,()=>o.get(E,()=>o.set(E,g()).then(d=>Promise.all([o.delete(E),d]),d=>Promise.all([o.delete(E),Promise.reject(d)])).then(([d,v])=>v)),{miss:d=>i.set(E,d)})}return {hostsCache:e,requester:a,timeouts:p,logger:t,algoliaAgent:u,baseHeaders:s,baseQueryParameters:n,hosts:r,request:P,requestsCache:o,responsesCache:i}}var A="5.47.0",N=["de","us"];function de(r){return [{url:r?"insights.{region}.algolia.io".replace("{region}",r):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function X({appId:r,apiKey:e,authMode:s,algoliaAgents:t,region:n,...u}){let p=J(r,e,s),a=B({hosts:de(n),...u,algoliaAgent:z({algoliaAgents:t,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...p.headers(),...u.baseHeaders},baseQueryParameters:{...p.queryParameters(),...u.baseQueryParameters}});return {transporter:a,appId:r,apiKey:e,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(o,i){a.algoliaAgent.add({segment:o,version:i});},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=o:a.baseQueryParameters["x-algolia-api-key"]=o;},customDelete({path:o,parameters:i},l){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let m={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(m,l)},customGet({path:o,parameters:i},l){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let m={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(m,l)},customPost({path:o,parameters:i,body:l},h){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:l||{}};return a.request(g,h)},customPut({path:o,parameters:i,body:l},h){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:l||{}};return a.request(g,h)},deleteUserToken({userToken:o},i){if(!o)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let c={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,i)},pushEvents(o,i){if(!o)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!o.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");let c={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:o};return a.request(c,i)}}}function er(r,e,s,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!N.includes(s)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return X({appId:r,apiKey:e,region:s,timeouts:{connect:1e3,read:2e3,write:3e4},logger:M(),requester:H(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:q(),requestsCache:q({serializable:false}),hostsCache:x({caches:[W({key:`${A}-${r}`}),q()]}),...t})} | ||
| function j(r){let e,s=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function n(){return JSON.parse(t().getItem(s)||"{}")}function u(a){t().setItem(s,JSON.stringify(a));}function p(){let a=r.timeToLive?r.timeToLive*1e3:null,o=n(),i=Object.fromEntries(Object.entries(o).filter(([,h])=>h.timestamp!==void 0));if(u(i),!a)return;let l=Object.fromEntries(Object.entries(i).filter(([,h])=>{let P=new Date().getTime();return !(h.timestamp+a<P)}));u(l);}return {get(a,o,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),n()[JSON.stringify(a)])).then(l=>Promise.all([l?l.value:o(),l!==void 0])).then(([l,h])=>Promise.all([l,h||i.miss(l)])).then(([l])=>l)},set(a,o){return Promise.resolve().then(()=>{let i=n();return i[JSON.stringify(a)]={timestamp:new Date().getTime(),value:o},t().setItem(s,JSON.stringify(i)),o})},delete(a){return Promise.resolve().then(()=>{let o=n();delete o[JSON.stringify(a)],t().setItem(s,JSON.stringify(o));})},clear(){return Promise.resolve().then(()=>{t().removeItem(s);})}}}function V(){return {get(r,e,s={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,s.miss(n)])).then(([n])=>n)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function x(r){let e=[...r.caches],s=e.shift();return s===void 0?V():{get(t,n,u={miss:()=>Promise.resolve()}){return s.get(t,n,u).catch(()=>x({caches:e}).get(t,n,u))},set(t,n){return s.set(t,n).catch(()=>x({caches:e}).set(t,n))},delete(t){return s.delete(t).catch(()=>x({caches:e}).delete(t))},clear(){return s.clear().catch(()=>x({caches:e}).clear())}}}function q(r={serializable:true}){let e={};return {get(s,t,n={miss:()=>Promise.resolve()}){let u=JSON.stringify(s);if(u in e)return Promise.resolve(r.serializable?JSON.parse(e[u]):e[u]);let p=t();return p.then(a=>n.miss(a)).then(()=>p)},set(s,t){return e[JSON.stringify(s)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}function Y(r){let e={value:`Algolia for JavaScript (${r})`,add(s){let t=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function W(r,e,s="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return {headers(){return s==="WithinHeaders"?t:{}},queryParameters(){return s==="WithinQueryParameters"?t:{}}}}function J({algoliaAgents:r,client:e,version:s}){let t=Y(s).add({segment:e,version:s});return r.forEach(n=>t.add(n)),t}function z(){return {debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var H=120*1e3;function $(r,e="up"){let s=Date.now();function t(){return e==="up"||Date.now()-s>H}function n(){return e==="timed out"&&Date.now()-s<=H}return {...r,status:e,lastUpdate:s,isUp:t,isTimedOut:n}}var M=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e);}};var Q=class extends M{stackTrace;constructor(r,e,s){super(r,s),this.stackTrace=e;}},Z=class extends Q{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please visit our help center https://alg.li/support-unreachable-hosts or reach out to the Algolia Support team: https://alg.li/support",r,"RetryError");}},I=class extends Q{status;constructor(r,e,s,t="ApiError"){super(r,s,t),this.status=e;}},ee=class extends M{response;constructor(r,e){super(r,"DeserializationError"),this.response=e;}},re=class extends I{error;constructor(r,e,s,t){super(r,e,t,"DetailedApiError"),this.error=s;}};function te(r,e,s){let t=se(s),n=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(n+=`?${t}`),n}function se(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 oe(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let s=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(s)}function ne(r,e,s){let t={Accept:"application/json",...r,...e,...s},n={};return Object.keys(t).forEach(u=>{let p=t[u];n[u.toLowerCase()]=p;}),n}function ae(r){try{return JSON.parse(r.content)}catch(e){throw new ee(e.message,r)}}function ie({content:r,status:e},s){try{let t=JSON.parse(r);return "error"in t?new re(t.message,e,t.error,s):new I(t.message,e,s)}catch{}return new I(r,e,s)}function ce({isTimedOut:r,status:e}){return !r&&~~e===0}function ue({isTimedOut:r,status:e}){return r||ce({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:r}){return ~~(r/100)===2}function me(r){return r.map(e=>G(e))}function G(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 F({hosts:r,hostsCache:e,baseHeaders:s,logger:t,baseQueryParameters:n,algoliaAgent:u,timeouts:p,requester:a,requestsCache:o,responsesCache:i}){async function l(c){let m=await Promise.all(c.map(d=>e.get(d,()=>Promise.resolve($(d))))),g=m.filter(d=>d.isUp()),y=m.filter(d=>d.isTimedOut()),w=[...g,...y];return {hosts:w.length>0?w:c,getTimeout(d,v){return (y.length===0&&d===0?1:y.length+3+d)*v}}}async function h(c,m,g){let y=[],w=oe(c,m),E=ne(s,c.headers,m.headers),d=c.method==="GET"?{...c.data,...m.data}:{},v={...n,...c.queryParameters,...d};if(u.value&&(v["x-algolia-agent"]=u.value),m&&m.queryParameters)for(let f of Object.keys(m.queryParameters))!m.queryParameters[f]||Object.prototype.toString.call(m.queryParameters[f])==="[object Object]"?v[f]=m.queryParameters[f]:v[f]=m.queryParameters[f].toString();let O=0,D=async(f,S)=>{let R=f.pop();if(R===void 0)throw new Z(me(y));let b={...p,...m.timeouts},_={data:w,headers:E,method:c.method,url:te(R,c.path,v),connectTimeout:S(O,b.connect),responseTimeout:S(O,g?b.read:b.write)},U=C=>{let L={request:_,response:C,host:R,triesLeft:f.length};return y.push(L),L},T=await a.send(_);if(ue(T)){let C=U(T);return T.isTimedOut&&O++,t.info("Retryable failure",G(C)),await e.set(R,$(R,T.isTimedOut?"timed out":"down")),D(f,S)}if(le(T))return ae(T);throw U(T),ie(T,y)},K=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),k=await l(K);return D([...k.hosts].reverse(),k.getTimeout)}function P(c,m={}){let g=()=>h(c,m,y),y=c.useReadTransporter||c.method==="GET";if((m.cacheable||c.cacheable)!==true)return g();let E={request:c,requestOptions:m,transporter:{queryParameters:n,headers:s}};return i.get(E,()=>o.get(E,()=>o.set(E,g()).then(d=>Promise.all([o.delete(E),d]),d=>Promise.all([o.delete(E),Promise.reject(d)])).then(([d,v])=>v)),{miss:d=>i.set(E,d)})}return {hostsCache:e,requester:a,timeouts:p,logger:t,algoliaAgent:u,baseHeaders:s,baseQueryParameters:n,hosts:r,request:P,requestsCache:o,responsesCache:i}}function B(){function r(e){return new Promise(s=>{let t=new XMLHttpRequest;t.open(e.method,e.url,true),Object.keys(e.headers).forEach(a=>t.setRequestHeader(a,e.headers[a]));let n=(a,o)=>setTimeout(()=>{t.abort(),s({status:0,content:o,isTimedOut:true});},a),u=n(e.connectTimeout,"Connection timeout"),p;t.onreadystatechange=()=>{t.readyState>t.OPENED&&p===void 0&&(clearTimeout(u),p=n(e.responseTimeout,"Socket timeout"));},t.onerror=()=>{t.status===0&&(clearTimeout(u),clearTimeout(p),s({content:t.responseText||"Network request failed",status:t.status,isTimedOut:false}));},t.onload=()=>{clearTimeout(u),clearTimeout(p),s({content:t.responseText,status:t.status,isTimedOut:false});},t.send(e.data);})}return {send:r}}var A="5.48.0",N=["de","us"];function de(r){return [{url:r?"insights.{region}.algolia.io".replace("{region}",r):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function X({appId:r,apiKey:e,authMode:s,algoliaAgents:t,region:n,...u}){let p=W(r,e,s),a=F({hosts:de(n),...u,algoliaAgent:J({algoliaAgents:t,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...p.headers(),...u.baseHeaders},baseQueryParameters:{...p.queryParameters(),...u.baseQueryParameters}});return {transporter:a,appId:r,apiKey:e,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(o,i){a.algoliaAgent.add({segment:o,version:i});},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=o:a.baseQueryParameters["x-algolia-api-key"]=o;},customDelete({path:o,parameters:i},l){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let m={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(m,l)},customGet({path:o,parameters:i},l){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let m={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(m,l)},customPost({path:o,parameters:i,body:l},h){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:l||{}};return a.request(g,h)},customPut({path:o,parameters:i,body:l},h){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:l||{}};return a.request(g,h)},deleteUserToken({userToken:o},i){if(!o)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let c={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,i)},pushEvents(o,i){if(!o)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!o.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");let c={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:o};return a.request(c,i)}}}function er(r,e,s,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!N.includes(s)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return X({appId:r,apiKey:e,region:s,timeouts:{connect:1e3,read:2e3,write:3e4},logger:z(),requester:B(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:q(),requestsCache:q({serializable:false}),hostsCache:x({caches:[j({key:`${A}-${r}`}),q()]}),...t})} | ||
@@ -10,0 +10,0 @@ exports.apiClientVersion = A; |
@@ -7,3 +7,3 @@ // builds/fetch.ts | ||
| import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
| var apiClientVersion = "5.47.0"; | ||
| var apiClientVersion = "5.48.0"; | ||
| var REGIONS = ["de", "us"]; | ||
@@ -10,0 +10,0 @@ function getDefaultHosts(region) { |
@@ -27,8 +27,8 @@ "use strict"; | ||
| module.exports = __toCommonJS(node_exports); | ||
| var import_client_common2 = require("@algolia/client-common"); | ||
| var import_requester_node_http = require("@algolia/requester-node-http"); | ||
| var import_client_common2 = require("@algolia/client-common"); | ||
| // src/insightsClient.ts | ||
| var import_client_common = require("@algolia/client-common"); | ||
| var apiClientVersion = "5.47.0"; | ||
| var apiClientVersion = "5.48.0"; | ||
| var REGIONS = ["de", "us"]; | ||
@@ -35,0 +35,0 @@ function getDefaultHosts(region) { |
| // builds/node.ts | ||
| import { createMemoryCache, createNullCache, createNullLogger } from "@algolia/client-common"; | ||
| import { createHttpRequester } from "@algolia/requester-node-http"; | ||
| import { createMemoryCache, createNullCache, createNullLogger } from "@algolia/client-common"; | ||
| // src/insightsClient.ts | ||
| import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
| var apiClientVersion = "5.47.0"; | ||
| var apiClientVersion = "5.48.0"; | ||
| var REGIONS = ["de", "us"]; | ||
@@ -9,0 +9,0 @@ function getDefaultHosts(region) { |
@@ -7,3 +7,3 @@ // builds/worker.ts | ||
| import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
| var apiClientVersion = "5.47.0"; | ||
| var apiClientVersion = "5.48.0"; | ||
| var REGIONS = ["de", "us"]; | ||
@@ -10,0 +10,0 @@ function getDefaultHosts(region) { |
+2
-2
@@ -210,3 +210,3 @@ import * as _algolia_client_common from '@algolia/client-common'; | ||
| /** | ||
| * Click event after an Algolia request. Use this event to track when users click items in the search results. If you\'re building your category pages with Algolia, you\'ll also use this event. | ||
| * Click event after an Algolia request. Use this event to track when users click items in the search results. If you\'re building your category pages with Algolia, you\'ll also use this event. | ||
| */ | ||
@@ -578,3 +578,3 @@ type ClickedObjectIDsAfterSearch = { | ||
| declare const apiClientVersion = "5.47.0"; | ||
| declare const apiClientVersion = "5.48.0"; | ||
| declare const REGIONS: readonly ["de", "us"]; | ||
@@ -581,0 +581,0 @@ type Region = (typeof REGIONS)[number]; |
+2
-2
@@ -210,3 +210,3 @@ import * as _algolia_client_common from '@algolia/client-common'; | ||
| /** | ||
| * Click event after an Algolia request. Use this event to track when users click items in the search results. If you\'re building your category pages with Algolia, you\'ll also use this event. | ||
| * Click event after an Algolia request. Use this event to track when users click items in the search results. If you\'re building your category pages with Algolia, you\'ll also use this event. | ||
| */ | ||
@@ -578,3 +578,3 @@ type ClickedObjectIDsAfterSearch = { | ||
| declare const apiClientVersion = "5.47.0"; | ||
| declare const apiClientVersion = "5.48.0"; | ||
| declare const REGIONS: readonly ["de", "us"]; | ||
@@ -581,0 +581,0 @@ type Region = (typeof REGIONS)[number]; |
+2
-2
@@ -210,3 +210,3 @@ import * as _algolia_client_common from '@algolia/client-common'; | ||
| /** | ||
| * Click event after an Algolia request. Use this event to track when users click items in the search results. If you\'re building your category pages with Algolia, you\'ll also use this event. | ||
| * Click event after an Algolia request. Use this event to track when users click items in the search results. If you\'re building your category pages with Algolia, you\'ll also use this event. | ||
| */ | ||
@@ -578,3 +578,3 @@ type ClickedObjectIDsAfterSearch = { | ||
| declare const apiClientVersion = "5.47.0"; | ||
| declare const apiClientVersion = "5.48.0"; | ||
| declare const REGIONS: readonly ["de", "us"]; | ||
@@ -581,0 +581,0 @@ type Region = (typeof REGIONS)[number]; |
@@ -29,3 +29,3 @@ "use strict"; | ||
| var import_client_common = require("@algolia/client-common"); | ||
| var apiClientVersion = "5.47.0"; | ||
| var apiClientVersion = "5.48.0"; | ||
| var REGIONS = ["de", "us"]; | ||
@@ -32,0 +32,0 @@ function getDefaultHosts(region) { |
| // src/insightsClient.ts | ||
| import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
| var apiClientVersion = "5.47.0"; | ||
| var apiClientVersion = "5.48.0"; | ||
| var REGIONS = ["de", "us"]; | ||
@@ -5,0 +5,0 @@ function getDefaultHosts(region) { |
+2
-2
@@ -210,3 +210,3 @@ import * as _algolia_client_common from '@algolia/client-common'; | ||
| /** | ||
| * Click event after an Algolia request. Use this event to track when users click items in the search results. If you\'re building your category pages with Algolia, you\'ll also use this event. | ||
| * Click event after an Algolia request. Use this event to track when users click items in the search results. If you\'re building your category pages with Algolia, you\'ll also use this event. | ||
| */ | ||
@@ -578,3 +578,3 @@ type ClickedObjectIDsAfterSearch = { | ||
| declare const apiClientVersion = "5.47.0"; | ||
| declare const apiClientVersion = "5.48.0"; | ||
| declare const REGIONS: readonly ["de", "us"]; | ||
@@ -581,0 +581,0 @@ type Region = (typeof REGIONS)[number]; |
+9
-9
| { | ||
| "version": "5.47.0", | ||
| "version": "5.48.0", | ||
| "repository": { | ||
@@ -52,12 +52,12 @@ "type": "git", | ||
| "dependencies": { | ||
| "@algolia/client-common": "5.47.0", | ||
| "@algolia/requester-browser-xhr": "5.47.0", | ||
| "@algolia/requester-fetch": "5.47.0", | ||
| "@algolia/requester-node-http": "5.47.0" | ||
| "@algolia/client-common": "5.48.0", | ||
| "@algolia/requester-browser-xhr": "5.48.0", | ||
| "@algolia/requester-fetch": "5.48.0", | ||
| "@algolia/requester-node-http": "5.48.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@arethetypeswrong/cli": "0.18.2", | ||
| "@types/node": "25.0.9", | ||
| "publint": "0.3.16", | ||
| "rollup": "4.55.1", | ||
| "@types/node": "25.1.0", | ||
| "publint": "0.3.17", | ||
| "rollup": "4.57.1", | ||
| "tsup": "8.5.1", | ||
@@ -69,3 +69,3 @@ "typescript": "5.9.3" | ||
| }, | ||
| "gitHead": "b6446940f6aac85b3963268cc33ddad0f2b99c37" | ||
| "gitHead": "b39976bd859ef66e65d2db182d69853a91a71139" | ||
| } |
+4
-4
@@ -43,7 +43,7 @@ <p align="center"> | ||
| ```bash | ||
| yarn add @algolia/client-insights@5.47.0 | ||
| yarn add @algolia/client-insights@5.48.0 | ||
| # or | ||
| npm install @algolia/client-insights@5.47.0 | ||
| npm install @algolia/client-insights@5.48.0 | ||
| # or | ||
| pnpm add @algolia/client-insights@5.47.0 | ||
| pnpm add @algolia/client-insights@5.48.0 | ||
| ``` | ||
@@ -56,3 +56,3 @@ | ||
| ```html | ||
| <script src="https://cdn.jsdelivr.net/npm/@algolia/client-insights@5.47.0/dist/builds/browser.umd.js"></script> | ||
| <script src="https://cdn.jsdelivr.net/npm/@algolia/client-insights@5.48.0/dist/builds/browser.umd.js"></script> | ||
| ``` | ||
@@ -59,0 +59,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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
444446
0+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed