MonetizationOS Docs
Workflows ReferenceType Definitions

TraitWorkflowManagementUtils

type TraitWorkflowManagementUtils = {
  identity: {
     assignTrait: (identifier, groupId, trait, options?) => Promise<void>;
     deleteTrait: (identifier, groupId, traitKey, options?) => Promise<void>;
     getTraitGroups: (identifier, options?) => Promise<Record<string, WorkflowTrait[]>>;
     setTraitGroup: (identifier, groupId, traits, options?) => Promise<void>;
  };
};

Utilities for managing trait groups within workflow execution.

Properties

identity

identity: {
  assignTrait: (identifier, groupId, trait, options?) => Promise<void>;
  deleteTrait: (identifier, groupId, traitKey, options?) => Promise<void>;
  getTraitGroups: (identifier, options?) => Promise<Record<string, WorkflowTrait[]>>;
  setTraitGroup: (identifier, groupId, traits, options?) => Promise<void>;
};
  • assignTrait

    assignTrait: (identifier, groupId, trait, options?) => Promise<void>;

    Assign a single trait to a group on a given identity. Other traits in the group are preserved. If a trait with the same key already exists, its validity periods are merged with the new ones (duplicates removed). The serialized trait groups for an identity must not exceed 256 kB.

    Parameters

    ParameterTypeDescription
    identifierWorkflowUserIdentifierThe user or session to assign the trait to.
    groupIdstringA non-empty string identifying the trait group. Must be no longer than 64 characters.
    traitWorkflowTraitThe trait to assign. Its key must be a non-empty string no longer than 128 characters.
    options?IdentityTraitWorkflowOptionsOptional settings for the operation.

    Returns

    Promise<void>

  • deleteTrait

    deleteTrait: (identifier, groupId, traitKey, options?) => Promise<void>;

    Delete a single trait from a group on a given identity. Other traits in the group are preserved.

    Parameters

    ParameterTypeDescription
    identifierWorkflowUserIdentifierThe user or session to delete the trait from.
    groupIdstringA non-empty string identifying the trait group.
    traitKeystringThe non-empty key of the trait to delete.
    options?IdentityTraitWorkflowOptionsOptional settings for the operation.

    Returns

    Promise<void>

  • getTraitGroups

    getTraitGroups: (identifier, options?) => Promise<Record<string, WorkflowTrait[]>>;

    Retrieves all trait groups for the specified identity.

    Returns a mapping where each key is a trait group ID and each value is the array of traits currently stored for that group.

    Parameters

    ParameterTypeDescription
    identifierWorkflowUserIdentifierThe user or session whose trait groups should be fetched.
    options?IdentityTraitWorkflowOptionsOptional settings for the retrieval operation.

    Returns

    Promise<Record<string, WorkflowTrait[]>>

    A promise that resolves to a record of trait groups keyed by group ID.

  • setTraitGroup

    setTraitGroup: (identifier, groupId, traits, options?) => Promise<void>;

    Replace the traits for a group on a given identity. Any traits previously stored under this group ID are overwritten entirely. The serialized trait-groups blob for this identity must not exceed 256 kB.

    Parameters

    ParameterTypeDescription
    identifierWorkflowUserIdentifierThe user or session to assign the traits to.
    groupIdstringA non-empty string identifying the trait group. Must be no longer than 64 characters.
    traitsWorkflowTrait[]The traits to assign. Trait keys must be a non-empty string no longer than 128 characters.
    options?IdentityTraitWorkflowOptionsOptional settings for the operation.

    Returns

    Promise<void>

On this page