Writing Webtrends Infinity Tag Mutations

Mutations and Priority Ordering

Mutations are the Webtrends Infinity Tag equivalent of transforms, but allow access to a greater depth of the data payload. In the Webtrends Infinity Tag, the concept of data payload is separate from the communication protocol, and now creates messages. Messages include payload and specify the communication protocol to use. This allows us to switch out a given payload and communication protocol with ease.

Mutations have access to the entire message, and consequently can alter the data payload, as well as specify different communication protocols and endpoints. Mutations have the following priority ordering:

  1. System level transforms
  2. User level transforms (Default)
  3. Final level transforms

There are no guarantees on ordering of mutations within the same level. If no priority is given then the default is 2.

Example of adding mutation to add a value:

    var testMutation1 = function(msg){
        msg.payload["addedVal1"] = "value1";
    };

    WT.analytics.addMutation("myunique id", testMutation1);

Example of a mutation to add a value only once then deregister mutation:

    var testMutation2 = function(msg){
        msg.payload["addedVal2"] = "value2";
        WT.analytics.rmMutation("mutationId2")
    };

    WT.analytics.addMutation("myunique id", testMutation2);

Mutations API

WT.analytics.addMutation(mutantId, mutation)

Add a mutation to alter any data sent to the Webtrends servers:

  • mutantId {String}: A unique string identifier that is just a label used in debug messages
  • mutation {Function}: A function which takes a msg object as an argument

WT.analytics.rmMutation(mutantId)

Remove a mutation to alter any data being sent on the pipeline:

  • mutantId {String}: A unique string identifier that is just a label used in debug messages

Message API

The mutation function is called with a single argument containing the message object. Methods of that message object include setParam(key, val), getParam(key) and WT.common.TrackingPipeline.listMutations().

setParam(key, val)

This sets a parameter of lower case key to the value val:

  • key {String}: Unique key for payload parameter
  • val {String}: Value to set
    var testMutation1 = function(msg){
        msg.setParam("key1", "value1");
    };

    WT.analytics.addMutation("myunique id", testMutation1);

getParam(key)

Returns the value of key lowercase, or null if key is not currently defined in the message payload.

  • key {String}: Unique key for payload parameter
    var testMutation1 = function(msg){
        console.log(msg.getParam("key1"));

    };
    WT.analytics.addMutation("myunique id", testMutation1);

WT.common.TrackingPipeline.listMutations()

Sends list of mutation IdGenerator’s to debug output and returns an array containing a mutation tuple which includes both the ID and mutation function. Example below:

    var res = WT.common.TrackingPipeline.listMutations();
    // res[x] = {
    //    "id":"mutationId"
    //    "mutant": mutationFn
    // }