TrackerRepository

TrackerRepository is a global Singleton.

TrackerRepository<T extends Tracker>

It allows the creation and use of multiple Tracker instances in the same Application.

Properties

trackersMap

trackersMap = new Map<string, T>();

A Map of all Trackers that have been pushed in the Repository using add.

FYI

makeTracker and getOrMakeTracker automatically push new Tracker instances in the TrackerRepository.

defaultTracker

defaultTracker?: T;

The default Tracker instance. It's going to be used by any API not receiving a specific Tracker instance.

FYI

The first Tracker instance added to the TrackerRepository is also automatically set as default

Methods

add

add(newInstance: T): void

Add a new Tracker instance to the trackersMap. The first instance added is also set onto defaultTracker.

delete

delete(trackerId: string): void

Delete a Tracker instance from the trackersMap by trackerId.

get

get(trackerId?: string): T

Get a Tracker instance from the trackersMap by trackerId. If trackerId is omitted, defaultTracker is returned, if set.

FYI

This method can be invoked also by using the getTracker general API.

setDefault

setDefault(trackerId: string): void

Changes the default Tracker instance by replacing the instance stored in defaultTracker.

FYI

This method can be invoked also by using the setDefaultTracker general API.

activateAll

activateAll(): void

Iterates through all instances in trackersMap and calls setActive(true) method for each.

deactivateAll

deactivateAll(): void

Iterates through all instances in trackersMap and calls setActive(false) method for each.

flushAllQueues

flushAllQueues(): void

Iterates through all instances in trackersMap and calls flushQueue() method for each.