0.1.0 • Published 5 years ago

@viewdo/dxp-experience-host v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

Built With Stencil

View.DO Experience Host

This is a simple web component that handles the basics of bringing View.DO experience data along with a simple API for interacting with the Experience API.

Getting Started

To start building a new web component using Stencil, clone this repo

and run:

npm install
npm start

To build the component for production, run:

npm run build

To run the unit tests for the components, run:

npm test

Using this component

This component encapsulated all experience interactions. From retrieving by XID, funnel or you can configure it for a static story.

  • Put a script tag in the head of your page:

    <script type='module' src='https://unpkg.com/@viewdo/dxp-experience-host@0.1.0/dist/dxp-experience-host/dxp-experience-host.esm.js'></script>
  • Then you can use the element anywhere in your template, JSX, html etc

    <dxp-experience xapi-url="https://xapi.view.do/v4"></dxp-experience>
  • Attach to the 'initialized' event to get a handle on the experience data.

    <script>
      const experienceTag = document.querySelector('dxp-experience');
      experienceTag.addEventListener('initialized', async event => {
        let experience = event.detail;
        await experience.setData('color', 'red');
        console.dir(experience)
      })
    </script>

Properties

PropertyAttributeDescriptionTypeDefault
debugdebugEnable Debug mode to prevent API calls.booleanundefined
displaydisplayDisplay mode for this element."json" \| "message" \| "none"'none'
experienceData--Experience data (bypasses XAPI to retrieve it)ExperienceInformationundefined
loadAssetsload-assetsEnable Debug mode to prevent API calls.booleanundefined
namespacenamespaceThe platform environment target. (optional)"develop" \| "local" \| "master" \| "other" \| "stage"'develop'
storyKeystory-keyStory Key (optional)stringundefined
userKeyuser-keyUser Keystringundefined
xapiUrlxapi-urlExperience API Url (optional)stringundefined

Events

EventDescriptionType
initializedWhen an experience is retrieved, this event fires with 'event.detail' = experienceCustomEvent<ExperienceInformation>

Node Modules

  • Run npm install @viewdo/dxp-experience-host --save
  • Put a script tag similar to this <script src='node_modules/@viewdo/dxp-experience-host/dist/dxp-experience-host.js'></script> in the head of your index.html
  • Then you can use the element anywhere in your template, JSX, html etc

In a stencil-starter app

  • Run npm install @viewdo/dxp-experience-host --save
  • Add an import to the npm packages import @viewdo/dxp-experience-host;
  • Then you can use the element anywhere in your template, JSX, html etc
0.1.2

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago