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

@commercetools-frontend/userguiding

v0.0.9

Published

React-flavored methods for consuming UserGuiding scripts in commercetools frontend applications

Downloads

148

Readme

@commercetools-frontend/userguiding

This is a package used internally for Merchant Center applications. We do not provide any guarantees or support for the functionality.

This package provides an easy-to-use integration with UserGuiding that initializes UserGuiding scripts as methods on the window object.

This is achieved by initializing a UserGuiding container. The official documentation for UserGuiding's container workflow can be found here.

Once a UserGuiding container is initialized, the UserGuiding javascript API is made available as methods on window, as documented in their UserGuiding "JS API" documentation.

Installation

$ npm install --save @commercetools-frontend/userguiding

Usage

Initialization

You will first need to initialize the userguiding provider by instantiating it at the preferred root component of your application.

Configuiration via Custom Application configuration file

If you are developing a Custom Application for the Merchant Center, we recommend adding a USERGUIDING_CONTAINER_KEY value to your environment.

The environment variable should then be exposed by adding a userGuidingContainerKey property to the additionalEnv field of your Custom Application's configuration file.

additionalEnv: {
    userGuidingContainerKey: '${env:USERGUIDING_CONTAINER_KEY}',
},

You will need to specify whether or not to disable UserGuiding using the disabled param.

import { initializeUserGuiding } from '@commercetools-frontend/userguiding';

initializeUserGuiding({
  disabled: false,
});

In order for the module to be able to connect with UserGuiding's APIs you have to extend the headers.csp property of your Custom Application config to contain the following properties:

import { CONTENT_SECURITY_POLICIES as USERGUIDING_CONTENT_SECURITY_POLICIES } from '@commercetools-frontend/userguiding/constants';

headers: {
    csp: {
        'connect-src': [...USERGUIDING_CONTENT_SECURITY_POLICIES.CONNECT_SRC],
        'script-src': [...USERGUIDING_CONTENT_SECURITY_POLICIES.SCRIPT_SRC],
        'font-src': [...USERGUIDING_CONTENT_SECURITY_POLICIES.FONT_SRC],
    },
},

Configuration without Custom Application configuration

If you are not building a Custom Application or prefer not to configure UserGuiding using the Custom Application's configuration, you will need to pass a containerKey for the UserGuiding container you wish to initialize to the initializeUserGuiding method. The containerKey is the last param specified in the IIFE code snippet UserGuiding provides in the container settings page, as documented here.

import { initializeUserGuiding } from '@commercetools-frontend/userguiding';

initializeUserGuiding({
  containerKey: '<your-container-key>',
  disabled: false,
});

Please also make sure that the connect-src, script-src, and font-src Content Security Policies allow UserGuiding to connect with their services. If needed you can use the provided constants from @commercetools-frontend/userguiding/constants exported as CONTENT_SECURITY_POLICIES.

Setting up the tracking effect

In order to provide UserGuiding with data necessary to be able to target specific segments of users with custom user guides, you must call the useTrackingEffect react hook in the entry point of your application. This method is meant to be used with the commercetools-frontend ApplicationShell component and must be rendered as a child of ApplicationShell because it depends on its react context.

import { useTrackingEffect as useUserGuidingTrackingEffect } from '@commercetools-frontend/userguiding';

function EntryPoint() {
    useUserGuidingTrackingEffect();

    return <>
        <Application>
    </>
}
  1. If you intend to send additional user variables you can pass them using the additionalUserVars object
  2. If you intend to disable UserGuiding entirely (e.g. based on a feature flag), use the disable flag
    • Note that you can only disable until you initialized once.

FAQ

Question: I want to disable UserGuiding in a specific environment Answer: Unset or do not set the USERGUIDING_CONTAINER_KEY on that environment's .env file.