Web SDK

This document provides a technical reference for the functionality available in the MMOB Web SDK. The SDK exposes various methods on the global mmob object. Each section below details the available methods, their parameters, and expected usage.

Methods

init

Fields

Attribute Type Required Default Description
deployer_id string Yes N/A The unique identifier of the entity deploying the application.
integration_id string Yes N/A A unique identifier for the specific integration instance. It represents a particular configuration of the application, distinguishing it from other integrations. It is generated on instance creation.
location string | HTMLElement Yes #YOUR-TARGET-ELEMENT

Defines the location where the embedded application will be placed.

  • A CSS selector string (e.g., "#app-container", ".embed-target").

  • A direct DOM element reference (e.g., document.getElementById("app-container")).
owner_id string Yes N/A

The unique identifier of the owner of the application.

view_id string No N/A

An optional unique identifier for the initial view (or page) that the application will render. If not provided, the application will default to rendering the first created view.

uid string No N/A

The uid is an optional unique identifier for the user. It can be any value that uniquely represents the user, such as an email or a custom user ID. For more details, see Managing User Sessions.

data_passport Record<string, string | number | boolean> No N/A

An optional object for "passporting" or sending data into the application, making it available for use inside the embedded environment.
The object consists of key-value pairs where:

  • Keys must be string.
  • Values can be string, number, or boolean.

This allows passing configuration settings, user-specific data, or other contextual information the application needs at runtime.


Usage

  • The snippet is generated with #YOUR-TARGET-ELEMENT as the default location value, but this must be modified to match an actual element in your DOM. Ensure that the specified selector or element reference correctly identifies the target container where the application should be injected. If the location value is not found or remains unchanged, the application will not render.
  • If no uid is provided, a random identifier will be assigned, but this will only persist for a single session. To maintain user sessions across visits, it is strongly recommended to provide a consistent uid for each user entering your application. For more details, see Managing User Sessions.

Example

mmob.init({
  deployer_id: "dr_RWs0O1fmlJ5ysB3e1brOp",
  integration_id: "cpd_dJcFTENMGy90ez6jP3Fwf",
  location: "#app-container",
  owner_id: "owner_mmob",
  view_id: "view_XXX",
  uid: "example-user@example.com",
  data_passport: {
    first_name: "John",
    last_name: "Doe",
    age: 30,
    marketing_opt_in: false
  }
});

Events

onEnd

The onEnd method allows you to listen for an "Application End" event triggered within the embedded application. This event is fired when the application owner defines an end action within the Flow Composer. The event can be triggered by user interactions or other logic configured by the application owner, allowing developers to execute additional actions in response.

Usage

The onEnd method registers an event listener that provides a timestamp indicating when the event occurs. It returns an unsubscribe function, which can be used to remove the listener when it is no longer needed.

Example

// Register an event listener for the "Application End" event
const unsubscribe = mmob.onEnd((timestamp) => {
    console.log("Application has ended at:", timestamp);

    // Perform any necessary cleanup or trigger additional actions
    window.alert("The embedded application has ended!");
});

// To stop listening for the event, call the unsubscribe function when needed
// unsubscribe();

In this example:

  • mmob.onEnd() listens for the application end event.
  • The event is triggered based on the application's configuration.
  • When the event fires, your callback function is executed with a timestamp and an alert is displayed.
  • The returned unsubscribe function allows for manual removal of the event listener.

Unsubscribing from the listener

If you need to stop listening for the "Application End" event, you can call the unsubscribe function:

unsubscribe();

The function returned by mmob.onEnd() is the unsubscribe function. You can store it in a variable and call it later to remove the event listener. While unsubscribe is used in this example, you can name this function whatever you prefer.

This ensures that the listener is removed, preventing unnecessary event calls and avoiding potential memory leaks.

Since this event is controlled by the application owner, its behaviour depends on how the embedded application is designed. By using onEnd(), you can track when users complete their interaction with the application and trigger cleanup operations, analytics events, or other business logic.

Further Reading

For more guidance on using the SDK, refer to the following resources:

Was this page helpful?