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

@algolia/client-abtesting

Package Overview
Dependencies
Maintainers
85
Versions
163
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/client-abtesting - npm Package Compare versions

Comparing version 5.8.1 to 5.9.0

13

dist/browser.d.ts

@@ -44,3 +44,3 @@ import * as _algolia_client_common from '@algolia/client-common';

type ABTestConfiguration = {
outliers: Outliers;
outliers?: Outliers;
emptySearch?: EmptySearch;

@@ -148,3 +148,3 @@ minimumDetectableEffect?: MinimumDetectableEffect;

*/
description: string;
description?: string;
/**

@@ -443,8 +443,9 @@ * Estimated number of searches required to achieve the desired statistical significance. The A/B test configuration must include a `mininmumDetectableEffect` setting for this number to be included in the response.

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 createAbtestingClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & {
type RegionOptions = {
region?: Region;
}): {
};
declare function createAbtestingClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & RegionOptions): {
transporter: _algolia_client_common.Transporter;

@@ -586,2 +587,2 @@ /**

export { type ABTest, type ABTestConfiguration, type ABTestResponse, type AbTestsVariant, type AbTestsVariantSearchParams, type AbtestingClient, type AddABTestsRequest, type AddABTestsVariant, type Currency, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type CustomSearchParams, type DeleteABTestProps, type Effect, type EmptySearch, type EmptySearchFilter, type ErrorBase, type FilterEffects, type GetABTestProps, type ListABTestsProps, type ListABTestsResponse, type MinimumDetectableEffect, type Outliers, type OutliersFilter, type Region, type ScheduleABTestResponse, type ScheduleABTestsRequest, type Status, type StopABTestProps, type Variant, abtestingClient, apiClientVersion };
export { type ABTest, type ABTestConfiguration, type ABTestResponse, type AbTestsVariant, type AbTestsVariantSearchParams, type AbtestingClient, type AddABTestsRequest, type AddABTestsVariant, type Currency, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type CustomSearchParams, type DeleteABTestProps, type Effect, type EmptySearch, type EmptySearchFilter, type ErrorBase, type FilterEffects, type GetABTestProps, type ListABTestsProps, type ListABTestsResponse, type MinimumDetectableEffect, type Outliers, type OutliersFilter, type Region, type RegionOptions, type ScheduleABTestResponse, type ScheduleABTestsRequest, type Status, type StopABTestProps, type Variant, abtestingClient, apiClientVersion };

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

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

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

@@ -10,0 +10,0 @@ exports.abtestingClient = tt;

@@ -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) {

@@ -44,3 +44,3 @@ import * as _algolia_client_common from '@algolia/client-common';

type ABTestConfiguration = {
outliers: Outliers;
outliers?: Outliers;
emptySearch?: EmptySearch;

@@ -148,3 +148,3 @@ minimumDetectableEffect?: MinimumDetectableEffect;

*/
description: string;
description?: string;
/**

@@ -443,8 +443,9 @@ * Estimated number of searches required to achieve the desired statistical significance. The A/B test configuration must include a `mininmumDetectableEffect` setting for this number to be included in the response.

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 createAbtestingClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & {
type RegionOptions = {
region?: Region;
}): {
};
declare function createAbtestingClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & RegionOptions): {
transporter: _algolia_client_common.Transporter;

@@ -587,2 +588,2 @@ /**

export { type ABTest, type ABTestConfiguration, type ABTestResponse, type AbTestsVariant, type AbTestsVariantSearchParams, type AbtestingClient, type AddABTestsRequest, type AddABTestsVariant, type Currency, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type CustomSearchParams, type DeleteABTestProps, type Effect, type EmptySearch, type EmptySearchFilter, type ErrorBase, type FilterEffects, type GetABTestProps, type ListABTestsProps, type ListABTestsResponse, type MinimumDetectableEffect, type Outliers, type OutliersFilter, type Region, type ScheduleABTestResponse, type ScheduleABTestsRequest, type Status, type StopABTestProps, type Variant, abtestingClient, apiClientVersion };
export { type ABTest, type ABTestConfiguration, type ABTestResponse, type AbTestsVariant, type AbTestsVariantSearchParams, type AbtestingClient, type AddABTestsRequest, type AddABTestsVariant, type Currency, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type CustomSearchParams, type DeleteABTestProps, type Effect, type EmptySearch, type EmptySearchFilter, type ErrorBase, type FilterEffects, type GetABTestProps, type ListABTestsProps, type ListABTestsResponse, type MinimumDetectableEffect, type Outliers, type OutliersFilter, type Region, type RegionOptions, type ScheduleABTestResponse, type ScheduleABTestsRequest, type Status, type StopABTestProps, type Variant, abtestingClient, apiClientVersion };

@@ -44,3 +44,3 @@ import * as _algolia_client_common from '@algolia/client-common';

type ABTestConfiguration = {
outliers: Outliers;
outliers?: Outliers;
emptySearch?: EmptySearch;

@@ -148,3 +148,3 @@ minimumDetectableEffect?: MinimumDetectableEffect;

*/
description: string;
description?: string;
/**

@@ -443,8 +443,9 @@ * Estimated number of searches required to achieve the desired statistical significance. The A/B test configuration must include a `mininmumDetectableEffect` setting for this number to be included in the response.

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 createAbtestingClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & {
type RegionOptions = {
region?: Region;
}): {
};
declare function createAbtestingClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & RegionOptions): {
transporter: _algolia_client_common.Transporter;

@@ -587,2 +588,2 @@ /**

export { type ABTest, type ABTestConfiguration, type ABTestResponse, type AbTestsVariant, type AbTestsVariantSearchParams, type AbtestingClient, type AddABTestsRequest, type AddABTestsVariant, type Currency, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type CustomSearchParams, type DeleteABTestProps, type Effect, type EmptySearch, type EmptySearchFilter, type ErrorBase, type FilterEffects, type GetABTestProps, type ListABTestsProps, type ListABTestsResponse, type MinimumDetectableEffect, type Outliers, type OutliersFilter, type Region, type ScheduleABTestResponse, type ScheduleABTestsRequest, type Status, type StopABTestProps, type Variant, abtestingClient, apiClientVersion };
export { type ABTest, type ABTestConfiguration, type ABTestResponse, type AbTestsVariant, type AbTestsVariantSearchParams, type AbtestingClient, type AddABTestsRequest, type AddABTestsVariant, type Currency, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type CustomSearchParams, type DeleteABTestProps, type Effect, type EmptySearch, type EmptySearchFilter, type ErrorBase, type FilterEffects, type GetABTestProps, type ListABTestsProps, type ListABTestsResponse, type MinimumDetectableEffect, type Outliers, type OutliersFilter, type Region, type RegionOptions, type ScheduleABTestResponse, type ScheduleABTestsRequest, type Status, type StopABTestProps, type Variant, abtestingClient, apiClientVersion };
// src/abtestingClient.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) {

@@ -11,3 +11,3 @@ // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

export type ABTestConfiguration = {
outliers: Outliers;
outliers?: Outliers;

@@ -14,0 +14,0 @@ emptySearch?: EmptySearch;

@@ -50,3 +50,3 @@ // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

*/
description: string;
description?: string;

@@ -53,0 +53,0 @@ /**

{
"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": {

@@ -44,7 +44,7 @@ <p align="center">

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

@@ -57,3 +57,3 @@

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

@@ -60,0 +60,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