@friendemic/catalyst-chat-widget

0.3.0 • Public • Published

DISTRIBUTION

NOTE: public/index.html should be updated to reflect changes to example/snippet.html & example/snippet-example.html

See snippet.html for distribution snippet

TESTING A SPECIFIC VERSION

NOTE: Update the app_id value in snippet.html to override the production Application

  • Update snippet.html URLs to use a specific npm version
  • Update app_id to use the Staging enviornment
app_id: '70C5B4F2-A7CF-4BD6-81C4-68841DE927CC', // Staging

https://cdn.jsdelivr.net/npm/@friendemic/catalyst-chat-widget@1.2.3-next.4/build/static/css/main.css
https://cdn.jsdelivr.net/npm/@friendemic/catalyst-chat-widget@1.2.3-next.4/build/static/js/main.js

PUBLISHING

NOTE: See root README.md


MIGRATION

From version 0.2.6 => 0.2.8

All previous active systems should remain supported

Changes were made to ratain support for previous configuration techniques

New snippet looks like this:

<html>
  <head>
    <link rel="stylesheet" href="https://unpkg.com/@friendemic/catalyst-chat-widget@latest/build/static/css/main.css" />
  </head>
  <body>
    <!-- place at bottom in root of <body /> element -->
    <div id="friendemic_chat_widget" data-client-id="PLACE_ULID"></div>
    <script src="https://unpkg.com/@friendemic/catalyst-chat-widget@latest/build/static/js/main.js"></script>
  </body>
</html>
  • The data-client-id html attribute contains the place ulid that identifies which configuration to load.
  • If window.CS_WIDGET_CONFIG exists and the request to Glovebox fails, the window config object will be used.
  • If no configuration can be found, something has gone completely 🤧🤚 wonko and the widget will be hidden.

From version 0.2.* => 0.3.0

Minor bump due to refactor

<div id="friendemic_chat_widget" data-client-id="ULID"></div>

System now uses data-client-id="ULID" falling back to window.CS_WIDGET_CONFIG if fetch to glovebox fails.

From version 0.2.* => 0.2.6

No action is required

Changes are set up to prepare for API, but allows for the previous systems to function

Updated the .env to state both prod and staging APP_IDs for sendbird:

REACT_APP_SENDBIRD_APP_ID_STAGING="" # applies in development enviornment
REACT_APP_SENDBIRD_APP_ID=""         # applies during build for production

Added new window variables

  • CS_WIDGET_CONFIG: Deprecated will be removed
  • CS_CLIENT_ID: Currently a noop
    • Used in fetch to retrieve config from non-existent API
    • If this has a value, it will fail and use CS_WIDGET_CONFIG as a fallback
  • CS_WIDGET_MOCK:
    • Mock response from faked API, default timeout of 1000ms
window.CS_WIDGET_MOCK = false;
window.CS_CLIENT_ID = '';
window.CS_WIDGET_CONFIG = {};

These options are attempted in order.

MOCK

  1. If window.CS_WIDGET_MOCK
  2. Uses the mocked API response

FETCH

  1. If window.CS_CLIENT_ID exists, attempt to use it.
  2. If the fetch fails, see if there's a window.CS_WIDGET_CONFIG
  3. If window.CS_WIDGET_CONFIG does NOT exist -- don't render the widget

CONFIG

  1. If window.CS_CLIENT_ID does NOT exist
  2. Checks for a window.CS_WIDGET_CONFIG
  3. If window.CS_WIDGET_CONFIG does NOT exist -- don't render the widget

Readme

Keywords

none

Package Sidebar

Install

npm i @friendemic/catalyst-chat-widget

Weekly Downloads

48

Version

0.3.0

License

MIT

Unpacked Size

1.78 MB

Total Files

6

Last publish

Collaborators

  • friendemic-master