Developer
User guidesDeveloper websiteHelp centerLog in
  • Welcome!
  • Organisations structure
    • Datamart
    • Users and roles
  • User points
    • User identifiers
      • Networks IDs
        • Device-based Network IDs
          • Custom Device ID integration
          • ID5
          • First ID
        • User-based Network IDs
          • Custom User ID integration
          • UTIQ martechpass
      • Accounts
      • Emails
      • Device identifiers
    • User activities and events
    • Compartments
    • User profiles
    • User segments
    • Hyper point & Quarantine
  • Data model
    • Defining your schema
    • Computed fields
      • Concepts
      • Setup
      • Development
      • Examples
  • Data ingestion
    • Real time user tracking
      • Website tracking
      • Mobile apps tracking
      • Ads exposure tracking
      • AMP tracking
      • Conversions tracking
      • Email views and clicks
      • Tracking API
      • Event rules
      • Activity analyzers
    • Bulk processing
      • Imports
        • User activities import
        • User profiles import
        • User choices import
        • Segments import
      • Deletions
        • User identifiers deletion
        • Device points deletion
        • User points deletion
      • User identifiers association
      • Integration batch
    • Activities analytics
    • Data warehouse
      • Preliminary setup
        • BigQuery
      • Create data warehouse
  • Querying your data
    • OTQL queries
    • OTQL examples
    • GraphQL queries
    • UserPoint API
    • User activities
    • Activities analytics queries
      • API Quickstart
      • Dimensions and metrics
      • Use cases
    • Funnel API
  • Alerting
    • Alert configurations
  • Data visualisation
    • Quickstart
    • Dashboards
    • Sections and cards
    • Charts
    • Datasets and data sources
      • Using a data file data source
    • Transformations
    • Filters
    • Cookbook
    • Reference
  • Advanced usages
    • Audience segmentation
      • Audience features
      • Segment builders
      • Audience segment metrics
      • Audience segment feed
        • Building new feeds
        • Monitoring a feed
        • Curated Audiences (SDA)
      • Edge segments
      • Cohort-based Lookalike
    • Contextual targeting
      • Setup
      • Activation
        • Google Ad Manager
        • Xandr (through prebid.js)
      • API documentation
    • Exporting your data
      • Query Exports
      • Datamart replication
    • Data privacy compliance
      • User choices
      • Cleaning rules
      • Exercise of user rights
      • Cookies
    • Campaigns
    • Automations
      • Email routers
      • Email renderers
      • Opt-in provider
      • Custom action plugins
      • Usage limits for automations
    • Plugins
      • Concepts
      • Creation & Deployment
      • Coding your plugin
      • Manage existing plugins
      • Layouts
      • Presets
      • Monitoring
      • Throttling
      • Batching (for external feeds)
    • Platform monitoring
      • Resources usage
        • Dimensions and metrics
      • Collection volumes
        • Dimensions and metrics
      • Events ingestion monitoring
        • Dimensions and metrics
    • Data Clean Room
      • Bunker
      • Clean room
  • Resources
    • Tutorial: Data Ingestion
      • Your first events
        • Add the mediarithmics tag
          • Getting the tag
          • Adding the tag
        • Send events using the tag
          • Adding event properties
          • Finding the UserEvent type in your schema
          • Matching your schema
          • Standard events
      • Your first bulk imports
        • API basics
          • Authentication
          • Your first API call
        • Send documents using the API
          • Requirements
          • Sending documents
    • Using our API
      • Authentication
    • Tools & libraries
      • mics CLI
      • JS Tag
      • Plugin SDK
    • Data cubes
      • Creating a report
      • Reference
Powered by GitBook
On this page
  • List of Methods
  • OnUpdate methods
  • buildResult
  • Test
  • Best Practices

Was this helpful?

Export as PDF
  1. Data model
  2. Computed fields

Development

List of Methods

OnUpdate methods

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

These methods must be commutative to ensure consistency during initial loading, where event order is not guaranteed. It should always produce the same result, regardless of the sequence in which events are processed.

To prevent system overload, the State size is restricted to a maximum of 1 MB. If this limit is exceeded, the update will be discarded and not saved.

onUpdateActivity

onUpdateActivity(state: State, userActivity: UserActivity): State

  • Inputs:

    • state: Current state object.

    • userActivity: New user activity data.

  • Outputs: Updated state object.

  • What It Does: Updates the state with new user activities and removes outdated activities.

  • Example:

// Trigger by a new activity
onUpdateActivity(state, userActivity) {
    // Logic to update state
    return updatedState;
}

The activities or profiles received by the plugin are raw data, so you can't rely on the structure defined in your schema to understand its design. However, you can refer to the structure outlined on the User Lookup page.

onUpdateUserProfile

onUpdateUserProfile(state: State, userProfile: UserProfile, operation: core.Operation): State

  • Inputs:

    • state: Current state object.

    • userProfile: Updated user profile data.

    • operation: Operation type (enum: UPDATE | DELETE).

  • Outputs: Updated state object.

  • What It Does: Handles updates to user profiles.

  • Example:

// Trigger by an update on the user profile
onUpdateUserProfile(state, userProfile, operation) {
    // Logic to handle user profile updates
    return updatedState;
}

onUpdateComputedFields

onUpdateComputedFields(state: State | null): Result

  • Inputs: state: Current state object or null.

  • Outputs: Result object.

  • What It Does: Computes the result from the current state.

  • Example:

// Trigger by the result computation of another computed field
onUpdateComputedFields(state) {
    // Logic to compute result
    return state;
}

This method must be implemented, even if it not currently used.

Please return the same state.

buildResult

buildResult(state: State | null): Result

  • Inputs: state: Current state object or null.

  • Outputs: Result object.

  • What It Does: Computes the result from the current state.

  • Example:

buildResult(state) {
    // Logic to compute result
    return result;
}

Test

Before deploying the plugin, create tests to ensure the function behaves as expected.

Test cases might include:

  • Adding new activities, and update profiles and verifying the state is updated correctly. Check that the order we send profile updates and activities has no impact.

  • Checking that activities which are no more relevant to compute the result are removed from the state.

  • Validating that the correct values are returned in the result.

Best Practices

  • How to decide if we create 1 or several plugin(s)? (example with 2 scores)

    • If the required data in the state is the same for both scores → 1 plugin

    • If the required data in the state is different (state is polymorph) → 2 plugins

  • Always return the same state in case of error, or null. Otherwise, we delete the state, and so reset the result.

  • Maximize the number of scores calculated by a Computed Field Function to optimize performance. Therefore, the same state is used to calculate multiple scores, and we avoid storing the same state multiple times.

  • Ensure that the state is designed to store relevant information efficiently and is commutative to maintain consistency while building the result.

  • Be sure to have a cleaning rule to update the state base on the defined lookback window for both userProfile and userActivities.

    • In other words, when updating the state, be sure to remove the data that are no more useful to compute the result, in order to limit the state size.

  • When editing a live computed field, you must relaunch an Initial Loading through API.

PreviousSetupNextExamples

Last updated 3 days ago

Was this helpful?