1.0.4 • Published 1 year ago

manyways-run v1.0.4

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

REMOVED:

"prompts": "^2.4.2",

NOTE : NOTHING IN PUBLIC WILL BE AVAILABLE FOR THE END USER _ ONLY FOR DEV

Public methods

separate in src/publicmethod.js

Includes:

  • Restart: window.manyways.restart()
  • Dispatcher: window.manyways.dispatcher()
  • Back: window.manyways.back()
  • Share: window.manyways.share()

can disable w 'disablePublicMethods' on custom element

Running defaults

<manyways-wrapper
  slug="my-slug"
  mode="scroll"
  locale="en"
  customcss=".somecss {color: red}"
  disablePublicMethods
></manyways-wrapper>

Running the SDK.

Initialization

import ManywaysProvider from "@manyways/run";

const MyApp = ({ children }) => {
  return (
    <>
      <ManywaysRunProvider
        slug="my-slug"
        mode="scroll"
        customComponents={{
          choiceWithImage: MyComponent,
        }}
        disableRender={false}
      >
        {children}
      </ManywaysRunProvider>
    </>
  );
};

Props

PropDescription
slug (required)Your Journey Slug
disableRenderThis causes the Provider not to render any components at all, ideally used when in pure headless mode
customComponentsThis is ignored if disableRender is true. Can provide a object mapped with name and value. Expects the value to be a react component. Full list of component names can be found here @todo
modeAccepts scroll or slideshow. Default is scroll
  • locale
  • classNamePrefix
customComponents

All Custom components will have value and onChange props passed to them.

INPUTS

  • ChoiceWithImage
  • Text
  • Number
  • Date
  • DateTime
  • Checkbox
  • Dropdown (Select)

NULL FIELDS

  • Prose (HTML)
  • Content Switcher
  • Slideshow

TBD:

  • AutoComplete
  • MapWithDynamicSource

useManyways hook

This is the main way to utilize the various methods and journey states used by manyways.

import { useManyways } from "@manyways/run";
Getters, setters and actions
NameDesc
currentNodeThe current node object from the api
currentResponseThe current user response to the current node if it exists. Will return null if unanswered
goBackTake the user to the previous node. Will return current node if the user is unable to go back
setResponseSet the current response
goForwardGo to the next node with the current response
responseHistoryAn array of response objects with node ids and responses
getResponseByNodeIDGet response for node based on nodeID
treeConfigGet tree config
journeyNodesArray of all journey nodes
localeGet the current language
setLocaleSet the current language

Run Mode Variables

  • backgroundImage - takes an image
  • nodeLayout - center, content-left, and content-right (can be overriden on node)
  • foregroundImage -
  • customNextButton - global default, can be overriden on node
  • customPreviewButton - global default, can be overriden on node

TODO

  • ManywaysContext - Double check this is workign correctly with umami tracking... is this needed? If not remove. const isPreview = () => { // @TODO // if (window.location.search.includes("revision")) { // let revisionId = window.location.search // .split("revision=")[1] // .split("&")[0]; // setSlugAndRevisionParams(${slug}/begin?revision=${revisionId}`); // }

    return window.location.search.includes("preview");

    }; `

other

  • Page titles (+ share titles)
  • Header

Mini things

  • ManywaysContext: check currentNodeId instead of setCurrentNodeId let currentNode = currentNodeId !== false ? nodes.find((n) => n.id === currentNodeId) : false;
  • ManywaysContext - removed let umamidata = { website: treeConfig?.analytics_config?.umami_id, };