Native storefront login Event

Events generated when a User logs in to your store

swat.JSEvents.customerInfoRefreshed

Swym APIs allow a couple of modes of connecting shopper accounts either via a native storefront login or a via connect link.

Definition

swat.JSEvents.customerInfoRefreshed

Native storefront login is detected asynchronously and raises a Swym JSEvent swat.JSEvents.customerInfoRefreshed which can be subscribed.

Example

// Define event
let event = swat.JSEvents.customerInfoRefreshed;

// Define listener
let listener = function(evt) {
  swat.authCheck(function(shopperContext) {
    console.log(shopperContext, "Here is all the information we know about the shopper")
  });
};

swat.evtLayer.addEventListener(event, listener);

Success Response

{
  "authn": true,
  "email": "shopper email",
  "regn": {
    "userinfo": { // where available
      "fname": "", // where available
      "lname": "", // where available
      "acc_mkt": null // accepts marketing flag - boolean where available
    }
  }
}
{
  "authn": false,
  "email": null
}