Releases: algolia/recommend
v1.16.0
v1.15.0
v1.14.0
1.14.0 (2024-02-01)
Features
Personalized recommendations
We want to add experimental support for personalized recommendations, using Algolia Personalization "Classic"
This is an experimental UI library implementation that stitches together existing APIs.
A reference guide will also be shared for users who want to implement this in the flavor of their choice.
How to use
To enable personalisation with recommend, you'll need to import from /experimental-personalization like the following:
JavaScript
import { trendingItems } from '@algolia/recommend-js/dist/esm/experimental-personalization';
trendingItems({
region: 'eu', // "eu" | "us"
userToken: 'user_token',
indexName: "indexName"
// ...Or by using a standalone endpoint:
<script src="https://cdn.jsdelivr.net/npm/@algolia/recommend-js/dist/umd/experimental-personalization/index.js"></script>
React
import { TrendingItems } from '@algolia/recommend-react/dist/esm/experimental-personalization';
<TrendingItems
region="eu" // "eu" | "us"
userToken="user_token"
indexName="indexName"
// ...Or by using a standalone endpoint:
<script src="https://cdn.jsdelivr.net/npm/@algolia/recommend-react/dist/umd/experimental-personalization/index.js"></script>
We avoid using the pre-existing queryParameters for userToken to avoid unexpected side-effects as well as possible semantic-versioning headaches if/when personalized recommendations is supported by the Recommend API and the experimental parameter is removed.
Parameters
The following parameters are all required for personalization:
region: Personalization data is stored and processed in a specific region. You can check the region for your account in the Algolia dashboard.userToken: Associates a certain user token with the current query learn moresuppressExperimentalWarning: (optional) boolean parameter to disable the experimental console warning message.
Notes
-
When using
recommend-react: if theRecommendcontext is used for batching, theuserTokenpassed to the component take precedence over the one passed to the context. (ie if you pass 2 different user-tokens between the context provider and the recommend component, the one from the component is used) -
When using the
<Recommend>React context provider, you will need to import all the components from/experimental-personalization. -
Caching is proposed in a follow-up PR #175
v1.13.0
v1.12.1
v1.12.0
1.12.0 (2024-01-09)
Bug Fixes
Update trending-facets model types inherited from @algolia/recommend v4.22.0
https://github.com/algolia/algoliasearch-client-javascript/releases/tag/4.22.0
🤷 Why
The trending-facets API only returns type string for facetValue.
All other models return items/hits which are of type RecordWithObjectID
However trending-facets model returns a list of TrendingFacetHit which (by definition) don't have an objectID property.
To simplify the code, we can remove the type argument TObject for trending-facets
🔍 How to upgrade
If you're not using TypeScript, there is nothing to change. You can ignore the following.
If you're using TypeScript, and the trending-facets model, you should update your code like the following, by removing the type argument passed:
// The TrendingFacets React component usage goes from this:
type FacetHit = Hit<{
facetName: string;
facetValue: string;
}>
<TrendingFacets<FacetHit>
indexName="my-index"
// ...
// To this:
<TrendingFacets
indexName="my-index"
// ...
// or using hooks
const results = useTrendingFacets<FacetHit>(/* params */)
// becomes like this in v1.12.0
const results = useTrendingFacets(/* params */)If you're using @algolia/recommend-js you can remove the FacetHit type in a similar way:
trendingFacets<FacetHit>({
container: '#trendingFacets',
indexName,
// ...
// needs to be changed like this after v1.12.0:
trendingFacets({
container: '#trendingFacets',
indexName,
// ...If you encounter an issue with the upgrade, open an issue referencing this release.