AnalyticsManager Class
Provides functionality to render HTML snippets to report metrics back to registered analytics providers.
Constructor
AnalyticsManager
-
options
Parameters:
-
optionsObject-
[site='global']String optional -
[timeout=25]Integer optionalThe amount of time, in milliseconds, that the manager will wait for each provider to render.
-
Item Index
Methods
- buildDomainErrorHandler static
- buildProviderResponseHandler static
- buildRenderTask static
- buildTimeoutHandler static
- gatherData
- getKeys static
- getStats static
- getStats static
- isRegistered static
- keyHandler static
- onPageRender static
- registerProvider static
- unregisterProvider static
- updateStatBlock static
Properties
- DEFAULT_RESULT static
- DEFAULT_TIMEOUT static
- PROVIDER_HOOKS static
- site
- STATS static
- timeout
Methods
buildDomainErrorHandler
-
opts
Parameters:
-
optsObject-
keyString -
methodString -
urlString -
startIntegerThe epoch when the provider started execution
-
thObjectThe timeout handle for the provider execution
-
callbackFunction
-
Returns:
buildProviderResponseHandler
-
opts
Parameters:
-
optsObject-
keyString -
methodString -
urlString -
startIntegerThe epoch when the provider started execution
-
thObjectThe timeout handle for the provider execution
-
callbackFunction
-
Returns:
buildRenderTask
-
key -
req -
session -
ls
Parameters:
-
keyString -
reqRequest -
sessionObject -
lsLocalization
Returns:
buildTimeoutHandler
-
opts
Parameters:
-
optsObject
Returns:
gatherData
-
req -
session -
ls -
cb
Takes the provided request and session then checks with each of the registered analytics providers to ensure get the HTML snippets to be executed for analytics reporting.
Parameters:
-
reqRequestThe current incoming request
-
sessionObjectThe current user session
-
lsLocalizationAn instance of the Localization service
-
cbFunctionA callback that provides two parameters. An error, if occurred, and a TemplateValue representing the HTML snippets for the analytic providers.
getKeys
-
site
Parameters:
-
siteString
Returns:
getStats
()
Object
static
Retrieves timing metrics for analytic providers. Handy for debugging timeouts
Returns:
getStats
()
Object
static
Updates the runtime statistics to include
Returns:
isRegistered
-
name -
[site='global']
Indicates if an analytics provider with the specified name has already registered itself.
Parameters:
-
nameStringThe name of the analytics provider to check registration for
-
[site='global']String optional
Returns:
TRUE when the provider is registered, FALSE if not
keyHandler
-
keyHash
Parameters:
-
keyHashObject
Returns:
onPageRender
-
req -
session -
ls -
cb
Called when a page is rendering. It creates a new instance of the analytics manager and constructs the javascript snippets (wrappered in TemplateValue) needed for the analytics plugins
Parameters:
-
reqRequest -
sessionObject -
lsLocalization -
cbFunctionA callback that provides two parameters. An error, if occurred, and a TemplateValue representing the HTML snippets for the analytic providers.
registerProvider
-
name -
[site='global'] -
onPageRendering
Registers an analytics provider. When a template is being rendered and encounters the ^analytics^ directive "onPageRender" is called.
Parameters:
-
nameStringThe provider's name
-
[site='global']String optional -
onPageRenderingFunctionA function that is called for every requests that intends to execute HTML snippets to track analytics. The function is expected to take 4 parameters. The first is the current Request object. The second is the current user session object. The third is an instance of Localization. The last is a callback that should be called with two parameters. The first is an error, if occurred and the second is raw HTML string that represents the snippet to be executed by the analytics plugin.
unregisterProvider
-
name -
[site='global']
Unregisters an analytics provider
Parameters:
-
nameString -
[site='global']String optional
Returns:
TRUE if was unregistered, FALSE if not found
updateStatBlock
-
runTime -
block
Parameters:
-
runTimeIntegerThe amount of time that the provider ran in milliseconds
-
blockObjectThe block that contains the stats for the provider
Properties
DEFAULT_RESULT
String
private
static
The value provided as the result of the rendering when there is nothing to perform for a task
DEFAULT_TIMEOUT
Integer
private
static
The default amount of time, in milliseconds that the manager will wait for each provider to render.
PROVIDER_HOOKS
Object
private
static
Stores the registered analytics providers
site
String
The site context for the instance
STATS
Object
private
static
Stores the registered runtime metrics for the providers
timeout
Integer
The amount of time, in milliseconds, that the manager will wait for each provider to render.
