Skip to main content

Migrate from SmileUI.init() to SmileUI.initialize()

Migrate away from the deprecated JavaScript SDK init() method and start using the new initialize() method instead.

Matt (he/him) avatar
Written by Matt (he/him)
Updated today

πŸ›’ Supported on all platforms

πŸ’³ Available on Plus and Enterprise plans

πŸ‘€ Accessible to all roles

Smile has introduced a new JavaScript SDK method called SmileUI.initialize() which is intended to replace the SmileUI.init() method (which is now deprecated). This article explains everything you need to know about the differences between them, who is impacted by this change, and how to migrate from the old to the new method.

Differences between init() and initialize()


Fundamentally, the only difference between the SmileUI.init() and SmileUI.initialize() methods is their arguments. Both accept an option hash (as described in our developer documentation), however the keys of the options hash have changed. Besides the new keys and their values, the behaviour of the two methods is identical.

Old Options Key

New Options Key

New Value

channel_key

publishableKey

The account's publishable key.

customer_identity_jwt

customerToken

A JWT signed using one of the account's signing keys. Full instructions on JWT generation can be found here.

βœ… Tip: Previously, you would use an account's Private Key to sign the JWT passed in as the customer_identity_jwt. However with the new initialize() method and the customerToken argument, the JWT has a different format and must be signed with one of the account's signing key. Be sure not to mix these up!

How to determine if migration is needed


For most merchants using Smile on a standard Shopify or BigCommerce storefront, no action will be required. However, you'll need to migrate if:

  • You're manually added Smile's rewards popup (launcher & panel) on a custom storefront or another website.

  • You've manually included Smile's JavaScript SDK on a custom checkout, landing page, or any other webpage.

  • You're using Smile's legacy integration with an e-commerce platform other than Shopify or BigCommerce (e.g. are using Storefront.js).

In short, if you've ever followed the instructions here, then you'll need to migrate.

Migrating from init() to initialize()


πŸ’‘ Important: If you're currently using Storefront.js, refer to our guide for migrating from Storefront.js to Smile.js instead.

Pre-requisites: Before completing this guide, you'll need to ensure the following.

  • Your account is on a plan that includes JavaScript SDK access. The easiest way to confirm this is in Smile Admin, going to Settings > Developer Tools. If you see a card to Manage signing keys and there is a button to generate a new signing key, then you have access!

  • You have a full and complete list of any frontends where you've manually included Smile UI / Smile.js / Smile's JavaScript SDK (see above).

Migration steps: For each of the places/websites ("web properties") where you've manually included the JavaScript SDK, follow these steps.

  1. In Smile Admin, create a new signing key specifically for the web property.

    1. Choose a name that represents the web property the key will be used on (e.g. "Marketing Website").

  2. Replace any calls to the old SmileUI.init() method to instead call SmileUI.initialize(), ensuring that you're using the new keys in the options hash (refer to our developer documentation).

  3. Repeat these steps for every web property where you've manually included the JavaScript SDK.

Once you've repeated the steps above for every place where you've manually included the JavaScript SDK, your migration is complete! Smile will announce an official end-of-life date for the old SmileUI.init() method sometime in the future, so you'll need to ensure that you've migrated before that date or your code will stop working.

Did this answer your question?