@lemieux lemieux released this Sep 18, 2017 · 56 commits to master since this release

Assets 2

v4.0.0

What's new?

  • Web Messenger is now rendered in an iframe to minimize conflicts with the host page that may arise due to other Javascript libraries that are in use

  • Web Messenger is now loaded asynchronously using a script loader to minimize initial page load impact

  • Web Messenger now uses a new optimized initialization sequence. This new sequence alters the timing of key events such as creating a new user or establishing a websocket connection.

What's changed?

Usage

Including Web Messenger

Web Messenger now uses a script loader to reduce its initial footprint and to allow the global variable to be available as soon as possible. This change doesn't apply to projects using npm to include Web Messenger.

Initializing Web Messenger

Previously, an app token could be used to initialize Web Messenger. The app token is now deprecated. An app ID is now required at initialization time. You can retrieve this ID from the app settings page.

Before (3.9.7 or older)
// Initialize with appToken
Smooch.init({ appToken: '<app-token>'});

// Initialize with JWT
Smooch.init({ userId: '<user-id>', jwt: '<jwt>'});
After (4.0.0 or newer)
// Intialize with appId
Smooch.init({ appId: '<app-id>' });

// Initialize with appId and JWT
Smooch.init({ appId: '<app-id>', userId: '<user-id>', jwt: '<jwt>'});

Rendering

Web Messenger is now run and rendered inside of an iframe in order to maximize compatibility with sites where it is used.

CSS Customization

In order to maximize Javascript compatibility, Web Messenger is now isolated in an iframe. Unfortunately, one side effect of this new way of rendering it makes previous CSS customization unusable since they can't target the inside of the iframe. Color customization is still available through the settings on the Smooch Dashboard.

Behaviour changes

As part of this major update, the behaviour of Web Messenger has slightly changed:

init()

Since Web Messenger is now loaded asynchronously using a script loader, only a subset of the public methods are available to use before init() is called. Those methods are on, off, init, and destroy. Once init() is successfully called, the library is considered fully initialized and all public methods are available to use.

getConversation()

A call to getConversation() would previously call the server to retrieve the conversation, returning a promise. With this update, getConversation() no longer returns a promise and instead returns the local copy of the conversation synchronously.

render()

This method no longer returns the HTML node where Web Messenger is mounted.

getUserId()

This method no longer exists, but has been replaced by getUser() which will return the entire user object. The ID is available at user._id.

track()

The track() method has been removed.

getCore()

As Web Messenger no longer relies on smooch-core to talk to the Smooch API, getCore() has been removed.

Email capture

Email capture capability has been deprecated in favor of channel linking and was completely removed from Web Messenger as part of this update. We will soon be delivering much improved e-mail linking support.

Bower and AMD

As part of this update, Web Messenger will no longer be offering an AMD build and new versions won't be available on bower.