npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sitecore-discover-starter-kit

v1.0.0

Published

<p align="center"> <a href="https://www.sitecore.com/"> <img src="https://wwwsitecorecom.azureedge.net/-/media/sitecoresite/images/global/logo/sitecore-logo.svg?la=es-ES&hash=89E5BCF25116F0D8B53F53F0E3D33A0E" alt="RBE logo" target="_blank" width="20

Downloads

3

Readme

Sitecore Discover Starter Kit

This repository has an example implementation of an e-commerce platform using the Sitecore Discover JS SDK which integrates with Discover services and supports event tracking.

Table of contents

Prerequisites

Node.js

The Discover Starter Kit needs to have Node.js installed to build the project. We recommend using the LTS version of Node.js. You can find the latest version of Node.js here.

Environment variables

The Discover Starter Kit needs some environment variables to work. You can get the values for them in the Developers resources section of Customer Engagement Console (CEC). For full functionality, create a .env.local file in the root of the project and add the following environment variables.

The following variables should exist within the .env.local file:

REACT_APP_ENV="<environment - Expected values: prod, staging or prodEu >"
REACT_APP_CUSTOMER_KEY="<customer key>"
REACT_APP_API_KEY="<API key provided in CEC>"

Quick start

To start using Discover Starter Kit:

  1. Install Node.js. We recommend the LTS version.
  2. Clone the repository: git clone https://github.com/Sitecore/Discover-JS-SDK-Starter-kit.git
  3. In the repository, to install all dependencies, run npm install.
  4. In the root of the project, create a .env.local file then add the following environment variables to it:
REACT_APP_ENV="<environment - Expected values: prod, staging or prodEu >"
REACT_APP_CUSTOMER_KEY="<customer key>"
REACT_APP_API_KEY="<API key provided in CEC>"
  1. To start the development server, run npm start.
  2. To view the site, open your browser to http://localhost:3000
  3. To build the app for production, run: npm run build

Widget configurations

The application renders widgets based on page or URL, as configured in the CEC. It loads a custom page widgets component that uses the PageWidgets component or the usePageWidgets hook. The index.jsx imports a configuration file called sitecoreWidgetsConfig.js that registers all the components used for each widget type.

You can access the documentation for details on components, functions, query hooks, templates, and ui primitives.

Pages

The JS SDK uses React Router to perform page navigation. Each page is a React component with a useEffect hook used to register uri change.

For example, for home page we have:

useEffect(() => {
    PageController.getContext().setPageUri('/');
}.[]);

With this, the SDK can change browser context and customize tracking/service response.

In the starter kit, we use a higher order function called withPageTracking in each page to register page uri and track the page view event.

Home

Route: / shows the main page of the site. This page is an example of how you can render widgets configured for the page in the CEC. The page component uses the usePageWidgets query hook and other recommendation widgets.

Events tracked are:

  • A page view event.
  • A widget appear event per widget that appears on the page.

Search

Route: /search shows the results returned after submitting the form in the header.

Events tracked are:

  • A page view event.
  • A widget appear event for the search result widget present on the page.

Category pages

Route: /category/<category sanitized name>. E.g.: /category/fan-gear-jerseys Only shows search results for the category.

Events tracked are:

  • A page view event.
  • A widget appear event for the search result widget present on the page (this page also uses a search results type widget to show the products).

Product detail page

Route: /product/detail/<product sku>/<product id>. E.g.: /product/detail/3107756/prod1100011 shows the details of a product. It also has a recommendation widget for related products.

Note: In this example, the product information has been filtered from the SearchResults widget data for demonstration purposes. We do not recommend this approach in production. Restrict Discover services to search and recommendations and create separate services for other data.

Events tracked are:

  • A page view event.
  • A PDP view event with the SKU from the product shown (dispatched verbosely).
  • A widget appear event for the search result.

Cart page

Route: /cart shows a list of the products added to the cart. The page also has a recommendation widget showing products that were recently purchased together.

Events tracked are:

  • A page view event.
  • A widget appear event for the recommendation widget.
  • add to cart or cart status events.

Order confirm page

Route: /order/confirmation shows the confirmation for the purchase and includes a recommendation widget showing products that were recently purchased.

Events tracked are:

  • A page view event.
  • A widget appear event for the Recommendation widget present on the page.
  • An order confirm event (the user sent on the event is a mock user).

Events

Events are an important part of the Discover platform. The JS SDK automatically fires events it can infer when they happen. To register other events, you have to verbosely dispatch them.

Refer to the JS SDK documentation for more about dispatching events.

Monitoring example

An example of monitoring could be debug event tracking in the CEC. The following video shows how you can verify the events that the SDK trigger:

Documentation

Discover documentation is written for both developers and business users.

JS SDK for React documentation includes:

For data feeds and URL configuration, refer to the Discover developer guide.

Contributions

We are very grateful to the community for contributing bug fixes and improvements. We welcome all efforts to evolve and improve the Discover Starter Kit. The following sections explain how you can participate in these efforts.

Bug reports

You can use GitHub to submit bug reports for Discover Starter Kit.

Feature requests

You can use GitHub to submit feature requests for Discover Starter Kit.

Code of Conduct

Sitecore has adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.

Contributing Guide

If you want to make changes to the code, follow these steps:

  1. Fork the Discover Starter Kit Repo GitHub repo.
  2. Clone the forked repo to your local machine.
  3. Create a feature branch from main for your changes. e.g. git checkout -b my-feature-branch
  4. Run npm install
  5. Run npm start (to preview your changes locally)
  6. Commit, push to your remote fork of the Discover Starter Kit repo, then open a pull request (PR) to the main branch of the Developer Portal repo.

Your changes will be reviewed and merged if appropriate.