MetricDependency: how it works

#1

Hi, I would like to know in depth the the type MetricDependency. I discovered this type when I started working with Analytics. I saw that if this type have no entries in the environment, Analytics are not triggered.
In 7.2 version, having several errors with the Analytics, I deleted all the entry present in this table with the command

MetricDependency.removeAll()

And recreated the dependencies, but is not clear how it works.

To re-create the dependencies what is the correct command to launch? And what is the logic that the system follows to create automatically the entries for this type?

Thanks,
Laura

1 Like

#2

A Tag rebuild is the preferred way to build those dependencies.
Tag.rebuild({id: "yourTagId"}, {metricDeps: true})

High level explanation: Analytics rely on a series of DFEs to trigger, those DFEs create a dependency graph all the way to the database. If data changes then a Data Flow Event is triggered, then another, etc. until Analytics are reached.
Resolving those dependencies every time would be expensive, so a form of cache is used. It basically builds a correspondance table between the series where the “listeners” are placed to capture a database transaction, and the source objects that need to be invalidated.

4 Likes