Skip to main content

Skin Analysis Events

GlamAR SDK sends triggers all essential events for the user on every ui interaction, data change and api resolution. We will dive deep into these events and when and how to use them. First we will go over basic events.

Life Cycle Events

loading

Fired when the GlamAR module is initiated and the SDK proceeds with the loading process.

Don't call any other function before you recieve the loaded event as it may cause misbehaviour due to incomplete initialization

GlamAR.addEventListener("loading", () => { console.log("GlamAR: Is Loading..."); })

loaded

Fired when the GlamAR module initialization is completed

Use this event as a starting point to call any other fuction, as shown below

// Initilization Function
GlamAR.init("Your Contianer Id", "Your Access Key", { platform: "web" });

// Listen for loaded event
GlamAR.addEventListener("loaded", () => {
console.log("GlamAR: Loaded successfully");
// Continue with desired flow

// Example: apply a specific SKU
// GlamAR.applyBySku("valid-skuId");

// Example: apply a category by name
// GlamAR.applyByCategory("valid-subcategory");

// Example: start EyePD tracking
// GlamAR.eyePD("start");
});

opened

Fired when GlamAR module starts showing any type of viewer ,i.e, Live Try-on, Model Try-on or Model Viewer

// Opens the GlamAR SDK or activates the AR session
GlamAR.open();

// Listen for the 'opened' event
GlamAR.addEventListener("opened", () => {
console.log("GlamAR: Opened successfully");
});

closed

Fired when GlamAR module is told to stop working

// Closes the GlamAR SDK
GlamAR.close();

// Listen for the 'closed' event
GlamAR.addEventListener("closed", () => {
console.log("GlamAR: Closed successfully");
});

reset

Fired when GlamAR module removes all the applied effects are reset.

// Resets the GlamAR SDK applied effects
GlamAR.reset();

// Listen for the 'reset' event
GlamAR.addEventListener("reset", () => {
console.log("GlamAR: Reset successfully");
});

error

Fired anytime an error occurs. This event returns Error object with a description of the error that has been encountered. If your toasts are active you will see the same message on screen. If you want to use your own error handling UI just listen to this event and show errors using the Error we send.

GlamAR.addEventListener("error", (error) => {
console.log("GlamAR: Error encountered", error);
});

Camera Events

camera-opened

Fired when the camera is opened successfully.

camera-closed

Fired when the camera is closed successfully.

camera-access-issue

Fired when the camera fails. This can occur if the user refuses to grant permission or the app is unable to retrieve the video stream normally.

// Fired when the GlamAR camera is opened
GlamAR.addEventListener("camera-opened", () => {
console.log("GlamAR: Camera opened");
});

// Fired when the GlamAR camera is closed
GlamAR.addEventListener("camera-closed", () => {
console.log("GlamAR: Camera closed");
});

// Fired when camera permission is not granted
GlamAR.addEventListener("camera-access-issue", () => {
console.log("GlamAR: Camera permission not granted");
});

Skin Analysis Events

skin-analysis

Fired for every skin realted data response that has been enabled by user in GlamAR console.

GlamAR.addEventListener("skin-analysis", ({ option, value }) => { 
console.log("GlamAR: Skin Analysis");
switch(option) {
case "capture":
// Image that was clicked
console.log("GlamAR: Capture", value);
break;
case "result":
// Skin Analysis data
console.log("GlamAR: Result", value);
break;
case "retouch":
// Retouch data
console.log("GlamAR: Retouch", value);
break;
case "recommendation":
// Recommendation data
console.log("GlamAR: Recommendation", value);
break;
case "error":
// Error
console.log("GlamAR: Error", value);
break;
}
});

share

Fired when user clicks on share button or calls snapshot() function.

GlamAR.snapshot();
// Listen for share event to get PDF generated
GlamAR.addEventListener("share", (pdf) => {
console.log("GlamAR: Skin Analysis PDF", pdf);
});

UI Events

ui-interactions

Fired when user interacts with any UI element. You can register these events to trigger specific actions or to track behavior on your side. GlamAR provides its own analytics as well, but you can also log these for custom analytics.

UI elements have two behaviours:

  • clicked
  • toggleOn| toggleOff

Note: Exception for ,modelscreen, is that it sends index of the selected model.

topNavigationPanel

This is the top navigation panel. It has four buttons, each with an interaction event:

  • Clicked on Back button
  • Clicked on Global Cart button
  • Clicked on Share button
  • Clicked on Close button
UI ElementAction
backclicked
globalCartclicked
shareclicked
closeclicked
GlamAR.addEventListener("ui-interactions", ({ screenType, buttonType, value }) => {
console.log("GlamAR: UI event:", screenType, "interacted with:", buttonType, "value:", value);
if (screenType === "topNavigationPanel") {
if (buttonType === "back") { /* Back button clicked */ }
if (buttonType === "globalCart") { /* Global Cart button clicked */ }
if (buttonType === "share") { /* Share button clicked */ }
if (buttonType === "close") { /* Close button clicked */ }
}
});

saHeroScreen

Image

This is the landing screen for Skin Analysis. It has one button event:

  • Clicked on Start Scan button
GlamAR.addEventListener("ui-interactions", ({ screenType, buttonType }) => {
console.log("GlamAR: UI event:", screenType, "interacted with:", buttonType);
if (screenType === "saHeroScreen") {
if (buttonType === "startNow") { /* Start Scan button clicked */ }
}
});

saResultScreen

Image

This is the result screen of Skin Analysis, where all scores, journeys, and recommendations are displayed. It has one button event:

  • Clicked on Add to Cart button
GlamAR.addEventListener("ui-interactions", ({ screenType, buttonType }) => {
console.log("GlamAR: UI event:", screenType, "interacted with:", buttonType);
if (screenType === "saResultScreen") {
if (buttonType === "addToCart") { /* Add to Cart button clicked */ }
}
});

saBottomNavigationPanel

Image

In the result screen of Skin Analysis, there is a bottom navigation panel with multiple buttons:

  • Clicked on Summary button
  • Clicked on Score button
  • Clicked on Product button
  • Clicked on Ask Me button
GlamAR.addEventListener("ui-interactions", ({ screenType, buttonType }) => {
console.log("GlamAR: UI event:", screenType, "interacted with:", buttonType);
if (screenType === "saBottomNavigationPanel") {
if (buttonType === "summary") { /* Summary button clicked */ }
if (buttonType === "score") { /* Score button clicked */ }
if (buttonType === "product") { /* Product button clicked */ }
if (buttonType === "askMe") { /* Ask Me button clicked */ }
}
});

somethingWentWrongScreen

Image

This is the main error screen that appears if the ML model or SKU fails to load.

  • Clicked on Choose different method button
GlamAR.addEventListener("ui-interactions", ({ screenType, buttonType }) => {
console.log("GlamAR: UI event:", screenType, "interacted with:", buttonType);
if (screenType === "somethingWentWrongScreen") {
if (buttonType === "chooseDifferentMethod") { /* Choose different method button clicked */ }
}
});

cameraFailed and cameraAccessDenied

Image

These are camera-related error screens that appear if the camera fails to load properly or access is denied.

  • Clicked on Choose different method button
GlamAR.addEventListener("ui-interactions", ({ screenType, buttonType }) => {
console.log("GlamAR: UI event:", screenType, "interacted with:", buttonType);
if (screenType === "cameraFailed" || screenType === "cameraAccessDenied") {
if (buttonType === "chooseDifferentMethod") { /* Choose different method button clicked */ }
}
});

restartPopUp

Image

Restart popup used in EyePD flow and Skin Analysis flow.

  • Clicked on No button
  • Clicked on Yes, restart button
GlamAR.addEventListener("ui-interactions", ({ screenType, buttonType }) => {
console.log("GlamAR: UI event:", screenType, "interacted with:", buttonType);
if (screenType === "restartPopUp") {
if (buttonType === "no") { /* No button clicked */ }
if (buttonType === "yes") { /* Yes, restart button clicked */ }
}
});

quitPopUp

Image

Quit confirmation popup used in EyePD and Skin Analysis flows.

  • Clicked on No button
  • Clicked on Yes, quit button
GlamAR.addEventListener("ui-interactions", ({ screenType, buttonType }) => {
console.log("GlamAR: UI event:", screenType, "interacted with:", buttonType);
if (screenType === "quitPopUp") {
if (buttonType === "no") { /* No button clicked */ }
if (buttonType === "yes") { /* Yes, quit button clicked */ }
}
});

toast

Image

Default toast shown for errors encountered.

  • Clicked on Close (X) button
GlamAR.addEventListener("ui-interactions", ({ screenType, buttonType }) => {
console.log("GlamAR: UI event:", screenType, "interacted with:", buttonType);
if (screenType === "toast") {
if (buttonType === "close") { /* Close button clicked */ }
}
});

add-to-cart

Fired when user clicks on add to cart button of any particular SKU. This event returns two variables inside its payload,

  • skuId in string format
  • productName in string format

This can be used to identify which product was selected to add to cart. On your end, you can add it to the cart or do anything required, and then if you want SDK's UI to reflect this confirmation that required action was completed, you will have to call

// Listen for the 'add-to-cart' event
GlamAR.addEventListener('add-to-cart', ({ skuId, productName }) => {
console.log("GlamAR: Add to cart:", productName, "id:", skuId);

// Perform your add-to-cart operation in your system
// ...

// Notify the SDK that the item was successfully added
GlamAR.addedToCart(skuId);
// Note: skuId must match the one received from the event
});

add-to-cart-global

Fired when user clicks on the cart icon in the top navigation bar. This is can be used to open your own cart section, to show all the items in cart.

// Listen for the 'add-to-cart-global' event
GlamAR.addEventListener('add-to-cart-global', () => {
console.log("GlamAR: Open Global Cart clicked");

// Open your own global Cart section in your app
// ...

// If desired, close the SDK after opening the cart
// GlamAR.close();
});

Advanced Events

subscription-invalid

Fired when the subscription is found to be invalid or expired. Check the Pixelbin > GlamAR > Plans to make sure your plan is active and has enough credits.

// Listen for the 'subscription-invalid' event
GlamAR.addEventListener('subscription-invalid', () => {
console.log("GlamAR: Subscription has expired or credits consumed. Check plan status in console");
});

overriden-ui-action

Fired when any UI that is prompted to be shown but has been deactivated from GlamAR console. User inside custom code can toggle ui as per his need. So when inside SDK that perticular UI is supposed to activate, instead of activating it, it will send this event with two variables

  • type in string | with possible values of popup|screen as values
  • name in string | with possible value of name of any overriden ui available

Note: Restart popup is dependent on the category choosen, it shows up for EyePD flow and Skin Analysis flow. So if you override this popup it will not show up for both cases

Image

// If 'heroScreen' has been overridden, this triggers once the SDK loads successfully after 'init'
GlamAR.addEventListener('overriden-ui-action', ({ type, name }) => {
console.log("GlamAR: type", type, "name", name);
if (type === "screen" && name === "heroScreen") {
// Show your own hero screen
// Show your own UI for Live TryOn or Model TryOn
// Call GlamAR.open() and GlamAR.open("imgTryOn") respectively
}
});

// If 'quit' has been overridden, this triggers when the popup opens after 'X' icon is clicked
GlamAR.addEventListener('overriden-ui-action', ({ type, name }) => {
console.log("GlamAR: type", type, "name", name);
if (type === "popup" && name === "quit") {
// Show your own quit popup
// 'No' just closes the popup
// 'Yes' call GlamAR.close()
}
});