AnalyticsManager Class
Provides functionality to render HTML snippets to report metrics back to registered analytics providers.
Constructor
AnalyticsManager
-
options
Parameters:
-
options
Object-
[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:
-
opts
Object-
key
String -
method
String -
url
String -
start
IntegerThe epoch when the provider started execution
-
th
ObjectThe timeout handle for the provider execution
-
callback
Function
-
Returns:
buildProviderResponseHandler
-
opts
Parameters:
-
opts
Object-
key
String -
method
String -
url
String -
start
IntegerThe epoch when the provider started execution
-
th
ObjectThe timeout handle for the provider execution
-
callback
Function
-
Returns:
buildRenderTask
-
key
-
req
-
session
-
ls
Parameters:
-
key
String -
req
Request -
session
Object -
ls
Localization
Returns:
buildTimeoutHandler
-
opts
Parameters:
-
opts
Object
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:
-
req
RequestThe current incoming request
-
session
ObjectThe current user session
-
ls
LocalizationAn instance of the Localization service
-
cb
FunctionA callback that provides two parameters. An error, if occurred, and a TemplateValue representing the HTML snippets for the analytic providers.
getKeys
-
site
Parameters:
-
site
String
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:
-
name
StringThe 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:
-
keyHash
Object
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:
-
req
Request -
session
Object -
ls
Localization -
cb
FunctionA 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:
-
name
StringThe provider's name
-
[site='global']
String optional -
onPageRendering
FunctionA 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:
-
name
String -
[site='global']
String optional
Returns:
TRUE if was unregistered, FALSE if not found
updateStatBlock
-
runTime
-
block
Parameters:
-
runTime
IntegerThe amount of time that the provider ran in milliseconds
-
block
ObjectThe 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.