export function buildClientInfoSection()

in glean/src/core/pings/maker.ts [199:225]


export function buildClientInfoSection(ping: CommonPingData): ClientInfo {
  let clientInfo = Context.metricsDatabase.getPingMetrics(
    CLIENT_INFO_STORAGE,
    true
  );
  if (!clientInfo) {
    // TODO: Watch Bug 1685705 and change behaviour in here accordingly.
    log(PINGS_MAKER_LOG_TAG, "Empty client info data. Will submit anyways.", LoggingLevel.Warn);
    clientInfo = {};
  }

  let finalClientInfo: ClientInfo = {
    telemetry_sdk_build: GLEAN_VERSION
  };
  for (const metricType in clientInfo) {
    finalClientInfo = { ...finalClientInfo, ...clientInfo[metricType] };
  }

  if (!ping.includeClientId) {
    delete finalClientInfo["client_id"];

    // If the ping doesn't include the client_id, we also should exclude session_id.
    delete finalClientInfo["session_id"];
  }

  return finalClientInfo;
}