Setup

Computed fields are created as of plugin, requiring collaboration with mediarithmics Professional Services (PS) team.

The implementation involves defining the logic, writing plugin specifications, developing the plugin, and configuring the computed fields.

Please discuss your needs with your account manager.

Step 1: Create your computed field function (plugin)

Check the following documentation to learn more about Plugin development. Bellow are some precisions about specific Computed fields Function implementation.

Develop the plugin with the SDK and create a build from it

You are required to implement 4 key functions from the Plugin SDK.

OnUpdate functions

These 3 functions are triggered during the initialization of the Computed Field Function and whenever a new activity, profile update, or computed field modification occurs, updating the State accordingly.

You can find the list of all the methods to be developed here.

BuildResult

This function returns the result of the computed field function for a specific State. The Result will be stored for a defined duration, and querying the field will return the stored value during that period.

You can find all the details about this method here.

Create a plugin and a version

Follow the standard procedure to create a plugin with the type COMPUTED_FIELD_FUNCTION. Once the plugin is created, you can generate a new version from the build.

Step 2: Create your computed field within the platform

  1. In the Navigator > Settings > Datamart, navigate to Computed Fields.

  2. Add a new computed field.

  3. Select the plugin and version of the new instance you want to use.

  4. Complete the necessary fields:

Fields
Description

Name

Name of the computed field

Description

(Optional) Describe the computed field

Technical name

Name of the computed field used in the schema

Compute period (in days)

Maximal duration before the periodic update of the Result in days.

Events filter

GraphQL selector query to filter the activity which will trigger the State updates

This will set up the computed field linked to your computedfield function for use in the schema.

Step 3: Declare your computed field in your schema

After creating the computed field, you need to connect it to your schema:

  1. Use the directive @ComputedField(technical_name = "...") at the appropriate level of your schema.

  2. Ensure the technical name matches the one used when creating the computed field.

This will integrate the computed field into your schema and make it available for use in queries and operations.

// Example in your schema 
type UserPoint {
  id: ID!
  accounts: [UserAccount]

  rfm_score: RfmScore @ComputedField(technical_name = “RfmScore”) @TreeIndex(index:"USER_INDEX")
}

type RfmScore {

}

A schema validation will be triggered when you click Save. It will ensure that your Datamart has access to all the declared computed fields and verify their integration with the schema.

Step 4: Wait until the end of the initial loading

Once your schema is validated, our service will run a job to initialize your computed field and set the state to match the current status of the timeline. For each user point in your Datamart, we will process their timeline and execute the OnUpdateXXX() function.

To monitor the progress:

  1. Go to the Computing Console > Computed Fields.

  2. Check if your computed field is ready or if the initial loading is still in progress.

Please note, this process may take some time to complete (up to 72h) as it computes the timelines for all user points.

Step 5: Use your computed field

Once the initial loading is complete, you can start using your computed field just like any other standard field in mediarithmics features.

For example, in query tools or any OTQL query:

SELECT { rfm_score } FROM UserPoint

If your computed field is indexed, you can also perform queries like:

SELECT { id } FROM UserPoint WHERE rfm_score = "PASSIVE"

This allows you to incorporate the computed field into your data analysis and queries once it's fully initialized.

Last updated

Was this helpful?