getOrMakeTracker

Retrieves a specific Tracker's instance from the TrackerRepository or creates one if it doesn't exist yet.

const getOrMakeTracker = (trackerConfig: BrowserTrackerConfig) => BrowserTracker 

Returns

BrowserTracker

Use case

When calling makeTracker once is not possible due to SPA concerns, like re-renders, this function can be used instead. It's safe to be called multiple times a long as the given configuration remains the same. Exception made for the active and anonymous parameter.

Internally uses compareTrackerConfig to determine configuration equality.

Tracker configuration collisions

An error will be logged if the given Tracker ID exists in TrackerRepository but its configuration doesn't match the given one.

This usually means that getOrMakeTracker is unstable and has been called multiple times with different configurations.

When this happens, the new configuration will be ignored and the existing Tracker instance will be returned.