Self-Describing Events with Contexts?

Direct question:
is it possible to track a self-describing event and also track contexts alongside it?

For context:

We’re planning on using snowplow to track performance and user behavior of an application. For the performance metrics, we’ve designed context schemas to represent different components of the system, and were hoping to piggyback those as contexts alongside specific events. As an example, when a user clicks on our custom “share” UI, we want to report a “share” to snowplow along with the element that was clicked and other custom share-related info, as well as metrics about the underlying state of the application at the same time.

The problem we’re running into is that we want the schemas to be modular - the components of the application that report on their specific performance state should validate against a schema containing only those properties relevant to that component. We also don’t necessarily want to use the default structured event, because category /action / label aren’t as descriptive as we’d like for the specific event’s info. We settled on a few contexts, once for each component, and then self-describing event for that particular event’s properties. But, in trying to implement this system, we saw that the documentation describes contexts vs self-describing events as an either / or situation.

If not, we have a few solutions

Use structured events and only the category field and then give individual events their own context type
Use self-describing events with (nested) references inside to other context schemas

But are definitely open to suggestions

Thanks,
Scotty

@scotty, sure you can add contexts to self-describing events too. Here’s how (assuming Javascript tracker - see wiki here):

snowplow('trackSelfDescribingEvent', 
    {
        schema: 'iglu:com.acme/custom_event/jsonschema/1-0-0',
        data: {
            // custom event data
        },
    },
    [
        {
            schema: 'iglu:com.acme/custom_context_1/jsonschema/1-0-0',
            data: {
                // custom context 1 data
            }
        },
        {
            schema: 'iglu:com.acme/custom_context_2/jsonschema/1-0-0',
            data: {
                // custom context 2 data
            }
        },
        . . .
        // more contexts
    ]
);

The contexts are added as the last argument in the form of an array of contexts.

2 Likes