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(headless): refresh commerce recommendations server-side #4617

Merged
merged 40 commits into from
Nov 26, 2024

Conversation

y-lakhdar
Copy link
Contributor

@y-lakhdar y-lakhdar commented Oct 31, 2024

Adding server-side rendering for commerce SSR package only.

  • Updated headless-react package to reflect the new changes
  • Updated headless-ssr-commerce sample to reflect the new changes

Features

Customizable Recommendation Controller

  • Users can specify which recommendation controller to refresh by providing the recommendation key (as defined in the engine configuration).
  • If no key is specified, the recommendation controller will not perform any queries.
image
  • Supports selecting recommendations using the build method.
image

Recommendation Name Validation

  • Validation against invalid recommendation names.
  • Prevention of duplicate recommendation names.

Code to increase readability

Factory methods

Moved factory methods into dedicated files to avoid bloating the commerce-engine-ssr file.
Examples include:

  • hydrated-state-factory.ts
  • static-state-factory.ts

Core Engine Types

Centralized all core engine types into types/core-engine.ts.

Recommendation State Factories

Created dedicated factories for handling static and hydrated states for recommendations (recommendation-static-state-factory.ts).

Improved Controller Handling

Simplified the logic for building controllers based on solution type to eliminate complex, hard-to-read conditional blocks (677fd45)

https://coveord.atlassian.net/browse/KIT-3503

Copy link

github-actions bot commented Oct 31, 2024

Pull Request Report

PR Title

✅ Title follows the conventional commit spec.

Live demo links

Bundle Size

File Old (kb) New (kb) Change (%)
case-assist 242.6 242.6 0
commerce 347.3 347.3 0
search 413.8 413.8 0
insight 404.9 404.9 0
recommendation 254.9 254.9 0
ssr 407.3 407.3 0
ssr-commerce 359.6 362.3 0.8

SSR Progress

Use case SSR (#) CSR (#) Progress (%)
search 39 44 89
recommendation 0 4 0
case-assist 0 6 0
insight 0 27 0
commerce 0 15 0
Detailed logs search : buildInteractiveResult
search : buildInteractiveInstantResult
search : buildInteractiveRecentResult
search : buildInteractiveCitation
search : buildGeneratedAnswer
recommendation : missing SSR support
case-assist : missing SSR support
insight : missing SSR support
commerce : missing SSR support

@y-lakhdar y-lakhdar changed the title feat(headless ssr): refresh recommendations server-side feat(headless ssr)!: refresh recommendations server-side Nov 6, 2024
@y-lakhdar y-lakhdar changed the title feat(headless ssr)!: refresh recommendations server-side feat(headless ssr): refresh recommendations server-side Nov 6, 2024
Copy link
Collaborator

@louis-bompart louis-bompart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nit pik.
It's quite complex tho for me to review this. @fbeaudoincoveo will probably understand it better than me.

Copy link
Collaborator

@louis-bompart louis-bompart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

https://coveord.atlassian.net/browse/KIT-3758

While drafting Commerce SSR docs, I noticed that we had no annotations
for NavigatorContext, which I thought would be useful.
Copy link
Contributor

@fbeaudoincoveo fbeaudoincoveo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@alexprudhomme alexprudhomme added this pull request to the merge queue Nov 26, 2024
Merged via the queue into master with commit 51708a0 Nov 26, 2024
122 checks passed
@alexprudhomme alexprudhomme deleted the ssr-recs branch November 26, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants