For the complete documentation index, see llms.txt. This page is also available as Markdown.

Plugin architecture

How the platform hosts your code: plugins, versions, workers, instances, and properties.

Your goal

Understand the model before you write a plugin, so your first version is versioned, configurable, and deployable without surprises.

Expected outcome

You can say what a plugin, a version, a worker, and an instance each are - and you know which of them your code has to be aware of at runtime.

What a plugin is

A plugin is a package of code hosted by the platform, used to modify or extend the platform's features. It is a piece of logic encapsulated in a web service, and it can be developed in many languages.

The platform hosts and monitors it directly, which is what enables event-based triggering and fast access to the data. Once instantiated, a plugin listens on an HTTP port for requests coming from the platform, and depending on its type it must comply with a specific REST API.

Use the Plugin SDK to get off-the-shelf endpoint connectivity and accelerate development. With Node.js, the SDK handles the instance and property fetching described below for you.

The plugin types

Type
What it does
Documented in

Activity analyzer

Enriches real-time user tracking data.

Audience segment external feed

Sends data to a partner, either in server-side streams or by showing a pixel to users in the segment.

Computed field function

Manages a calculated field in your schema.

Custom action

Launches a custom action in automations.

Display ad renderer

Customises the rendering of display ads.

-

Attribution engine

Customises the attribution of a marketing goal to different campaigns.

-

Integration batch

Manages data imports or exports by producing a batch of multiple items at once, one stage at a time.

-

ML Algorithm

Manages the calculation of predictions attached to a user, in an event-based manner. Used together with an ML Function.

-

The plugin objects

They are easiest to understand as a chain: you declare a plugin, publish a version of it, the platform runs workers for that version, and your users create instances configured through properties.

The same thing as a story

A developer wants an activity analyzer that parses real-time navigation data from a site and adds a product code taken from an external system.

  1. The developer declares a plugin with the activity analyzer type.

  2. They create version 1.0.0, declaring two properties - a string for the configuration file name to retrieve, and a boolean asking whether the code overwrites the product name - plus a layout for the form end users will fill in. They deploy the code attached to this version.

  3. The platform automatically creates a worker running the code, waiting for activities.

  4. A user attaches version 1.0.0 to their site and sets the properties. An instance is created. Each time an activity arrives for that site, the worker receives a request and adapts its logic to the context and the properties.

  5. The same user attaches the same version to an app. A second instance is created, with its own properties.

  6. The user asks for a new parameter. The developer creates version 2.0.0, redeclares the old properties and adds the new one, specifies a new layout, and deploys new code. The platform creates a new worker for it.

  7. The user adds version 2.0.0 to the site and removes 1.0.0 from it. Activities from the site are now analysed by 2.0.0, while activities from the app are still analysed by 1.0.0.

Plugin

The top-level declaration. It is attached to a specific organisation and has a specific type.

It is classified by a group_id and an artifact_id:

  • group_id is the name of the context, usually a reversed domain name such as com.mediarithmics.creative.display. Lowercase alphanumeric characters, dots, hyphens, and underscores.

  • artifact_id is the technical name of the plugin, such as image-iframe. Lowercase alphanumeric characters, hyphens, and underscores - no dots.

Versions

A plugin supports multiple versions, each with its own codebase, layouts, properties, declarations, and configuration files, and several can be available at once. A version number is three digits with an optional suffix - 1.0.0, 1.2.0-rcl.

Status
What it means

DRAFT

The initial state. Editable, but not usable until deployed.

DEPLOYING

For hosted containers: the platform is creating the container.

TESTING

Accessible to organisation administrators only. Can still be updated and tested in production, but users cannot create instances yet.

LIVE

Available to all users, and cannot be modified. Can be designated as the current_version, making it the default.

DECOMMISSIONED

Still visible, no longer usable. A version can only be decommissioned if no active instances exist in production.

ARCHIVED

Removed from the interface.

When to create a new version - when you need to edit properties, or when you want plugins already added by users to keep their existing behaviour.

You do not create a version to fix something in the code, or to change a delay in a configuration file. You do create one if the user should enter a new property value, or if your code changes so that existing instances should not use it.

Updating a version, you can change
You cannot change

Configuration files, external services, code, layouts

Properties

Creating a new version means redeclaring properties - changed or not - re-uploading configuration files, redeclaring external services and making sure they are enabled, redeploying the code with an updated version number in the build definition, and redeclaring the layouts.

Workers

To scale the processing of your plugin, the platform deploys its code several times on different servers and load-balances between them. Each of those deployments is a worker.

A new worker is created each time you create a version, or when scaling is needed. During that process the worker's /init route is called for initialisation and authentication, and it joins the other workers once its /status route responds ready.

Instances

An instance is created in the interface when a user configures a plugin for a use case. It links a plugin version, property values, and a context of execution - a segment, a channel, a datamart.

Configuring the same plugin for a different target does not necessarily create a new worker, but it always creates a new instance. Your code must therefore retrieve the instance to adapt to its context:

1

Find the instance in the request

Its ID is always in the request body - creative_id for a display ad renderer, activity_analyzer_id for an activity analyzer.

2

Fetch the properties of that instance

And cache them for future use.

3

Process according to that configuration

Properties

A version declares the properties available in its instances.

The possible origins:

Origin
Meaning

PLUGIN_STATIC

Reserved for mandatory properties defined by mediarithmics. Every version must define name and provider. You can set their values, but change nothing else. Not writable, so the value is identical in every instance.

PLUGIN

Your custom properties, declared per version. Set writable: true to give a default value that instances can override, or false for a value shared by all instances.

INSTANCE

Properties specific to one instance of a version.

provider is usually mediarithmics for plugins made by mediarithmics, and the integrator or customer name otherwise.

For usability, keep to no more than 15 PLUGIN properties per version. Beyond that, use a DATA_FILE property.

Property types

Type
Value shape

STRING

{"value":"mystring"}

INT

{"value":12}

DOUBLE

{"value":12.45}

BOOLEAN

{"value":true}

URL

{"url": "https://example.com"}

ASSET (deprecated)

{"original_file_name": "cat.png", "asset_id": "1333", "file_path": "/1/public/assets/cat.png"}

DATA_FILE

{"uri": "", "last_modified": null}

ASSET_FILE

{"original_name": "cat.png", "asset_id": "1333", "path": "/1/public/assets/cat.png"}

ASSET_FOLDER

{"original_name": "cat.png", "asset_id": "1333", "path": "/1/public/assets/cat.png"}

AD_LAYOUT

{"id": "12", "version": "34"}

STYLE_SHEET

{"id": "12", "version": "34"}

PIXEL_TAG

{"value": "https://example.com/pixel"}

RECOMMENDER

{"recommender_id": "1"}

Some plugin types add their own property types, documented with that type.

Data files

A DATA_FILE property points to a file uploaded to the platform - usually JSON - containing information the plugin uses at runtime.

Use one instead of many properties when you want to:

  • update several versions or instances at once by uploading a new version of the file,

  • store a large number of advanced properties,

  • keep properties that only power users should touch out of the ordinary form.

Layouts

A layout lets you customise the new-instance and edit-instance screens: grouping properties into categories, and choosing the type of field representing each one. A layout is bound to a plugin version.

Controlling how hard a plugin is called

Some plugins call external providers with their own API limits, and not every plugin handles the errors that occur when those limits are hit. Throttlings reduce plugin calls before the limits are reached.

A throttling limits a given plugin version in these ways - you must define at least one:

Field
What it limits

max_qps

Calls per second. It can be decimal: 0.5 means at most one call every two seconds.

max_concurrency

Simultaneous calls.

timeout_ms

Maximum call duration - the call is killed beyond it.

Throttlings can be defined at these scopes: GLOBAL, CONTAINER, ORGANISATION, and DATAMART. For the organisation and datamart scopes, throttling_key holds the corresponding ID, and plugin_endpoint names the routes affected - for example /v1/user_segment_update. scope and plugin_endpoint are required.

Last updated

Was this helpful?