import { errorRecord } from "../../common/libEventLog/libCrashlytics/libCrashlyticsEvent";
import { AUTO_PI_DECISION_URL } from "../../Api/ApiUrls";
var UserExperior = require("react-native-userexperior");

// instructions
export const getActivityForAutoPIDecision = async ({ activityId }) => {
  UserExperior.startTimer(`${AUTO_PI_DECISION_URL}${activityId}`);
  console.log("URL ",`${AUTO_PI_DECISION_URL}${activityId}`);
  try {
    const res = await fetch(`${AUTO_PI_DECISION_URL}${activityId}`, {
      method: "GET",
    });
    let data = await res.json();
    if (res.status !== 200) {
      throw new Error(data?.error);
    }
    UserExperior.endTimer(`${AUTO_PI_DECISION_URL}+${activityId}`);
    return data;
  } catch (err) {
    errorRecord(err);
    console.log(err);
  }
};
