Condition types for web extensions

A condition type library module has one goal: evaluate whether something is true or false. What it evaluates is up to you.

NOTE

This document covers condition types for web extensions. If you are developing an edge extension, see the guide on condition types for edge extensions instead.

This document also assumes you are familiar with library modules and how they are integrated in Platform Launch extensions. If you require an introduction, see the overview on library module formatting before returning to this guide.

For example, if you wanted to evaluate whether the user is on the host example.com, your module may look like this:

module.exports = function(settings) {
  return document.location.hostname === 'example.com';
};

Now, consider a situation where you want to make the hostname configurable by the Adobe Experience Platform Launch user. You may allow the user to input a hostname and then save the hostname to the settings object. The object might look something like this:

{
  "hostname": "example.com"
}

In order to operate on the user-defined hostname, your module would need to change to this:

module.exports = function(settings) {
  return document.location.hostname === settings.hostname;
};

Contextual event data

A second argument is passed to your module which contains contextual information regarding the event that fired the rule. It may be beneficial in certain cases and can be accessed as follows:

module.exports = function(settings, event) {
  // event contains information regarding the event that fired the rule
};

The event object must contain the following properties:

Property Description
$type A string describing the extension name and event name, joined using a period. For example, youtube.play.
$rule An object containing information about the currently executing rule. The object must contain the following sub-properties:
  • id: The ID of the currently executing rule.
  • name: The name of the currently executing rule.

The extension providing the event type that triggered the rule may optionally add any other useful information to this event object.

On this page

Adobe Summit Banner

A virtual event April 27-28.

Expand your skills and get inspired.

Register for free
Adobe Summit Banner

A virtual event April 27-28.

Expand your skills and get inspired.

Register for free
Adobe Maker Awards Banner

Time to shine!

Apply now for the 2021 Adobe Experience Maker Awards.

Apply now
Adobe Maker Awards Banner

Time to shine!

Apply now for the 2021 Adobe Experience Maker Awards.

Apply now