// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/constants/Constants.java
// public class Constants {
//     public static final String PROTOCOL_VENDOR = "com.snowplowanalytics.snowplow";
//     public static final String PROTOCOL_VERSION = "tp2";
// 
//     public static final String SCHEMA_PAYLOAD_DATA = "iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-4";
//     public static final String SCHEMA_CONTEXTS = "iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-1";
//     public static final String SCHEMA_UNSTRUCT_EVENT = "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0";
//     public static final String SCHEMA_SCREEN_VIEW = "iglu:com.snowplowanalytics.snowplow/screen_view/jsonschema/1-0-0";
//     public static final String SCHEMA_USER_TIMINGS = "iglu:com.snowplowanalytics.snowplow/timing/jsonschema/1-0-0";
// 
//     public static final String POST_CONTENT_TYPE = "application/json; charset=utf-8";
// 
//     public static final String EVENT_PAGE_VIEW = "pv";
//     public static final String EVENT_STRUCTURED = "se";
//     public static final String EVENT_UNSTRUCTURED = "ue";
//     public static final String EVENT_ECOMM = "tr";
//     public static final String EVENT_ECOMM_ITEM = "ti";
// }


import com.google.common.base.Preconditions;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.snowplowanalytics.snowplow.tracker.constants.Constants;
    /**
     * Attempts to send a group of payloads with a
     * GET request to the configured endpoint.
     *
     * @param url the URL send
     * @return the HttpResponse for the Request
     */
    public int doGet(String url) {
        try {
            HttpGet httpGet = new HttpGet(url);
            HttpResponse httpResponse = httpClient.execute(httpGet);
            httpGet.releaseConnection();
            return httpResponse.getStatusLine().getStatusCode();
        } catch (Exception e) {
            LOGGER.error("ApacheHttpClient GET Request failed: {}", e.getMessage());
            return -1;
        }
    }

    /**
     * Attempts to send a group of payloads with a
     * POST request to the configured endpoint.
     *
     * @param url the URL to send to
     * @param payload the payload to send
     * @return the HttpResponse for the Request
     */
    public int doPost(String url, String payload) {
        try {
            HttpPost httpPost = new HttpPost(url);
// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/constants/Constants.java
// public class Constants {
//     public static final String PROTOCOL_VENDOR = "com.snowplowanalytics.snowplow";
//     public static final String PROTOCOL_VERSION = "tp2";
// 
//     public static final String SCHEMA_PAYLOAD_DATA = "iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-4";
//     public static final String SCHEMA_CONTEXTS = "iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-1";
//     public static final String SCHEMA_UNSTRUCT_EVENT = "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0";
//     public static final String SCHEMA_SCREEN_VIEW = "iglu:com.snowplowanalytics.snowplow/screen_view/jsonschema/1-0-0";
//     public static final String SCHEMA_USER_TIMINGS = "iglu:com.snowplowanalytics.snowplow/timing/jsonschema/1-0-0";
// 
//     public static final String POST_CONTENT_TYPE = "application/json; charset=utf-8";
// 
//     public static final String EVENT_PAGE_VIEW = "pv";
//     public static final String EVENT_STRUCTURED = "se";
//     public static final String EVENT_UNSTRUCTURED = "ue";
//     public static final String EVENT_ECOMM = "tr";
//     public static final String EVENT_ECOMM_ITEM = "ti";
// }


// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/http/ApacheHttpClientAdapter.java
import com.google.common.base.Preconditions;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.snowplowanalytics.snowplow.tracker.constants.Constants;

    /**
     * Attempts to send a group of payloads with a
     * GET request to the configured endpoint.
     *
     * @param url the URL send
     * @return the HttpResponse for the Request
     */
    public int doGet(String url) {
        try {
            HttpGet httpGet = new HttpGet(url);
            HttpResponse httpResponse = httpClient.execute(httpGet);
            httpGet.releaseConnection();
            return httpResponse.getStatusLine().getStatusCode();
        } catch (Exception e) {
            LOGGER.error("ApacheHttpClient GET Request failed: {}", e.getMessage());
            return -1;
        }
    }

    /**
     * Attempts to send a group of payloads with a
     * POST request to the configured endpoint.
     *
     * @param url the URL to send to
     * @param payload the payload to send
     * @return the HttpResponse for the Request
     */
    public int doPost(String url, String payload) {
        try {
            HttpPost httpPost = new HttpPost(url);
            httpPost.addHeader("Content-Type", Constants.POST_CONTENT_TYPE);