feat: Add Personalized Recommendations (experimental)#174
Conversation
|
francoischalifour
left a comment
There was a problem hiding this comment.
We gonna need some tests for all components to make sure that
- the correct search parameters are sent
- the correct warnings trigger
- the correct errors trigger
| ); | ||
|
|
||
| function useFrequentlyBoughtTogether<TObject>( | ||
| export function useFrequentlyBoughtTogether<TObject>( |
There was a problem hiding this comment.
Just bringing awareness that this will now be exported from the package, which isn't part of the contract. (Could be fine as long as we don't document it, so we can remove it after the experimental package is removed.)
| if (queries.length === 0) { | ||
| return Promise.resolve({ recommendations: [] }); | ||
| } |
There was a problem hiding this comment.
I guess that's fine but there's no way back after we release it this way. What used to be an API error now fails silently.
Haroenv
left a comment
There was a problem hiding this comment.
interesting approach, I think it works overall
| TrendingItems, | ||
| RecommendedForYou, | ||
| } from '@algolia/recommend-react'; | ||
| } from '@algolia/recommend-react/dist/esm/experimental-personalization'; |
There was a problem hiding this comment.
| } from '@algolia/recommend-react/dist/esm/experimental-personalization'; | |
| } from '@algolia/recommend-react/experimental-personalization'; |
this would be possible with exports in package.json (but not sure if it's worth it of course)
There was a problem hiding this comment.
Good catch, i thought about adding some config for it, but for a beta feature where we will guide the initial clients during the setup, i don't think it is really needed.
There was a problem hiding this comment.
alternatively if you put it directly in a experimental-personalization folder instead of inside dist/esm, that should work too, but again, same considerations apply.
| @@ -0,0 +1,45 @@ | |||
| import { PersonalizationProps } from '@algolia/recommend-core'; | |||
There was a problem hiding this comment.
what do you think about adding a readme to this folder that explains what to remove once it's done?
There was a problem hiding this comment.
Theoretically everything will be removed, as this will be part of the regular API calls, and the userToken will be part of queryParameters
| <Recommend recommendClient={recommendClient}> | ||
| <> | ||
| <TrendingFacets | ||
| recommendClient={recommendClient} |
There was a problem hiding this comment.
does this have a reason to move the client out of the provider? Can you not mix Recommend from regular RecommendReact with the experimental one? Is there a good error message if it's mixed?
There was a problem hiding this comment.
I just wanted to show 2 ways to use Recommend with the Context Provider (PDP) and without (HomePage).
There was a problem hiding this comment.
And yes if you're using the Recommend Context (like the PDP), you will need to import all components from /experimental-personalization
There was a problem hiding this comment.
So is there a clear error if you use the regular provider with the experimental components? I didn't see it in the files.
There was a problem hiding this comment.
I just added a note in the PR description (that will go also in the release note). Again this is something we can guide the beta clients through their implementation.
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-personalizationlike the following:JavaScript
Or by using a standalone endpoint:
React
Or by using a standalone endpoint:
We avoid using the pre-existing
queryParametersforuserTokento avoid unexpected side-effects as well as possible semantic-versioning headaches if/when personalized recommendations is supported by the Recommend API and theexperimentalparameter 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 stacked PR feat: Add Personalized Recommendations (cache) #175