Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use the inferQueryID feature of search-insights #180

Merged
merged 12 commits into from
Jan 24, 2025
Merged

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function encode(format, ...args) {
return format.replace(/%s/g, () => encodeURIComponent(args[i++]));
}

const version = '4.20.0';
const version = '4.24.0';

const AuthMode = {
/**
Expand Down Expand Up @@ -671,7 +671,7 @@ function createDeserializationError(message, response) {
function createRetryError(transporterStackTrace) {
return {
name: 'RetryError',
message: 'Unreachable hosts - your application id may be incorrect. If the error persists, contact [email protected].',
message: 'Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support .',
transporterStackTrace,
};
}
Expand Down Expand Up @@ -836,6 +836,26 @@ function createConsoleLogger(logLevel) {
};
}

const getRecommendations = base => {
return (queries, requestOptions) => {
const requests = queries.map(query => ({
...query,
// The `threshold` param is required by the endpoint to make it easier
// to provide a default value later, so we default it in the client
// so that users don't have to provide a value.
threshold: query.threshold || 0,
}));
return base.transporter.read({
method: MethodEnum.Post,
path: '1/indexes/*/recommendations',
data: {
requests,
},
cacheable: true,
}, requestOptions);
};
};

function createBrowserXhrRequester() {
return {
send(request) {
Expand Down Expand Up @@ -931,6 +951,7 @@ function algoliasearch(appId, apiKey, options) {
methods: { search, searchForFacetValues, findAnswers },
});
},
getRecommendations,
},
});
}
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,8 @@ function getSourcesArray(config) {
item.firstImage = smallImageGroup.images[0];
}

// add queryID, objectID and indexName to the URL (analytics)
let newURL = '';
if (item.url) {
newURL = new URL(item.url, window.location.origin);
newURL.searchParams.append('objectID', item.objectID);
newURL.searchParams.append('queryID', item.__autocomplete_queryID);
newURL.searchParams.append('indexName', item.__autocomplete_indexName);
}

return html `
<a href="${newURL.href}">
<a href="${item.url}">
<div class="text-truncate text-nowrap">
<img class="swatch-circle hidden-xs-down" src=${item.firstImage.dis_base_link}></img>
<span>${components.Highlight({ hit: item, attribute: "name", tagName: "em" })}</span>
Expand Down
Loading
Loading