Class: GoogleAnalytics

GoogleAnalytics()

A model that connects with an analytics service to record user interactions with the app

Constructor

new GoogleAnalytics()

Since:
  • 2.25.0
Source:

Extends

Members

track :function

The main function for sending analytics events to the service. window.gtag may not exist when the model is created, but it will be set when the setupAnalytics() method is completed.
Type:
  • function
Overrides:
Source:

trackMethods :Array.<string>

The name of methods that will be wrapped to ensure they are called after the analytics service is ready.
Type:
  • Array.<string>
Since:
  • 2.34.0
Overrides:
Source:

type :string

The name of this Model
Type:
  • string
Overrides:
Source:

Methods

createExceptionDescription(message, id) → {string}

Given a message and an optional ID, create a description of an exception event that can be sent to an analytics service.
Parameters:
Name Type Description
message string A description of the exception
id string The ID for the associated package or object
Inherited From:
Source:
Returns:
A description of the exception event
Type
string

defaults() → {object}

Default attributes for this model
Inherited From:
Source:
Returns:
Type
object

getKey() → {string}

Get the key for the analytics service. This is the ID that is used to initialize the analytics service.
Overrides:
Source:
Returns:
The key for the analytics service
Type
string

getVersion() → {string}

Get the version number of the MetacatUI app.
Inherited From:
Source:
Returns:
The version number of the MetacatUI app
Type
string

initialize()

Creates a new Analytics model
Inherited From:
Source:

ready() → {boolean}

Check if analytics service is enabled and ready to use.
Overrides:
Source:
Returns:
True if the service is enabled in the app and the track method is available.
Type
boolean

setupAnalytics()

Set up the analytics service. Any overwritten versions of this function should make sure to set the track method on the model, and also call this.trigger("ready") when the service is ready to use, and this.trigger("setupError", error) if there is an error during setup.
Overrides:
Source:

trackCustomEvent(eventName, paramsopt)

Track a custom event.
Parameters:
Name Type Attributes Description
eventName string The name of the event to track
params Object <optional>
The parameters to send with the event.
Since:
  • 2.34.0
Overrides:
Source:

trackEvent(category, action, label, value)

Send the details of an event to an analytics service. The function will do nothing if an analytics service is not enabled.
Parameters:
Name Type Description
category string The category of the event
action string The action of the event
label string The label of the event
value string The value of the event
Overrides:
Source:

trackException(message, id, fatal)

Send the details of an exception event to an analytics service. This will automatically include the MetacatUI version number in the event details. The function will do nothing if an analytics service is not enabled.
Parameters:
Name Type Description
message string A description of the exception
id string The ID for the associated package or object
fatal boolean Whether the exception was fatal
Overrides:
Source:

trackPageView(path, title)

Send the details of a page view to an analytics service. The function will do nothing if an analytics service is not enabled.
Parameters:
Name Type Description
path string The path of the page
title string The title of the page
Overrides:
Source:

whenReady() → {Promise}

Wait for the analytics service to be ready before sending events. Depends on the setupAnalytics triggering a "ready" event as well as a "setupError" event if there is an error during setup.
Since:
  • 2.34.0
Inherited From:
Source:
Returns:
A promise that resolves when the analytics service is ready to use.
Type
Promise