package org.ccci.gto.android.common.snowplow.util;

import android.support.annotation.NonNull;

import com.snowplowanalytics.snowplow.tracker.Emitter;

import org.ccci.gto.android.common.okhttp3.util.OkHttpClientUtil;

import java.lang.reflect.Field;

import okhttp3.OkHttpClient;
import timber.log.Timber;

public final class EmitterUtils {
    public static void attachOkHttp3GlobalInterceptors(@NonNull final Emitter emitter) {
        try {
            final Field field = Emitter.class.getDeclaredField("client");
            field.setAccessible(true);
            final OkHttpClient original = (OkHttpClient) field.get(emitter);
            field.set(emitter, OkHttpClientUtil.attachGlobalInterceptors(original.newBuilder()).build());
        } catch (final Exception e) {
            Timber.tag("EmitterUtils")
                    .e(e, "error attaching OkHttp global interceptors to SnowPlow Emitter");
        }
    }
}

@@ -49,52 +49,8 @@
 l;%0A%0A
-import android.support.annotation.NonNull;%0A%0A
 impo
@@ -201,16 +201,52 @@
 Field;%0A%0A
+import androidx.annotation.NonNull;%0A
 import o

update gto-support-snowplow for AndroidX