/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.focus.utils;

import android.content.Context;
import android.text.TextUtils;

import com.adjust.sdk.Adjust;
import com.adjust.sdk.AdjustConfig;

import org.mozilla.focus.BuildConfig;
import org.mozilla.focus.telemetry.TelemetryWrapper;

public class AdjustHelper {
    public static void setupAdjustIfNeeded(Context context) {
        // RELEASE: Enable Adjust - This class has different implementations for all build types.

        //noinspection ConstantConditions
        if (TextUtils.isEmpty(BuildConfig.ADJUST_TOKEN)) {
            throw new IllegalStateException("No adjust token defined for release build");
        }

        if (!TelemetryWrapper.isTelemetryEnabled(context)) {
            return;
        }

        AdjustConfig config = new AdjustConfig(context, BuildConfig.ADJUST_TOKEN, AdjustConfig.ENVIRONMENT_PRODUCTION);

        Adjust.onCreate(config);
    }
}

@@ -442,16 +442,48 @@
 tConfig;
+%0Aimport com.adjust.sdk.LogLevel;
 %0A%0Aimport
@@ -1055,24 +1055,30 @@
  %7D%0A%0A        
+final 
 AdjustConfig
@@ -1112,16 +1112,32 @@
 context,
+%0A               
  BuildCo
@@ -1154,16 +1154,32 @@
 T_TOKEN,
+%0A               
  AdjustC
@@ -1206,16 +1206,85 @@
 ODUCTION
+,%0A                true);%0A%0A        config.setLogLevel(LogLevel.SUPRESS
 );%0A%0A    

Disable Adjust logging. (#198)