private buildPingRequest()

in glean/src/core/upload/worker.ts [42:61]


  private buildPingRequest(ping: QueuedPing): PingRequest<string | Uint8Array> {
    let headers = ping.headers || {};
    headers = {
      ...ping.headers,
      "Content-Type": "application/json; charset=utf-8",
      Date: new Date().toISOString(),
      "X-Telemetry-Agent": `Glean/${GLEAN_VERSION} (JS on ${(Context.platform).info.os()})`
    };

    const stringifiedBody = JSON.stringify(ping.payload);

    if (stringifiedBody.length > this.policy.maxPingBodySize) {
      throw new PingBodyOverflowError(
        `Body for ping ${ping.identifier} exceeds ${this.policy.maxPingBodySize}bytes. Discarding.`
      );
    }

    headers["Content-Length"] = stringifiedBody.length.toString();
    return new PingRequest(ping.identifier, headers, stringifiedBody, this.policy.maxPingBodySize);
  }