package it.integry.integrywmsnative.core.utility;

import com.google.firebase.perf.FirebasePerformance;
import com.google.firebase.perf.metrics.Trace;

import it.integry.integrywmsnative.core.settings.SettingsManager;

public class UtilityFirebase {

    public static Trace getNewPerformanceTrace(String traceName) {
        String username = SettingsManager.i().user.fullname;

        Trace newTrace = FirebasePerformance.getInstance().newTrace(traceName);

        newTrace.putAttribute("user_fullame", username);
        newTrace.putAttribute("profile_db", SettingsManager.i().userSession.profileDB);

        return newTrace;
    }


    public static void stopPerformanceTrace(Trace traceToStop, boolean withError) {
        if(withError) {
            traceToStop.putAttribute("failed", "true");
        }

        traceToStop.stop();
    }

}
