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

Klevu Components integration #25

Merged
merged 5 commits into from
Feb 29, 2024

Conversation

rallu
Copy link
Contributor

@rallu rallu commented Dec 13, 2023

Overview

This pull request introduces a practical guide for integrating Klevu's advanced AI-driven search functionalities into the Composable-UI framework. Klevu, renowned for its e-commerce search capabilities, offers features like autocomplete, natural language processing, and machine learning insights, all aimed at elevating the user experience on e-commerce platforms.

Challenge

A key challenge in this integration is the circular dependency between @composable/klevu and @composable/ui. Housing these components in separate packages would create interdependencies that are impractical for efficient development and deployment.

Solution

To circumvent this issue, we propose a streamlined approach. This integration comprises three essential files rather than creating separate packages. These files are designed to be seamlessly integrated into the main project's structure.

Implementation Guide

Detailed instructions for the integration process are provided in the attached README. This guide outlines the necessary steps to embed Klevu's search components into your Composable-UI project, ensuring a smooth and effective integration.

Copy link

netlify bot commented Dec 13, 2023

‼️ Deploy request for composable-ui-storefront rejected.

Name Link
🔨 Latest commit 360980c

Copy link

vercel bot commented Dec 13, 2023

@rallu is attempting to deploy a commit to the Composable Development Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Dec 19, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
composable-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 29, 2024 4:08pm
composable-ui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 29, 2024 4:08pm
composable-ui-docs-public ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 29, 2024 4:08pm
composable-ui-public ❌ Failed (Inspect) Feb 29, 2024 4:08pm

@dannytlake
Copy link
Contributor

Hi @rallu!

The pnpm-lock.yaml file looks to be stale and is preventing a successful build on Vercel. Please commit an updated lock file for the newly installed @klevu/ packages(see here and here)

image

Copy link
Contributor

@dannytlake dannytlake left a comment

Choose a reason for hiding this comment

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

  • The changes applied by following the installation steps must be able to successfully deploy to Vercel and Netlify, please provide a link to a deploy running on Vercel and Netlify
  • pnpm-lock.yaml file was not updated and prevented build on Vercel, see PR comment
  • Klevu UI components must be built with Chakra UI
    • The Klevu UI components should be built with Chakra UI to fit into the Composable UI component ecosystem, and can be most likely be based on, or use, the components that power the default Product Listing Page
    • Concern: separate CSS files are imported in _app.tsx to style the Klevu components. 
      • This diverges from the Chakra UI theme, and takes the styling and building of  these components out of Chakra UI and into an isolated pattern for Klevu
      • Can lead to several issues: specificity issues, ssr issues, difficulty in theming
  • command # 6 in Klevu README needs to be escaped
    • cp ../packages/klevu/copythese/\[slug\].tsx src/pages/category/\[slug\].tsx
  • command # 8 in readme should provide sample code of the QuickSearch component placed in header.tsx, with a sample screenshot of the code and expected UI output
  • The Klevu README should contain screenshots of the outcome after installation of all Kelvu code + components
  • Please explain how to create a new Klevu account and sandbox
    • How to configure a new Klevu sandbox
    • How to retrieve the API keys used for KLEVU_API_KEY and KLEVU_REST_KEY
    • How to populate this new sandbox to power the Product Listing Page and QuickSearch
  • klevu.tsx has hard coded variables: apiKey, url, and assetsPath
    • These should be changed to environment variables
  • README does not explain whether "Data Indexing in Klevu” is an additional optional step or if it is required for the QuickSearch component.
    • Will QuickSearch function only after this step has been completed?
  • Product grid is not contained within max page width, see screenshot image

@dannytlake
Copy link
Contributor

@rallu please also add a page to in the Docusaurus app in docs, under docs/docs/integrations/search. See Composable UI Docs for the deployed Docusaurus app.

Please add an introduction, screenshots, etc - anything you would want a developer to understand about the integration to Klevu, and how to get started. Referencing the klevu package README for installation steps is great as well.

@rallu
Copy link
Contributor Author

rallu commented Jan 12, 2024

New version of Klevu installation instructions has been added. We have done following changes:

  • @composable/klevu package is not imported by composable-ui in any way.
  • packages/klevu is now just storage that keeps all files related to Klevu in one place.
  • NPM script copyfiles was created to simplify the installation process.
  • CSS styles are copied also to the composable-ui project so that it can be easily modified
  • Proper ENV variables were created
  • Created modified docusaurus page from the README.md. I removed the images the docusaurus version as I don't know if they work in there.

@dannytlake
Copy link
Contributor

@rallu I'll be looking at reviewing + merging this PR this week.

@nikhil-narayana-klevu
Copy link
Contributor

@dannytlake Hello Danny, my name is Nikhil and I work in the Klevu components team. I wanted to check if anything is still pending in this PR and if you need anything else from our side to get this merged. Let me know. Thanks.

@dannytlake
Copy link
Contributor

dannytlake commented Feb 21, 2024

@dannytlake Hello Danny, my name is Nikhil and I work in the Klevu components team. I wanted to check if anything is still pending in this PR and if you need anything else from our side to get this merged. Let me know. Thanks.

Hello @nikhil-narayana-klevu, nice to meet you.

  1. Can you please reset my Klevu sandbox account trial period, my account is under danny.lake@orium.com?
    Screenshot 2024-02-21 at 3 49 30 PM

  2. Please run pnpm install at the root of your branch klevu-empty-state, it should modify the root pnpm-lock.yaml file with changes similar to the below screenshot. Please commit this change to the branch.

Screenshot 2024-02-21 at 3 51 33 PM

Please let me when the two items above are completed, and then I will run through the install instructions again to verify I can successfuly install Klevu UI and run the components on the storefront.

I also suggest adding screenshots to the documentation (/docs/integrations/search/klevu) of the expected output on the Composable UI storefront once the Klevui UI components have been installed, this will greatly help illustrate to developers the features offered in this integration.

Thank you!

@dannytlake
Copy link
Contributor

dannytlake commented Feb 23, 2024

Hi @nikhil-narayana-klevu, thank you for resetting my account.

I'm not able to successfully run the setup process of importing products via command pnpm run klevu-setup

Please see the below logs as I run the command. I am receiving error The request payload was invalid

➜  scripts git:(klevu-empty-state) ✗ pnpm run klevu-setup

> scripts@0.0.0 klevu-setup /Users/dannylake/Documents/code/accelerator/composable-ui/klevu-cui/scripts
> ts-node src/klevu-setup/index.ts

Starting setting up Klevu!
=== Indexing attributes ===
[KlevuClient] PUT https://indexing.ksearchnet.com/v2/attributes/slug
Attribute saved successfully
[KlevuClient] PUT https://indexing.ksearchnet.com/v2/attributes/brand
Attribute saved successfully
[KlevuClient] PUT https://indexing.ksearchnet.com/v2/attributes/materialAndCare
Attribute saved successfully
=== Indexing categories ===
[KlevuClient] PUT https://indexing.ksearchnet.com/v2/batch
Batch accepted successfully
=== Indexing products ===
[KlevuClient] PUT https://indexing.ksearchnet.com/v2/batch
The request payload was invalid. Please check the provided payload for errors.

I am using the API keys
image
image

Am I expected to modify this script? I see this message in the Klevu integration doc:

Modifying the Indexing Script

Before running the script, ensure that it is tailored to your site's specific data structure. The script provided requires customization to match the attributes and data types you wish to index. This step is crucial for accurate and efficient search functionality.

Should I be able to successfully upload the default product dataset without any code modifications?

@nikhil-narayana-klevu
Copy link
Contributor

nikhil-narayana-klevu commented Feb 26, 2024

Hi @nikhil-narayana-klevu, thank you for resetting my account.

I'm not able to successfully run the setup process of importing products via command pnpm run klevu-setup

Please see the below logs as I run the command. I am receiving error The request payload was invalid

➜  scripts git:(klevu-empty-state) ✗ pnpm run klevu-setup

> scripts@0.0.0 klevu-setup /Users/dannylake/Documents/code/accelerator/composable-ui/klevu-cui/scripts
> ts-node src/klevu-setup/index.ts

Starting setting up Klevu!
=== Indexing attributes ===
[KlevuClient] PUT https://indexing.ksearchnet.com/v2/attributes/slug
Attribute saved successfully
[KlevuClient] PUT https://indexing.ksearchnet.com/v2/attributes/brand
Attribute saved successfully
[KlevuClient] PUT https://indexing.ksearchnet.com/v2/attributes/materialAndCare
Attribute saved successfully
=== Indexing categories ===
[KlevuClient] PUT https://indexing.ksearchnet.com/v2/batch
Batch accepted successfully
=== Indexing products ===
[KlevuClient] PUT https://indexing.ksearchnet.com/v2/batch
The request payload was invalid. Please check the provided payload for errors.

I am using the API keys image image

Am I expected to modify this script? I see this message in the Klevu integration doc:

Modifying the Indexing Script

Before running the script, ensure that it is tailored to your site's specific data structure. The script provided requires customization to match the attributes and data types you wish to index. This step is crucial for accurate and efficient search functionality.

Should I be able to successfully upload the default product dataset without any code modifications?

Hi @dannytlake
I have pushed a change in the payload to the branch, there is also a change in the indexing package we use to push catalog data to our servers. Can you reinstall the packages and try again, it should work now.
Let me know if you still face issues.

@dannytlake
Copy link
Contributor

Thank you @nikhil-narayana-klevu, pnpm run klevu-setup now runs successfully. I can now see products in the Klevu dashboard, and on my Composable UI storefront. Both Global Search and the Product Listing pages are functioning with the Klevu UI components :)

One small issue I see is the Global Search component, there is an "undefined" row in the "Last searches" section. Even if I perform a couple of searches, the "undefined" row still exists. Can you please investigate?

image

@nikhil-narayana-klevu
Copy link
Contributor

@dannytlake I am unable to replicate on my end. can you try once in an Incognito window and check?
I have also updated the klevu packages to the latest version which has some improvements and bug fixes. Please reinstall the packages for your local testing.
You can also try by clearing all the browser cache and storage values.
For this issue in particular, we have taken note and will review what could have caused this to appear.

@dannytlake
Copy link
Contributor

@nikhil-narayana-klevu clearing the site data for localhost:3000 solved the issue. Everything looks great now thank you for working on these last few items.

@@ -27,6 +27,9 @@
"@emotion/react": "^11.9.3",
"@emotion/styled": "^11.9.3",
"@hookform/resolvers": "^2.9.7",
"@klevu/core": "^5.0.0",
"@klevu/ui": "^2.0.0",
"@klevu/ui-react": "^2.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

@nikhil-narayana-klevu please remove these dependencies, as they should not be a part of the baseline composable-ui package.json. The developer will install these when following the Klevu install documentation.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have removed these packages. Please check now.

pnpm-lock.yaml Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

@nikhil-narayana-klevu please regenerate this lock file. There is an issue in this lock file, it downgrades many dependencies compared to the lock file in main. Please start with a fresh working copy from here and re-run pnpm i to update the lock file in this branch as needed. This current lock file is the breaking build of the next.js application.

image

Copy link
Contributor

Choose a reason for hiding this comment

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

This is updated, please check now.

Copy link
Contributor

Choose a reason for hiding this comment

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

@dannytlake dannytlake merged commit 2b29727 into composable-com:main Feb 29, 2024
7 checks passed
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.

3 participants