makeTracker
Creates a new BrowserTracker and adds it to the TrackerRepository. Then calls startAutoTracking for it.
makeTracker = (parameters: {
applicationId: string,
trackerId?: string,
queue?: TrackerQueue,
endpoint?: string,
transport?: TrackerTransport,
plugins?: TrackerPlugins,
active?: boolean,
anonymous?: boolean,
trackApplicationContext?: boolean
trackHttpContext?: boolean
trackPathContextFromURL?: boolean
trackRootLocationContextFromURL?: boolean
trackApplicationLoadedEvent?: boolean
}) => BrowserTracker
info
The first created Tracker is automatically set as default in the TrackerRepository. See also getTracker and setDefaultTracker
Parameters
type | default value | ||
---|---|---|---|
required | applicationId | string | |
optional | trackerId | string | Same value as applicationId |
optional | queue | TrackerQueue | The result of makeBrowserTrackerDefaultQueue |
optional | endpoint | string | |
optional | transport | TrackerTransport | The result of makeBrowserTrackerDefaultTransport |
optional | plugins | TrackerPlugins | The result of makeBrowserTrackerDefaultPluginsList |
optional | active | boolean | true |
optional | anonymous | boolean | false |
optional | trackApplicationContext | boolean | true |
optional | trackHttpContext | boolean | true |
optional | trackPathContextFromURL | boolean | true |
optional | trackRootLocationContextFromURL | boolean | true |
optional | trackApplicationLoadedEvent | boolean | true |
caution
endpoint
and transport
are mutually exclusive. While both optional, either one must be specified.
When providing only endpoint
, the Tracker will automatically create a Transport configuration initialized with it.
Returns
Usage example
import { makeTracker } from '@objectiv/tracker-browser';
makeTracker({
applicationId: 'awesome-app',
endpoint: 'https://collector.app.dev'
})
makeTracker({
applicationId: 'awesome-app',
transport: CustomTransport
})
Transport ?