Skip to content

Setting up Glean.js

Initializing Glean.js

Glean.js must be initialized to collect data and send pings.

Glean.initialize

import Glean from '@mozilla/glean/web';
/**
* Initialize Glean
*
* @param {string} appName Name of the application.
* @param {boolean} uploadEnabled True if upload is enabled, false otherwise.
* @param {Configuration} config Customizable configuration object for Glean.
*/
Glean.initialize("app-name", uploadEnabled, config);

Configuration object

Glean.js-specific configuration options:

  • enableAutoPageLoadEvents: Enables automatic page load events.
  • enableAutoElementClickEvents: Enables automatic click events.
  • sessionLengthInMinutesOverride: Overrides the default session length of 30 minutes.
  • experimentationId: Experimentation identifier to be set in all pings.

Full list of configuration options

When to initialize

Glean.js should be initialized as soon as possible at the start of the application. You should set all debugging options prior to Glean.initialize.

Example initialization