constructor()

in glean/src/core/config.ts [77:104]


  constructor(config?: ConfigurationInterface) {
    this.channel = config?.channel;
    this.appBuild = config?.appBuild;
    this.appDisplayVersion = config?.appDisplayVersion;
    this.buildDate = config?.buildDate;
    this.maxEvents = config?.maxEvents || DEFAULT_MAX_EVENTS;
    this.enableAutoPageLoadEvents = config?.enableAutoPageLoadEvents;
    this.enableAutoElementClickEvents = config?.enableAutoElementClickEvents;
    this.experimentationId = config?.experimentationId;
    this.sessionLengthInMinutesOverride = config?.sessionLengthInMinutesOverride;

    this.debug = {};

    if (config?.serverEndpoint && !validateURL(config.serverEndpoint)) {
      throw new Error(
        `Unable to initialize Glean, serverEndpoint ${config.serverEndpoint} is an invalid URL.`);
    }

    if (!Context.testing && config?.serverEndpoint?.startsWith("http:")) {
      throw new Error(
        `Unable to initialize Glean, serverEndpoint ${config.serverEndpoint} must use the HTTPS protocol.`);
    }

    this.serverEndpoint = (config && config.serverEndpoint)
      ? config.serverEndpoint : DEFAULT_TELEMETRY_ENDPOINT;

    this.httpClient = config?.httpClient;
  }