import {
  Dynatrace,
  Platform as DynatracePlatform,
} from "@dynatrace/react-native-plugin";
import { Platform } from "react-native";

const IS_ANDROID =
  Platform.OS === DynatracePlatform.Android
    ? DynatracePlatform.Android
    : DynatracePlatform.Ios;

export const DTLogEvent = (eventName) => {
  try {
    const event = Dynatrace.enterAction(eventName, IS_ANDROID);
    console.log("[Dynatrce - Info] Event -", eventName);
    event.leaveAction();
  } catch (e) {
    console.log("[ERROR] . LibDynatrace . DTLogEvent .error - ", e.message);
  }
};

//
export const DTLogError = (errorName) => {
  try {
    Dynatrace.reportError(errorName, 1, IS_ANDROID);
    console.log("[Dynatrce - Error] Error -", errorName);
  } catch (e) {
    console.log("[ERROR] . LibDynatrace . DTLogError . error - ", e.message);
  }
};
