GithubHelp home page GithubHelp logo

klevultd / frontend-sdk Goto Github PK

View Code? Open in Web Editor NEW
19.0 5.0 5.0 25.93 MB

Monorepository for Klevu headless

Home Page: https://www.klevu.com

License: MIT License

JavaScript 3.10% TypeScript 77.55% HTML 0.44% CSS 6.70% MDX 12.21%
typescript api-client headlessui ecommerce react remix-run search-engine ssr vue

frontend-sdk's Introduction

Klevu

Headless product discovery, for every body

With Klevu’s brand new SDK, you can pull the power of AI product discovery into anything.

A traditional website, a single page application (SPA), progressive web app (PWA), a mobile app, a campaign website, an in-store kiosk, a spaceship… whatever.

Simpler for developers, faster to innovate.

Klevu headless monorepository

Here are the links to different projects.

Integrate Klevu into your application with ease. We do all the heavy lifting.

Klevu SDK brings smart search, category merchandising and recommendations solution to your ecommerce store. Klevu makes it easy to create the best product browsing experience for your customers.

Klevu already has a simple to implement JavaScript library that is perfect for most users, so who is this library good for?

TypeScript SDK

The Klevu SDK is written in TypeScript which gives you:

  • Full auto-completion support of integrated development environments (IDEs)
  • Full documenation from the code comments!
  • Easy and fast way to integrate Klevu to your custom UI

SPA (Single Page Applications)

This library supports all the major frontend libraries like React and Vue. This SDK however gives you the ability to plugin Klevu smart search, category merchandizing and recommendations any way that you would like. Including event tracking of product clicks, searches, and purchases that drive the AI at Klevu's core.

PWA (Progressive Web Applications)

PWAs are designed to give users an experience on par with native apps. With the Klevu SDK, you can also bring the power of Klevu AI into your PWA.

SSR & SSG (Server Side Rendering & Static Site Generation)

SSR & SSG are quickly becoming standard features in all of the most popular frontend frameworks such as NextJS and NuxtJS. With the Klevu SDK you can both increase your store's SEO and your user's experience by requesting search results, category pages, and recommendations before the page loads.

Full Creative Control, on Full Power

The Klevu SDK gives developers maximum control over the way they want to display and allow users to interact with your product catalog. When you add the SDK library to your project you have all the building blocks necessary to create trully unique user experiences that perfectly fit your brand.

Klevu SDK Feature List

We've packed a lot of features into the React Example included with this SDK. Here are many of the features and where to find a working example. You can also take a look a the React Example README for more information on what is implemented in the example and click here to:

Search

Feature Description Example
Quick Search Example used to display search results as you type into a text field. quicksearch.tsx
Search Results Landing Page Example to show search results based on a keyword passed in the URL. SearchResultPage.tsx
Category Navigation Example display of products in a Category/Collection. CategoryPage.tsx
Single Product Search Example of using search to query the data for a single product. ProductPage.tsx
Filters Examples of filters to narrow down products based on product facets. SearchResultPage.tsx
CategoryPage.tsx
Load More Results Example of a Load More button to request more products. SearchResultPage.tsx

Analytics

Analytics drive the Machine Learning Klevu uses to provide users the best results.

Feature Description Example
SearchEvent Track what was searched. quicksearch.tsx
Search Product Click Event Track the products that are clicked from search results. SearchResultPage.tsx
Category Navigation Product Click Event Track the products that are clicked from category pages. CategoryPage.tsx
Buy/Purchase Event Track the products that are purchased. CheckoutPage.tsx

Recommendations

Feature Description Example
Klevu Merchant Center Recommendations Add recommendations created within KMC. 1 HomePage.tsx
CategoryPage.tsx
ProductPage.tsx
Similar Products ProductPage.tsx

Personalization

Feature Description Example
Personalisation Easily add personlization to your klevuFetch searches by adding a modifier. HomePage.tsx

Utilities

Feature Description Example
KlevuKMCSettings Load your Klevu Merchant Center settings into the browser's localstorage. index.tsx

Internal development

Node.js and npm is required to be installed on your system before starting. This should be done once before starting development.

Core

To run build and test @klevu/core you need to first go to packages/klevu-core.

Before starting you need to have all packages installed with npm install

Creating release version

npm run build creates production version of the @klevu/core. It does a clean build every time it runned.

To actually release there is CI/CD script utils/release-klevu-core.js. Use Node.JS to run it.

Developing core

npm run build:watch

build:watch runs build in watch mode rebuilding application every time there is changes. It doesn't do clean build, but incremental builds and it doesn't do all tricks required for the release. It is good if you wish make changes to library while developing other package like @klevu/ui that require changes to core.

npm run qoc

This checks that quality of code is good enough. Will be automatically run by GitHub.

npm run test

Runs big suite of tests for core. Doesn't require building. It can be possible just to develop and run test once in a while to see everything works perfectly. Will be automatically run by GitHub.

UI

To start building @klevu/ui you first need to go to packages/klevu-ui folder and do the npm install. To make build work correctly you need to run npm install also in packages/klevu-ui-react and packages/klevu-ui-vue.

React and Vue packages do not need any other changes. Their contens are automatically generated by klevu-ui project.

Creating release version

npm run build creates a distributed version of @klevu/ui. But to create proper version and release all three UI libraries there is a CI/CD node script in utils/update-klevu-ui.js.

Developing

Easiest way to develop and test components is by running Storybook. For that you need to watch build the ui project and run the storybook.

npm run build:watch

And in separate window

npm run storybook

This should open the development environment.

To create generate components you can use the command:

npm run generate

VSCode extensions

It is recommened to have ESLint and Prettier extensions installed in order to produce clean code.

Footnotes

  1. Klevu's Merchant Center allows you to create recommendations for specific uses that take into account the context of the pages they are added into.

frontend-sdk's People

Contributors

davidwarrington avatar dependabot[bot] avatar dhawalmodi avatar forgiveme avatar github-actions[bot] avatar jerrypena1 avatar klevu avatar nikhil-narayana-klevu avatar rallu avatar zellenka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

frontend-sdk's Issues

Create tools to work with filters

Create a tool that can take filters and handle their current selection. This model should be passable to search queries in order to make handling easier.

Web component: Product component

A simple product component taking in KlevuRecord from @klevu/core and rendering a HTML output from that.

Component should be as extensible as possible so that developers can easily change the way it renders.

Issue with requesting next results

Hi, there's a problem with next function's offset property, instead of adding the offset value as a number it gets appended as a string

view screenshots below:

Screenshot from 2022-05-28 22-44-46

Screenshot from 2022-05-28 22-45-06

Data formatter for incoming data

We need to clean and format incoming data. For example slider filter min/max values are coming in as string even though they are numbers in reality.

There are multiple cases this happens. There are also boolean values coming from API "true" or "false" strings.

Search

Simple SDK to do search to Klevu API

Required features

  • Search
  • Pagination
  • Getting filters
  • Applying filters to search

Pagination should have easy to use API that takes caches and applies filters automatically for better performance.

Can we add the boiler plate code for adding and removing KlevuDomEvents.FilterSelectionUpdate to core?

Instead of having add:

document.addEventListener(
    KlevuDomEvents.FilterSelectionUpdate,
    handleFilterUpdate
)

onBeforeRouteLeave((to, from, next) => {
    document.removeEventListener(
        KlevuDomEvents.FilterSelectionUpdate,
        handleFilterUpdate
    )
})

Could we do something like:

const removeFilterSelectionUpdate = KlevuDomEvents.addFilterSelectionUpdate(usersFilterUpdateHandler)

usersFilterUpdateHandler & removeFilterSelectionUpdate can be called anything, and this would allow the implementation to require less boiler plate.

Web component: Recommendation app

Recommendation web component pulls data from given KMC recommendation ID and it creates horizontal swiper component from products fetched by @klevu/core

It is preferred that no external UI libraries is used to create this component.

Required UI web component

Move next() page function from upper level of results to individual query results

Currently calling next() page will automatically try to detect which of the queries should be paginated. That is not optimal way of it working.

We need to move next() to same level as sendEvent functions in the result so that developer explicitly selects which of the queries they wish get next page from.

Old function should be @deprecated in documentation and then removed in next version.

Recommendations

Implement simple to use functions to get recommendations from the Klevu API

Recommendation templates and banners.

Currently recommendations are created in Klevu Merchant Center and the data coming in is plain HTML and Javascript that should be injected using Klevu JSv2 library.

In milestone 1.0.0 we support only fetching recommendations through the API and KMC based builder is not available.
In milestone 2.0.0 we give a way to inject JSv2 into website and init these banners. Banners are loaded through the library.

After these in the next version we should build up provide JSON output from KMC that it's easier to build UI builder with any library.

Filters are not reset while switching the categories (still happening)

When you enable a filter (say color: blue) and change to a different category, the blue filter is still selected.

There was a fix submitted, but after QA the same issue is still there.

In addition:

  • there seems to be a problem with the color swatch for "oliv". sometimes it's white, sometimes it burgundy, etc. My guess is that its having a hard time because it does not actually match a real color without the full spelling.
  • there seems to be a problem with the price slider filtering.

There are videos that show these issues in Jira.

Jira: KS-12397

Category Navigation

Simple API to fetch data for category navigation.

Should implement helper function that fetches filters has ability to paginate category navigation fetches.

Issue with Filters

Hi, we are using the @klevu-core v1.1.0 for the project, developed using React, as a dependency and we have a problem with filter options.

  1. issue with price range filters, we could not find the detailed info and examples for it. using the updateSlider, filters were sent in payload but in the result the values ( end and start ) were returning null and records were empty.
  2. the issue with filter toggle. filters get applied correctly and product records get updated, but the value ( selected ) isn't updated correctly, there are some issues with FilterManager. the same issue is noticeable on the demo page.

I wanted to ask for some suggestions or information about these issues if they are currently in development

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.