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

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