public static void addClientIdFromPayload()

in ingestion-beam/src/main/java/com/mozilla/telemetry/decoder/ParsePayload.java [342:375]


  public static void addClientIdFromPayload(Map<String, String> attributes, ObjectNode json) {
    // Try to get glean-style client_info object.
    JsonNode gleanClientInfo = getGleanClientInfo(json);

    if (gleanClientInfo.isObject()) {
      // from glean ping
      Optional.ofNullable(gleanClientInfo.path(Attribute.CLIENT_ID).textValue()) //
          .filter(v -> !Strings.isNullOrEmpty(v)) //
          .map(ParsePayload::normalizeUuid) //
          .ifPresent(v -> {
            attributes.put(Attribute.CLIENT_ID, v);
            ((ObjectNode) gleanClientInfo).put(Attribute.CLIENT_ID, v);
          });
    }

    if (attributes.get(Attribute.CLIENT_ID) == null) {
      // from common ping
      Optional.ofNullable(json.path(Attribute.CLIENT_ID).textValue()) //
          .map(ParsePayload::normalizeUuid) //
          .ifPresent(v -> {
            attributes.put(Attribute.CLIENT_ID, v);
            json.put(Attribute.CLIENT_ID, v);
          });
    }

    if (attributes.get(Attribute.CLIENT_ID) == null) {
      Optional.ofNullable(json.path("clientId").textValue()) //
          .map(ParsePayload::normalizeUuid) //
          .ifPresent(v -> {
            attributes.put(Attribute.CLIENT_ID, v);
            json.put("clientId", v);
          });
    }
  }