Local development using Personalization components

Description

This guides provides instructions on how to have the personalization components running in local development in [me-ui](https://github.com/emartech/me-ui).

Steps

Clone the following personalization repositories and set them up as follows:

  1. [personalization-components](https://github.com/emartech/personalization-components)

npm run build
http-server dist -p 8081
  1. [personalization-editor-service](https://github.com/emartech/personalization-editor-service)

The term "token" can refer to a use case with OID. The collections for Tokens (for storing tokens) and Use cases (for defining different use cases) should be already created. If not, please create them. If you only require a token without associating it with any specific use case, you can simply leave the 'use_cases' key as an empty array in the token document. However, if you need tokens with presets such as 'rds' or 'external_content', you will also have to create other collections.

token with contact:

{
   "_id":{
      "$oid":"5b055b3f92e1cb0004378741"
   },
   "updated_at":{
      "$date":{
         "$numberLong":"1527077695473"
      }
   },
   "created_at":{
      "$date":{
         "$numberLong":"1527077695473"
      }
   },
   "customer_id":{
      "$numberInt":"212479853"
   },
   "name":"DummyName",
   "source":"contact",
   "content":{
      "field":"1"
   },
   "code":"{{ contact.1 | default(\"Anonymus\") }}",
   "filters":{
      "fallback":"Anonymus",
      "modifier":"",
      "required":false
   },
   "use_cases":[
      {
         "$oid":"5b055aec92e1cb0004378740"
      }
   ],
   "__v":{
      "$numberInt":"0"
   }
}

usecase:

{
   "_id":{
      "$oid":"5b03cac5b5a188000473bff9"
   },
   "customer_id":{
      "$numberInt":"211194355"
   },
   "name":"alma",
   "description":"",
   "__v":{
      "$numberInt":"0"
   }
}

token with event:

{
   "_id":{
      "$oid":"5b17c392f7e9490004f0e8f6"
   },
   "updated_at":{
      "$date":{
         "$numberLong":"1671025447996"
      }
   },
   "created_at":{
      "$date":{
         "$numberLong":"1528284050504"
      }
   },
   "customer_id":{
      "$numberInt":"211194355"
   },
   "name":"test external",
   "code":"{{ event.cica }}",
   "filters":{
      "fallback":"",
      "modifier":"",
      "required":false
   },
   "content":{
      "event_id":"5b17c3869789bd00047924b9",
      "variable":"event.cica"
   },
   "source":"event",
   "use_cases":[

   ],
   "__v":{
      "$numberInt":"0"
   }
}

JWT Workaround

Additionally to get these Personalization components to display for the Push campaigns, @ejwalker had to:

  jwt: {
    noAuth: true
  }

2 Change the getClientToken() function in https://github.com/emartech/personalization-components/blob/master/src/services/handshake/handshake.js#L10 to return a valid token via a Promise.resolve since the this.uiKit.utils.getAuthenticationToken() method was failing:

  return Promise.resolve('valid_token_for_the_personalization-editor')